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,200 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/css/base64/Base64ImageEncoderPostProcessor.java
|
Base64ImageEncoderPostProcessor.prependBase64EncodedResources
|
protected void prependBase64EncodedResources(StringBuffer sb, Map<String, Base64EncodedResource> encodedImages) {
Iterator<Entry<String, Base64EncodedResource>> it = encodedImages.entrySet().iterator();
StringBuilder mhtml = new StringBuilder();
String lineSeparator = StringUtils.STR_LINE_FEED;
mhtml.append("/*!").append(lineSeparator);
mhtml.append("Content-Type: multipart/related; boundary=\"" + BOUNDARY_SEPARATOR + "\"").append(lineSeparator)
.append(lineSeparator);
while (it.hasNext()) {
Entry<String, Base64EncodedResource> pair = it.next();
Base64EncodedResource encodedResource = (Base64EncodedResource) pair.getValue();
mhtml.append(BOUNDARY_SEPARATOR_PREFIX + BOUNDARY_SEPARATOR).append(lineSeparator);
mhtml.append("Content-Type:").append(encodedResource.getType()).append(lineSeparator);
mhtml.append("Content-Location:").append(encodedResource.getId()).append(lineSeparator);
mhtml.append("Content-Transfer-Encoding:base64").append(lineSeparator).append(lineSeparator);
mhtml.append(encodedResource.getBase64Encoding()).append(lineSeparator).append(lineSeparator);
}
mhtml.append(BOUNDARY_SEPARATOR_PREFIX + BOUNDARY_SEPARATOR + BOUNDARY_SEPARATOR_PREFIX).append(lineSeparator);
mhtml.append("*/").append(lineSeparator).append(lineSeparator);
sb.insert(0, mhtml.toString());
}
|
java
|
protected void prependBase64EncodedResources(StringBuffer sb, Map<String, Base64EncodedResource> encodedImages) {
Iterator<Entry<String, Base64EncodedResource>> it = encodedImages.entrySet().iterator();
StringBuilder mhtml = new StringBuilder();
String lineSeparator = StringUtils.STR_LINE_FEED;
mhtml.append("/*!").append(lineSeparator);
mhtml.append("Content-Type: multipart/related; boundary=\"" + BOUNDARY_SEPARATOR + "\"").append(lineSeparator)
.append(lineSeparator);
while (it.hasNext()) {
Entry<String, Base64EncodedResource> pair = it.next();
Base64EncodedResource encodedResource = (Base64EncodedResource) pair.getValue();
mhtml.append(BOUNDARY_SEPARATOR_PREFIX + BOUNDARY_SEPARATOR).append(lineSeparator);
mhtml.append("Content-Type:").append(encodedResource.getType()).append(lineSeparator);
mhtml.append("Content-Location:").append(encodedResource.getId()).append(lineSeparator);
mhtml.append("Content-Transfer-Encoding:base64").append(lineSeparator).append(lineSeparator);
mhtml.append(encodedResource.getBase64Encoding()).append(lineSeparator).append(lineSeparator);
}
mhtml.append(BOUNDARY_SEPARATOR_PREFIX + BOUNDARY_SEPARATOR + BOUNDARY_SEPARATOR_PREFIX).append(lineSeparator);
mhtml.append("*/").append(lineSeparator).append(lineSeparator);
sb.insert(0, mhtml.toString());
}
|
[
"protected",
"void",
"prependBase64EncodedResources",
"(",
"StringBuffer",
"sb",
",",
"Map",
"<",
"String",
",",
"Base64EncodedResource",
">",
"encodedImages",
")",
"{",
"Iterator",
"<",
"Entry",
"<",
"String",
",",
"Base64EncodedResource",
">",
">",
"it",
"=",
"encodedImages",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"StringBuilder",
"mhtml",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"lineSeparator",
"=",
"StringUtils",
".",
"STR_LINE_FEED",
";",
"mhtml",
".",
"append",
"(",
"\"/*!\"",
")",
".",
"append",
"(",
"lineSeparator",
")",
";",
"mhtml",
".",
"append",
"(",
"\"Content-Type: multipart/related; boundary=\\\"\"",
"+",
"BOUNDARY_SEPARATOR",
"+",
"\"\\\"\"",
")",
".",
"append",
"(",
"lineSeparator",
")",
".",
"append",
"(",
"lineSeparator",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Entry",
"<",
"String",
",",
"Base64EncodedResource",
">",
"pair",
"=",
"it",
".",
"next",
"(",
")",
";",
"Base64EncodedResource",
"encodedResource",
"=",
"(",
"Base64EncodedResource",
")",
"pair",
".",
"getValue",
"(",
")",
";",
"mhtml",
".",
"append",
"(",
"BOUNDARY_SEPARATOR_PREFIX",
"+",
"BOUNDARY_SEPARATOR",
")",
".",
"append",
"(",
"lineSeparator",
")",
";",
"mhtml",
".",
"append",
"(",
"\"Content-Type:\"",
")",
".",
"append",
"(",
"encodedResource",
".",
"getType",
"(",
")",
")",
".",
"append",
"(",
"lineSeparator",
")",
";",
"mhtml",
".",
"append",
"(",
"\"Content-Location:\"",
")",
".",
"append",
"(",
"encodedResource",
".",
"getId",
"(",
")",
")",
".",
"append",
"(",
"lineSeparator",
")",
";",
"mhtml",
".",
"append",
"(",
"\"Content-Transfer-Encoding:base64\"",
")",
".",
"append",
"(",
"lineSeparator",
")",
".",
"append",
"(",
"lineSeparator",
")",
";",
"mhtml",
".",
"append",
"(",
"encodedResource",
".",
"getBase64Encoding",
"(",
")",
")",
".",
"append",
"(",
"lineSeparator",
")",
".",
"append",
"(",
"lineSeparator",
")",
";",
"}",
"mhtml",
".",
"append",
"(",
"BOUNDARY_SEPARATOR_PREFIX",
"+",
"BOUNDARY_SEPARATOR",
"+",
"BOUNDARY_SEPARATOR_PREFIX",
")",
".",
"append",
"(",
"lineSeparator",
")",
";",
"mhtml",
".",
"append",
"(",
"\"*/\"",
")",
".",
"append",
"(",
"lineSeparator",
")",
".",
"append",
"(",
"lineSeparator",
")",
";",
"sb",
".",
"insert",
"(",
"0",
",",
"mhtml",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Prepend the base64 encoded resources to the bundle data
@param sb
the string buffer containing the processed bundle data
@param encodedImages
a map of encoded images
|
[
"Prepend",
"the",
"base64",
"encoded",
"resources",
"to",
"the",
"bundle",
"data"
] |
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/css/base64/Base64ImageEncoderPostProcessor.java#L152-L173
|
7,201 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/reader/ResourceReaderComparator.java
|
ResourceReaderComparator.getPriority
|
private int getPriority(ResourceReader o1) {
int priority = 0;
if (o1 instanceof ServletContextResourceReader) {
priority = baseDirHighPriority ? 5 : 4;
} else if (o1 instanceof FileSystemResourceReader) {
priority = baseDirHighPriority ? 4 : 5;
} else if (o1 instanceof CssSmartSpritesResourceReader) {
priority = 1;
} else if (o1 instanceof ResourceGenerator) {
if (((ResourceGenerator) o1).getResolver().getType().equals(ResolverType.PREFIXED)) {
priority = 3;
} else {
priority = 2;
}
}
return priority;
}
|
java
|
private int getPriority(ResourceReader o1) {
int priority = 0;
if (o1 instanceof ServletContextResourceReader) {
priority = baseDirHighPriority ? 5 : 4;
} else if (o1 instanceof FileSystemResourceReader) {
priority = baseDirHighPriority ? 4 : 5;
} else if (o1 instanceof CssSmartSpritesResourceReader) {
priority = 1;
} else if (o1 instanceof ResourceGenerator) {
if (((ResourceGenerator) o1).getResolver().getType().equals(ResolverType.PREFIXED)) {
priority = 3;
} else {
priority = 2;
}
}
return priority;
}
|
[
"private",
"int",
"getPriority",
"(",
"ResourceReader",
"o1",
")",
"{",
"int",
"priority",
"=",
"0",
";",
"if",
"(",
"o1",
"instanceof",
"ServletContextResourceReader",
")",
"{",
"priority",
"=",
"baseDirHighPriority",
"?",
"5",
":",
"4",
";",
"}",
"else",
"if",
"(",
"o1",
"instanceof",
"FileSystemResourceReader",
")",
"{",
"priority",
"=",
"baseDirHighPriority",
"?",
"4",
":",
"5",
";",
"}",
"else",
"if",
"(",
"o1",
"instanceof",
"CssSmartSpritesResourceReader",
")",
"{",
"priority",
"=",
"1",
";",
"}",
"else",
"if",
"(",
"o1",
"instanceof",
"ResourceGenerator",
")",
"{",
"if",
"(",
"(",
"(",
"ResourceGenerator",
")",
"o1",
")",
".",
"getResolver",
"(",
")",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"ResolverType",
".",
"PREFIXED",
")",
")",
"{",
"priority",
"=",
"3",
";",
"}",
"else",
"{",
"priority",
"=",
"2",
";",
"}",
"}",
"return",
"priority",
";",
"}"
] |
Returns the priority of the resource reader
if the FileSystemResourceReader is configured with high priority the list
of priorities is as follows :
5 - ServletContextResourceReader 4 - FileSystemResourceReader 3 -
Generator with prefixed path 2 - Generator with suffixed path 1 -
CssSmartSpriteResourceReader
if the FileSystemResourceReader is configured with high priority the list
of priorities is as follows :
5 - FileSystemResourceReader 4 - ServletContextResourceReader 3 -
Generator with prefixed path 2 - Generator with suffixed path 1 -
CssSmartSpriteResourceReader
@param o1
the resource reader
@return the priority of the resource reader
|
[
"Returns",
"the",
"priority",
"of",
"the",
"resource",
"reader"
] |
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/ResourceReaderComparator.java#L81-L98
|
7,202 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrBinaryResourceRequestHandler.java
|
JawrBinaryResourceRequestHandler.initMapping
|
private void initMapping(BinaryResourcesHandler binaryRsHandler) {
if (jawrConfig.getUseBundleMapping() && rsBundleHandler.isExistingMappingFile()) {
// Initialize the binary web resource mapping
Iterator<Entry<Object, Object>> mapIterator = bundleMapping.entrySet().iterator();
while (mapIterator.hasNext()) {
Entry<Object, Object> entry = mapIterator.next();
binaryRsHandler.addMapping((String) entry.getKey(), entry.getValue().toString());
}
} else {
// Create a resource handler to read files from the WAR archive or
// exploded dir.
String binaryResourcesDefinition = jawrConfig.getBinaryResourcesDefinition();
if (binaryResourcesDefinition != null) {
StringTokenizer tokenizer = new StringTokenizer(binaryResourcesDefinition, ",");
while (tokenizer.hasMoreTokens()) {
String pathMapping = tokenizer.nextToken();
// path is a generated image and ends with an image
// extension
if (generatorRegistry.isGeneratedBinaryResource(pathMapping)
&& hasBinaryFileExtension(pathMapping)) {
addBinaryResourcePath(binaryRsHandler, pathMapping);
}
// path ends in /, the folder is included without subfolders
else if (pathMapping.endsWith("/")) {
addItemsFromDir(binaryRsHandler, pathMapping, false);
}
// path ends in /, the folder is included with all
// subfolders
else if (pathMapping.endsWith("/**")) {
addItemsFromDir(binaryRsHandler, pathMapping.substring(0, pathMapping.lastIndexOf("**")), true);
} else if (hasBinaryFileExtension(pathMapping)) {
addBinaryResourcePath(binaryRsHandler, pathMapping);
} else
LOGGER.warn(
"Wrong mapping [" + pathMapping + "] for image bundle. Please check configuration. ");
}
}
}
// Store the bundle mapping
if (jawrConfig.getUseBundleMapping() && !rsBundleHandler.isExistingMappingFile()) {
rsBundleHandler.storeJawrBundleMapping(bundleMapping);
}
if (LOGGER.isDebugEnabled())
LOGGER.debug("Finish creation of map for image bundle");
}
|
java
|
private void initMapping(BinaryResourcesHandler binaryRsHandler) {
if (jawrConfig.getUseBundleMapping() && rsBundleHandler.isExistingMappingFile()) {
// Initialize the binary web resource mapping
Iterator<Entry<Object, Object>> mapIterator = bundleMapping.entrySet().iterator();
while (mapIterator.hasNext()) {
Entry<Object, Object> entry = mapIterator.next();
binaryRsHandler.addMapping((String) entry.getKey(), entry.getValue().toString());
}
} else {
// Create a resource handler to read files from the WAR archive or
// exploded dir.
String binaryResourcesDefinition = jawrConfig.getBinaryResourcesDefinition();
if (binaryResourcesDefinition != null) {
StringTokenizer tokenizer = new StringTokenizer(binaryResourcesDefinition, ",");
while (tokenizer.hasMoreTokens()) {
String pathMapping = tokenizer.nextToken();
// path is a generated image and ends with an image
// extension
if (generatorRegistry.isGeneratedBinaryResource(pathMapping)
&& hasBinaryFileExtension(pathMapping)) {
addBinaryResourcePath(binaryRsHandler, pathMapping);
}
// path ends in /, the folder is included without subfolders
else if (pathMapping.endsWith("/")) {
addItemsFromDir(binaryRsHandler, pathMapping, false);
}
// path ends in /, the folder is included with all
// subfolders
else if (pathMapping.endsWith("/**")) {
addItemsFromDir(binaryRsHandler, pathMapping.substring(0, pathMapping.lastIndexOf("**")), true);
} else if (hasBinaryFileExtension(pathMapping)) {
addBinaryResourcePath(binaryRsHandler, pathMapping);
} else
LOGGER.warn(
"Wrong mapping [" + pathMapping + "] for image bundle. Please check configuration. ");
}
}
}
// Store the bundle mapping
if (jawrConfig.getUseBundleMapping() && !rsBundleHandler.isExistingMappingFile()) {
rsBundleHandler.storeJawrBundleMapping(bundleMapping);
}
if (LOGGER.isDebugEnabled())
LOGGER.debug("Finish creation of map for image bundle");
}
|
[
"private",
"void",
"initMapping",
"(",
"BinaryResourcesHandler",
"binaryRsHandler",
")",
"{",
"if",
"(",
"jawrConfig",
".",
"getUseBundleMapping",
"(",
")",
"&&",
"rsBundleHandler",
".",
"isExistingMappingFile",
"(",
")",
")",
"{",
"// Initialize the binary web resource mapping",
"Iterator",
"<",
"Entry",
"<",
"Object",
",",
"Object",
">",
">",
"mapIterator",
"=",
"bundleMapping",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"mapIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"Entry",
"<",
"Object",
",",
"Object",
">",
"entry",
"=",
"mapIterator",
".",
"next",
"(",
")",
";",
"binaryRsHandler",
".",
"addMapping",
"(",
"(",
"String",
")",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"// Create a resource handler to read files from the WAR archive or",
"// exploded dir.",
"String",
"binaryResourcesDefinition",
"=",
"jawrConfig",
".",
"getBinaryResourcesDefinition",
"(",
")",
";",
"if",
"(",
"binaryResourcesDefinition",
"!=",
"null",
")",
"{",
"StringTokenizer",
"tokenizer",
"=",
"new",
"StringTokenizer",
"(",
"binaryResourcesDefinition",
",",
"\",\"",
")",
";",
"while",
"(",
"tokenizer",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"pathMapping",
"=",
"tokenizer",
".",
"nextToken",
"(",
")",
";",
"// path is a generated image and ends with an image",
"// extension",
"if",
"(",
"generatorRegistry",
".",
"isGeneratedBinaryResource",
"(",
"pathMapping",
")",
"&&",
"hasBinaryFileExtension",
"(",
"pathMapping",
")",
")",
"{",
"addBinaryResourcePath",
"(",
"binaryRsHandler",
",",
"pathMapping",
")",
";",
"}",
"// path ends in /, the folder is included without subfolders",
"else",
"if",
"(",
"pathMapping",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"addItemsFromDir",
"(",
"binaryRsHandler",
",",
"pathMapping",
",",
"false",
")",
";",
"}",
"// path ends in /, the folder is included with all",
"// subfolders",
"else",
"if",
"(",
"pathMapping",
".",
"endsWith",
"(",
"\"/**\"",
")",
")",
"{",
"addItemsFromDir",
"(",
"binaryRsHandler",
",",
"pathMapping",
".",
"substring",
"(",
"0",
",",
"pathMapping",
".",
"lastIndexOf",
"(",
"\"**\"",
")",
")",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"hasBinaryFileExtension",
"(",
"pathMapping",
")",
")",
"{",
"addBinaryResourcePath",
"(",
"binaryRsHandler",
",",
"pathMapping",
")",
";",
"}",
"else",
"LOGGER",
".",
"warn",
"(",
"\"Wrong mapping [\"",
"+",
"pathMapping",
"+",
"\"] for image bundle. Please check configuration. \"",
")",
";",
"}",
"}",
"}",
"// Store the bundle mapping",
"if",
"(",
"jawrConfig",
".",
"getUseBundleMapping",
"(",
")",
"&&",
"!",
"rsBundleHandler",
".",
"isExistingMappingFile",
"(",
")",
")",
"{",
"rsBundleHandler",
".",
"storeJawrBundleMapping",
"(",
"bundleMapping",
")",
";",
"}",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"LOGGER",
".",
"debug",
"(",
"\"Finish creation of map for image bundle\"",
")",
";",
"}"
] |
Initialize the mapping of the binary web resources handler
@param binaryRsHandler
the binary web resources handler
|
[
"Initialize",
"the",
"mapping",
"of",
"the",
"binary",
"web",
"resources",
"handler"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrBinaryResourceRequestHandler.java#L223-L276
|
7,203 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrBinaryResourceRequestHandler.java
|
JawrBinaryResourceRequestHandler.addBinaryResourcePath
|
private void addBinaryResourcePath(BinaryResourcesHandler binRsHandler, String resourcePath) {
try {
String resultPath = CheckSumUtils.getCacheBustedUrl(resourcePath, rsReaderHandler, jawrConfig);
binRsHandler.addMapping(resourcePath, resultPath);
bundleMapping.put(resourcePath, resultPath);
} catch (IOException e) {
LOGGER.error("An exception occurs while defining the mapping for the file : " + resourcePath, e);
} catch (ResourceNotFoundException e) {
LOGGER.error("Impossible to define the checksum for the resource '" + resourcePath
+ "'. Unable to retrieve the content of the file.");
}
}
|
java
|
private void addBinaryResourcePath(BinaryResourcesHandler binRsHandler, String resourcePath) {
try {
String resultPath = CheckSumUtils.getCacheBustedUrl(resourcePath, rsReaderHandler, jawrConfig);
binRsHandler.addMapping(resourcePath, resultPath);
bundleMapping.put(resourcePath, resultPath);
} catch (IOException e) {
LOGGER.error("An exception occurs while defining the mapping for the file : " + resourcePath, e);
} catch (ResourceNotFoundException e) {
LOGGER.error("Impossible to define the checksum for the resource '" + resourcePath
+ "'. Unable to retrieve the content of the file.");
}
}
|
[
"private",
"void",
"addBinaryResourcePath",
"(",
"BinaryResourcesHandler",
"binRsHandler",
",",
"String",
"resourcePath",
")",
"{",
"try",
"{",
"String",
"resultPath",
"=",
"CheckSumUtils",
".",
"getCacheBustedUrl",
"(",
"resourcePath",
",",
"rsReaderHandler",
",",
"jawrConfig",
")",
";",
"binRsHandler",
".",
"addMapping",
"(",
"resourcePath",
",",
"resultPath",
")",
";",
"bundleMapping",
".",
"put",
"(",
"resourcePath",
",",
"resultPath",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"An exception occurs while defining the mapping for the file : \"",
"+",
"resourcePath",
",",
"e",
")",
";",
"}",
"catch",
"(",
"ResourceNotFoundException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Impossible to define the checksum for the resource '\"",
"+",
"resourcePath",
"+",
"\"'. Unable to retrieve the content of the file.\"",
")",
";",
"}",
"}"
] |
Add an binary resource path to the binary map
@param binRsHandler
the image resources handler
@param resourcePath
the image path
|
[
"Add",
"an",
"binary",
"resource",
"path",
"to",
"the",
"binary",
"map"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrBinaryResourceRequestHandler.java#L286-L298
|
7,204 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrBinaryResourceRequestHandler.java
|
JawrBinaryResourceRequestHandler.hasBinaryFileExtension
|
private boolean hasBinaryFileExtension(String path) {
boolean result = false;
int extFileIdx = path.lastIndexOf(".");
if (extFileIdx != -1 && extFileIdx + 1 < path.length()) {
String extension = path.substring(extFileIdx + 1);
result = binaryMimeTypeMap.containsKey(extension);
}
return result;
}
|
java
|
private boolean hasBinaryFileExtension(String path) {
boolean result = false;
int extFileIdx = path.lastIndexOf(".");
if (extFileIdx != -1 && extFileIdx + 1 < path.length()) {
String extension = path.substring(extFileIdx + 1);
result = binaryMimeTypeMap.containsKey(extension);
}
return result;
}
|
[
"private",
"boolean",
"hasBinaryFileExtension",
"(",
"String",
"path",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"int",
"extFileIdx",
"=",
"path",
".",
"lastIndexOf",
"(",
"\".\"",
")",
";",
"if",
"(",
"extFileIdx",
"!=",
"-",
"1",
"&&",
"extFileIdx",
"+",
"1",
"<",
"path",
".",
"length",
"(",
")",
")",
"{",
"String",
"extension",
"=",
"path",
".",
"substring",
"(",
"extFileIdx",
"+",
"1",
")",
";",
"result",
"=",
"binaryMimeTypeMap",
".",
"containsKey",
"(",
"extension",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Returns true of the path contains a binary file extension
@param path
the path
@return the binary file extension
|
[
"Returns",
"true",
"of",
"the",
"path",
"contains",
"a",
"binary",
"file",
"extension"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrBinaryResourceRequestHandler.java#L307-L317
|
7,205 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrBinaryResourceRequestHandler.java
|
JawrBinaryResourceRequestHandler.addItemsFromDir
|
private void addItemsFromDir(BinaryResourcesHandler binRsHandler, String dirName, boolean addSubDirs) {
Set<String> resources = rsReaderHandler.getResourceNames(dirName);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Adding " + resources.size() + " resources from path [" + dirName + "] to binary bundle");
}
GeneratorRegistry binGeneratorRegistry = binRsHandler.getConfig().getGeneratorRegistry();
List<String> folders = new ArrayList<>();
boolean generatedPath = binGeneratorRegistry.isPathGenerated(dirName);
for (String resourceName : resources) {
String resourcePath = PathNormalizer.joinPaths(dirName, resourceName, generatedPath);
if (hasBinaryFileExtension(resourceName)) {
addBinaryResourcePath(binRsHandler, resourcePath);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Added to item path list:" + PathNormalizer.asPath(resourcePath));
} else if (addSubDirs) {
try {
if (rsReaderHandler.isDirectory(resourcePath)) {
folders.add(resourceName);
}
} catch (InvalidPathException e) {
if (LOGGER.isDebugEnabled())
LOGGER.debug("Enable to define if the following resource is a directory : "
+ PathNormalizer.asPath(resourcePath));
}
}
}
// Add subfolders if requested. Subfolders are added last unless
// specified in sorting file.
if (addSubDirs) {
for (String folderName : folders) {
addItemsFromDir(binRsHandler, PathNormalizer.joinPaths(dirName, folderName), true);
}
}
}
|
java
|
private void addItemsFromDir(BinaryResourcesHandler binRsHandler, String dirName, boolean addSubDirs) {
Set<String> resources = rsReaderHandler.getResourceNames(dirName);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Adding " + resources.size() + " resources from path [" + dirName + "] to binary bundle");
}
GeneratorRegistry binGeneratorRegistry = binRsHandler.getConfig().getGeneratorRegistry();
List<String> folders = new ArrayList<>();
boolean generatedPath = binGeneratorRegistry.isPathGenerated(dirName);
for (String resourceName : resources) {
String resourcePath = PathNormalizer.joinPaths(dirName, resourceName, generatedPath);
if (hasBinaryFileExtension(resourceName)) {
addBinaryResourcePath(binRsHandler, resourcePath);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Added to item path list:" + PathNormalizer.asPath(resourcePath));
} else if (addSubDirs) {
try {
if (rsReaderHandler.isDirectory(resourcePath)) {
folders.add(resourceName);
}
} catch (InvalidPathException e) {
if (LOGGER.isDebugEnabled())
LOGGER.debug("Enable to define if the following resource is a directory : "
+ PathNormalizer.asPath(resourcePath));
}
}
}
// Add subfolders if requested. Subfolders are added last unless
// specified in sorting file.
if (addSubDirs) {
for (String folderName : folders) {
addItemsFromDir(binRsHandler, PathNormalizer.joinPaths(dirName, folderName), true);
}
}
}
|
[
"private",
"void",
"addItemsFromDir",
"(",
"BinaryResourcesHandler",
"binRsHandler",
",",
"String",
"dirName",
",",
"boolean",
"addSubDirs",
")",
"{",
"Set",
"<",
"String",
">",
"resources",
"=",
"rsReaderHandler",
".",
"getResourceNames",
"(",
"dirName",
")",
";",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Adding \"",
"+",
"resources",
".",
"size",
"(",
")",
"+",
"\" resources from path [\"",
"+",
"dirName",
"+",
"\"] to binary bundle\"",
")",
";",
"}",
"GeneratorRegistry",
"binGeneratorRegistry",
"=",
"binRsHandler",
".",
"getConfig",
"(",
")",
".",
"getGeneratorRegistry",
"(",
")",
";",
"List",
"<",
"String",
">",
"folders",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"boolean",
"generatedPath",
"=",
"binGeneratorRegistry",
".",
"isPathGenerated",
"(",
"dirName",
")",
";",
"for",
"(",
"String",
"resourceName",
":",
"resources",
")",
"{",
"String",
"resourcePath",
"=",
"PathNormalizer",
".",
"joinPaths",
"(",
"dirName",
",",
"resourceName",
",",
"generatedPath",
")",
";",
"if",
"(",
"hasBinaryFileExtension",
"(",
"resourceName",
")",
")",
"{",
"addBinaryResourcePath",
"(",
"binRsHandler",
",",
"resourcePath",
")",
";",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"LOGGER",
".",
"debug",
"(",
"\"Added to item path list:\"",
"+",
"PathNormalizer",
".",
"asPath",
"(",
"resourcePath",
")",
")",
";",
"}",
"else",
"if",
"(",
"addSubDirs",
")",
"{",
"try",
"{",
"if",
"(",
"rsReaderHandler",
".",
"isDirectory",
"(",
"resourcePath",
")",
")",
"{",
"folders",
".",
"add",
"(",
"resourceName",
")",
";",
"}",
"}",
"catch",
"(",
"InvalidPathException",
"e",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"LOGGER",
".",
"debug",
"(",
"\"Enable to define if the following resource is a directory : \"",
"+",
"PathNormalizer",
".",
"asPath",
"(",
"resourcePath",
")",
")",
";",
"}",
"}",
"}",
"// Add subfolders if requested. Subfolders are added last unless",
"// specified in sorting file.",
"if",
"(",
"addSubDirs",
")",
"{",
"for",
"(",
"String",
"folderName",
":",
"folders",
")",
"{",
"addItemsFromDir",
"(",
"binRsHandler",
",",
"PathNormalizer",
".",
"joinPaths",
"(",
"dirName",
",",
"folderName",
")",
",",
"true",
")",
";",
"}",
"}",
"}"
] |
Adds all the resources within a path to the image map.
@param binRsHandler
the binary resources handler
@param dirName
the directory name
@param addSubDirs
boolean If subfolders will be included. In such case, every
folder below the path is included.
|
[
"Adds",
"all",
"the",
"resources",
"within",
"a",
"path",
"to",
"the",
"image",
"map",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrBinaryResourceRequestHandler.java#L330-L369
|
7,206 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrBinaryResourceRequestHandler.java
|
JawrBinaryResourceRequestHandler.getContentType
|
@Override
protected String getContentType(String filePath, HttpServletRequest request) {
String requestUri = request.getRequestURI();
// Retrieve the extension
String extension = getExtension(filePath);
if (extension == null) {
LOGGER.info("No extension found for the request URI : " + requestUri);
return null;
}
String binContentType = (String) binaryMimeTypeMap.get(extension);
if (binContentType == null) {
LOGGER.info(
"No binary extension match the extension '" + extension + "' for the request URI : " + requestUri);
return null;
}
return binContentType;
}
|
java
|
@Override
protected String getContentType(String filePath, HttpServletRequest request) {
String requestUri = request.getRequestURI();
// Retrieve the extension
String extension = getExtension(filePath);
if (extension == null) {
LOGGER.info("No extension found for the request URI : " + requestUri);
return null;
}
String binContentType = (String) binaryMimeTypeMap.get(extension);
if (binContentType == null) {
LOGGER.info(
"No binary extension match the extension '" + extension + "' for the request URI : " + requestUri);
return null;
}
return binContentType;
}
|
[
"@",
"Override",
"protected",
"String",
"getContentType",
"(",
"String",
"filePath",
",",
"HttpServletRequest",
"request",
")",
"{",
"String",
"requestUri",
"=",
"request",
".",
"getRequestURI",
"(",
")",
";",
"// Retrieve the extension",
"String",
"extension",
"=",
"getExtension",
"(",
"filePath",
")",
";",
"if",
"(",
"extension",
"==",
"null",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"No extension found for the request URI : \"",
"+",
"requestUri",
")",
";",
"return",
"null",
";",
"}",
"String",
"binContentType",
"=",
"(",
"String",
")",
"binaryMimeTypeMap",
".",
"get",
"(",
"extension",
")",
";",
"if",
"(",
"binContentType",
"==",
"null",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"No binary extension match the extension '\"",
"+",
"extension",
"+",
"\"' for the request URI : \"",
"+",
"requestUri",
")",
";",
"return",
"null",
";",
"}",
"return",
"binContentType",
";",
"}"
] |
Returns the content type for the image
@param filePath
the image file path
@param request
the request
@return the content type of the image
|
[
"Returns",
"the",
"content",
"type",
"for",
"the",
"image"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrBinaryResourceRequestHandler.java#L532-L552
|
7,207 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrBinaryResourceRequestHandler.java
|
JawrBinaryResourceRequestHandler.getRealFilePath
|
private String getRealFilePath(String fileName, BundleHashcodeType bundleHashcodeType) {
String realFilePath = fileName;
if (bundleHashcodeType.equals(BundleHashcodeType.INVALID_HASHCODE)) {
int idx = realFilePath.indexOf(JawrConstant.URL_SEPARATOR, 1);
if (idx != -1) {
realFilePath = realFilePath.substring(idx);
}
} else {
String[] resourceInfo = PathNormalizer.extractBinaryResourceInfo(realFilePath);
realFilePath = resourceInfo[0];
}
return realFilePath;
}
|
java
|
private String getRealFilePath(String fileName, BundleHashcodeType bundleHashcodeType) {
String realFilePath = fileName;
if (bundleHashcodeType.equals(BundleHashcodeType.INVALID_HASHCODE)) {
int idx = realFilePath.indexOf(JawrConstant.URL_SEPARATOR, 1);
if (idx != -1) {
realFilePath = realFilePath.substring(idx);
}
} else {
String[] resourceInfo = PathNormalizer.extractBinaryResourceInfo(realFilePath);
realFilePath = resourceInfo[0];
}
return realFilePath;
}
|
[
"private",
"String",
"getRealFilePath",
"(",
"String",
"fileName",
",",
"BundleHashcodeType",
"bundleHashcodeType",
")",
"{",
"String",
"realFilePath",
"=",
"fileName",
";",
"if",
"(",
"bundleHashcodeType",
".",
"equals",
"(",
"BundleHashcodeType",
".",
"INVALID_HASHCODE",
")",
")",
"{",
"int",
"idx",
"=",
"realFilePath",
".",
"indexOf",
"(",
"JawrConstant",
".",
"URL_SEPARATOR",
",",
"1",
")",
";",
"if",
"(",
"idx",
"!=",
"-",
"1",
")",
"{",
"realFilePath",
"=",
"realFilePath",
".",
"substring",
"(",
"idx",
")",
";",
"}",
"}",
"else",
"{",
"String",
"[",
"]",
"resourceInfo",
"=",
"PathNormalizer",
".",
"extractBinaryResourceInfo",
"(",
"realFilePath",
")",
";",
"realFilePath",
"=",
"resourceInfo",
"[",
"0",
"]",
";",
"}",
"return",
"realFilePath",
";",
"}"
] |
Removes the cache buster
@param fileName
the file name
@return the file name without the cache buster.
|
[
"Removes",
"the",
"cache",
"buster"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrBinaryResourceRequestHandler.java#L612-L626
|
7,208 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/js/coffee/CoffeeScriptGenerator.java
|
CoffeeScriptGenerator.getResourceInputStream
|
private InputStream getResourceInputStream(String path) {
InputStream is = config.getContext().getResourceAsStream(path);
if (is == null) {
try {
is = ClassLoaderResourceUtils.getResourceAsStream(path, this);
} catch (FileNotFoundException e) {
throw new BundlingProcessException(e);
}
}
return is;
}
|
java
|
private InputStream getResourceInputStream(String path) {
InputStream is = config.getContext().getResourceAsStream(path);
if (is == null) {
try {
is = ClassLoaderResourceUtils.getResourceAsStream(path, this);
} catch (FileNotFoundException e) {
throw new BundlingProcessException(e);
}
}
return is;
}
|
[
"private",
"InputStream",
"getResourceInputStream",
"(",
"String",
"path",
")",
"{",
"InputStream",
"is",
"=",
"config",
".",
"getContext",
"(",
")",
".",
"getResourceAsStream",
"(",
"path",
")",
";",
"if",
"(",
"is",
"==",
"null",
")",
"{",
"try",
"{",
"is",
"=",
"ClassLoaderResourceUtils",
".",
"getResourceAsStream",
"(",
"path",
",",
"this",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"e",
")",
";",
"}",
"}",
"return",
"is",
";",
"}"
] |
Returns the resource input stream
@param path
the resource path
@return the resource input stream
|
[
"Returns",
"the",
"resource",
"input",
"stream"
] |
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/js/coffee/CoffeeScriptGenerator.java#L133-L144
|
7,209 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/js/coffee/CoffeeScriptGenerator.java
|
CoffeeScriptGenerator.compile
|
public String compile(String resourcePath, String coffeeScriptSource) {
String result = null;
try {
result = (String) jsEngine.invokeMethod(coffeeScript, "compile", coffeeScriptSource, options);
} catch (NoSuchMethodException | ScriptException e) {
throw new BundlingProcessException(e);
}
return result;
}
|
java
|
public String compile(String resourcePath, String coffeeScriptSource) {
String result = null;
try {
result = (String) jsEngine.invokeMethod(coffeeScript, "compile", coffeeScriptSource, options);
} catch (NoSuchMethodException | ScriptException e) {
throw new BundlingProcessException(e);
}
return result;
}
|
[
"public",
"String",
"compile",
"(",
"String",
"resourcePath",
",",
"String",
"coffeeScriptSource",
")",
"{",
"String",
"result",
"=",
"null",
";",
"try",
"{",
"result",
"=",
"(",
"String",
")",
"jsEngine",
".",
"invokeMethod",
"(",
"coffeeScript",
",",
"\"compile\"",
",",
"coffeeScriptSource",
",",
"options",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"|",
"ScriptException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"e",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Compile the CoffeeScript source to a JS source
@param resourcePath
the resource path
@param coffeeScriptSource
the CoffeeScript source
@return the JS source
|
[
"Compile",
"the",
"CoffeeScript",
"source",
"to",
"a",
"JS",
"source"
] |
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/js/coffee/CoffeeScriptGenerator.java#L237-L247
|
7,210 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/message/BundleStringJsonifier.java
|
BundleStringJsonifier.serializeBundles
|
public StringBuffer serializeBundles() {
StringBuffer sb = new StringBuffer("{");
// Iterates over the
for (Iterator<String> it = keyMap.keySet().iterator(); it.hasNext();) {
String currentKey = it.next();
handleKey(sb, keyMap, currentKey, currentKey, !it.hasNext());
}
return sb.append("}");
}
|
java
|
public StringBuffer serializeBundles() {
StringBuffer sb = new StringBuffer("{");
// Iterates over the
for (Iterator<String> it = keyMap.keySet().iterator(); it.hasNext();) {
String currentKey = it.next();
handleKey(sb, keyMap, currentKey, currentKey, !it.hasNext());
}
return sb.append("}");
}
|
[
"public",
"StringBuffer",
"serializeBundles",
"(",
")",
"{",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
"\"{\"",
")",
";",
"// Iterates over the",
"for",
"(",
"Iterator",
"<",
"String",
">",
"it",
"=",
"keyMap",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"String",
"currentKey",
"=",
"it",
".",
"next",
"(",
")",
";",
"handleKey",
"(",
"sb",
",",
"keyMap",
",",
"currentKey",
",",
"currentKey",
",",
"!",
"it",
".",
"hasNext",
"(",
")",
")",
";",
"}",
"return",
"sb",
".",
"append",
"(",
"\"}\"",
")",
";",
"}"
] |
Creates a javascript object literal representing a set of message
resources.
@return StringBuffer the object literal.
|
[
"Creates",
"a",
"javascript",
"object",
"literal",
"representing",
"a",
"set",
"of",
"message",
"resources",
"."
] |
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/message/BundleStringJsonifier.java#L95-L105
|
7,211 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/message/BundleStringJsonifier.java
|
BundleStringJsonifier.handleKey
|
@SuppressWarnings("unchecked")
private void handleKey(final StringBuffer sb, Map<String, Object> currentLeaf, String currentKey, String fullKey,
boolean isLeafLast) {
Map<String, Object> newLeaf = (Map<String, Object>) currentLeaf.get(currentKey);
if (bundleValues.containsKey(fullKey)) {
addValuedKey(sb, currentKey, fullKey);
if (!newLeaf.isEmpty()) {
sb.append(",({");
for (Iterator<String> it = newLeaf.keySet().iterator(); it.hasNext();) {
String newKey = it.next();
handleKey(sb, newLeaf, newKey, fullKey + "." + newKey, !it.hasNext());
}
sb.append("}))");
} else {
sb.append(")");
}
} else if (!newLeaf.isEmpty()) {
sb.append(getJsonKey(currentKey)).append(":{");
for (Iterator<String> it = newLeaf.keySet().iterator(); it.hasNext();) {
String newKey = it.next();
handleKey(sb, newLeaf, newKey, fullKey + "." + newKey, !it.hasNext());
}
sb.append("}");
}
if (!isLeafLast)
sb.append(",");
}
|
java
|
@SuppressWarnings("unchecked")
private void handleKey(final StringBuffer sb, Map<String, Object> currentLeaf, String currentKey, String fullKey,
boolean isLeafLast) {
Map<String, Object> newLeaf = (Map<String, Object>) currentLeaf.get(currentKey);
if (bundleValues.containsKey(fullKey)) {
addValuedKey(sb, currentKey, fullKey);
if (!newLeaf.isEmpty()) {
sb.append(",({");
for (Iterator<String> it = newLeaf.keySet().iterator(); it.hasNext();) {
String newKey = it.next();
handleKey(sb, newLeaf, newKey, fullKey + "." + newKey, !it.hasNext());
}
sb.append("}))");
} else {
sb.append(")");
}
} else if (!newLeaf.isEmpty()) {
sb.append(getJsonKey(currentKey)).append(":{");
for (Iterator<String> it = newLeaf.keySet().iterator(); it.hasNext();) {
String newKey = it.next();
handleKey(sb, newLeaf, newKey, fullKey + "." + newKey, !it.hasNext());
}
sb.append("}");
}
if (!isLeafLast)
sb.append(",");
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"handleKey",
"(",
"final",
"StringBuffer",
"sb",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"currentLeaf",
",",
"String",
"currentKey",
",",
"String",
"fullKey",
",",
"boolean",
"isLeafLast",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"newLeaf",
"=",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"currentLeaf",
".",
"get",
"(",
"currentKey",
")",
";",
"if",
"(",
"bundleValues",
".",
"containsKey",
"(",
"fullKey",
")",
")",
"{",
"addValuedKey",
"(",
"sb",
",",
"currentKey",
",",
"fullKey",
")",
";",
"if",
"(",
"!",
"newLeaf",
".",
"isEmpty",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\",({\"",
")",
";",
"for",
"(",
"Iterator",
"<",
"String",
">",
"it",
"=",
"newLeaf",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"String",
"newKey",
"=",
"it",
".",
"next",
"(",
")",
";",
"handleKey",
"(",
"sb",
",",
"newLeaf",
",",
"newKey",
",",
"fullKey",
"+",
"\".\"",
"+",
"newKey",
",",
"!",
"it",
".",
"hasNext",
"(",
")",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"}))\"",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"\")\"",
")",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"newLeaf",
".",
"isEmpty",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"getJsonKey",
"(",
"currentKey",
")",
")",
".",
"append",
"(",
"\":{\"",
")",
";",
"for",
"(",
"Iterator",
"<",
"String",
">",
"it",
"=",
"newLeaf",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"String",
"newKey",
"=",
"it",
".",
"next",
"(",
")",
";",
"handleKey",
"(",
"sb",
",",
"newLeaf",
",",
"newKey",
",",
"fullKey",
"+",
"\".\"",
"+",
"newKey",
",",
"!",
"it",
".",
"hasNext",
"(",
")",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"}\"",
")",
";",
"}",
"if",
"(",
"!",
"isLeafLast",
")",
"sb",
".",
"append",
"(",
"\",\"",
")",
";",
"}"
] |
Processes a leaf from the key map, adding its name and values recursively
in a javascript object literal structure, where values are invocations of
a method that returns a function.
@param sb
StringBuffer to append the javascript code.
@param currentLeaf
Current Map from the keys tree.
@param currentKey
Current key from the keys tree.
@param fullKey
Key with ancestors as it appears in the message bundle(foo -->
com.mycompany.foo)
@param isLeafLast
Whether this is the last item in the current leaf, to append a
separator.
|
[
"Processes",
"a",
"leaf",
"from",
"the",
"key",
"map",
"adding",
"its",
"name",
"and",
"values",
"recursively",
"in",
"a",
"javascript",
"object",
"literal",
"structure",
"where",
"values",
"are",
"invocations",
"of",
"a",
"method",
"that",
"returns",
"a",
"function",
"."
] |
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/message/BundleStringJsonifier.java#L125-L154
|
7,212 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/message/BundleStringJsonifier.java
|
BundleStringJsonifier.getJsonKey
|
private String getJsonKey(String key) {
String jsonKey = key;
if (addQuoteToKey) {
jsonKey = JavascriptStringUtil.quote(key);
}
return jsonKey;
}
|
java
|
private String getJsonKey(String key) {
String jsonKey = key;
if (addQuoteToKey) {
jsonKey = JavascriptStringUtil.quote(key);
}
return jsonKey;
}
|
[
"private",
"String",
"getJsonKey",
"(",
"String",
"key",
")",
"{",
"String",
"jsonKey",
"=",
"key",
";",
"if",
"(",
"addQuoteToKey",
")",
"{",
"jsonKey",
"=",
"JavascriptStringUtil",
".",
"quote",
"(",
"key",
")",
";",
"}",
"return",
"jsonKey",
";",
"}"
] |
Returns the json key for messages taking in account the addQuoteToKey
attribute.
@param key
the key
@return the json key
|
[
"Returns",
"the",
"json",
"key",
"for",
"messages",
"taking",
"in",
"account",
"the",
"addQuoteToKey",
"attribute",
"."
] |
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/message/BundleStringJsonifier.java#L164-L170
|
7,213 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/message/BundleStringJsonifier.java
|
BundleStringJsonifier.addValuedKey
|
private void addValuedKey(final StringBuffer sb, String key, String fullKey) {
sb.append(getJsonKey(key)).append(":").append(FUNC)
.append(JavascriptStringUtil.quote(bundleValues.get(fullKey).toString()));
}
|
java
|
private void addValuedKey(final StringBuffer sb, String key, String fullKey) {
sb.append(getJsonKey(key)).append(":").append(FUNC)
.append(JavascriptStringUtil.quote(bundleValues.get(fullKey).toString()));
}
|
[
"private",
"void",
"addValuedKey",
"(",
"final",
"StringBuffer",
"sb",
",",
"String",
"key",
",",
"String",
"fullKey",
")",
"{",
"sb",
".",
"append",
"(",
"getJsonKey",
"(",
"key",
")",
")",
".",
"append",
"(",
"\":\"",
")",
".",
"append",
"(",
"FUNC",
")",
".",
"append",
"(",
"JavascriptStringUtil",
".",
"quote",
"(",
"bundleValues",
".",
"get",
"(",
"fullKey",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"}"
] |
Add a key and its value to the object literal.
@param sb
@param key
@param fullKey
|
[
"Add",
"a",
"key",
"and",
"its",
"value",
"to",
"the",
"object",
"literal",
"."
] |
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/message/BundleStringJsonifier.java#L179-L183
|
7,214 |
j-a-w-r/jawr-main-repo
|
jawr-dwr3.x/jawr-dwr3.x-webapp-sample/src/main/java/org/getahead/dwrdemo/asmg/Generator.java
|
Generator.generateAntiSpamMailto
|
public String generateAntiSpamMailto(String name, String email)
{
StringTokenizer st = new StringTokenizer(email, "@");
if (Security.containsXssRiskyCharacters(email) || st.countTokens() != 2)
{
throw new IllegalArgumentException("Invalid email address: " + email);
}
String before = st.nextToken();
String after = st.nextToken();
StringBuffer buffer = new StringBuffer();
buffer.append("Contact ");
buffer.append(Security.replaceXmlCharacters(name));
buffer.append(" using: <span id=\"asmgLink\"></span>\n");
buffer.append("<script type='text/javascript'>\n");
buffer.append("var before = '");
buffer.append(before);
buffer.append("';\n");
buffer.append("var after = '");
buffer.append(after);
buffer.append("';\n");
buffer.append("var link = \"<a href='mail\" + \"to:\" + before + '@' + after + \"'>\" + before + '@' + after + \"</a>\";\n");
buffer.append("document.getElementById(\"asmgLink\").innerHTML = link;\n");
buffer.append("</script>\n");
buffer.append("<noscript>[");
buffer.append(before);
buffer.append(" at ");
buffer.append(after);
buffer.append("]</noscript>\n");
return buffer.toString();
}
|
java
|
public String generateAntiSpamMailto(String name, String email)
{
StringTokenizer st = new StringTokenizer(email, "@");
if (Security.containsXssRiskyCharacters(email) || st.countTokens() != 2)
{
throw new IllegalArgumentException("Invalid email address: " + email);
}
String before = st.nextToken();
String after = st.nextToken();
StringBuffer buffer = new StringBuffer();
buffer.append("Contact ");
buffer.append(Security.replaceXmlCharacters(name));
buffer.append(" using: <span id=\"asmgLink\"></span>\n");
buffer.append("<script type='text/javascript'>\n");
buffer.append("var before = '");
buffer.append(before);
buffer.append("';\n");
buffer.append("var after = '");
buffer.append(after);
buffer.append("';\n");
buffer.append("var link = \"<a href='mail\" + \"to:\" + before + '@' + after + \"'>\" + before + '@' + after + \"</a>\";\n");
buffer.append("document.getElementById(\"asmgLink\").innerHTML = link;\n");
buffer.append("</script>\n");
buffer.append("<noscript>[");
buffer.append(before);
buffer.append(" at ");
buffer.append(after);
buffer.append("]</noscript>\n");
return buffer.toString();
}
|
[
"public",
"String",
"generateAntiSpamMailto",
"(",
"String",
"name",
",",
"String",
"email",
")",
"{",
"StringTokenizer",
"st",
"=",
"new",
"StringTokenizer",
"(",
"email",
",",
"\"@\"",
")",
";",
"if",
"(",
"Security",
".",
"containsXssRiskyCharacters",
"(",
"email",
")",
"||",
"st",
".",
"countTokens",
"(",
")",
"!=",
"2",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid email address: \"",
"+",
"email",
")",
";",
"}",
"String",
"before",
"=",
"st",
".",
"nextToken",
"(",
")",
";",
"String",
"after",
"=",
"st",
".",
"nextToken",
"(",
")",
";",
"StringBuffer",
"buffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"buffer",
".",
"append",
"(",
"\"Contact \"",
")",
";",
"buffer",
".",
"append",
"(",
"Security",
".",
"replaceXmlCharacters",
"(",
"name",
")",
")",
";",
"buffer",
".",
"append",
"(",
"\" using: <span id=\\\"asmgLink\\\"></span>\\n\"",
")",
";",
"buffer",
".",
"append",
"(",
"\"<script type='text/javascript'>\\n\"",
")",
";",
"buffer",
".",
"append",
"(",
"\"var before = '\"",
")",
";",
"buffer",
".",
"append",
"(",
"before",
")",
";",
"buffer",
".",
"append",
"(",
"\"';\\n\"",
")",
";",
"buffer",
".",
"append",
"(",
"\"var after = '\"",
")",
";",
"buffer",
".",
"append",
"(",
"after",
")",
";",
"buffer",
".",
"append",
"(",
"\"';\\n\"",
")",
";",
"buffer",
".",
"append",
"(",
"\"var link = \\\"<a href='mail\\\" + \\\"to:\\\" + before + '@' + after + \\\"'>\\\" + before + '@' + after + \\\"</a>\\\";\\n\"",
")",
";",
"buffer",
".",
"append",
"(",
"\"document.getElementById(\\\"asmgLink\\\").innerHTML = link;\\n\"",
")",
";",
"buffer",
".",
"append",
"(",
"\"</script>\\n\"",
")",
";",
"buffer",
".",
"append",
"(",
"\"<noscript>[\"",
")",
";",
"buffer",
".",
"append",
"(",
"before",
")",
";",
"buffer",
".",
"append",
"(",
"\" at \"",
")",
";",
"buffer",
".",
"append",
"(",
"after",
")",
";",
"buffer",
".",
"append",
"(",
"\"]</noscript>\\n\"",
")",
";",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] |
Generate an anti-spam mailto link from an email address
@param name The person to contact
@param email The address to generate a link from
@return The HTML snippet
|
[
"Generate",
"an",
"anti",
"-",
"spam",
"mailto",
"link",
"from",
"an",
"email",
"address"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr3.x/jawr-dwr3.x-webapp-sample/src/main/java/org/getahead/dwrdemo/asmg/Generator.java#L44-L81
|
7,215 |
j-a-w-r/jawr-main-repo
|
jawr-grails/jawr-grails-plugin/src/java/net/jawr/web/resource/bundle/locale/GrailsLocaleUtils.java
|
GrailsLocaleUtils.addSuffixIfAvailable
|
private static void addSuffixIfAvailable(String messageBundlePath,
List<String> availableLocaleSuffixes, Locale locale,
String fileSuffix, GrailsServletContextResourceReader rsReader) {
String localMsgResourcePath = toBundleName(messageBundlePath, locale)
+ fileSuffix;
boolean isFileSystemResourcePath = rsReader
.isFileSystemPath(localMsgResourcePath);
boolean resourceFound = false;
String path = localMsgResourcePath;
if (!isFileSystemResourcePath) {
// Try to retrieve the resource from the servlet context (used in war mode)
path = WEB_INF_DIR + localMsgResourcePath;
}
InputStream is = null;
try{
is = rsReader.getResourceAsStream(path);
resourceFound = is != null;
}finally{
IOUtils.close(is);
}
if (resourceFound) {
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,
List<String> availableLocaleSuffixes, Locale locale,
String fileSuffix, GrailsServletContextResourceReader rsReader) {
String localMsgResourcePath = toBundleName(messageBundlePath, locale)
+ fileSuffix;
boolean isFileSystemResourcePath = rsReader
.isFileSystemPath(localMsgResourcePath);
boolean resourceFound = false;
String path = localMsgResourcePath;
if (!isFileSystemResourcePath) {
// Try to retrieve the resource from the servlet context (used in war mode)
path = WEB_INF_DIR + localMsgResourcePath;
}
InputStream is = null;
try{
is = rsReader.getResourceAsStream(path);
resourceFound = is != null;
}finally{
IOUtils.close(is);
}
if (resourceFound) {
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",
",",
"List",
"<",
"String",
">",
"availableLocaleSuffixes",
",",
"Locale",
"locale",
",",
"String",
"fileSuffix",
",",
"GrailsServletContextResourceReader",
"rsReader",
")",
"{",
"String",
"localMsgResourcePath",
"=",
"toBundleName",
"(",
"messageBundlePath",
",",
"locale",
")",
"+",
"fileSuffix",
";",
"boolean",
"isFileSystemResourcePath",
"=",
"rsReader",
".",
"isFileSystemPath",
"(",
"localMsgResourcePath",
")",
";",
"boolean",
"resourceFound",
"=",
"false",
";",
"String",
"path",
"=",
"localMsgResourcePath",
";",
"if",
"(",
"!",
"isFileSystemResourcePath",
")",
"{",
"// Try to retrieve the resource from the servlet context (used in war mode)",
"path",
"=",
"WEB_INF_DIR",
"+",
"localMsgResourcePath",
";",
"}",
"InputStream",
"is",
"=",
"null",
";",
"try",
"{",
"is",
"=",
"rsReader",
".",
"getResourceAsStream",
"(",
"path",
")",
";",
"resourceFound",
"=",
"is",
"!=",
"null",
";",
"}",
"finally",
"{",
"IOUtils",
".",
"close",
"(",
"is",
")",
";",
"}",
"if",
"(",
"resourceFound",
")",
"{",
"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",
")",
";",
"}",
"}"
] |
Add 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
@param rsReader
the grails servlet context resource reader
|
[
"Add",
"the",
"locale",
"suffix",
"if",
"the",
"message",
"resource",
"bundle",
"file",
"exists",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-grails/jawr-grails-plugin/src/java/net/jawr/web/resource/bundle/locale/GrailsLocaleUtils.java#L194-L234
|
7,216 |
j-a-w-r/jawr-main-repo
|
jawr-grails/jawr-grails-plugin/src/java/net/jawr/web/resource/bundle/locale/GrailsLocaleUtils.java
|
GrailsLocaleUtils.isPluginResoucePath
|
public static boolean isPluginResoucePath(String resourcePath) {
Matcher matcher = PLUGIN_RESOURCE_PATTERN.matcher(resourcePath);
return matcher.find();
}
|
java
|
public static boolean isPluginResoucePath(String resourcePath) {
Matcher matcher = PLUGIN_RESOURCE_PATTERN.matcher(resourcePath);
return matcher.find();
}
|
[
"public",
"static",
"boolean",
"isPluginResoucePath",
"(",
"String",
"resourcePath",
")",
"{",
"Matcher",
"matcher",
"=",
"PLUGIN_RESOURCE_PATTERN",
".",
"matcher",
"(",
"resourcePath",
")",
";",
"return",
"matcher",
".",
"find",
"(",
")",
";",
"}"
] |
Returns true is the resource path is a plugin path
@param resourcePath
the resource path
@return true is the resource path is a plugin path
|
[
"Returns",
"true",
"is",
"the",
"resource",
"path",
"is",
"a",
"plugin",
"path"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-grails/jawr-grails-plugin/src/java/net/jawr/web/resource/bundle/locale/GrailsLocaleUtils.java#L349-L353
|
7,217 |
j-a-w-r/jawr-main-repo
|
jawr-grails/jawr-grails-plugin/src/java/net/jawr/web/resource/bundle/locale/GrailsLocaleUtils.java
|
GrailsLocaleUtils.getRealResourcePath
|
public static String getRealResourcePath(String path,
Map<String, String> pluginMsgPathMap) {
String realPath = path;
Matcher matcher = PLUGIN_RESOURCE_PATTERN.matcher(path);
StringBuffer sb = new StringBuffer();
if (matcher.find()) {
String pluginName = matcher.group(2);
String pluginPath = pluginMsgPathMap.get(pluginName);
if (pluginPath != null) {
matcher.appendReplacement(sb,
RegexUtil.adaptReplacementToMatcher(pluginPath + "/"));
matcher.appendTail(sb);
realPath = sb.toString();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Plugin path '" + path + "' mapped to '"
+ realPath + "'");
}
} else {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("No Plugin path found for '" + pluginName);
}
}
}
return realPath;
}
|
java
|
public static String getRealResourcePath(String path,
Map<String, String> pluginMsgPathMap) {
String realPath = path;
Matcher matcher = PLUGIN_RESOURCE_PATTERN.matcher(path);
StringBuffer sb = new StringBuffer();
if (matcher.find()) {
String pluginName = matcher.group(2);
String pluginPath = pluginMsgPathMap.get(pluginName);
if (pluginPath != null) {
matcher.appendReplacement(sb,
RegexUtil.adaptReplacementToMatcher(pluginPath + "/"));
matcher.appendTail(sb);
realPath = sb.toString();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Plugin path '" + path + "' mapped to '"
+ realPath + "'");
}
} else {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("No Plugin path found for '" + pluginName);
}
}
}
return realPath;
}
|
[
"public",
"static",
"String",
"getRealResourcePath",
"(",
"String",
"path",
",",
"Map",
"<",
"String",
",",
"String",
">",
"pluginMsgPathMap",
")",
"{",
"String",
"realPath",
"=",
"path",
";",
"Matcher",
"matcher",
"=",
"PLUGIN_RESOURCE_PATTERN",
".",
"matcher",
"(",
"path",
")",
";",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"if",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"String",
"pluginName",
"=",
"matcher",
".",
"group",
"(",
"2",
")",
";",
"String",
"pluginPath",
"=",
"pluginMsgPathMap",
".",
"get",
"(",
"pluginName",
")",
";",
"if",
"(",
"pluginPath",
"!=",
"null",
")",
"{",
"matcher",
".",
"appendReplacement",
"(",
"sb",
",",
"RegexUtil",
".",
"adaptReplacementToMatcher",
"(",
"pluginPath",
"+",
"\"/\"",
")",
")",
";",
"matcher",
".",
"appendTail",
"(",
"sb",
")",
";",
"realPath",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Plugin path '\"",
"+",
"path",
"+",
"\"' mapped to '\"",
"+",
"realPath",
"+",
"\"'\"",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"No Plugin path found for '\"",
"+",
"pluginName",
")",
";",
"}",
"}",
"}",
"return",
"realPath",
";",
"}"
] |
Handle the mapping of the resource path to the right one. This can be the
case for plugin resources. It will returns the file system path or the
real path or the same path if the path has not been remapped
@param path
the path
@param pluginMsgPathMap
the map for plugin path
@return the real path or the same path if the path has not been remapped
|
[
"Handle",
"the",
"mapping",
"of",
"the",
"resource",
"path",
"to",
"the",
"right",
"one",
".",
"This",
"can",
"be",
"the",
"case",
"for",
"plugin",
"resources",
".",
"It",
"will",
"returns",
"the",
"file",
"system",
"path",
"or",
"the",
"real",
"path",
"or",
"the",
"same",
"path",
"if",
"the",
"path",
"has",
"not",
"been",
"remapped"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-grails/jawr-grails-plugin/src/java/net/jawr/web/resource/bundle/locale/GrailsLocaleUtils.java#L366-L393
|
7,218 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ClientSideHandlerScriptRequestHandler.java
|
ClientSideHandlerScriptRequestHandler.handleClientSideHandlerRequest
|
public void handleClientSideHandlerRequest(HttpServletRequest request, HttpServletResponse response) {
Handler handler;
Map<String, String> variants = config.getGeneratorRegistry().resolveVariants(request);
String variantKey = VariantUtils.getVariantKey(variants);
if (handlerCache.containsKey(variantKey)) {
handler = (Handler) handlerCache.get(variantKey);
} else {
StringBuffer sb = rsHandler.getClientSideHandler().getClientSideHandlerScript(request);
handler = new Handler(sb, Integer.toString(sb.hashCode()));
handlerCache.put(variantKey, handler);
}
// Decide whether to set a 304 response
if (useNotModifiedHeader(request, handler.hash)) {
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return;
}
response.setHeader(HEADER_ETAG, handler.hash);
response.setDateHeader(HEADER_LAST_MODIFIED, START_TIME);
response.setContentType(JAVASCRIPT_CONTENT_TYPE);
if (RendererRequestUtils.isRequestGzippable(request, this.config)) {
try {
response.setHeader("Content-Encoding", "gzip");
GZIPOutputStream gzOut = new GZIPOutputStream(response.getOutputStream());
byte[] data = handler.data.toString().getBytes(this.config.getResourceCharset().name());
gzOut.write(data, 0, data.length);
gzOut.close();
} catch (IOException e) {
throw new BundlingProcessException("Unexpected IOException writing ClientSideHandlerScript", e);
}
} else {
StringReader rd = new StringReader(handler.data.toString());
try {
Writer writer = response.getWriter();
IOUtils.copy(rd, writer, true);
} catch (IOException e) {
throw new BundlingProcessException("Unexpected IOException writing ClientSideHandlerScript", e);
}
}
}
|
java
|
public void handleClientSideHandlerRequest(HttpServletRequest request, HttpServletResponse response) {
Handler handler;
Map<String, String> variants = config.getGeneratorRegistry().resolveVariants(request);
String variantKey = VariantUtils.getVariantKey(variants);
if (handlerCache.containsKey(variantKey)) {
handler = (Handler) handlerCache.get(variantKey);
} else {
StringBuffer sb = rsHandler.getClientSideHandler().getClientSideHandlerScript(request);
handler = new Handler(sb, Integer.toString(sb.hashCode()));
handlerCache.put(variantKey, handler);
}
// Decide whether to set a 304 response
if (useNotModifiedHeader(request, handler.hash)) {
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return;
}
response.setHeader(HEADER_ETAG, handler.hash);
response.setDateHeader(HEADER_LAST_MODIFIED, START_TIME);
response.setContentType(JAVASCRIPT_CONTENT_TYPE);
if (RendererRequestUtils.isRequestGzippable(request, this.config)) {
try {
response.setHeader("Content-Encoding", "gzip");
GZIPOutputStream gzOut = new GZIPOutputStream(response.getOutputStream());
byte[] data = handler.data.toString().getBytes(this.config.getResourceCharset().name());
gzOut.write(data, 0, data.length);
gzOut.close();
} catch (IOException e) {
throw new BundlingProcessException("Unexpected IOException writing ClientSideHandlerScript", e);
}
} else {
StringReader rd = new StringReader(handler.data.toString());
try {
Writer writer = response.getWriter();
IOUtils.copy(rd, writer, true);
} catch (IOException e) {
throw new BundlingProcessException("Unexpected IOException writing ClientSideHandlerScript", e);
}
}
}
|
[
"public",
"void",
"handleClientSideHandlerRequest",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"{",
"Handler",
"handler",
";",
"Map",
"<",
"String",
",",
"String",
">",
"variants",
"=",
"config",
".",
"getGeneratorRegistry",
"(",
")",
".",
"resolveVariants",
"(",
"request",
")",
";",
"String",
"variantKey",
"=",
"VariantUtils",
".",
"getVariantKey",
"(",
"variants",
")",
";",
"if",
"(",
"handlerCache",
".",
"containsKey",
"(",
"variantKey",
")",
")",
"{",
"handler",
"=",
"(",
"Handler",
")",
"handlerCache",
".",
"get",
"(",
"variantKey",
")",
";",
"}",
"else",
"{",
"StringBuffer",
"sb",
"=",
"rsHandler",
".",
"getClientSideHandler",
"(",
")",
".",
"getClientSideHandlerScript",
"(",
"request",
")",
";",
"handler",
"=",
"new",
"Handler",
"(",
"sb",
",",
"Integer",
".",
"toString",
"(",
"sb",
".",
"hashCode",
"(",
")",
")",
")",
";",
"handlerCache",
".",
"put",
"(",
"variantKey",
",",
"handler",
")",
";",
"}",
"// Decide whether to set a 304 response",
"if",
"(",
"useNotModifiedHeader",
"(",
"request",
",",
"handler",
".",
"hash",
")",
")",
"{",
"response",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_NOT_MODIFIED",
")",
";",
"return",
";",
"}",
"response",
".",
"setHeader",
"(",
"HEADER_ETAG",
",",
"handler",
".",
"hash",
")",
";",
"response",
".",
"setDateHeader",
"(",
"HEADER_LAST_MODIFIED",
",",
"START_TIME",
")",
";",
"response",
".",
"setContentType",
"(",
"JAVASCRIPT_CONTENT_TYPE",
")",
";",
"if",
"(",
"RendererRequestUtils",
".",
"isRequestGzippable",
"(",
"request",
",",
"this",
".",
"config",
")",
")",
"{",
"try",
"{",
"response",
".",
"setHeader",
"(",
"\"Content-Encoding\"",
",",
"\"gzip\"",
")",
";",
"GZIPOutputStream",
"gzOut",
"=",
"new",
"GZIPOutputStream",
"(",
"response",
".",
"getOutputStream",
"(",
")",
")",
";",
"byte",
"[",
"]",
"data",
"=",
"handler",
".",
"data",
".",
"toString",
"(",
")",
".",
"getBytes",
"(",
"this",
".",
"config",
".",
"getResourceCharset",
"(",
")",
".",
"name",
"(",
")",
")",
";",
"gzOut",
".",
"write",
"(",
"data",
",",
"0",
",",
"data",
".",
"length",
")",
";",
"gzOut",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Unexpected IOException writing ClientSideHandlerScript\"",
",",
"e",
")",
";",
"}",
"}",
"else",
"{",
"StringReader",
"rd",
"=",
"new",
"StringReader",
"(",
"handler",
".",
"data",
".",
"toString",
"(",
")",
")",
";",
"try",
"{",
"Writer",
"writer",
"=",
"response",
".",
"getWriter",
"(",
")",
";",
"IOUtils",
".",
"copy",
"(",
"rd",
",",
"writer",
",",
"true",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Unexpected IOException writing ClientSideHandlerScript\"",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Generates a locale dependent script used to include bundles in non
dynamic html pages. Uses a cache of said scripts to avoid constant
regeneration. It also keeps track of eTags and if-modified-since headers
to take advantage of client side caching.
@param request
the request
@param response
the response
|
[
"Generates",
"a",
"locale",
"dependent",
"script",
"used",
"to",
"include",
"bundles",
"in",
"non",
"dynamic",
"html",
"pages",
".",
"Uses",
"a",
"cache",
"of",
"said",
"scripts",
"to",
"avoid",
"constant",
"regeneration",
".",
"It",
"also",
"keeps",
"track",
"of",
"eTags",
"and",
"if",
"-",
"modified",
"-",
"since",
"headers",
"to",
"take",
"advantage",
"of",
"client",
"side",
"caching",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ClientSideHandlerScriptRequestHandler.java#L131-L173
|
7,219 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ClientSideHandlerScriptRequestHandler.java
|
ClientSideHandlerScriptRequestHandler.useNotModifiedHeader
|
private boolean useNotModifiedHeader(HttpServletRequest request, String scriptEtag) {
long modifiedHeader = -1;
try {
modifiedHeader = request.getDateHeader(HEADER_IF_MODIFIED);
if (modifiedHeader != -1)
modifiedHeader -= modifiedHeader % 1000;
} catch (RuntimeException ex) {
}
String eTag = request.getHeader(HEADER_IF_NONE);
if (modifiedHeader == -1) {
return scriptEtag.equals(eTag);
} else if (null == eTag) {
return modifiedHeader <= START_TIME;
} else {
return scriptEtag.equals(eTag) && modifiedHeader <= START_TIME;
}
}
|
java
|
private boolean useNotModifiedHeader(HttpServletRequest request, String scriptEtag) {
long modifiedHeader = -1;
try {
modifiedHeader = request.getDateHeader(HEADER_IF_MODIFIED);
if (modifiedHeader != -1)
modifiedHeader -= modifiedHeader % 1000;
} catch (RuntimeException ex) {
}
String eTag = request.getHeader(HEADER_IF_NONE);
if (modifiedHeader == -1) {
return scriptEtag.equals(eTag);
} else if (null == eTag) {
return modifiedHeader <= START_TIME;
} else {
return scriptEtag.equals(eTag) && modifiedHeader <= START_TIME;
}
}
|
[
"private",
"boolean",
"useNotModifiedHeader",
"(",
"HttpServletRequest",
"request",
",",
"String",
"scriptEtag",
")",
"{",
"long",
"modifiedHeader",
"=",
"-",
"1",
";",
"try",
"{",
"modifiedHeader",
"=",
"request",
".",
"getDateHeader",
"(",
"HEADER_IF_MODIFIED",
")",
";",
"if",
"(",
"modifiedHeader",
"!=",
"-",
"1",
")",
"modifiedHeader",
"-=",
"modifiedHeader",
"%",
"1000",
";",
"}",
"catch",
"(",
"RuntimeException",
"ex",
")",
"{",
"}",
"String",
"eTag",
"=",
"request",
".",
"getHeader",
"(",
"HEADER_IF_NONE",
")",
";",
"if",
"(",
"modifiedHeader",
"==",
"-",
"1",
")",
"{",
"return",
"scriptEtag",
".",
"equals",
"(",
"eTag",
")",
";",
"}",
"else",
"if",
"(",
"null",
"==",
"eTag",
")",
"{",
"return",
"modifiedHeader",
"<=",
"START_TIME",
";",
"}",
"else",
"{",
"return",
"scriptEtag",
".",
"equals",
"(",
"eTag",
")",
"&&",
"modifiedHeader",
"<=",
"START_TIME",
";",
"}",
"}"
] |
Determines whether a response should get a 304 response and empty body,
according to etags and if-modified-since headers.
@param request
@param scriptEtag
@return
|
[
"Determines",
"whether",
"a",
"response",
"should",
"get",
"a",
"304",
"response",
"and",
"empty",
"body",
"according",
"to",
"etags",
"and",
"if",
"-",
"modified",
"-",
"since",
"headers",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ClientSideHandlerScriptRequestHandler.java#L183-L199
|
7,220 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/CompositeBundlePathMappingBuilder.java
|
CompositeBundlePathMappingBuilder.addFilePathMapping
|
private void addFilePathMapping(BundlePathMapping bundlePathMapping, Set<String> paths) {
for (String path : paths) {
addFilePathMapping(bundlePathMapping, path);
}
}
|
java
|
private void addFilePathMapping(BundlePathMapping bundlePathMapping, Set<String> paths) {
for (String path : paths) {
addFilePathMapping(bundlePathMapping, path);
}
}
|
[
"private",
"void",
"addFilePathMapping",
"(",
"BundlePathMapping",
"bundlePathMapping",
",",
"Set",
"<",
"String",
">",
"paths",
")",
"{",
"for",
"(",
"String",
"path",
":",
"paths",
")",
"{",
"addFilePathMapping",
"(",
"bundlePathMapping",
",",
"path",
")",
";",
"}",
"}"
] |
Adds paths to the file path mapping
@param bundlePathMapping
the bundle path mapping
@param paths
the paths to add
|
[
"Adds",
"paths",
"to",
"the",
"file",
"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/bundle/mappings/CompositeBundlePathMappingBuilder.java#L83-L87
|
7,221 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/CompositeBundlePathMappingBuilder.java
|
CompositeBundlePathMappingBuilder.addFilePathMapping
|
private void addFilePathMapping(BundlePathMapping bundlePathMapping, List<BundlePath> itemPathList) {
for (BundlePath bundlePath : itemPathList) {
addFilePathMapping(bundlePathMapping, bundlePath.getPath());
}
}
|
java
|
private void addFilePathMapping(BundlePathMapping bundlePathMapping, List<BundlePath> itemPathList) {
for (BundlePath bundlePath : itemPathList) {
addFilePathMapping(bundlePathMapping, bundlePath.getPath());
}
}
|
[
"private",
"void",
"addFilePathMapping",
"(",
"BundlePathMapping",
"bundlePathMapping",
",",
"List",
"<",
"BundlePath",
">",
"itemPathList",
")",
"{",
"for",
"(",
"BundlePath",
"bundlePath",
":",
"itemPathList",
")",
"{",
"addFilePathMapping",
"(",
"bundlePathMapping",
",",
"bundlePath",
".",
"getPath",
"(",
")",
")",
";",
"}",
"}"
] |
Adds bundle paths to the file path mapping
@param bundlePathMapping
the bundle path mapping
@param paths
the paths to add
|
[
"Adds",
"bundle",
"paths",
"to",
"the",
"file",
"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/bundle/mappings/CompositeBundlePathMappingBuilder.java#L97-L101
|
7,222 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/taglib/ImageTagUtils.java
|
ImageTagUtils.getFullImagePath
|
private static String getFullImagePath(String imgSrc, BinaryResourcesHandler binaryRsHandler,
HttpServletRequest request) {
String contextPath = request.getContextPath();
// relative path
if (!binaryRsHandler.getConfig().getGeneratorRegistry().isGeneratedBinaryResource(imgSrc)
&& !imgSrc.startsWith("/")) {
imgSrc = PathNormalizer.concatWebPath(request.getRequestURI(), imgSrc);
int idx = imgSrc.indexOf(contextPath);
if (idx > -1) {
imgSrc = imgSrc.substring(idx + contextPath.length());
}
}
return imgSrc;
}
|
java
|
private static String getFullImagePath(String imgSrc, BinaryResourcesHandler binaryRsHandler,
HttpServletRequest request) {
String contextPath = request.getContextPath();
// relative path
if (!binaryRsHandler.getConfig().getGeneratorRegistry().isGeneratedBinaryResource(imgSrc)
&& !imgSrc.startsWith("/")) {
imgSrc = PathNormalizer.concatWebPath(request.getRequestURI(), imgSrc);
int idx = imgSrc.indexOf(contextPath);
if (idx > -1) {
imgSrc = imgSrc.substring(idx + contextPath.length());
}
}
return imgSrc;
}
|
[
"private",
"static",
"String",
"getFullImagePath",
"(",
"String",
"imgSrc",
",",
"BinaryResourcesHandler",
"binaryRsHandler",
",",
"HttpServletRequest",
"request",
")",
"{",
"String",
"contextPath",
"=",
"request",
".",
"getContextPath",
"(",
")",
";",
"// relative path",
"if",
"(",
"!",
"binaryRsHandler",
".",
"getConfig",
"(",
")",
".",
"getGeneratorRegistry",
"(",
")",
".",
"isGeneratedBinaryResource",
"(",
"imgSrc",
")",
"&&",
"!",
"imgSrc",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"imgSrc",
"=",
"PathNormalizer",
".",
"concatWebPath",
"(",
"request",
".",
"getRequestURI",
"(",
")",
",",
"imgSrc",
")",
";",
"int",
"idx",
"=",
"imgSrc",
".",
"indexOf",
"(",
"contextPath",
")",
";",
"if",
"(",
"idx",
">",
"-",
"1",
")",
"{",
"imgSrc",
"=",
"imgSrc",
".",
"substring",
"(",
"idx",
"+",
"contextPath",
".",
"length",
"(",
")",
")",
";",
"}",
"}",
"return",
"imgSrc",
";",
"}"
] |
Returns the full image path to handle the relative path
@param imgSrc
the image source path
@param binaryRsHandler
the binary resource handler
@param request
the request
@return the full image path
|
[
"Returns",
"the",
"full",
"image",
"path",
"to",
"handle",
"the",
"relative",
"path"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/taglib/ImageTagUtils.java#L155-L169
|
7,223 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/taglib/ImageTagUtils.java
|
ImageTagUtils.getImageUrl
|
public static String getImageUrl(String imgSrc, PageContext pageContext) {
BinaryResourcesHandler imgRsHandler = (BinaryResourcesHandler) pageContext.getServletContext()
.getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);
if (null == imgRsHandler)
throw new JawrLinkRenderingException(
"You are using a Jawr image tag while the Jawr Image servlet has not been initialized. Initialization of Jawr Image servlet either failed or never occurred.");
HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
return getImageUrl(imgSrc, imgRsHandler, request, response);
}
|
java
|
public static String getImageUrl(String imgSrc, PageContext pageContext) {
BinaryResourcesHandler imgRsHandler = (BinaryResourcesHandler) pageContext.getServletContext()
.getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);
if (null == imgRsHandler)
throw new JawrLinkRenderingException(
"You are using a Jawr image tag while the Jawr Image servlet has not been initialized. Initialization of Jawr Image servlet either failed or never occurred.");
HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
return getImageUrl(imgSrc, imgRsHandler, request, response);
}
|
[
"public",
"static",
"String",
"getImageUrl",
"(",
"String",
"imgSrc",
",",
"PageContext",
"pageContext",
")",
"{",
"BinaryResourcesHandler",
"imgRsHandler",
"=",
"(",
"BinaryResourcesHandler",
")",
"pageContext",
".",
"getServletContext",
"(",
")",
".",
"getAttribute",
"(",
"JawrConstant",
".",
"BINARY_CONTEXT_ATTRIBUTE",
")",
";",
"if",
"(",
"null",
"==",
"imgRsHandler",
")",
"throw",
"new",
"JawrLinkRenderingException",
"(",
"\"You are using a Jawr image tag while the Jawr Image servlet has not been initialized. Initialization of Jawr Image servlet either failed or never occurred.\"",
")",
";",
"HttpServletResponse",
"response",
"=",
"(",
"HttpServletResponse",
")",
"pageContext",
".",
"getResponse",
"(",
")",
";",
"HttpServletRequest",
"request",
"=",
"(",
"HttpServletRequest",
")",
"pageContext",
".",
"getRequest",
"(",
")",
";",
"return",
"getImageUrl",
"(",
"imgSrc",
",",
"imgRsHandler",
",",
"request",
",",
"response",
")",
";",
"}"
] |
Sames as its counterpart, only meant to be used as a JSP EL function.
@param imgSrc
the image path
@param pageContext
the page context
@return the image URL
|
[
"Sames",
"as",
"its",
"counterpart",
"only",
"meant",
"to",
"be",
"used",
"as",
"a",
"JSP",
"EL",
"function",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/taglib/ImageTagUtils.java#L180-L193
|
7,224 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/taglib/ImageTagUtils.java
|
ImageTagUtils.getBase64EncodedImage
|
public static String getBase64EncodedImage(String imgSrc, BinaryResourcesHandler binaryRsHandler,
HttpServletRequest request) {
String encodedResult = null;
if (null == binaryRsHandler) {
throw new JawrLinkRenderingException(
"You are using a Jawr image tag while the Jawr Image servlet has not been initialized. Initialization of Jawr Image servlet either failed or never occurred.");
}
imgSrc = getFullImagePath(imgSrc, binaryRsHandler, request);
encodedResult = binaryRsHandler.getCacheUrl(BASE64_KEY_PREFIX + imgSrc);
if (encodedResult == null) {
try {
String fileExtension = FileNameUtils.getExtension(imgSrc);
String fileMimeType = (String) MIMETypesSupport.getSupportedProperties(ImageTagUtils.class)
.get(fileExtension);
InputStream is = binaryRsHandler.getRsReaderHandler().getResourceAsStream(imgSrc);
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.copy(is, out, true);
byte[] data = out.toByteArray();
encodedResult = new String(Base64Encoder.encode(data));
encodedResult = DATA_PREFIX + fileMimeType + ";base64," + encodedResult;
binaryRsHandler.addMapping(BASE64_KEY_PREFIX + imgSrc, encodedResult);
} catch (ResourceNotFoundException e) {
LOGGER.warn("Unable to find the image '" + imgSrc + "' while generating image tag.");
} catch (IOException e) {
LOGGER.warn("Unable to copy the image '" + imgSrc + "' while generating image tag.");
}
}
return encodedResult;
}
|
java
|
public static String getBase64EncodedImage(String imgSrc, BinaryResourcesHandler binaryRsHandler,
HttpServletRequest request) {
String encodedResult = null;
if (null == binaryRsHandler) {
throw new JawrLinkRenderingException(
"You are using a Jawr image tag while the Jawr Image servlet has not been initialized. Initialization of Jawr Image servlet either failed or never occurred.");
}
imgSrc = getFullImagePath(imgSrc, binaryRsHandler, request);
encodedResult = binaryRsHandler.getCacheUrl(BASE64_KEY_PREFIX + imgSrc);
if (encodedResult == null) {
try {
String fileExtension = FileNameUtils.getExtension(imgSrc);
String fileMimeType = (String) MIMETypesSupport.getSupportedProperties(ImageTagUtils.class)
.get(fileExtension);
InputStream is = binaryRsHandler.getRsReaderHandler().getResourceAsStream(imgSrc);
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.copy(is, out, true);
byte[] data = out.toByteArray();
encodedResult = new String(Base64Encoder.encode(data));
encodedResult = DATA_PREFIX + fileMimeType + ";base64," + encodedResult;
binaryRsHandler.addMapping(BASE64_KEY_PREFIX + imgSrc, encodedResult);
} catch (ResourceNotFoundException e) {
LOGGER.warn("Unable to find the image '" + imgSrc + "' while generating image tag.");
} catch (IOException e) {
LOGGER.warn("Unable to copy the image '" + imgSrc + "' while generating image tag.");
}
}
return encodedResult;
}
|
[
"public",
"static",
"String",
"getBase64EncodedImage",
"(",
"String",
"imgSrc",
",",
"BinaryResourcesHandler",
"binaryRsHandler",
",",
"HttpServletRequest",
"request",
")",
"{",
"String",
"encodedResult",
"=",
"null",
";",
"if",
"(",
"null",
"==",
"binaryRsHandler",
")",
"{",
"throw",
"new",
"JawrLinkRenderingException",
"(",
"\"You are using a Jawr image tag while the Jawr Image servlet has not been initialized. Initialization of Jawr Image servlet either failed or never occurred.\"",
")",
";",
"}",
"imgSrc",
"=",
"getFullImagePath",
"(",
"imgSrc",
",",
"binaryRsHandler",
",",
"request",
")",
";",
"encodedResult",
"=",
"binaryRsHandler",
".",
"getCacheUrl",
"(",
"BASE64_KEY_PREFIX",
"+",
"imgSrc",
")",
";",
"if",
"(",
"encodedResult",
"==",
"null",
")",
"{",
"try",
"{",
"String",
"fileExtension",
"=",
"FileNameUtils",
".",
"getExtension",
"(",
"imgSrc",
")",
";",
"String",
"fileMimeType",
"=",
"(",
"String",
")",
"MIMETypesSupport",
".",
"getSupportedProperties",
"(",
"ImageTagUtils",
".",
"class",
")",
".",
"get",
"(",
"fileExtension",
")",
";",
"InputStream",
"is",
"=",
"binaryRsHandler",
".",
"getRsReaderHandler",
"(",
")",
".",
"getResourceAsStream",
"(",
"imgSrc",
")",
";",
"ByteArrayOutputStream",
"out",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"IOUtils",
".",
"copy",
"(",
"is",
",",
"out",
",",
"true",
")",
";",
"byte",
"[",
"]",
"data",
"=",
"out",
".",
"toByteArray",
"(",
")",
";",
"encodedResult",
"=",
"new",
"String",
"(",
"Base64Encoder",
".",
"encode",
"(",
"data",
")",
")",
";",
"encodedResult",
"=",
"DATA_PREFIX",
"+",
"fileMimeType",
"+",
"\";base64,\"",
"+",
"encodedResult",
";",
"binaryRsHandler",
".",
"addMapping",
"(",
"BASE64_KEY_PREFIX",
"+",
"imgSrc",
",",
"encodedResult",
")",
";",
"}",
"catch",
"(",
"ResourceNotFoundException",
"e",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Unable to find the image '\"",
"+",
"imgSrc",
"+",
"\"' while generating image tag.\"",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Unable to copy the image '\"",
"+",
"imgSrc",
"+",
"\"' while generating image tag.\"",
")",
";",
"}",
"}",
"return",
"encodedResult",
";",
"}"
] |
Returns the base64 image of the image path given in parameter
@param imgSrc
the image path
@param binaryRsHandler
the binary resource handler
@param request
the HTTP request
@return he base64 image of the image path given in parameter
@throws JawrLinkRenderingException
if an exception occurs
|
[
"Returns",
"the",
"base64",
"image",
"of",
"the",
"image",
"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/taglib/ImageTagUtils.java#L209-L243
|
7,225 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/CSSHTMLBundleLinkRenderer.java
|
CSSHTMLBundleLinkRenderer.setClosingTag
|
public static void setClosingTag(String flavor) {
if (FLAVORS_XHTML_EXTENDED.equalsIgnoreCase(flavor)) {
closingFlavor = POST_XHTML_EXT_TAG;
} else if (FLAVORS_HTML.equalsIgnoreCase(flavor))
closingFlavor = POST_HTML_TAG;
else
closingFlavor = POST_TAG;
}
|
java
|
public static void setClosingTag(String flavor) {
if (FLAVORS_XHTML_EXTENDED.equalsIgnoreCase(flavor)) {
closingFlavor = POST_XHTML_EXT_TAG;
} else if (FLAVORS_HTML.equalsIgnoreCase(flavor))
closingFlavor = POST_HTML_TAG;
else
closingFlavor = POST_TAG;
}
|
[
"public",
"static",
"void",
"setClosingTag",
"(",
"String",
"flavor",
")",
"{",
"if",
"(",
"FLAVORS_XHTML_EXTENDED",
".",
"equalsIgnoreCase",
"(",
"flavor",
")",
")",
"{",
"closingFlavor",
"=",
"POST_XHTML_EXT_TAG",
";",
"}",
"else",
"if",
"(",
"FLAVORS_HTML",
".",
"equalsIgnoreCase",
"(",
"flavor",
")",
")",
"closingFlavor",
"=",
"POST_HTML_TAG",
";",
"else",
"closingFlavor",
"=",
"POST_TAG",
";",
"}"
] |
Utility method to get the closing tag value based on a config parameter.
@param flavor
the flavor
|
[
"Utility",
"method",
"to",
"get",
"the",
"closing",
"tag",
"value",
"based",
"on",
"a",
"config",
"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/renderer/CSSHTMLBundleLinkRenderer.java#L139-L148
|
7,226 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/CSSHTMLBundleLinkRenderer.java
|
CSSHTMLBundleLinkRenderer.isForcedToRenderIeCssBundleInDebug
|
private boolean isForcedToRenderIeCssBundleInDebug(BundleRendererContext ctx, boolean debugOn) {
return debugOn && getResourceType().equals(JawrConstant.CSS_TYPE)
&& bundler.getConfig().isForceCssBundleInDebugForIEOn() && RendererRequestUtils.isIE(ctx.getRequest());
}
|
java
|
private boolean isForcedToRenderIeCssBundleInDebug(BundleRendererContext ctx, boolean debugOn) {
return debugOn && getResourceType().equals(JawrConstant.CSS_TYPE)
&& bundler.getConfig().isForceCssBundleInDebugForIEOn() && RendererRequestUtils.isIE(ctx.getRequest());
}
|
[
"private",
"boolean",
"isForcedToRenderIeCssBundleInDebug",
"(",
"BundleRendererContext",
"ctx",
",",
"boolean",
"debugOn",
")",
"{",
"return",
"debugOn",
"&&",
"getResourceType",
"(",
")",
".",
"equals",
"(",
"JawrConstant",
".",
"CSS_TYPE",
")",
"&&",
"bundler",
".",
"getConfig",
"(",
")",
".",
"isForceCssBundleInDebugForIEOn",
"(",
")",
"&&",
"RendererRequestUtils",
".",
"isIE",
"(",
"ctx",
".",
"getRequest",
"(",
")",
")",
";",
"}"
] |
Returns true if the renderer must render a CSS bundle link even in debug
mode
@param ctx
the context
@param debugOn
the debug flag
@return true if the renderer must render a CSS bundle link even in debug
mode
|
[
"Returns",
"true",
"if",
"the",
"renderer",
"must",
"render",
"a",
"CSS",
"bundle",
"link",
"even",
"in",
"debug",
"mode"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/CSSHTMLBundleLinkRenderer.java#L172-L176
|
7,227 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/CSSHTMLBundleLinkRenderer.java
|
CSSHTMLBundleLinkRenderer.renderIeCssBundleLink
|
private void renderIeCssBundleLink(BundleRendererContext ctx, Writer out, BundlePath bundlePath)
throws IOException {
Random randomSeed = new Random();
int random = randomSeed.nextInt();
if (random < 0)
random *= -1;
String path = GeneratorRegistry.IE_CSS_GENERATOR_PREFIX + GeneratorRegistry.PREFIX_SEPARATOR
+ bundlePath.getPath();
path = PathNormalizer.createGenerationPath(path, bundler.getConfig().getGeneratorRegistry(), "d=" + random);
out.write(createBundleLink(path, null, null, ctx.getContextPath(), ctx.isSslRequest()));
}
|
java
|
private void renderIeCssBundleLink(BundleRendererContext ctx, Writer out, BundlePath bundlePath)
throws IOException {
Random randomSeed = new Random();
int random = randomSeed.nextInt();
if (random < 0)
random *= -1;
String path = GeneratorRegistry.IE_CSS_GENERATOR_PREFIX + GeneratorRegistry.PREFIX_SEPARATOR
+ bundlePath.getPath();
path = PathNormalizer.createGenerationPath(path, bundler.getConfig().getGeneratorRegistry(), "d=" + random);
out.write(createBundleLink(path, null, null, ctx.getContextPath(), ctx.isSslRequest()));
}
|
[
"private",
"void",
"renderIeCssBundleLink",
"(",
"BundleRendererContext",
"ctx",
",",
"Writer",
"out",
",",
"BundlePath",
"bundlePath",
")",
"throws",
"IOException",
"{",
"Random",
"randomSeed",
"=",
"new",
"Random",
"(",
")",
";",
"int",
"random",
"=",
"randomSeed",
".",
"nextInt",
"(",
")",
";",
"if",
"(",
"random",
"<",
"0",
")",
"random",
"*=",
"-",
"1",
";",
"String",
"path",
"=",
"GeneratorRegistry",
".",
"IE_CSS_GENERATOR_PREFIX",
"+",
"GeneratorRegistry",
".",
"PREFIX_SEPARATOR",
"+",
"bundlePath",
".",
"getPath",
"(",
")",
";",
"path",
"=",
"PathNormalizer",
".",
"createGenerationPath",
"(",
"path",
",",
"bundler",
".",
"getConfig",
"(",
")",
".",
"getGeneratorRegistry",
"(",
")",
",",
"\"d=\"",
"+",
"random",
")",
";",
"out",
".",
"write",
"(",
"createBundleLink",
"(",
"path",
",",
"null",
",",
"null",
",",
"ctx",
".",
"getContextPath",
"(",
")",
",",
"ctx",
".",
"isSslRequest",
"(",
")",
")",
")",
";",
"}"
] |
Renders the CSS link to retrieve the CSS bundle for IE in debug mode.
@param ctx
the context
@param out
the writer
@param bundle
the bundle
@throws IOException
if an IOException occurs
|
[
"Renders",
"the",
"CSS",
"link",
"to",
"retrieve",
"the",
"CSS",
"bundle",
"for",
"IE",
"in",
"debug",
"mode",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/CSSHTMLBundleLinkRenderer.java#L350-L360
|
7,228 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/sass/ruby/SassRubyGenerator.java
|
SassRubyGenerator.compile
|
private String compile(JoinableResourceBundle bundle, String content, String path, GeneratorContext ctx)
throws ScriptException, IOException {
try(InputStream is = getResourceInputStream(JAWR_IMPORTER_RB)){
String script = IOUtils.toString(is);
rubyEngine.eval(script);
}
SimpleBindings bindings = new SimpleBindings();
JawrSassResolver scssResolver = new JawrSassResolver(bundle, path, rsHandler, useAbsoluteURL);
bindings.put(JAWR_RESOLVER_VAR, scssResolver);
String compiledScss = rubyEngine.eval(buildScript(path, content), bindings).toString();
addLinkedResources(path, ctx, scssResolver.getLinkedResources());
return compiledScss;
}
|
java
|
private String compile(JoinableResourceBundle bundle, String content, String path, GeneratorContext ctx)
throws ScriptException, IOException {
try(InputStream is = getResourceInputStream(JAWR_IMPORTER_RB)){
String script = IOUtils.toString(is);
rubyEngine.eval(script);
}
SimpleBindings bindings = new SimpleBindings();
JawrSassResolver scssResolver = new JawrSassResolver(bundle, path, rsHandler, useAbsoluteURL);
bindings.put(JAWR_RESOLVER_VAR, scssResolver);
String compiledScss = rubyEngine.eval(buildScript(path, content), bindings).toString();
addLinkedResources(path, ctx, scssResolver.getLinkedResources());
return compiledScss;
}
|
[
"private",
"String",
"compile",
"(",
"JoinableResourceBundle",
"bundle",
",",
"String",
"content",
",",
"String",
"path",
",",
"GeneratorContext",
"ctx",
")",
"throws",
"ScriptException",
",",
"IOException",
"{",
"try",
"(",
"InputStream",
"is",
"=",
"getResourceInputStream",
"(",
"JAWR_IMPORTER_RB",
")",
")",
"{",
"String",
"script",
"=",
"IOUtils",
".",
"toString",
"(",
"is",
")",
";",
"rubyEngine",
".",
"eval",
"(",
"script",
")",
";",
"}",
"SimpleBindings",
"bindings",
"=",
"new",
"SimpleBindings",
"(",
")",
";",
"JawrSassResolver",
"scssResolver",
"=",
"new",
"JawrSassResolver",
"(",
"bundle",
",",
"path",
",",
"rsHandler",
",",
"useAbsoluteURL",
")",
";",
"bindings",
".",
"put",
"(",
"JAWR_RESOLVER_VAR",
",",
"scssResolver",
")",
";",
"String",
"compiledScss",
"=",
"rubyEngine",
".",
"eval",
"(",
"buildScript",
"(",
"path",
",",
"content",
")",
",",
"bindings",
")",
".",
"toString",
"(",
")",
";",
"addLinkedResources",
"(",
"path",
",",
"ctx",
",",
"scssResolver",
".",
"getLinkedResources",
"(",
")",
")",
";",
"return",
"compiledScss",
";",
"}"
] |
Compile the Sass content
@param bundle
the bundle
@param content
the content to compile
@param path
the path
@param ctx
the generator context
@return the compiled Sass content
@throws ScriptException
if a ScriptException occurs
@throws IOException
if an IOExceptions occurs
|
[
"Compile",
"the",
"Sass",
"content"
] |
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/css/sass/ruby/SassRubyGenerator.java#L196-L210
|
7,229 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/sass/ruby/SassRubyGenerator.java
|
SassRubyGenerator.buildScript
|
private String buildScript(String path, String content) {
StringBuilder script = new StringBuilder();
script.append("require 'rubygems'\n" + "require 'sass/plugin'\n" + "require 'sass/engine'\n");
content = SassRubyUtils.normalizeMultiByteString(content);
script.append(String.format(
"customImporter = Sass::Importers::JawrImporter.new(@jawrResolver) \n" + "name = \"%s\"\n"
+ "result = Sass::Engine.new(\"%s\", {:importer => customImporter, :filename => name, :syntax => :scss, :cache => false}).render",
path, content.replace("\"", "\\\"").replace("#", "\\#")));
return script.toString();
}
|
java
|
private String buildScript(String path, String content) {
StringBuilder script = new StringBuilder();
script.append("require 'rubygems'\n" + "require 'sass/plugin'\n" + "require 'sass/engine'\n");
content = SassRubyUtils.normalizeMultiByteString(content);
script.append(String.format(
"customImporter = Sass::Importers::JawrImporter.new(@jawrResolver) \n" + "name = \"%s\"\n"
+ "result = Sass::Engine.new(\"%s\", {:importer => customImporter, :filename => name, :syntax => :scss, :cache => false}).render",
path, content.replace("\"", "\\\"").replace("#", "\\#")));
return script.toString();
}
|
[
"private",
"String",
"buildScript",
"(",
"String",
"path",
",",
"String",
"content",
")",
"{",
"StringBuilder",
"script",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"script",
".",
"append",
"(",
"\"require 'rubygems'\\n\"",
"+",
"\"require 'sass/plugin'\\n\"",
"+",
"\"require 'sass/engine'\\n\"",
")",
";",
"content",
"=",
"SassRubyUtils",
".",
"normalizeMultiByteString",
"(",
"content",
")",
";",
"script",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"customImporter = Sass::Importers::JawrImporter.new(@jawrResolver) \\n\"",
"+",
"\"name = \\\"%s\\\"\\n\"",
"+",
"\"result = Sass::Engine.new(\\\"%s\\\", {:importer => customImporter, :filename => name, :syntax => :scss, :cache => false}).render\"",
",",
"path",
",",
"content",
".",
"replace",
"(",
"\"\\\"\"",
",",
"\"\\\\\\\"\"",
")",
".",
"replace",
"(",
"\"#\"",
",",
"\"\\\\#\"",
")",
")",
")",
";",
"return",
"script",
".",
"toString",
"(",
")",
";",
"}"
] |
Builds the ruby script to execute
@param path
the resource path
@param content
the resource content
@return the ruby script to execute
|
[
"Builds",
"the",
"ruby",
"script",
"to",
"execute"
] |
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/css/sass/ruby/SassRubyGenerator.java#L221-L234
|
7,230 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/config/JawrConfig.java
|
JawrConfig.setCharsetName
|
public final void setCharsetName(String charsetName) {
if (!Charset.isSupported(charsetName))
throw new IllegalArgumentException(
"The specified charset [" + charsetName + "] is not supported by the jvm.");
this.charsetName = charsetName;
}
|
java
|
public final void setCharsetName(String charsetName) {
if (!Charset.isSupported(charsetName))
throw new IllegalArgumentException(
"The specified charset [" + charsetName + "] is not supported by the jvm.");
this.charsetName = charsetName;
}
|
[
"public",
"final",
"void",
"setCharsetName",
"(",
"String",
"charsetName",
")",
"{",
"if",
"(",
"!",
"Charset",
".",
"isSupported",
"(",
"charsetName",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The specified charset [\"",
"+",
"charsetName",
"+",
"\"] is not supported by the jvm.\"",
")",
";",
"this",
".",
"charsetName",
"=",
"charsetName",
";",
"}"
] |
Set the charsetname to be used to interpret and generate resource.
@param charsetName
the charset name to set
|
[
"Set",
"the",
"charsetname",
"to",
"be",
"used",
"to",
"interpret",
"and",
"generate",
"resource",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/config/JawrConfig.java#L869-L874
|
7,231 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/config/JawrConfig.java
|
JawrConfig.setGeneratorRegistry
|
public void setGeneratorRegistry(GeneratorRegistry generatorRegistry) {
this.generatorRegistry = generatorRegistry;
this.generatorRegistry.setConfig(this);
localeResolver = null;
if (configProperties.getProperty(JAWR_LOCALE_RESOLVER) == null) {
localeResolver = new DefaultLocaleResolver();
} else {
localeResolver = (LocaleResolver) ClassLoaderResourceUtils
.buildObjectInstance(configProperties.getProperty(JAWR_LOCALE_RESOLVER));
}
this.generatorRegistry.registerVariantResolver(new LocaleVariantResolverWrapper(localeResolver));
registerResolver(new BrowserResolver(), JAWR_BROWSER_RESOLVER);
registerResolver(new ConnectionTypeResolver(), JAWR_CONNECTION_TYPE_SCHEME_RESOLVER);
registerResolver(new CssSkinVariantResolver(), JAWR_CSS_SKIN_RESOLVER);
}
|
java
|
public void setGeneratorRegistry(GeneratorRegistry generatorRegistry) {
this.generatorRegistry = generatorRegistry;
this.generatorRegistry.setConfig(this);
localeResolver = null;
if (configProperties.getProperty(JAWR_LOCALE_RESOLVER) == null) {
localeResolver = new DefaultLocaleResolver();
} else {
localeResolver = (LocaleResolver) ClassLoaderResourceUtils
.buildObjectInstance(configProperties.getProperty(JAWR_LOCALE_RESOLVER));
}
this.generatorRegistry.registerVariantResolver(new LocaleVariantResolverWrapper(localeResolver));
registerResolver(new BrowserResolver(), JAWR_BROWSER_RESOLVER);
registerResolver(new ConnectionTypeResolver(), JAWR_CONNECTION_TYPE_SCHEME_RESOLVER);
registerResolver(new CssSkinVariantResolver(), JAWR_CSS_SKIN_RESOLVER);
}
|
[
"public",
"void",
"setGeneratorRegistry",
"(",
"GeneratorRegistry",
"generatorRegistry",
")",
"{",
"this",
".",
"generatorRegistry",
"=",
"generatorRegistry",
";",
"this",
".",
"generatorRegistry",
".",
"setConfig",
"(",
"this",
")",
";",
"localeResolver",
"=",
"null",
";",
"if",
"(",
"configProperties",
".",
"getProperty",
"(",
"JAWR_LOCALE_RESOLVER",
")",
"==",
"null",
")",
"{",
"localeResolver",
"=",
"new",
"DefaultLocaleResolver",
"(",
")",
";",
"}",
"else",
"{",
"localeResolver",
"=",
"(",
"LocaleResolver",
")",
"ClassLoaderResourceUtils",
".",
"buildObjectInstance",
"(",
"configProperties",
".",
"getProperty",
"(",
"JAWR_LOCALE_RESOLVER",
")",
")",
";",
"}",
"this",
".",
"generatorRegistry",
".",
"registerVariantResolver",
"(",
"new",
"LocaleVariantResolverWrapper",
"(",
"localeResolver",
")",
")",
";",
"registerResolver",
"(",
"new",
"BrowserResolver",
"(",
")",
",",
"JAWR_BROWSER_RESOLVER",
")",
";",
"registerResolver",
"(",
"new",
"ConnectionTypeResolver",
"(",
")",
",",
"JAWR_CONNECTION_TYPE_SCHEME_RESOLVER",
")",
";",
"registerResolver",
"(",
"new",
"CssSkinVariantResolver",
"(",
")",
",",
"JAWR_CSS_SKIN_RESOLVER",
")",
";",
"}"
] |
Set the generator registry
@param generatorRegistry
the generatorRegistry to set
|
[
"Set",
"the",
"generator",
"registry"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/config/JawrConfig.java#L1207-L1223
|
7,232 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/config/JawrConfig.java
|
JawrConfig.registerResolver
|
private VariantResolver registerResolver(VariantResolver defaultResolver, String configPropertyName) {
VariantResolver resolver = null;
if (configProperties.getProperty(configPropertyName) == null) {
resolver = defaultResolver;
} else {
resolver = (VariantResolver) ClassLoaderResourceUtils
.buildObjectInstance(configProperties.getProperty(configPropertyName));
}
this.generatorRegistry.registerVariantResolver(resolver);
return resolver;
}
|
java
|
private VariantResolver registerResolver(VariantResolver defaultResolver, String configPropertyName) {
VariantResolver resolver = null;
if (configProperties.getProperty(configPropertyName) == null) {
resolver = defaultResolver;
} else {
resolver = (VariantResolver) ClassLoaderResourceUtils
.buildObjectInstance(configProperties.getProperty(configPropertyName));
}
this.generatorRegistry.registerVariantResolver(resolver);
return resolver;
}
|
[
"private",
"VariantResolver",
"registerResolver",
"(",
"VariantResolver",
"defaultResolver",
",",
"String",
"configPropertyName",
")",
"{",
"VariantResolver",
"resolver",
"=",
"null",
";",
"if",
"(",
"configProperties",
".",
"getProperty",
"(",
"configPropertyName",
")",
"==",
"null",
")",
"{",
"resolver",
"=",
"defaultResolver",
";",
"}",
"else",
"{",
"resolver",
"=",
"(",
"VariantResolver",
")",
"ClassLoaderResourceUtils",
".",
"buildObjectInstance",
"(",
"configProperties",
".",
"getProperty",
"(",
"configPropertyName",
")",
")",
";",
"}",
"this",
".",
"generatorRegistry",
".",
"registerVariantResolver",
"(",
"resolver",
")",
";",
"return",
"resolver",
";",
"}"
] |
Register a resolver in the generator registry
@param defaultResolver
the default resolver
@param configPropertyName
the configuration property whose the value define the resolver
class
@return
|
[
"Register",
"a",
"resolver",
"in",
"the",
"generator",
"registry"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/config/JawrConfig.java#L1235-L1246
|
7,233 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/config/JawrConfig.java
|
JawrConfig.setCssLinkFlavor
|
public final void setCssLinkFlavor(String cssLinkFlavor) {
if (CSSHTMLBundleLinkRenderer.FLAVORS_HTML.equalsIgnoreCase(cssLinkFlavor)
|| CSSHTMLBundleLinkRenderer.FLAVORS_XHTML.equalsIgnoreCase(cssLinkFlavor)
|| CSSHTMLBundleLinkRenderer.FLAVORS_XHTML_EXTENDED.equalsIgnoreCase(cssLinkFlavor))
CSSHTMLBundleLinkRenderer.setClosingTag(cssLinkFlavor);
else {
throw new IllegalArgumentException("The value for the jawr.csslinks.flavor " + "property [" + cssLinkFlavor
+ "] is invalid. " + "Please check the docs for valid values ");
}
}
|
java
|
public final void setCssLinkFlavor(String cssLinkFlavor) {
if (CSSHTMLBundleLinkRenderer.FLAVORS_HTML.equalsIgnoreCase(cssLinkFlavor)
|| CSSHTMLBundleLinkRenderer.FLAVORS_XHTML.equalsIgnoreCase(cssLinkFlavor)
|| CSSHTMLBundleLinkRenderer.FLAVORS_XHTML_EXTENDED.equalsIgnoreCase(cssLinkFlavor))
CSSHTMLBundleLinkRenderer.setClosingTag(cssLinkFlavor);
else {
throw new IllegalArgumentException("The value for the jawr.csslinks.flavor " + "property [" + cssLinkFlavor
+ "] is invalid. " + "Please check the docs for valid values ");
}
}
|
[
"public",
"final",
"void",
"setCssLinkFlavor",
"(",
"String",
"cssLinkFlavor",
")",
"{",
"if",
"(",
"CSSHTMLBundleLinkRenderer",
".",
"FLAVORS_HTML",
".",
"equalsIgnoreCase",
"(",
"cssLinkFlavor",
")",
"||",
"CSSHTMLBundleLinkRenderer",
".",
"FLAVORS_XHTML",
".",
"equalsIgnoreCase",
"(",
"cssLinkFlavor",
")",
"||",
"CSSHTMLBundleLinkRenderer",
".",
"FLAVORS_XHTML_EXTENDED",
".",
"equalsIgnoreCase",
"(",
"cssLinkFlavor",
")",
")",
"CSSHTMLBundleLinkRenderer",
".",
"setClosingTag",
"(",
"cssLinkFlavor",
")",
";",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The value for the jawr.csslinks.flavor \"",
"+",
"\"property [\"",
"+",
"cssLinkFlavor",
"+",
"\"] is invalid. \"",
"+",
"\"Please check the docs for valid values \"",
")",
";",
"}",
"}"
] |
Sets the css link flavor
@param cssLinkFlavor
the cssLinkFlavor to set
|
[
"Sets",
"the",
"css",
"link",
"flavor"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/config/JawrConfig.java#L1310-L1319
|
7,234 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/config/JawrConfig.java
|
JawrConfig.getBooleanProperty
|
public boolean getBooleanProperty(String propertyName, boolean defaultValue) {
return Boolean.valueOf(getProperty(propertyName, Boolean.toString(defaultValue)));
}
|
java
|
public boolean getBooleanProperty(String propertyName, boolean defaultValue) {
return Boolean.valueOf(getProperty(propertyName, Boolean.toString(defaultValue)));
}
|
[
"public",
"boolean",
"getBooleanProperty",
"(",
"String",
"propertyName",
",",
"boolean",
"defaultValue",
")",
"{",
"return",
"Boolean",
".",
"valueOf",
"(",
"getProperty",
"(",
"propertyName",
",",
"Boolean",
".",
"toString",
"(",
"defaultValue",
")",
")",
")",
";",
"}"
] |
Returns the boolean property value
@param propertyName
the property name
@param defaultValue
the default value
@return the boolean property value
|
[
"Returns",
"the",
"boolean",
"property",
"value"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/config/JawrConfig.java#L1330-L1333
|
7,235 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/config/JawrConfig.java
|
JawrConfig.getProperty
|
public String getProperty(String key, String defaultValue) {
String property = configProperties.getProperty(key, defaultValue);
if (property != null) {
property = property.trim();
}
return property;
}
|
java
|
public String getProperty(String key, String defaultValue) {
String property = configProperties.getProperty(key, defaultValue);
if (property != null) {
property = property.trim();
}
return property;
}
|
[
"public",
"String",
"getProperty",
"(",
"String",
"key",
",",
"String",
"defaultValue",
")",
"{",
"String",
"property",
"=",
"configProperties",
".",
"getProperty",
"(",
"key",
",",
"defaultValue",
")",
";",
"if",
"(",
"property",
"!=",
"null",
")",
"{",
"property",
"=",
"property",
".",
"trim",
"(",
")",
";",
"}",
"return",
"property",
";",
"}"
] |
Returns the value of the property associated to the key passed in
parameter
@param key
the key of the property
@param defaultValue
the default value
@return the value of the property
|
[
"Returns",
"the",
"value",
"of",
"the",
"property",
"associated",
"to",
"the",
"key",
"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/config/JawrConfig.java#L1358-L1365
|
7,236 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/config/JawrConfig.java
|
JawrConfig.getJavascriptEngineName
|
public String getJavascriptEngineName(String defaultJsEnginePropName) {
String jsEngineName = null;
if (StringUtils.isEmpty(defaultJsEnginePropName)) {
jsEngineName = getJavascriptEngineName();
} else {
jsEngineName = getProperty(defaultJsEnginePropName);
if (StringUtils.isEmpty(jsEngineName)) {
jsEngineName = getJavascriptEngineName();
}
}
return jsEngineName;
}
|
java
|
public String getJavascriptEngineName(String defaultJsEnginePropName) {
String jsEngineName = null;
if (StringUtils.isEmpty(defaultJsEnginePropName)) {
jsEngineName = getJavascriptEngineName();
} else {
jsEngineName = getProperty(defaultJsEnginePropName);
if (StringUtils.isEmpty(jsEngineName)) {
jsEngineName = getJavascriptEngineName();
}
}
return jsEngineName;
}
|
[
"public",
"String",
"getJavascriptEngineName",
"(",
"String",
"defaultJsEnginePropName",
")",
"{",
"String",
"jsEngineName",
"=",
"null",
";",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"defaultJsEnginePropName",
")",
")",
"{",
"jsEngineName",
"=",
"getJavascriptEngineName",
"(",
")",
";",
"}",
"else",
"{",
"jsEngineName",
"=",
"getProperty",
"(",
"defaultJsEnginePropName",
")",
";",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"jsEngineName",
")",
")",
"{",
"jsEngineName",
"=",
"getJavascriptEngineName",
"(",
")",
";",
"}",
"}",
"return",
"jsEngineName",
";",
"}"
] |
Returns the name of JS engine to use
@param defaultJsEnginePropName
the default JS engine property name
@return the name of JS engine to use
|
[
"Returns",
"the",
"name",
"of",
"JS",
"engine",
"to",
"use"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/config/JawrConfig.java#L1418-L1431
|
7,237 |
j-a-w-r/jawr-main-repo
|
jawr-spring/jawr-spring-extension/src/main/java/net/jawr/web/servlet/JawrSpringController.java
|
JawrSpringController.setControllerMapping
|
public void setControllerMapping(String controllerMapping) {
if (controllerMapping.endsWith("/")) {
this.controllerMapping = controllerMapping.substring(0,
controllerMapping.length() - 1);
} else {
this.controllerMapping = controllerMapping;
}
}
|
java
|
public void setControllerMapping(String controllerMapping) {
if (controllerMapping.endsWith("/")) {
this.controllerMapping = controllerMapping.substring(0,
controllerMapping.length() - 1);
} else {
this.controllerMapping = controllerMapping;
}
}
|
[
"public",
"void",
"setControllerMapping",
"(",
"String",
"controllerMapping",
")",
"{",
"if",
"(",
"controllerMapping",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"this",
".",
"controllerMapping",
"=",
"controllerMapping",
".",
"substring",
"(",
"0",
",",
"controllerMapping",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"else",
"{",
"this",
".",
"controllerMapping",
"=",
"controllerMapping",
";",
"}",
"}"
] |
Sets the controller mapping
@param controllerMapping
the controllerMapping to set
|
[
"Sets",
"the",
"controller",
"mapping"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-spring/jawr-spring-extension/src/main/java/net/jawr/web/servlet/JawrSpringController.java#L175-L182
|
7,238 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ConfigPropertiesAugmenter.java
|
ConfigPropertiesAugmenter.augmentConfiguration
|
public void augmentConfiguration(Properties configToAdd) {
for (Entry<Object, Object> entry : configToAdd.entrySet()) {
String configKey = (String) entry.getKey();
String configValue = (String) entry.getValue();
// Skip the property is it is not overridable
if (null != privateConfigProperties && privateConfigProperties.contains(configKey)) {
LOGGER.warn("The property " + configKey + " can not be overridden. It will remain with a value of "
+ configProperties.get(configKey));
continue;
}
// Augment mappings
if (isAugmentable(configKey)) {
String currentValue = configProperties.getProperty(configKey);
currentValue += "," + configValue;
configProperties.put(configKey, currentValue);
} else
// replace properties
configProperties.put(configKey, configValue);
}
}
|
java
|
public void augmentConfiguration(Properties configToAdd) {
for (Entry<Object, Object> entry : configToAdd.entrySet()) {
String configKey = (String) entry.getKey();
String configValue = (String) entry.getValue();
// Skip the property is it is not overridable
if (null != privateConfigProperties && privateConfigProperties.contains(configKey)) {
LOGGER.warn("The property " + configKey + " can not be overridden. It will remain with a value of "
+ configProperties.get(configKey));
continue;
}
// Augment mappings
if (isAugmentable(configKey)) {
String currentValue = configProperties.getProperty(configKey);
currentValue += "," + configValue;
configProperties.put(configKey, currentValue);
} else
// replace properties
configProperties.put(configKey, configValue);
}
}
|
[
"public",
"void",
"augmentConfiguration",
"(",
"Properties",
"configToAdd",
")",
"{",
"for",
"(",
"Entry",
"<",
"Object",
",",
"Object",
">",
"entry",
":",
"configToAdd",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"configKey",
"=",
"(",
"String",
")",
"entry",
".",
"getKey",
"(",
")",
";",
"String",
"configValue",
"=",
"(",
"String",
")",
"entry",
".",
"getValue",
"(",
")",
";",
"// Skip the property is it is not overridable",
"if",
"(",
"null",
"!=",
"privateConfigProperties",
"&&",
"privateConfigProperties",
".",
"contains",
"(",
"configKey",
")",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"The property \"",
"+",
"configKey",
"+",
"\" can not be overridden. It will remain with a value of \"",
"+",
"configProperties",
".",
"get",
"(",
"configKey",
")",
")",
";",
"continue",
";",
"}",
"// Augment mappings",
"if",
"(",
"isAugmentable",
"(",
"configKey",
")",
")",
"{",
"String",
"currentValue",
"=",
"configProperties",
".",
"getProperty",
"(",
"configKey",
")",
";",
"currentValue",
"+=",
"\",\"",
"+",
"configValue",
";",
"configProperties",
".",
"put",
"(",
"configKey",
",",
"currentValue",
")",
";",
"}",
"else",
"// replace properties",
"configProperties",
".",
"put",
"(",
"configKey",
",",
"configValue",
")",
";",
"}",
"}"
] |
Augments the base configuration with the properties specified as
parameter.
@param configToAdd
the configuration properties to add
|
[
"Augments",
"the",
"base",
"configuration",
"with",
"the",
"properties",
"specified",
"as",
"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/factory/util/ConfigPropertiesAugmenter.java#L80-L101
|
7,239 |
j-a-w-r/jawr-main-repo
|
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/ServletDefinition.java
|
ServletDefinition.initServlet
|
public HttpServlet initServlet() throws Exception {
servlet = (HttpServlet) servletClass.newInstance();
servlet.init(servletConfig);
return servlet;
}
|
java
|
public HttpServlet initServlet() throws Exception {
servlet = (HttpServlet) servletClass.newInstance();
servlet.init(servletConfig);
return servlet;
}
|
[
"public",
"HttpServlet",
"initServlet",
"(",
")",
"throws",
"Exception",
"{",
"servlet",
"=",
"(",
"HttpServlet",
")",
"servletClass",
".",
"newInstance",
"(",
")",
";",
"servlet",
".",
"init",
"(",
"servletConfig",
")",
";",
"return",
"servlet",
";",
"}"
] |
Create a new instance of the servlet and initialize it.
@param servletClass the servlet class
@param servletConfig the servlet config
@throws ServletException if a servlet exception occurs.
|
[
"Create",
"a",
"new",
"instance",
"of",
"the",
"servlet",
"and",
"initialize",
"it",
"."
] |
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/ServletDefinition.java#L97-L102
|
7,240 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/CheckSumUtils.java
|
CheckSumUtils.getChecksum
|
public static String getChecksum(String url, ResourceReaderHandler rsReader, JawrConfig jawrConfig)
throws IOException, ResourceNotFoundException {
String checksum = null;
InputStream is = null;
boolean generatedBinaryResource = jawrConfig.getGeneratorRegistry().isGeneratedBinaryResource(url);
try {
if (!generatedBinaryResource) {
url = PathNormalizer.asPath(url);
}
is = rsReader.getResourceAsStream(url);
if (is != null) {
checksum = CheckSumUtils.getChecksum(is, jawrConfig.getBinaryHashAlgorithm());
} else {
throw new ResourceNotFoundException(url);
}
} catch (FileNotFoundException e) {
throw new ResourceNotFoundException(url);
} finally {
IOUtils.close(is);
}
return checksum;
}
|
java
|
public static String getChecksum(String url, ResourceReaderHandler rsReader, JawrConfig jawrConfig)
throws IOException, ResourceNotFoundException {
String checksum = null;
InputStream is = null;
boolean generatedBinaryResource = jawrConfig.getGeneratorRegistry().isGeneratedBinaryResource(url);
try {
if (!generatedBinaryResource) {
url = PathNormalizer.asPath(url);
}
is = rsReader.getResourceAsStream(url);
if (is != null) {
checksum = CheckSumUtils.getChecksum(is, jawrConfig.getBinaryHashAlgorithm());
} else {
throw new ResourceNotFoundException(url);
}
} catch (FileNotFoundException e) {
throw new ResourceNotFoundException(url);
} finally {
IOUtils.close(is);
}
return checksum;
}
|
[
"public",
"static",
"String",
"getChecksum",
"(",
"String",
"url",
",",
"ResourceReaderHandler",
"rsReader",
",",
"JawrConfig",
"jawrConfig",
")",
"throws",
"IOException",
",",
"ResourceNotFoundException",
"{",
"String",
"checksum",
"=",
"null",
";",
"InputStream",
"is",
"=",
"null",
";",
"boolean",
"generatedBinaryResource",
"=",
"jawrConfig",
".",
"getGeneratorRegistry",
"(",
")",
".",
"isGeneratedBinaryResource",
"(",
"url",
")",
";",
"try",
"{",
"if",
"(",
"!",
"generatedBinaryResource",
")",
"{",
"url",
"=",
"PathNormalizer",
".",
"asPath",
"(",
"url",
")",
";",
"}",
"is",
"=",
"rsReader",
".",
"getResourceAsStream",
"(",
"url",
")",
";",
"if",
"(",
"is",
"!=",
"null",
")",
"{",
"checksum",
"=",
"CheckSumUtils",
".",
"getChecksum",
"(",
"is",
",",
"jawrConfig",
".",
"getBinaryHashAlgorithm",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ResourceNotFoundException",
"(",
"url",
")",
";",
"}",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"throw",
"new",
"ResourceNotFoundException",
"(",
"url",
")",
";",
"}",
"finally",
"{",
"IOUtils",
".",
"close",
"(",
"is",
")",
";",
"}",
"return",
"checksum",
";",
"}"
] |
Return the checksum of the path given in parameter, if the resource is
not found, null will b returned.
@param url
the url path to the resource file
@param rsReader
the resource reader handler
@param jawrConfig
the jawrConfig
@return checksum of the path given in parameter
@throws IOException
if an IO exception occurs.
@throws ResourceNotFoundException
if the resource is not found.
|
[
"Return",
"the",
"checksum",
"of",
"the",
"path",
"given",
"in",
"parameter",
"if",
"the",
"resource",
"is",
"not",
"found",
"null",
"will",
"b",
"returned",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/CheckSumUtils.java#L59-L87
|
7,241 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/CheckSumUtils.java
|
CheckSumUtils.getCacheBustedUrl
|
public static String getCacheBustedUrl(String url, ResourceReaderHandler rsReader, JawrConfig jawrConfig)
throws IOException, ResourceNotFoundException {
String checksum = getChecksum(url, rsReader, jawrConfig);
String result = JawrConstant.CACHE_BUSTER_PREFIX;
boolean generatedBinaryResource = jawrConfig.getGeneratorRegistry().isGeneratedBinaryResource(url);
if (generatedBinaryResource) {
int idx = url.indexOf(GeneratorRegistry.PREFIX_SEPARATOR);
String generatorPrefix = url.substring(0, idx);
url = url.substring(idx + 1);
result = generatorPrefix + "_cb";
}
result = result + checksum;
if (!url.startsWith("/")) {
result = result + "/";
}
// Add the cache buster extension
return PathNormalizer.asPath(result + url);
}
|
java
|
public static String getCacheBustedUrl(String url, ResourceReaderHandler rsReader, JawrConfig jawrConfig)
throws IOException, ResourceNotFoundException {
String checksum = getChecksum(url, rsReader, jawrConfig);
String result = JawrConstant.CACHE_BUSTER_PREFIX;
boolean generatedBinaryResource = jawrConfig.getGeneratorRegistry().isGeneratedBinaryResource(url);
if (generatedBinaryResource) {
int idx = url.indexOf(GeneratorRegistry.PREFIX_SEPARATOR);
String generatorPrefix = url.substring(0, idx);
url = url.substring(idx + 1);
result = generatorPrefix + "_cb";
}
result = result + checksum;
if (!url.startsWith("/")) {
result = result + "/";
}
// Add the cache buster extension
return PathNormalizer.asPath(result + url);
}
|
[
"public",
"static",
"String",
"getCacheBustedUrl",
"(",
"String",
"url",
",",
"ResourceReaderHandler",
"rsReader",
",",
"JawrConfig",
"jawrConfig",
")",
"throws",
"IOException",
",",
"ResourceNotFoundException",
"{",
"String",
"checksum",
"=",
"getChecksum",
"(",
"url",
",",
"rsReader",
",",
"jawrConfig",
")",
";",
"String",
"result",
"=",
"JawrConstant",
".",
"CACHE_BUSTER_PREFIX",
";",
"boolean",
"generatedBinaryResource",
"=",
"jawrConfig",
".",
"getGeneratorRegistry",
"(",
")",
".",
"isGeneratedBinaryResource",
"(",
"url",
")",
";",
"if",
"(",
"generatedBinaryResource",
")",
"{",
"int",
"idx",
"=",
"url",
".",
"indexOf",
"(",
"GeneratorRegistry",
".",
"PREFIX_SEPARATOR",
")",
";",
"String",
"generatorPrefix",
"=",
"url",
".",
"substring",
"(",
"0",
",",
"idx",
")",
";",
"url",
"=",
"url",
".",
"substring",
"(",
"idx",
"+",
"1",
")",
";",
"result",
"=",
"generatorPrefix",
"+",
"\"_cb\"",
";",
"}",
"result",
"=",
"result",
"+",
"checksum",
";",
"if",
"(",
"!",
"url",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"result",
"=",
"result",
"+",
"\"/\"",
";",
"}",
"// Add the cache buster extension",
"return",
"PathNormalizer",
".",
"asPath",
"(",
"result",
"+",
"url",
")",
";",
"}"
] |
Return the cache busted url associated to the url passed in parameter, if
the resource is not found, null will b returned.
@param url
the url path to the resource file
@param rsReader
the resource reader handler
@param jawrConfig
the jawrConfig
@return the cache busted url
@throws IOException
if an IO exception occurs.
@throws ResourceNotFoundException
if the resource is not found.
|
[
"Return",
"the",
"cache",
"busted",
"url",
"associated",
"to",
"the",
"url",
"passed",
"in",
"parameter",
"if",
"the",
"resource",
"is",
"not",
"found",
"null",
"will",
"b",
"returned",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/CheckSumUtils.java#L105-L126
|
7,242 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/CheckSumUtils.java
|
CheckSumUtils.getChecksum
|
public static String getChecksum(InputStream is, String algorithm) throws IOException {
if (algorithm.equals(JawrConstant.CRC32_ALGORITHM)) {
return getCRC32Checksum(is);
} else if (algorithm.equals(JawrConstant.MD5_ALGORITHM)) {
return getMD5Checksum(is);
} else {
throw new BundlingProcessException("The checksum algorithm '" + algorithm + "' is not supported.\n"
+ "The only supported algorithm are 'CRC32' or 'MD5'.");
}
}
|
java
|
public static String getChecksum(InputStream is, String algorithm) throws IOException {
if (algorithm.equals(JawrConstant.CRC32_ALGORITHM)) {
return getCRC32Checksum(is);
} else if (algorithm.equals(JawrConstant.MD5_ALGORITHM)) {
return getMD5Checksum(is);
} else {
throw new BundlingProcessException("The checksum algorithm '" + algorithm + "' is not supported.\n"
+ "The only supported algorithm are 'CRC32' or 'MD5'.");
}
}
|
[
"public",
"static",
"String",
"getChecksum",
"(",
"InputStream",
"is",
",",
"String",
"algorithm",
")",
"throws",
"IOException",
"{",
"if",
"(",
"algorithm",
".",
"equals",
"(",
"JawrConstant",
".",
"CRC32_ALGORITHM",
")",
")",
"{",
"return",
"getCRC32Checksum",
"(",
"is",
")",
";",
"}",
"else",
"if",
"(",
"algorithm",
".",
"equals",
"(",
"JawrConstant",
".",
"MD5_ALGORITHM",
")",
")",
"{",
"return",
"getMD5Checksum",
"(",
"is",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"The checksum algorithm '\"",
"+",
"algorithm",
"+",
"\"' is not supported.\\n\"",
"+",
"\"The only supported algorithm are 'CRC32' or 'MD5'.\"",
")",
";",
"}",
"}"
] |
Returns the checksum value of the input stream taking in count the
algorithm passed in parameter
@param is
the input stream
@param algorithm
the checksum algorithm
@return the checksum value
@throws IOException
if an exception occurs.
|
[
"Returns",
"the",
"checksum",
"value",
"of",
"the",
"input",
"stream",
"taking",
"in",
"count",
"the",
"algorithm",
"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/resource/bundle/CheckSumUtils.java#L140-L150
|
7,243 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/CheckSumUtils.java
|
CheckSumUtils.getCRC32Checksum
|
public static String getCRC32Checksum(InputStream is) throws IOException {
Checksum checksum = new CRC32();
byte[] bytes = new byte[1024];
int len = 0;
while ((len = is.read(bytes)) >= 0) {
checksum.update(bytes, 0, len);
}
return Long.toString(checksum.getValue());
}
|
java
|
public static String getCRC32Checksum(InputStream is) throws IOException {
Checksum checksum = new CRC32();
byte[] bytes = new byte[1024];
int len = 0;
while ((len = is.read(bytes)) >= 0) {
checksum.update(bytes, 0, len);
}
return Long.toString(checksum.getValue());
}
|
[
"public",
"static",
"String",
"getCRC32Checksum",
"(",
"InputStream",
"is",
")",
"throws",
"IOException",
"{",
"Checksum",
"checksum",
"=",
"new",
"CRC32",
"(",
")",
";",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"1024",
"]",
";",
"int",
"len",
"=",
"0",
";",
"while",
"(",
"(",
"len",
"=",
"is",
".",
"read",
"(",
"bytes",
")",
")",
">=",
"0",
")",
"{",
"checksum",
".",
"update",
"(",
"bytes",
",",
"0",
",",
"len",
")",
";",
"}",
"return",
"Long",
".",
"toString",
"(",
"checksum",
".",
"getValue",
"(",
")",
")",
";",
"}"
] |
Returns the CRC 32 Checksum of the input stream
@param is
the input stream
@return the CRC 32 checksum of the input stream
@throws IOException
if an IO exception occurs
|
[
"Returns",
"the",
"CRC",
"32",
"Checksum",
"of",
"the",
"input",
"stream"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/CheckSumUtils.java#L162-L174
|
7,244 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/CheckSumUtils.java
|
CheckSumUtils.getMD5Checksum
|
public static String getMD5Checksum(InputStream is) throws IOException {
byte[] digest = null;
try {
MessageDigest md = MessageDigest.getInstance(JawrConstant.MD5_ALGORITHM);
InputStream digestIs = new DigestInputStream(is, md);
// read stream to EOF as normal...
while (digestIs.read() != -1) {
}
digest = md.digest();
} catch (NoSuchAlgorithmException e) {
throw new BundlingProcessException("MD5 algorithm needs to be installed", e);
}
return new BigInteger(1, digest).toString(16);
}
|
java
|
public static String getMD5Checksum(InputStream is) throws IOException {
byte[] digest = null;
try {
MessageDigest md = MessageDigest.getInstance(JawrConstant.MD5_ALGORITHM);
InputStream digestIs = new DigestInputStream(is, md);
// read stream to EOF as normal...
while (digestIs.read() != -1) {
}
digest = md.digest();
} catch (NoSuchAlgorithmException e) {
throw new BundlingProcessException("MD5 algorithm needs to be installed", e);
}
return new BigInteger(1, digest).toString(16);
}
|
[
"public",
"static",
"String",
"getMD5Checksum",
"(",
"InputStream",
"is",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"digest",
"=",
"null",
";",
"try",
"{",
"MessageDigest",
"md",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"JawrConstant",
".",
"MD5_ALGORITHM",
")",
";",
"InputStream",
"digestIs",
"=",
"new",
"DigestInputStream",
"(",
"is",
",",
"md",
")",
";",
"// read stream to EOF as normal...",
"while",
"(",
"digestIs",
".",
"read",
"(",
")",
"!=",
"-",
"1",
")",
"{",
"}",
"digest",
"=",
"md",
".",
"digest",
"(",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"MD5 algorithm needs to be installed\"",
",",
"e",
")",
";",
"}",
"return",
"new",
"BigInteger",
"(",
"1",
",",
"digest",
")",
".",
"toString",
"(",
"16",
")",
";",
"}"
] |
Returns the MD5 Checksum of the input stream
@param is
the input stream
@return the Checksum of the input stream
@throws IOException
if an IO exception occurs
|
[
"Returns",
"the",
"MD5",
"Checksum",
"of",
"the",
"input",
"stream"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/CheckSumUtils.java#L220-L236
|
7,245 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/util/PropertyUtils.java
|
PropertyUtils.getProperty
|
public static String getProperty(Object bean, String name)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
String value = null;
// Retrieve the property getter method for the specified property
PropertyDescriptor descriptor = getPropertyDescriptor(bean, name);
if (descriptor == null) {
throw new NoSuchMethodException("Unknown property '" + name + "'");
}
Method readMethod = descriptor.getReadMethod();
if (readMethod == null) {
throw new NoSuchMethodException("Property '" + name + "' has no getter method");
}
// Call the property getter and return the value
Object result = (Object) invokeMethod(readMethod, bean, new Object[0]);
if (result != null) {
value = result.toString();
}
return value;
}
|
java
|
public static String getProperty(Object bean, String name)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
String value = null;
// Retrieve the property getter method for the specified property
PropertyDescriptor descriptor = getPropertyDescriptor(bean, name);
if (descriptor == null) {
throw new NoSuchMethodException("Unknown property '" + name + "'");
}
Method readMethod = descriptor.getReadMethod();
if (readMethod == null) {
throw new NoSuchMethodException("Property '" + name + "' has no getter method");
}
// Call the property getter and return the value
Object result = (Object) invokeMethod(readMethod, bean, new Object[0]);
if (result != null) {
value = result.toString();
}
return value;
}
|
[
"public",
"static",
"String",
"getProperty",
"(",
"Object",
"bean",
",",
"String",
"name",
")",
"throws",
"NoSuchMethodException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"String",
"value",
"=",
"null",
";",
"// Retrieve the property getter method for the specified property",
"PropertyDescriptor",
"descriptor",
"=",
"getPropertyDescriptor",
"(",
"bean",
",",
"name",
")",
";",
"if",
"(",
"descriptor",
"==",
"null",
")",
"{",
"throw",
"new",
"NoSuchMethodException",
"(",
"\"Unknown property '\"",
"+",
"name",
"+",
"\"'\"",
")",
";",
"}",
"Method",
"readMethod",
"=",
"descriptor",
".",
"getReadMethod",
"(",
")",
";",
"if",
"(",
"readMethod",
"==",
"null",
")",
"{",
"throw",
"new",
"NoSuchMethodException",
"(",
"\"Property '\"",
"+",
"name",
"+",
"\"' has no getter method\"",
")",
";",
"}",
"// Call the property getter and return the value",
"Object",
"result",
"=",
"(",
"Object",
")",
"invokeMethod",
"(",
"readMethod",
",",
"bean",
",",
"new",
"Object",
"[",
"0",
"]",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"value",
"=",
"result",
".",
"toString",
"(",
")",
";",
"}",
"return",
"value",
";",
"}"
] |
Return the value of the specified simple property of the specified bean,
with string conversions.
@param bean
Bean whose property is to be extracted
@param name
Name of the property to be extracted
@return the value of the specified simple property of the specified bean,
with string conversions.
@exception IllegalAccessException
if the caller does not have access to the property
accessor method
@exception IllegalArgumentException
if <code>bean</code> or <code>name</code> is null
@exception IllegalArgumentException
if the property name is nested or indexed
@exception InvocationTargetException
if the property accessor method throws an exception
@exception NoSuchMethodException
if an accessor method for this propety cannot be found
|
[
"Return",
"the",
"value",
"of",
"the",
"specified",
"simple",
"property",
"of",
"the",
"specified",
"bean",
"with",
"string",
"conversions",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/util/PropertyUtils.java#L62-L86
|
7,246 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/util/PropertyUtils.java
|
PropertyUtils.setProperty
|
public static void setProperty(Object bean, String name, Object value)
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
if (bean == null) {
throw new IllegalArgumentException("No bean specified");
}
if (name == null) {
throw new IllegalArgumentException("No name specified");
}
// Retrieve the property setter method for the specified property
PropertyDescriptor descriptor = getPropertyDescriptor(bean, name);
if (descriptor == null) {
throw new NoSuchMethodException("Unknown property '" + name + "'");
}
Method writeMethod = descriptor.getWriteMethod();
if (writeMethod == null) {
throw new NoSuchMethodException("Property '" + name + "' has no setter method");
}
// Call the property setter method
Object values[] = new Object[1];
values[0] = value;
invokeMethod(writeMethod, bean, values);
}
|
java
|
public static void setProperty(Object bean, String name, Object value)
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
if (bean == null) {
throw new IllegalArgumentException("No bean specified");
}
if (name == null) {
throw new IllegalArgumentException("No name specified");
}
// Retrieve the property setter method for the specified property
PropertyDescriptor descriptor = getPropertyDescriptor(bean, name);
if (descriptor == null) {
throw new NoSuchMethodException("Unknown property '" + name + "'");
}
Method writeMethod = descriptor.getWriteMethod();
if (writeMethod == null) {
throw new NoSuchMethodException("Property '" + name + "' has no setter method");
}
// Call the property setter method
Object values[] = new Object[1];
values[0] = value;
invokeMethod(writeMethod, bean, values);
}
|
[
"public",
"static",
"void",
"setProperty",
"(",
"Object",
"bean",
",",
"String",
"name",
",",
"Object",
"value",
")",
"throws",
"IllegalAccessException",
",",
"InvocationTargetException",
",",
"NoSuchMethodException",
"{",
"if",
"(",
"bean",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No bean specified\"",
")",
";",
"}",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No name specified\"",
")",
";",
"}",
"// Retrieve the property setter method for the specified property",
"PropertyDescriptor",
"descriptor",
"=",
"getPropertyDescriptor",
"(",
"bean",
",",
"name",
")",
";",
"if",
"(",
"descriptor",
"==",
"null",
")",
"{",
"throw",
"new",
"NoSuchMethodException",
"(",
"\"Unknown property '\"",
"+",
"name",
"+",
"\"'\"",
")",
";",
"}",
"Method",
"writeMethod",
"=",
"descriptor",
".",
"getWriteMethod",
"(",
")",
";",
"if",
"(",
"writeMethod",
"==",
"null",
")",
"{",
"throw",
"new",
"NoSuchMethodException",
"(",
"\"Property '\"",
"+",
"name",
"+",
"\"' has no setter method\"",
")",
";",
"}",
"// Call the property setter method",
"Object",
"values",
"[",
"]",
"=",
"new",
"Object",
"[",
"1",
"]",
";",
"values",
"[",
"0",
"]",
"=",
"value",
";",
"invokeMethod",
"(",
"writeMethod",
",",
"bean",
",",
"values",
")",
";",
"}"
] |
Set the value of the specified simple property of the specified bean,
with no type conversions.
@param bean
Bean whose property is to be modified
@param name
Name of the property to be modified
@param value
Value to which the property should be set
@exception IllegalAccessException
if the caller does not have access to the property
accessor method
@exception IllegalArgumentException
if <code>bean</code> or <code>name</code> is null
@exception IllegalArgumentException
if the property name is nested or indexed
@exception InvocationTargetException
if the property accessor method throws an exception
@exception NoSuchMethodException
if an accessor method for this propety cannot be found
|
[
"Set",
"the",
"value",
"of",
"the",
"specified",
"simple",
"property",
"of",
"the",
"specified",
"bean",
"with",
"no",
"type",
"conversions",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/util/PropertyUtils.java#L191-L217
|
7,247 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/util/PropertyUtils.java
|
PropertyUtils.invokeMethod
|
private static Object invokeMethod(Method method, Object bean, Object[] values)
throws IllegalAccessException, InvocationTargetException {
try {
return method.invoke(bean, values);
} catch (IllegalArgumentException e) {
LOGGER.error("Method invocation failed.", e);
throw new IllegalArgumentException("Cannot invoke " + method.getDeclaringClass().getName() + "."
+ method.getName() + " - " + e.getMessage());
}
}
|
java
|
private static Object invokeMethod(Method method, Object bean, Object[] values)
throws IllegalAccessException, InvocationTargetException {
try {
return method.invoke(bean, values);
} catch (IllegalArgumentException e) {
LOGGER.error("Method invocation failed.", e);
throw new IllegalArgumentException("Cannot invoke " + method.getDeclaringClass().getName() + "."
+ method.getName() + " - " + e.getMessage());
}
}
|
[
"private",
"static",
"Object",
"invokeMethod",
"(",
"Method",
"method",
",",
"Object",
"bean",
",",
"Object",
"[",
"]",
"values",
")",
"throws",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"try",
"{",
"return",
"method",
".",
"invoke",
"(",
"bean",
",",
"values",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Method invocation failed.\"",
",",
"e",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot invoke \"",
"+",
"method",
".",
"getDeclaringClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\".\"",
"+",
"method",
".",
"getName",
"(",
")",
"+",
"\" - \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
This utility method just catches and wraps IllegalArgumentException.
@param method
the method to call
@param bean
the bean
@param values
the values
@return the returned value of the method
@throws IllegalAccessException
if an exception occurs
@throws InvocationTargetException
if an exception occurs
|
[
"This",
"utility",
"method",
"just",
"catches",
"and",
"wraps",
"IllegalArgumentException",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/util/PropertyUtils.java#L234-L247
|
7,248 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.isSearchingForVariantInPostProcessNeeded
|
private boolean isSearchingForVariantInPostProcessNeeded() {
boolean needToSearch = false;
ResourceBundlePostProcessor[] postprocessors = new ResourceBundlePostProcessor[] { postProcessor,
unitaryCompositePostProcessor, compositePostProcessor, unitaryCompositePostProcessor };
for (ResourceBundlePostProcessor resourceBundlePostProcessor : postprocessors) {
if (resourceBundlePostProcessor != null
&& ((AbstractChainedResourceBundlePostProcessor) resourceBundlePostProcessor)
.isVariantPostProcessor()) {
needToSearch = true;
break;
}
}
return needToSearch;
}
|
java
|
private boolean isSearchingForVariantInPostProcessNeeded() {
boolean needToSearch = false;
ResourceBundlePostProcessor[] postprocessors = new ResourceBundlePostProcessor[] { postProcessor,
unitaryCompositePostProcessor, compositePostProcessor, unitaryCompositePostProcessor };
for (ResourceBundlePostProcessor resourceBundlePostProcessor : postprocessors) {
if (resourceBundlePostProcessor != null
&& ((AbstractChainedResourceBundlePostProcessor) resourceBundlePostProcessor)
.isVariantPostProcessor()) {
needToSearch = true;
break;
}
}
return needToSearch;
}
|
[
"private",
"boolean",
"isSearchingForVariantInPostProcessNeeded",
"(",
")",
"{",
"boolean",
"needToSearch",
"=",
"false",
";",
"ResourceBundlePostProcessor",
"[",
"]",
"postprocessors",
"=",
"new",
"ResourceBundlePostProcessor",
"[",
"]",
"{",
"postProcessor",
",",
"unitaryCompositePostProcessor",
",",
"compositePostProcessor",
",",
"unitaryCompositePostProcessor",
"}",
";",
"for",
"(",
"ResourceBundlePostProcessor",
"resourceBundlePostProcessor",
":",
"postprocessors",
")",
"{",
"if",
"(",
"resourceBundlePostProcessor",
"!=",
"null",
"&&",
"(",
"(",
"AbstractChainedResourceBundlePostProcessor",
")",
"resourceBundlePostProcessor",
")",
".",
"isVariantPostProcessor",
"(",
")",
")",
"{",
"needToSearch",
"=",
"true",
";",
"break",
";",
"}",
"}",
"return",
"needToSearch",
";",
"}"
] |
Checks if it is needed to search for variant in post process
@return true if it is needed to search for variant in post process
|
[
"Checks",
"if",
"it",
"is",
"needed",
"to",
"search",
"for",
"variant",
"in",
"post",
"process"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L260-L275
|
7,249 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.splitBundlesByType
|
private void splitBundlesByType(List<JoinableResourceBundle> bundles) {
// Temporary lists (CopyOnWriteArrayList does not support sort())
List<JoinableResourceBundle> tmpGlobal = new ArrayList<>();
List<JoinableResourceBundle> tmpContext = new ArrayList<>();
for (JoinableResourceBundle bundle : bundles) {
if (bundle.getInclusionPattern().isGlobal()) {
tmpGlobal.add(bundle);
} else {
tmpContext.add(bundle);
}
}
// Sort the global bundles
Collections.sort(tmpGlobal, new GlobalResourceBundleComparator());
globalBundles = new CopyOnWriteArrayList<>();
globalBundles.addAll(tmpGlobal);
contextBundles = new CopyOnWriteArrayList<>();
contextBundles.addAll(tmpContext);
initBundlePrefixes();
initCompositeBundleMap(globalBundles);
initCompositeBundleMap(contextBundles);
}
|
java
|
private void splitBundlesByType(List<JoinableResourceBundle> bundles) {
// Temporary lists (CopyOnWriteArrayList does not support sort())
List<JoinableResourceBundle> tmpGlobal = new ArrayList<>();
List<JoinableResourceBundle> tmpContext = new ArrayList<>();
for (JoinableResourceBundle bundle : bundles) {
if (bundle.getInclusionPattern().isGlobal()) {
tmpGlobal.add(bundle);
} else {
tmpContext.add(bundle);
}
}
// Sort the global bundles
Collections.sort(tmpGlobal, new GlobalResourceBundleComparator());
globalBundles = new CopyOnWriteArrayList<>();
globalBundles.addAll(tmpGlobal);
contextBundles = new CopyOnWriteArrayList<>();
contextBundles.addAll(tmpContext);
initBundlePrefixes();
initCompositeBundleMap(globalBundles);
initCompositeBundleMap(contextBundles);
}
|
[
"private",
"void",
"splitBundlesByType",
"(",
"List",
"<",
"JoinableResourceBundle",
">",
"bundles",
")",
"{",
"// Temporary lists (CopyOnWriteArrayList does not support sort())",
"List",
"<",
"JoinableResourceBundle",
">",
"tmpGlobal",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"JoinableResourceBundle",
">",
"tmpContext",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"JoinableResourceBundle",
"bundle",
":",
"bundles",
")",
"{",
"if",
"(",
"bundle",
".",
"getInclusionPattern",
"(",
")",
".",
"isGlobal",
"(",
")",
")",
"{",
"tmpGlobal",
".",
"add",
"(",
"bundle",
")",
";",
"}",
"else",
"{",
"tmpContext",
".",
"add",
"(",
"bundle",
")",
";",
"}",
"}",
"// Sort the global bundles",
"Collections",
".",
"sort",
"(",
"tmpGlobal",
",",
"new",
"GlobalResourceBundleComparator",
"(",
")",
")",
";",
"globalBundles",
"=",
"new",
"CopyOnWriteArrayList",
"<>",
"(",
")",
";",
"globalBundles",
".",
"addAll",
"(",
"tmpGlobal",
")",
";",
"contextBundles",
"=",
"new",
"CopyOnWriteArrayList",
"<>",
"(",
")",
";",
"contextBundles",
".",
"addAll",
"(",
"tmpContext",
")",
";",
"initBundlePrefixes",
"(",
")",
";",
"initCompositeBundleMap",
"(",
"globalBundles",
")",
";",
"initCompositeBundleMap",
"(",
"contextBundles",
")",
";",
"}"
] |
Splits the bundles in two lists, one for global lists and other for the
remaining bundles.
|
[
"Splits",
"the",
"bundles",
"in",
"two",
"lists",
"one",
"for",
"global",
"lists",
"and",
"other",
"for",
"the",
"remaining",
"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/handler/ResourceBundlesHandlerImpl.java#L315-L341
|
7,250 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.initBundlePrefixes
|
protected void initBundlePrefixes() {
bundlePrefixes = new CopyOnWriteArrayList<>();
for (JoinableResourceBundle bundle : globalBundles) {
if (StringUtils.isNotEmpty(bundle.getBundlePrefix())) {
bundlePrefixes.add(bundle.getBundlePrefix());
}
}
for (JoinableResourceBundle bundle : contextBundles) {
if (StringUtils.isNotEmpty(bundle.getBundlePrefix())) {
bundlePrefixes.add(bundle.getBundlePrefix());
}
}
}
|
java
|
protected void initBundlePrefixes() {
bundlePrefixes = new CopyOnWriteArrayList<>();
for (JoinableResourceBundle bundle : globalBundles) {
if (StringUtils.isNotEmpty(bundle.getBundlePrefix())) {
bundlePrefixes.add(bundle.getBundlePrefix());
}
}
for (JoinableResourceBundle bundle : contextBundles) {
if (StringUtils.isNotEmpty(bundle.getBundlePrefix())) {
bundlePrefixes.add(bundle.getBundlePrefix());
}
}
}
|
[
"protected",
"void",
"initBundlePrefixes",
"(",
")",
"{",
"bundlePrefixes",
"=",
"new",
"CopyOnWriteArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"JoinableResourceBundle",
"bundle",
":",
"globalBundles",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"bundle",
".",
"getBundlePrefix",
"(",
")",
")",
")",
"{",
"bundlePrefixes",
".",
"add",
"(",
"bundle",
".",
"getBundlePrefix",
"(",
")",
")",
";",
"}",
"}",
"for",
"(",
"JoinableResourceBundle",
"bundle",
":",
"contextBundles",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"bundle",
".",
"getBundlePrefix",
"(",
")",
")",
")",
"{",
"bundlePrefixes",
".",
"add",
"(",
"bundle",
".",
"getBundlePrefix",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Initialize the bundle prefixes
|
[
"Initialize",
"the",
"bundle",
"prefixes"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L346-L358
|
7,251 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.getBundleIterator
|
private ResourceBundlePathsIterator getBundleIterator(DebugMode debugMode, List<JoinableResourceBundle> bundles,
ConditionalCommentCallbackHandler commentCallbackHandler, Map<String, String> variants) {
ResourceBundlePathsIterator bundlesIterator;
if (debugMode.equals(DebugMode.DEBUG)) {
bundlesIterator = new DebugModePathsIteratorImpl(bundles, commentCallbackHandler, variants);
} else if (debugMode.equals(DebugMode.FORCE_NON_DEBUG_IN_IE)) {
bundlesIterator = new IECssDebugPathsIteratorImpl(bundles, commentCallbackHandler, variants);
} else {
bundlesIterator = new PathsIteratorImpl(bundles, commentCallbackHandler, variants);
}
return bundlesIterator;
}
|
java
|
private ResourceBundlePathsIterator getBundleIterator(DebugMode debugMode, List<JoinableResourceBundle> bundles,
ConditionalCommentCallbackHandler commentCallbackHandler, Map<String, String> variants) {
ResourceBundlePathsIterator bundlesIterator;
if (debugMode.equals(DebugMode.DEBUG)) {
bundlesIterator = new DebugModePathsIteratorImpl(bundles, commentCallbackHandler, variants);
} else if (debugMode.equals(DebugMode.FORCE_NON_DEBUG_IN_IE)) {
bundlesIterator = new IECssDebugPathsIteratorImpl(bundles, commentCallbackHandler, variants);
} else {
bundlesIterator = new PathsIteratorImpl(bundles, commentCallbackHandler, variants);
}
return bundlesIterator;
}
|
[
"private",
"ResourceBundlePathsIterator",
"getBundleIterator",
"(",
"DebugMode",
"debugMode",
",",
"List",
"<",
"JoinableResourceBundle",
">",
"bundles",
",",
"ConditionalCommentCallbackHandler",
"commentCallbackHandler",
",",
"Map",
"<",
"String",
",",
"String",
">",
"variants",
")",
"{",
"ResourceBundlePathsIterator",
"bundlesIterator",
";",
"if",
"(",
"debugMode",
".",
"equals",
"(",
"DebugMode",
".",
"DEBUG",
")",
")",
"{",
"bundlesIterator",
"=",
"new",
"DebugModePathsIteratorImpl",
"(",
"bundles",
",",
"commentCallbackHandler",
",",
"variants",
")",
";",
"}",
"else",
"if",
"(",
"debugMode",
".",
"equals",
"(",
"DebugMode",
".",
"FORCE_NON_DEBUG_IN_IE",
")",
")",
"{",
"bundlesIterator",
"=",
"new",
"IECssDebugPathsIteratorImpl",
"(",
"bundles",
",",
"commentCallbackHandler",
",",
"variants",
")",
";",
"}",
"else",
"{",
"bundlesIterator",
"=",
"new",
"PathsIteratorImpl",
"(",
"bundles",
",",
"commentCallbackHandler",
",",
"variants",
")",
";",
"}",
"return",
"bundlesIterator",
";",
"}"
] |
Returns the bundle iterator
@param debugMode
the flag indicating if we are in debug mode or not
@param commentCallbackHandler
the comment callback handler
@param variants
the variant map
@return the bundle iterator
|
[
"Returns",
"the",
"bundle",
"iterator"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L508-L520
|
7,252 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.processInLive
|
private StringReader processInLive(Reader reader) throws IOException {
String requestURL = ThreadLocalJawrContext.getRequestURL();
StringWriter swriter = new StringWriter();
IOUtils.copy(reader, swriter, true);
String updatedContent = swriter.getBuffer().toString();
if (requestURL != null) {
updatedContent = updatedContent.replaceAll(JawrConstant.JAWR_BUNDLE_PATH_PLACEHOLDER_PATTERN, requestURL);
}
return new StringReader(updatedContent);
}
|
java
|
private StringReader processInLive(Reader reader) throws IOException {
String requestURL = ThreadLocalJawrContext.getRequestURL();
StringWriter swriter = new StringWriter();
IOUtils.copy(reader, swriter, true);
String updatedContent = swriter.getBuffer().toString();
if (requestURL != null) {
updatedContent = updatedContent.replaceAll(JawrConstant.JAWR_BUNDLE_PATH_PLACEHOLDER_PATTERN, requestURL);
}
return new StringReader(updatedContent);
}
|
[
"private",
"StringReader",
"processInLive",
"(",
"Reader",
"reader",
")",
"throws",
"IOException",
"{",
"String",
"requestURL",
"=",
"ThreadLocalJawrContext",
".",
"getRequestURL",
"(",
")",
";",
"StringWriter",
"swriter",
"=",
"new",
"StringWriter",
"(",
")",
";",
"IOUtils",
".",
"copy",
"(",
"reader",
",",
"swriter",
",",
"true",
")",
";",
"String",
"updatedContent",
"=",
"swriter",
".",
"getBuffer",
"(",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"requestURL",
"!=",
"null",
")",
"{",
"updatedContent",
"=",
"updatedContent",
".",
"replaceAll",
"(",
"JawrConstant",
".",
"JAWR_BUNDLE_PATH_PLACEHOLDER_PATTERN",
",",
"requestURL",
")",
";",
"}",
"return",
"new",
"StringReader",
"(",
"updatedContent",
")",
";",
"}"
] |
Process the bundle content in live
@param reader
the reader
@return the processed bundle content
@throws IOException
if an IOException occured
|
[
"Process",
"the",
"bundle",
"content",
"in",
"live"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L576-L587
|
7,253 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.getJawrConfigHashcode
|
protected String getJawrConfigHashcode() {
try {
return CheckSumUtils.getMD5Checksum(config.getConfigProperties().toString());
} catch (IOException e) {
throw new BundlingProcessException("Unable to calculate Jawr config checksum", e);
}
}
|
java
|
protected String getJawrConfigHashcode() {
try {
return CheckSumUtils.getMD5Checksum(config.getConfigProperties().toString());
} catch (IOException e) {
throw new BundlingProcessException("Unable to calculate Jawr config checksum", e);
}
}
|
[
"protected",
"String",
"getJawrConfigHashcode",
"(",
")",
"{",
"try",
"{",
"return",
"CheckSumUtils",
".",
"getMD5Checksum",
"(",
"config",
".",
"getConfigProperties",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Unable to calculate Jawr config checksum\"",
",",
"e",
")",
";",
"}",
"}"
] |
Returns the jawr config hashcode
@return the jawr config hashcode
|
[
"Returns",
"the",
"jawr",
"config",
"hashcode"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L713-L719
|
7,254 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.executeGlobalPreprocessing
|
private void executeGlobalPreprocessing(List<JoinableResourceBundle> bundlesToBuild, boolean processBundleFlag,
StopWatch stopWatch) {
stopProcessIfNeeded();
if (resourceTypePreprocessor != null) {
if (stopWatch != null) {
stopWatch.start("Global preprocessing");
}
GlobalPreprocessingContext ctx = new GlobalPreprocessingContext(config, resourceHandler, processBundleFlag);
resourceTypePreprocessor.processBundles(ctx, bundles);
// Update the list of bundle to rebuild if new bundles have been
// detected as dirty in the global preprocessing phase
List<JoinableResourceBundle> currentBundles = getBundlesToRebuild();
for (JoinableResourceBundle b : currentBundles) {
if (!bundlesToBuild.contains(b)) {
bundlesToBuild.add(b);
}
}
if (stopWatch != null) {
stopWatch.stop();
}
}
}
|
java
|
private void executeGlobalPreprocessing(List<JoinableResourceBundle> bundlesToBuild, boolean processBundleFlag,
StopWatch stopWatch) {
stopProcessIfNeeded();
if (resourceTypePreprocessor != null) {
if (stopWatch != null) {
stopWatch.start("Global preprocessing");
}
GlobalPreprocessingContext ctx = new GlobalPreprocessingContext(config, resourceHandler, processBundleFlag);
resourceTypePreprocessor.processBundles(ctx, bundles);
// Update the list of bundle to rebuild if new bundles have been
// detected as dirty in the global preprocessing phase
List<JoinableResourceBundle> currentBundles = getBundlesToRebuild();
for (JoinableResourceBundle b : currentBundles) {
if (!bundlesToBuild.contains(b)) {
bundlesToBuild.add(b);
}
}
if (stopWatch != null) {
stopWatch.stop();
}
}
}
|
[
"private",
"void",
"executeGlobalPreprocessing",
"(",
"List",
"<",
"JoinableResourceBundle",
">",
"bundlesToBuild",
",",
"boolean",
"processBundleFlag",
",",
"StopWatch",
"stopWatch",
")",
"{",
"stopProcessIfNeeded",
"(",
")",
";",
"if",
"(",
"resourceTypePreprocessor",
"!=",
"null",
")",
"{",
"if",
"(",
"stopWatch",
"!=",
"null",
")",
"{",
"stopWatch",
".",
"start",
"(",
"\"Global preprocessing\"",
")",
";",
"}",
"GlobalPreprocessingContext",
"ctx",
"=",
"new",
"GlobalPreprocessingContext",
"(",
"config",
",",
"resourceHandler",
",",
"processBundleFlag",
")",
";",
"resourceTypePreprocessor",
".",
"processBundles",
"(",
"ctx",
",",
"bundles",
")",
";",
"// Update the list of bundle to rebuild if new bundles have been",
"// detected as dirty in the global preprocessing phase",
"List",
"<",
"JoinableResourceBundle",
">",
"currentBundles",
"=",
"getBundlesToRebuild",
"(",
")",
";",
"for",
"(",
"JoinableResourceBundle",
"b",
":",
"currentBundles",
")",
"{",
"if",
"(",
"!",
"bundlesToBuild",
".",
"contains",
"(",
"b",
")",
")",
"{",
"bundlesToBuild",
".",
"add",
"(",
"b",
")",
";",
"}",
"}",
"if",
"(",
"stopWatch",
"!=",
"null",
")",
"{",
"stopWatch",
".",
"stop",
"(",
")",
";",
"}",
"}",
"}"
] |
Executes the global preprocessing
@param bundlesToBuild
The list of bundles to rebuild
@param processBundleFlag
the flag indicating if the bundles needs to be processed
@param stopWatch
the stopWatch
|
[
"Executes",
"the",
"global",
"preprocessing"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L732-L756
|
7,255 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.rebuildModifiedBundles
|
@Override
public synchronized void rebuildModifiedBundles() {
stopProcessIfNeeded();
StopWatch stopWatch = ThreadLocalJawrContext.getStopWatch();
if (config.getUseSmartBundling()) {
// Wait until all watch event has been processed
if (watcher != null) {
while (!watcher.hasNoEventToProcess()) {
try {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Wait until there is no more watch event to process");
}
Thread.sleep(config.getSmartBundlingDelayAfterLastEvent());
} catch (InterruptedException e) {
// Do nothing
}
}
}
List<JoinableResourceBundle> bundlesToRebuild = getBundlesToRebuild();
for (JoinableResourceBundle bundle : bundlesToRebuild) {
bundle.resetBundleMapping();
}
build(bundlesToRebuild, true, stopWatch);
} else {
LOGGER.warn("You should turn on \"smart bundling\" feature to be able to rebuild modified bundles.");
}
}
|
java
|
@Override
public synchronized void rebuildModifiedBundles() {
stopProcessIfNeeded();
StopWatch stopWatch = ThreadLocalJawrContext.getStopWatch();
if (config.getUseSmartBundling()) {
// Wait until all watch event has been processed
if (watcher != null) {
while (!watcher.hasNoEventToProcess()) {
try {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Wait until there is no more watch event to process");
}
Thread.sleep(config.getSmartBundlingDelayAfterLastEvent());
} catch (InterruptedException e) {
// Do nothing
}
}
}
List<JoinableResourceBundle> bundlesToRebuild = getBundlesToRebuild();
for (JoinableResourceBundle bundle : bundlesToRebuild) {
bundle.resetBundleMapping();
}
build(bundlesToRebuild, true, stopWatch);
} else {
LOGGER.warn("You should turn on \"smart bundling\" feature to be able to rebuild modified bundles.");
}
}
|
[
"@",
"Override",
"public",
"synchronized",
"void",
"rebuildModifiedBundles",
"(",
")",
"{",
"stopProcessIfNeeded",
"(",
")",
";",
"StopWatch",
"stopWatch",
"=",
"ThreadLocalJawrContext",
".",
"getStopWatch",
"(",
")",
";",
"if",
"(",
"config",
".",
"getUseSmartBundling",
"(",
")",
")",
"{",
"// Wait until all watch event has been processed",
"if",
"(",
"watcher",
"!=",
"null",
")",
"{",
"while",
"(",
"!",
"watcher",
".",
"hasNoEventToProcess",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"LOGGER",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Wait until there is no more watch event to process\"",
")",
";",
"}",
"Thread",
".",
"sleep",
"(",
"config",
".",
"getSmartBundlingDelayAfterLastEvent",
"(",
")",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// Do nothing",
"}",
"}",
"}",
"List",
"<",
"JoinableResourceBundle",
">",
"bundlesToRebuild",
"=",
"getBundlesToRebuild",
"(",
")",
";",
"for",
"(",
"JoinableResourceBundle",
"bundle",
":",
"bundlesToRebuild",
")",
"{",
"bundle",
".",
"resetBundleMapping",
"(",
")",
";",
"}",
"build",
"(",
"bundlesToRebuild",
",",
"true",
",",
"stopWatch",
")",
";",
"}",
"else",
"{",
"LOGGER",
".",
"warn",
"(",
"\"You should turn on \\\"smart bundling\\\" feature to be able to rebuild modified bundles.\"",
")",
";",
"}",
"}"
] |
Rebuilds the bundles given in parameter
|
[
"Rebuilds",
"the",
"bundles",
"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/handler/ResourceBundlesHandlerImpl.java#L762-L794
|
7,256 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.build
|
public void build(List<JoinableResourceBundle> bundlesToBuild, boolean forceWriteBundleMapping,
StopWatch stopWatch) {
stopProcessIfNeeded();
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Starting bundle processing");
}
notifyStartBundlingProcess();
boolean mappingFileExists = resourceBundleHandler.isExistingMappingFile();
boolean processBundleFlag = !config.getUseBundleMapping() || !mappingFileExists;
// Global preprocessing
executeGlobalPreprocessing(bundlesToBuild, processBundleFlag, stopWatch);
for (JoinableResourceBundle bundle : bundlesToBuild) {
stopProcessIfNeeded();
if (stopWatch != null) {
stopWatch.start("Processing bundle '" + bundle.getName() + "'");
}
if (!ThreadLocalJawrContext.isBundleProcessingAtBuildTime() && null != bundle.getAlternateProductionURL()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("No bundle generated for '" + bundle.getId()
+ "' because a production URL is defined for this bundle.");
}
}
if (bundle instanceof CompositeResourceBundle) {
joinAndStoreCompositeResourcebundle((CompositeResourceBundle) bundle);
} else {
joinAndStoreBundle(bundle);
}
if (config.getUseBundleMapping()) {
JoinableResourceBundlePropertySerializer.serializeInProperties(bundle,
resourceBundleHandler.getResourceType(), bundleMapping);
}
bundle.setDirty(false);
if (stopWatch != null) {
stopWatch.stop();
}
}
executeGlobalPostProcessing(processBundleFlag, stopWatch);
storeJawrBundleMapping(resourceBundleHandler.isExistingMappingFile(), true);
// Update the watcher with the path to watch
try {
if (watcher != null) {
watcher.initPathToResourceBundleMap(bundlesToBuild);
}
} catch (IOException e) {
throw new BundlingProcessException(e);
}
notifyEndBundlingProcess();
if (LOGGER.isInfoEnabled()) {
LOGGER.info("End of bundle processing");
}
}
|
java
|
public void build(List<JoinableResourceBundle> bundlesToBuild, boolean forceWriteBundleMapping,
StopWatch stopWatch) {
stopProcessIfNeeded();
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Starting bundle processing");
}
notifyStartBundlingProcess();
boolean mappingFileExists = resourceBundleHandler.isExistingMappingFile();
boolean processBundleFlag = !config.getUseBundleMapping() || !mappingFileExists;
// Global preprocessing
executeGlobalPreprocessing(bundlesToBuild, processBundleFlag, stopWatch);
for (JoinableResourceBundle bundle : bundlesToBuild) {
stopProcessIfNeeded();
if (stopWatch != null) {
stopWatch.start("Processing bundle '" + bundle.getName() + "'");
}
if (!ThreadLocalJawrContext.isBundleProcessingAtBuildTime() && null != bundle.getAlternateProductionURL()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("No bundle generated for '" + bundle.getId()
+ "' because a production URL is defined for this bundle.");
}
}
if (bundle instanceof CompositeResourceBundle) {
joinAndStoreCompositeResourcebundle((CompositeResourceBundle) bundle);
} else {
joinAndStoreBundle(bundle);
}
if (config.getUseBundleMapping()) {
JoinableResourceBundlePropertySerializer.serializeInProperties(bundle,
resourceBundleHandler.getResourceType(), bundleMapping);
}
bundle.setDirty(false);
if (stopWatch != null) {
stopWatch.stop();
}
}
executeGlobalPostProcessing(processBundleFlag, stopWatch);
storeJawrBundleMapping(resourceBundleHandler.isExistingMappingFile(), true);
// Update the watcher with the path to watch
try {
if (watcher != null) {
watcher.initPathToResourceBundleMap(bundlesToBuild);
}
} catch (IOException e) {
throw new BundlingProcessException(e);
}
notifyEndBundlingProcess();
if (LOGGER.isInfoEnabled()) {
LOGGER.info("End of bundle processing");
}
}
|
[
"public",
"void",
"build",
"(",
"List",
"<",
"JoinableResourceBundle",
">",
"bundlesToBuild",
",",
"boolean",
"forceWriteBundleMapping",
",",
"StopWatch",
"stopWatch",
")",
"{",
"stopProcessIfNeeded",
"(",
")",
";",
"if",
"(",
"LOGGER",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Starting bundle processing\"",
")",
";",
"}",
"notifyStartBundlingProcess",
"(",
")",
";",
"boolean",
"mappingFileExists",
"=",
"resourceBundleHandler",
".",
"isExistingMappingFile",
"(",
")",
";",
"boolean",
"processBundleFlag",
"=",
"!",
"config",
".",
"getUseBundleMapping",
"(",
")",
"||",
"!",
"mappingFileExists",
";",
"// Global preprocessing",
"executeGlobalPreprocessing",
"(",
"bundlesToBuild",
",",
"processBundleFlag",
",",
"stopWatch",
")",
";",
"for",
"(",
"JoinableResourceBundle",
"bundle",
":",
"bundlesToBuild",
")",
"{",
"stopProcessIfNeeded",
"(",
")",
";",
"if",
"(",
"stopWatch",
"!=",
"null",
")",
"{",
"stopWatch",
".",
"start",
"(",
"\"Processing bundle '\"",
"+",
"bundle",
".",
"getName",
"(",
")",
"+",
"\"'\"",
")",
";",
"}",
"if",
"(",
"!",
"ThreadLocalJawrContext",
".",
"isBundleProcessingAtBuildTime",
"(",
")",
"&&",
"null",
"!=",
"bundle",
".",
"getAlternateProductionURL",
"(",
")",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"No bundle generated for '\"",
"+",
"bundle",
".",
"getId",
"(",
")",
"+",
"\"' because a production URL is defined for this bundle.\"",
")",
";",
"}",
"}",
"if",
"(",
"bundle",
"instanceof",
"CompositeResourceBundle",
")",
"{",
"joinAndStoreCompositeResourcebundle",
"(",
"(",
"CompositeResourceBundle",
")",
"bundle",
")",
";",
"}",
"else",
"{",
"joinAndStoreBundle",
"(",
"bundle",
")",
";",
"}",
"if",
"(",
"config",
".",
"getUseBundleMapping",
"(",
")",
")",
"{",
"JoinableResourceBundlePropertySerializer",
".",
"serializeInProperties",
"(",
"bundle",
",",
"resourceBundleHandler",
".",
"getResourceType",
"(",
")",
",",
"bundleMapping",
")",
";",
"}",
"bundle",
".",
"setDirty",
"(",
"false",
")",
";",
"if",
"(",
"stopWatch",
"!=",
"null",
")",
"{",
"stopWatch",
".",
"stop",
"(",
")",
";",
"}",
"}",
"executeGlobalPostProcessing",
"(",
"processBundleFlag",
",",
"stopWatch",
")",
";",
"storeJawrBundleMapping",
"(",
"resourceBundleHandler",
".",
"isExistingMappingFile",
"(",
")",
",",
"true",
")",
";",
"// Update the watcher with the path to watch",
"try",
"{",
"if",
"(",
"watcher",
"!=",
"null",
")",
"{",
"watcher",
".",
"initPathToResourceBundleMap",
"(",
"bundlesToBuild",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"e",
")",
";",
"}",
"notifyEndBundlingProcess",
"(",
")",
";",
"if",
"(",
"LOGGER",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"End of bundle processing\"",
")",
";",
"}",
"}"
] |
Builds the bundles given in parameter
@param bundlesToBuild
the list of bundle to build
@param forceWriteBundleMapping
the flag indicating if the bundle mapping must be written in
any case
@param stopWatch
the stop watch
|
[
"Builds",
"the",
"bundles",
"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/handler/ResourceBundlesHandlerImpl.java#L832-L898
|
7,257 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.storeJawrBundleMapping
|
private void storeJawrBundleMapping(boolean mappingFileExists, boolean force) {
if (config.getUseBundleMapping() && (!mappingFileExists || force)) {
bundleMapping.setProperty(JawrConstant.JAWR_CONFIG_HASHCODE, getJawrConfigHashcode());
resourceBundleHandler.storeJawrBundleMapping(bundleMapping);
if (resourceBundleHandler.getResourceType().equals(JawrConstant.CSS_TYPE)) {
// Retrieve the image servlet mapping
BinaryResourcesHandler binaryRsHandler = (BinaryResourcesHandler) config.getContext()
.getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);
if (binaryRsHandler != null) {
// Here we update the image mapping if we are using the
// build time bundle processor
JawrConfig binaryJawrConfig = binaryRsHandler.getConfig();
// If we use the full image bundle mapping and the jawr
// working directory is not located inside the web
// application
// We store the image bundle maping which now contains the
// mapping for CSS images
String jawrWorkingDirectory = binaryJawrConfig.getJawrWorkingDirectory();
if (binaryJawrConfig.getUseBundleMapping() && (jawrWorkingDirectory == null
|| !jawrWorkingDirectory.startsWith(JawrConstant.URL_SEPARATOR))) {
// Store the bundle mapping
Properties props = new Properties();
props.putAll(binaryRsHandler.getBinaryPathMap());
props.setProperty(JawrConstant.JAWR_CONFIG_HASHCODE,
Integer.toString(binaryJawrConfig.getConfigProperties().hashCode()));
binaryRsHandler.getRsBundleHandler().storeJawrBundleMapping(props);
}
}
}
}
}
|
java
|
private void storeJawrBundleMapping(boolean mappingFileExists, boolean force) {
if (config.getUseBundleMapping() && (!mappingFileExists || force)) {
bundleMapping.setProperty(JawrConstant.JAWR_CONFIG_HASHCODE, getJawrConfigHashcode());
resourceBundleHandler.storeJawrBundleMapping(bundleMapping);
if (resourceBundleHandler.getResourceType().equals(JawrConstant.CSS_TYPE)) {
// Retrieve the image servlet mapping
BinaryResourcesHandler binaryRsHandler = (BinaryResourcesHandler) config.getContext()
.getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);
if (binaryRsHandler != null) {
// Here we update the image mapping if we are using the
// build time bundle processor
JawrConfig binaryJawrConfig = binaryRsHandler.getConfig();
// If we use the full image bundle mapping and the jawr
// working directory is not located inside the web
// application
// We store the image bundle maping which now contains the
// mapping for CSS images
String jawrWorkingDirectory = binaryJawrConfig.getJawrWorkingDirectory();
if (binaryJawrConfig.getUseBundleMapping() && (jawrWorkingDirectory == null
|| !jawrWorkingDirectory.startsWith(JawrConstant.URL_SEPARATOR))) {
// Store the bundle mapping
Properties props = new Properties();
props.putAll(binaryRsHandler.getBinaryPathMap());
props.setProperty(JawrConstant.JAWR_CONFIG_HASHCODE,
Integer.toString(binaryJawrConfig.getConfigProperties().hashCode()));
binaryRsHandler.getRsBundleHandler().storeJawrBundleMapping(props);
}
}
}
}
}
|
[
"private",
"void",
"storeJawrBundleMapping",
"(",
"boolean",
"mappingFileExists",
",",
"boolean",
"force",
")",
"{",
"if",
"(",
"config",
".",
"getUseBundleMapping",
"(",
")",
"&&",
"(",
"!",
"mappingFileExists",
"||",
"force",
")",
")",
"{",
"bundleMapping",
".",
"setProperty",
"(",
"JawrConstant",
".",
"JAWR_CONFIG_HASHCODE",
",",
"getJawrConfigHashcode",
"(",
")",
")",
";",
"resourceBundleHandler",
".",
"storeJawrBundleMapping",
"(",
"bundleMapping",
")",
";",
"if",
"(",
"resourceBundleHandler",
".",
"getResourceType",
"(",
")",
".",
"equals",
"(",
"JawrConstant",
".",
"CSS_TYPE",
")",
")",
"{",
"// Retrieve the image servlet mapping",
"BinaryResourcesHandler",
"binaryRsHandler",
"=",
"(",
"BinaryResourcesHandler",
")",
"config",
".",
"getContext",
"(",
")",
".",
"getAttribute",
"(",
"JawrConstant",
".",
"BINARY_CONTEXT_ATTRIBUTE",
")",
";",
"if",
"(",
"binaryRsHandler",
"!=",
"null",
")",
"{",
"// Here we update the image mapping if we are using the",
"// build time bundle processor",
"JawrConfig",
"binaryJawrConfig",
"=",
"binaryRsHandler",
".",
"getConfig",
"(",
")",
";",
"// If we use the full image bundle mapping and the jawr",
"// working directory is not located inside the web",
"// application",
"// We store the image bundle maping which now contains the",
"// mapping for CSS images",
"String",
"jawrWorkingDirectory",
"=",
"binaryJawrConfig",
".",
"getJawrWorkingDirectory",
"(",
")",
";",
"if",
"(",
"binaryJawrConfig",
".",
"getUseBundleMapping",
"(",
")",
"&&",
"(",
"jawrWorkingDirectory",
"==",
"null",
"||",
"!",
"jawrWorkingDirectory",
".",
"startsWith",
"(",
"JawrConstant",
".",
"URL_SEPARATOR",
")",
")",
")",
"{",
"// Store the bundle mapping",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"props",
".",
"putAll",
"(",
"binaryRsHandler",
".",
"getBinaryPathMap",
"(",
")",
")",
";",
"props",
".",
"setProperty",
"(",
"JawrConstant",
".",
"JAWR_CONFIG_HASHCODE",
",",
"Integer",
".",
"toString",
"(",
"binaryJawrConfig",
".",
"getConfigProperties",
"(",
")",
".",
"hashCode",
"(",
")",
")",
")",
";",
"binaryRsHandler",
".",
"getRsBundleHandler",
"(",
")",
".",
"storeJawrBundleMapping",
"(",
"props",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Stores the Jawr bundle mapping
@param mappingFileExists
the flag indicating if the mapping file exists
@param force
force the storage of Jawr bundle mapping
|
[
"Stores",
"the",
"Jawr",
"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/bundle/handler/ResourceBundlesHandlerImpl.java#L947-L981
|
7,258 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.executeGlobalPostProcessing
|
private void executeGlobalPostProcessing(boolean processBundleFlag, StopWatch stopWatch) {
// Launch global postprocessing
if (resourceTypePostprocessor != null) {
if (stopWatch != null) {
stopWatch.start("Global postprocessing");
}
GlobalPostProcessingContext ctx = new GlobalPostProcessingContext(config, this, resourceHandler,
processBundleFlag);
resourceTypePostprocessor.processBundles(ctx, this.bundles);
if (stopWatch != null) {
stopWatch.stop();
}
}
}
|
java
|
private void executeGlobalPostProcessing(boolean processBundleFlag, StopWatch stopWatch) {
// Launch global postprocessing
if (resourceTypePostprocessor != null) {
if (stopWatch != null) {
stopWatch.start("Global postprocessing");
}
GlobalPostProcessingContext ctx = new GlobalPostProcessingContext(config, this, resourceHandler,
processBundleFlag);
resourceTypePostprocessor.processBundles(ctx, this.bundles);
if (stopWatch != null) {
stopWatch.stop();
}
}
}
|
[
"private",
"void",
"executeGlobalPostProcessing",
"(",
"boolean",
"processBundleFlag",
",",
"StopWatch",
"stopWatch",
")",
"{",
"// Launch global postprocessing",
"if",
"(",
"resourceTypePostprocessor",
"!=",
"null",
")",
"{",
"if",
"(",
"stopWatch",
"!=",
"null",
")",
"{",
"stopWatch",
".",
"start",
"(",
"\"Global postprocessing\"",
")",
";",
"}",
"GlobalPostProcessingContext",
"ctx",
"=",
"new",
"GlobalPostProcessingContext",
"(",
"config",
",",
"this",
",",
"resourceHandler",
",",
"processBundleFlag",
")",
";",
"resourceTypePostprocessor",
".",
"processBundles",
"(",
"ctx",
",",
"this",
".",
"bundles",
")",
";",
"if",
"(",
"stopWatch",
"!=",
"null",
")",
"{",
"stopWatch",
".",
"stop",
"(",
")",
";",
"}",
"}",
"}"
] |
Execute the global post processing
@param processBundleFlag
the flag indicating if the bundle should be processed
@param stopWatch
the stopWatch
|
[
"Execute",
"the",
"global",
"post",
"processing"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L991-L1005
|
7,259 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.joinAndStoreCompositeResourcebundle
|
private void joinAndStoreCompositeResourcebundle(CompositeResourceBundle composite) {
stopProcessIfNeeded();
BundleProcessingStatus status = new BundleProcessingStatus(BundleProcessingStatus.FILE_PROCESSING_TYPE,
composite, resourceHandler, config);
// Collect all variant names from child bundles
Map<String, VariantSet> compositeBundleVariants = new HashMap<>();
for (JoinableResourceBundle childbundle : composite.getChildBundles()) {
if (childbundle.getVariants() != null)
compositeBundleVariants = VariantUtils.concatVariants(compositeBundleVariants,
childbundle.getVariants());
}
composite.setVariants(compositeBundleVariants);
if (needToSearchForVariantInPostProcess || hasVariantPostProcessor(composite)) {
status.setSearchingPostProcessorVariants(true);
joinAndPostProcessBundle(composite, status);
Map<String, VariantSet> postProcessVariants = status.getPostProcessVariants();
if (!postProcessVariants.isEmpty()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"Post process variants found for bundle " + composite.getId() + ":" + postProcessVariants);
}
Map<String, VariantSet> newVariants = VariantUtils.concatVariants(composite.getVariants(),
postProcessVariants);
composite.setVariants(newVariants);
status.setSearchingPostProcessorVariants(false);
joinAndPostProcessBundle(composite, status);
}
} else {
status.setSearchingPostProcessorVariants(false);
joinAndPostProcessBundle(composite, status);
}
}
|
java
|
private void joinAndStoreCompositeResourcebundle(CompositeResourceBundle composite) {
stopProcessIfNeeded();
BundleProcessingStatus status = new BundleProcessingStatus(BundleProcessingStatus.FILE_PROCESSING_TYPE,
composite, resourceHandler, config);
// Collect all variant names from child bundles
Map<String, VariantSet> compositeBundleVariants = new HashMap<>();
for (JoinableResourceBundle childbundle : composite.getChildBundles()) {
if (childbundle.getVariants() != null)
compositeBundleVariants = VariantUtils.concatVariants(compositeBundleVariants,
childbundle.getVariants());
}
composite.setVariants(compositeBundleVariants);
if (needToSearchForVariantInPostProcess || hasVariantPostProcessor(composite)) {
status.setSearchingPostProcessorVariants(true);
joinAndPostProcessBundle(composite, status);
Map<String, VariantSet> postProcessVariants = status.getPostProcessVariants();
if (!postProcessVariants.isEmpty()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"Post process variants found for bundle " + composite.getId() + ":" + postProcessVariants);
}
Map<String, VariantSet> newVariants = VariantUtils.concatVariants(composite.getVariants(),
postProcessVariants);
composite.setVariants(newVariants);
status.setSearchingPostProcessorVariants(false);
joinAndPostProcessBundle(composite, status);
}
} else {
status.setSearchingPostProcessorVariants(false);
joinAndPostProcessBundle(composite, status);
}
}
|
[
"private",
"void",
"joinAndStoreCompositeResourcebundle",
"(",
"CompositeResourceBundle",
"composite",
")",
"{",
"stopProcessIfNeeded",
"(",
")",
";",
"BundleProcessingStatus",
"status",
"=",
"new",
"BundleProcessingStatus",
"(",
"BundleProcessingStatus",
".",
"FILE_PROCESSING_TYPE",
",",
"composite",
",",
"resourceHandler",
",",
"config",
")",
";",
"// Collect all variant names from child bundles",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"compositeBundleVariants",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"JoinableResourceBundle",
"childbundle",
":",
"composite",
".",
"getChildBundles",
"(",
")",
")",
"{",
"if",
"(",
"childbundle",
".",
"getVariants",
"(",
")",
"!=",
"null",
")",
"compositeBundleVariants",
"=",
"VariantUtils",
".",
"concatVariants",
"(",
"compositeBundleVariants",
",",
"childbundle",
".",
"getVariants",
"(",
")",
")",
";",
"}",
"composite",
".",
"setVariants",
"(",
"compositeBundleVariants",
")",
";",
"if",
"(",
"needToSearchForVariantInPostProcess",
"||",
"hasVariantPostProcessor",
"(",
"composite",
")",
")",
"{",
"status",
".",
"setSearchingPostProcessorVariants",
"(",
"true",
")",
";",
"joinAndPostProcessBundle",
"(",
"composite",
",",
"status",
")",
";",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"postProcessVariants",
"=",
"status",
".",
"getPostProcessVariants",
"(",
")",
";",
"if",
"(",
"!",
"postProcessVariants",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Post process variants found for bundle \"",
"+",
"composite",
".",
"getId",
"(",
")",
"+",
"\":\"",
"+",
"postProcessVariants",
")",
";",
"}",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"newVariants",
"=",
"VariantUtils",
".",
"concatVariants",
"(",
"composite",
".",
"getVariants",
"(",
")",
",",
"postProcessVariants",
")",
";",
"composite",
".",
"setVariants",
"(",
"newVariants",
")",
";",
"status",
".",
"setSearchingPostProcessorVariants",
"(",
"false",
")",
";",
"joinAndPostProcessBundle",
"(",
"composite",
",",
"status",
")",
";",
"}",
"}",
"else",
"{",
"status",
".",
"setSearchingPostProcessorVariants",
"(",
"false",
")",
";",
"joinAndPostProcessBundle",
"(",
"composite",
",",
"status",
")",
";",
"}",
"}"
] |
Joins the members of a composite bundle in all its variants, storing in a
separate file for each variant.
@param composite
the composite resource bundle
|
[
"Joins",
"the",
"members",
"of",
"a",
"composite",
"bundle",
"in",
"all",
"its",
"variants",
"storing",
"in",
"a",
"separate",
"file",
"for",
"each",
"variant",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L1014-L1050
|
7,260 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.hasVariantPostProcessor
|
private boolean hasVariantPostProcessor(JoinableResourceBundle bundle) {
boolean hasVariantPostProcessor = false;
ResourceBundlePostProcessor bundlePostProcessor = bundle.getBundlePostProcessor();
if (bundlePostProcessor != null
&& ((AbstractChainedResourceBundlePostProcessor) bundlePostProcessor).isVariantPostProcessor()) {
hasVariantPostProcessor = true;
} else {
bundlePostProcessor = bundle.getUnitaryPostProcessor();
if (bundlePostProcessor != null
&& ((AbstractChainedResourceBundlePostProcessor) bundlePostProcessor).isVariantPostProcessor()) {
hasVariantPostProcessor = true;
}
}
return hasVariantPostProcessor;
}
|
java
|
private boolean hasVariantPostProcessor(JoinableResourceBundle bundle) {
boolean hasVariantPostProcessor = false;
ResourceBundlePostProcessor bundlePostProcessor = bundle.getBundlePostProcessor();
if (bundlePostProcessor != null
&& ((AbstractChainedResourceBundlePostProcessor) bundlePostProcessor).isVariantPostProcessor()) {
hasVariantPostProcessor = true;
} else {
bundlePostProcessor = bundle.getUnitaryPostProcessor();
if (bundlePostProcessor != null
&& ((AbstractChainedResourceBundlePostProcessor) bundlePostProcessor).isVariantPostProcessor()) {
hasVariantPostProcessor = true;
}
}
return hasVariantPostProcessor;
}
|
[
"private",
"boolean",
"hasVariantPostProcessor",
"(",
"JoinableResourceBundle",
"bundle",
")",
"{",
"boolean",
"hasVariantPostProcessor",
"=",
"false",
";",
"ResourceBundlePostProcessor",
"bundlePostProcessor",
"=",
"bundle",
".",
"getBundlePostProcessor",
"(",
")",
";",
"if",
"(",
"bundlePostProcessor",
"!=",
"null",
"&&",
"(",
"(",
"AbstractChainedResourceBundlePostProcessor",
")",
"bundlePostProcessor",
")",
".",
"isVariantPostProcessor",
"(",
")",
")",
"{",
"hasVariantPostProcessor",
"=",
"true",
";",
"}",
"else",
"{",
"bundlePostProcessor",
"=",
"bundle",
".",
"getUnitaryPostProcessor",
"(",
")",
";",
"if",
"(",
"bundlePostProcessor",
"!=",
"null",
"&&",
"(",
"(",
"AbstractChainedResourceBundlePostProcessor",
")",
"bundlePostProcessor",
")",
".",
"isVariantPostProcessor",
"(",
")",
")",
"{",
"hasVariantPostProcessor",
"=",
"true",
";",
"}",
"}",
"return",
"hasVariantPostProcessor",
";",
"}"
] |
Checks if the bundle has variant post processor
@param bundle
the bundle
@return true if the bundle has variant post processor
|
[
"Checks",
"if",
"the",
"bundle",
"has",
"variant",
"post",
"processor"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L1059-L1075
|
7,261 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.joinAndPostProcessBundle
|
private void joinAndPostProcessBundle(CompositeResourceBundle composite, BundleProcessingStatus status) {
JoinableResourceBundleContent store;
stopProcessIfNeeded();
List<Map<String, String>> allVariants = VariantUtils.getAllVariants(composite.getVariants());
// Add the default bundle variant (the non variant one)
allVariants.add(null);
// Process all variants
for (Map<String, String> variants : allVariants) {
status.setBundleVariants(variants);
store = new JoinableResourceBundleContent();
for (JoinableResourceBundle childbundle : composite.getChildBundles()) {
if (!childbundle.getInclusionPattern().isIncludeOnlyOnDebug()) {
JoinableResourceBundleContent childContent = joinAndPostprocessBundle(childbundle, variants,
status);
// Do unitary postprocessing.
status.setProcessingType(BundleProcessingStatus.FILE_PROCESSING_TYPE);
StringBuffer content = executeUnitaryPostProcessing(composite, status, childContent.getContent(),
this.unitaryCompositePostProcessor);
childContent.setContent(content);
store.append(childContent);
}
}
// Post process composite bundle as needed
store = postProcessJoinedCompositeBundle(composite, store.getContent(), status);
String variantKey = VariantUtils.getVariantKey(variants);
String name = VariantUtils.getVariantBundleName(composite.getId(), variantKey, false);
storeBundle(name, store);
initBundleDataHashcode(composite, store, variantKey);
}
}
|
java
|
private void joinAndPostProcessBundle(CompositeResourceBundle composite, BundleProcessingStatus status) {
JoinableResourceBundleContent store;
stopProcessIfNeeded();
List<Map<String, String>> allVariants = VariantUtils.getAllVariants(composite.getVariants());
// Add the default bundle variant (the non variant one)
allVariants.add(null);
// Process all variants
for (Map<String, String> variants : allVariants) {
status.setBundleVariants(variants);
store = new JoinableResourceBundleContent();
for (JoinableResourceBundle childbundle : composite.getChildBundles()) {
if (!childbundle.getInclusionPattern().isIncludeOnlyOnDebug()) {
JoinableResourceBundleContent childContent = joinAndPostprocessBundle(childbundle, variants,
status);
// Do unitary postprocessing.
status.setProcessingType(BundleProcessingStatus.FILE_PROCESSING_TYPE);
StringBuffer content = executeUnitaryPostProcessing(composite, status, childContent.getContent(),
this.unitaryCompositePostProcessor);
childContent.setContent(content);
store.append(childContent);
}
}
// Post process composite bundle as needed
store = postProcessJoinedCompositeBundle(composite, store.getContent(), status);
String variantKey = VariantUtils.getVariantKey(variants);
String name = VariantUtils.getVariantBundleName(composite.getId(), variantKey, false);
storeBundle(name, store);
initBundleDataHashcode(composite, store, variantKey);
}
}
|
[
"private",
"void",
"joinAndPostProcessBundle",
"(",
"CompositeResourceBundle",
"composite",
",",
"BundleProcessingStatus",
"status",
")",
"{",
"JoinableResourceBundleContent",
"store",
";",
"stopProcessIfNeeded",
"(",
")",
";",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"allVariants",
"=",
"VariantUtils",
".",
"getAllVariants",
"(",
"composite",
".",
"getVariants",
"(",
")",
")",
";",
"// Add the default bundle variant (the non variant one)",
"allVariants",
".",
"add",
"(",
"null",
")",
";",
"// Process all variants",
"for",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"variants",
":",
"allVariants",
")",
"{",
"status",
".",
"setBundleVariants",
"(",
"variants",
")",
";",
"store",
"=",
"new",
"JoinableResourceBundleContent",
"(",
")",
";",
"for",
"(",
"JoinableResourceBundle",
"childbundle",
":",
"composite",
".",
"getChildBundles",
"(",
")",
")",
"{",
"if",
"(",
"!",
"childbundle",
".",
"getInclusionPattern",
"(",
")",
".",
"isIncludeOnlyOnDebug",
"(",
")",
")",
"{",
"JoinableResourceBundleContent",
"childContent",
"=",
"joinAndPostprocessBundle",
"(",
"childbundle",
",",
"variants",
",",
"status",
")",
";",
"// Do unitary postprocessing.",
"status",
".",
"setProcessingType",
"(",
"BundleProcessingStatus",
".",
"FILE_PROCESSING_TYPE",
")",
";",
"StringBuffer",
"content",
"=",
"executeUnitaryPostProcessing",
"(",
"composite",
",",
"status",
",",
"childContent",
".",
"getContent",
"(",
")",
",",
"this",
".",
"unitaryCompositePostProcessor",
")",
";",
"childContent",
".",
"setContent",
"(",
"content",
")",
";",
"store",
".",
"append",
"(",
"childContent",
")",
";",
"}",
"}",
"// Post process composite bundle as needed",
"store",
"=",
"postProcessJoinedCompositeBundle",
"(",
"composite",
",",
"store",
".",
"getContent",
"(",
")",
",",
"status",
")",
";",
"String",
"variantKey",
"=",
"VariantUtils",
".",
"getVariantKey",
"(",
"variants",
")",
";",
"String",
"name",
"=",
"VariantUtils",
".",
"getVariantBundleName",
"(",
"composite",
".",
"getId",
"(",
")",
",",
"variantKey",
",",
"false",
")",
";",
"storeBundle",
"(",
"name",
",",
"store",
")",
";",
"initBundleDataHashcode",
"(",
"composite",
",",
"store",
",",
"variantKey",
")",
";",
"}",
"}"
] |
Joins and post process the variant composite bundle
@param composite
the composite bundle
@param status
the status
@param compositeBundleVariants
the variants
|
[
"Joins",
"and",
"post",
"process",
"the",
"variant",
"composite",
"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/handler/ResourceBundlesHandlerImpl.java#L1087-L1120
|
7,262 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.postProcessJoinedCompositeBundle
|
private JoinableResourceBundleContent postProcessJoinedCompositeBundle(CompositeResourceBundle composite,
StringBuffer content, BundleProcessingStatus status) {
JoinableResourceBundleContent store = new JoinableResourceBundleContent();
StringBuffer processedContent = null;
status.setProcessingType(BundleProcessingStatus.BUNDLE_PROCESSING_TYPE);
ResourceBundlePostProcessor bundlePostProcessor = composite.getBundlePostProcessor();
if (null != bundlePostProcessor) {
processedContent = bundlePostProcessor.postProcessBundle(status, content);
} else if (null != this.compositePostProcessor) {
processedContent = this.compositePostProcessor.postProcessBundle(status, content);
} else {
processedContent = content;
}
store.setContent(processedContent);
return store;
}
|
java
|
private JoinableResourceBundleContent postProcessJoinedCompositeBundle(CompositeResourceBundle composite,
StringBuffer content, BundleProcessingStatus status) {
JoinableResourceBundleContent store = new JoinableResourceBundleContent();
StringBuffer processedContent = null;
status.setProcessingType(BundleProcessingStatus.BUNDLE_PROCESSING_TYPE);
ResourceBundlePostProcessor bundlePostProcessor = composite.getBundlePostProcessor();
if (null != bundlePostProcessor) {
processedContent = bundlePostProcessor.postProcessBundle(status, content);
} else if (null != this.compositePostProcessor) {
processedContent = this.compositePostProcessor.postProcessBundle(status, content);
} else {
processedContent = content;
}
store.setContent(processedContent);
return store;
}
|
[
"private",
"JoinableResourceBundleContent",
"postProcessJoinedCompositeBundle",
"(",
"CompositeResourceBundle",
"composite",
",",
"StringBuffer",
"content",
",",
"BundleProcessingStatus",
"status",
")",
"{",
"JoinableResourceBundleContent",
"store",
"=",
"new",
"JoinableResourceBundleContent",
"(",
")",
";",
"StringBuffer",
"processedContent",
"=",
"null",
";",
"status",
".",
"setProcessingType",
"(",
"BundleProcessingStatus",
".",
"BUNDLE_PROCESSING_TYPE",
")",
";",
"ResourceBundlePostProcessor",
"bundlePostProcessor",
"=",
"composite",
".",
"getBundlePostProcessor",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"bundlePostProcessor",
")",
"{",
"processedContent",
"=",
"bundlePostProcessor",
".",
"postProcessBundle",
"(",
"status",
",",
"content",
")",
";",
"}",
"else",
"if",
"(",
"null",
"!=",
"this",
".",
"compositePostProcessor",
")",
"{",
"processedContent",
"=",
"this",
".",
"compositePostProcessor",
".",
"postProcessBundle",
"(",
"status",
",",
"content",
")",
";",
"}",
"else",
"{",
"processedContent",
"=",
"content",
";",
"}",
"store",
".",
"setContent",
"(",
"processedContent",
")",
";",
"return",
"store",
";",
"}"
] |
Postprocess the composite bundle only if a composite bundle post
processor is defined
@param composite
the composite bundle
@param content
the content
@param status
the status
@return the content
|
[
"Postprocess",
"the",
"composite",
"bundle",
"only",
"if",
"a",
"composite",
"bundle",
"post",
"processor",
"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/handler/ResourceBundlesHandlerImpl.java#L1134-L1154
|
7,263 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.initBundleDataHashcode
|
private void initBundleDataHashcode(JoinableResourceBundle bundle, JoinableResourceBundleContent store,
String variant) {
String bundleHashcode = bundleHashcodeGenerator.generateHashCode(config, store.getContent().toString());
bundle.setBundleDataHashCode(variant, bundleHashcode);
}
|
java
|
private void initBundleDataHashcode(JoinableResourceBundle bundle, JoinableResourceBundleContent store,
String variant) {
String bundleHashcode = bundleHashcodeGenerator.generateHashCode(config, store.getContent().toString());
bundle.setBundleDataHashCode(variant, bundleHashcode);
}
|
[
"private",
"void",
"initBundleDataHashcode",
"(",
"JoinableResourceBundle",
"bundle",
",",
"JoinableResourceBundleContent",
"store",
",",
"String",
"variant",
")",
"{",
"String",
"bundleHashcode",
"=",
"bundleHashcodeGenerator",
".",
"generateHashCode",
"(",
"config",
",",
"store",
".",
"getContent",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"bundle",
".",
"setBundleDataHashCode",
"(",
"variant",
",",
"bundleHashcode",
")",
";",
"}"
] |
Initialize the bundle data hashcode and initialize the bundle mapping if
needed
@param bundle
the bundle
@param store
the data to store
|
[
"Initialize",
"the",
"bundle",
"data",
"hashcode",
"and",
"initialize",
"the",
"bundle",
"mapping",
"if",
"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/handler/ResourceBundlesHandlerImpl.java#L1165-L1170
|
7,264 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.joinAndStoreBundle
|
private void joinAndStoreBundle(JoinableResourceBundle bundle) {
BundleProcessingStatus status = new BundleProcessingStatus(BundleProcessingStatus.FILE_PROCESSING_TYPE, bundle,
resourceHandler, config);
JoinableResourceBundleContent store = null;
// Process the bundle for searching variant
if (needToSearchForVariantInPostProcess || hasVariantPostProcessor(bundle)) {
status.setSearchingPostProcessorVariants(true);
joinAndPostProcessBundle(bundle, status);
// Process the bundles
status.setSearchingPostProcessorVariants(false);
Map<String, VariantSet> postProcessVariants = status.getPostProcessVariants();
if (!postProcessVariants.isEmpty()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"Post process variants found for bundle " + bundle.getId() + ":" + postProcessVariants);
}
Map<String, VariantSet> newVariants = VariantUtils.concatVariants(bundle.getVariants(),
postProcessVariants);
bundle.setVariants(newVariants);
joinAndPostProcessBundle(bundle, status);
}
} else {
status.setSearchingPostProcessorVariants(false);
joinAndPostProcessBundle(bundle, status);
}
// Store the collected resources as a single file, both in text and
// gzip formats.
store = joinAndPostprocessBundle(bundle, null, status);
storeBundle(bundle.getId(), store);
// Set the data hascode in the bundle, in case the prefix needs to
// be generated
initBundleDataHashcode(bundle, store, null);
}
|
java
|
private void joinAndStoreBundle(JoinableResourceBundle bundle) {
BundleProcessingStatus status = new BundleProcessingStatus(BundleProcessingStatus.FILE_PROCESSING_TYPE, bundle,
resourceHandler, config);
JoinableResourceBundleContent store = null;
// Process the bundle for searching variant
if (needToSearchForVariantInPostProcess || hasVariantPostProcessor(bundle)) {
status.setSearchingPostProcessorVariants(true);
joinAndPostProcessBundle(bundle, status);
// Process the bundles
status.setSearchingPostProcessorVariants(false);
Map<String, VariantSet> postProcessVariants = status.getPostProcessVariants();
if (!postProcessVariants.isEmpty()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"Post process variants found for bundle " + bundle.getId() + ":" + postProcessVariants);
}
Map<String, VariantSet> newVariants = VariantUtils.concatVariants(bundle.getVariants(),
postProcessVariants);
bundle.setVariants(newVariants);
joinAndPostProcessBundle(bundle, status);
}
} else {
status.setSearchingPostProcessorVariants(false);
joinAndPostProcessBundle(bundle, status);
}
// Store the collected resources as a single file, both in text and
// gzip formats.
store = joinAndPostprocessBundle(bundle, null, status);
storeBundle(bundle.getId(), store);
// Set the data hascode in the bundle, in case the prefix needs to
// be generated
initBundleDataHashcode(bundle, store, null);
}
|
[
"private",
"void",
"joinAndStoreBundle",
"(",
"JoinableResourceBundle",
"bundle",
")",
"{",
"BundleProcessingStatus",
"status",
"=",
"new",
"BundleProcessingStatus",
"(",
"BundleProcessingStatus",
".",
"FILE_PROCESSING_TYPE",
",",
"bundle",
",",
"resourceHandler",
",",
"config",
")",
";",
"JoinableResourceBundleContent",
"store",
"=",
"null",
";",
"// Process the bundle for searching variant",
"if",
"(",
"needToSearchForVariantInPostProcess",
"||",
"hasVariantPostProcessor",
"(",
"bundle",
")",
")",
"{",
"status",
".",
"setSearchingPostProcessorVariants",
"(",
"true",
")",
";",
"joinAndPostProcessBundle",
"(",
"bundle",
",",
"status",
")",
";",
"// Process the bundles",
"status",
".",
"setSearchingPostProcessorVariants",
"(",
"false",
")",
";",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"postProcessVariants",
"=",
"status",
".",
"getPostProcessVariants",
"(",
")",
";",
"if",
"(",
"!",
"postProcessVariants",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Post process variants found for bundle \"",
"+",
"bundle",
".",
"getId",
"(",
")",
"+",
"\":\"",
"+",
"postProcessVariants",
")",
";",
"}",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"newVariants",
"=",
"VariantUtils",
".",
"concatVariants",
"(",
"bundle",
".",
"getVariants",
"(",
")",
",",
"postProcessVariants",
")",
";",
"bundle",
".",
"setVariants",
"(",
"newVariants",
")",
";",
"joinAndPostProcessBundle",
"(",
"bundle",
",",
"status",
")",
";",
"}",
"}",
"else",
"{",
"status",
".",
"setSearchingPostProcessorVariants",
"(",
"false",
")",
";",
"joinAndPostProcessBundle",
"(",
"bundle",
",",
"status",
")",
";",
"}",
"// Store the collected resources as a single file, both in text and",
"// gzip formats.",
"store",
"=",
"joinAndPostprocessBundle",
"(",
"bundle",
",",
"null",
",",
"status",
")",
";",
"storeBundle",
"(",
"bundle",
".",
"getId",
"(",
")",
",",
"store",
")",
";",
"// Set the data hascode in the bundle, in case the prefix needs to",
"// be generated",
"initBundleDataHashcode",
"(",
"bundle",
",",
"store",
",",
"null",
")",
";",
"}"
] |
Joins the members of a bundle and stores it
@param bundle
the bundle
@param the
flag indicating if we should process the bundle or not
|
[
"Joins",
"the",
"members",
"of",
"a",
"bundle",
"and",
"stores",
"it"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L1215-L1253
|
7,265 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.storeBundle
|
private void storeBundle(String bundleId, JoinableResourceBundleContent store) {
stopProcessIfNeeded();
if (bundleMustBeProcessedInLive(store.getContent().toString())) {
liveProcessBundles.add(bundleId);
}
resourceBundleHandler.storeBundle(bundleId, store);
}
|
java
|
private void storeBundle(String bundleId, JoinableResourceBundleContent store) {
stopProcessIfNeeded();
if (bundleMustBeProcessedInLive(store.getContent().toString())) {
liveProcessBundles.add(bundleId);
}
resourceBundleHandler.storeBundle(bundleId, store);
}
|
[
"private",
"void",
"storeBundle",
"(",
"String",
"bundleId",
",",
"JoinableResourceBundleContent",
"store",
")",
"{",
"stopProcessIfNeeded",
"(",
")",
";",
"if",
"(",
"bundleMustBeProcessedInLive",
"(",
"store",
".",
"getContent",
"(",
")",
".",
"toString",
"(",
")",
")",
")",
"{",
"liveProcessBundles",
".",
"add",
"(",
"bundleId",
")",
";",
"}",
"resourceBundleHandler",
".",
"storeBundle",
"(",
"bundleId",
",",
"store",
")",
";",
"}"
] |
Store the bundle
@param bundleId
the bundle Id to store
@param store
the bundle
|
[
"Store",
"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/handler/ResourceBundlesHandlerImpl.java#L1263-L1271
|
7,266 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.joinAndPostProcessBundle
|
private void joinAndPostProcessBundle(JoinableResourceBundle bundle, BundleProcessingStatus status) {
JoinableResourceBundleContent store;
List<Map<String, String>> allVariants = VariantUtils.getAllVariants(bundle.getVariants());
// Add the default bundle variant (the non variant one)
allVariants.add(null);
for (Map<String, String> variantMap : allVariants) {
status.setBundleVariants(variantMap);
String variantKey = VariantUtils.getVariantKey(variantMap);
String name = VariantUtils.getVariantBundleName(bundle.getId(), variantKey, false);
store = joinAndPostprocessBundle(bundle, variantMap, status);
storeBundle(name, store);
initBundleDataHashcode(bundle, store, variantKey);
}
}
|
java
|
private void joinAndPostProcessBundle(JoinableResourceBundle bundle, BundleProcessingStatus status) {
JoinableResourceBundleContent store;
List<Map<String, String>> allVariants = VariantUtils.getAllVariants(bundle.getVariants());
// Add the default bundle variant (the non variant one)
allVariants.add(null);
for (Map<String, String> variantMap : allVariants) {
status.setBundleVariants(variantMap);
String variantKey = VariantUtils.getVariantKey(variantMap);
String name = VariantUtils.getVariantBundleName(bundle.getId(), variantKey, false);
store = joinAndPostprocessBundle(bundle, variantMap, status);
storeBundle(name, store);
initBundleDataHashcode(bundle, store, variantKey);
}
}
|
[
"private",
"void",
"joinAndPostProcessBundle",
"(",
"JoinableResourceBundle",
"bundle",
",",
"BundleProcessingStatus",
"status",
")",
"{",
"JoinableResourceBundleContent",
"store",
";",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"allVariants",
"=",
"VariantUtils",
".",
"getAllVariants",
"(",
"bundle",
".",
"getVariants",
"(",
")",
")",
";",
"// Add the default bundle variant (the non variant one)",
"allVariants",
".",
"add",
"(",
"null",
")",
";",
"for",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"variantMap",
":",
"allVariants",
")",
"{",
"status",
".",
"setBundleVariants",
"(",
"variantMap",
")",
";",
"String",
"variantKey",
"=",
"VariantUtils",
".",
"getVariantKey",
"(",
"variantMap",
")",
";",
"String",
"name",
"=",
"VariantUtils",
".",
"getVariantBundleName",
"(",
"bundle",
".",
"getId",
"(",
")",
",",
"variantKey",
",",
"false",
")",
";",
"store",
"=",
"joinAndPostprocessBundle",
"(",
"bundle",
",",
"variantMap",
",",
"status",
")",
";",
"storeBundle",
"(",
"name",
",",
"store",
")",
";",
"initBundleDataHashcode",
"(",
"bundle",
",",
"store",
",",
"variantKey",
")",
";",
"}",
"}"
] |
Join and post process the bundle taking in account all its variants.
@param bundle
the bundle
@param status
the bundle processing status
|
[
"Join",
"and",
"post",
"process",
"the",
"bundle",
"taking",
"in",
"account",
"all",
"its",
"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/handler/ResourceBundlesHandlerImpl.java#L1292-L1307
|
7,267 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.joinAndPostprocessBundle
|
private JoinableResourceBundleContent joinAndPostprocessBundle(JoinableResourceBundle bundle,
Map<String, String> variants, BundleProcessingStatus status) {
JoinableResourceBundleContent bundleContent = new JoinableResourceBundleContent();
StringBuffer bundleData = new StringBuffer();
StringBuffer store = null;
try {
boolean firstPath = true;
// Run through all the files belonging to the bundle
Iterator<BundlePath> pathIterator = null;
if (bundle.getInclusionPattern().isIncludeOnlyOnDebug()) {
pathIterator = bundle.getItemDebugPathList(variants).iterator();
} else {
pathIterator = bundle.getItemPathList(variants).iterator();
}
for (Iterator<BundlePath> it = pathIterator; it.hasNext();) {
// File is first created in memory using a stringwriter.
StringWriter writer = new StringWriter();
BufferedWriter bwriter = new BufferedWriter(writer);
String path = (String) it.next().getPath();
if (LOGGER.isDebugEnabled())
LOGGER.debug("Adding file [" + path + "] to bundle " + bundle.getId());
// Get a reader on the resource, with appropriate encoding
Reader rd = null;
try {
rd = resourceHandler.getResource(bundle, path, true);
} catch (ResourceNotFoundException e) {
// If a mapped file does not exist, a warning is issued and
// process continues normally.
LOGGER.warn("A mapped resource was not found: [" + path + "]. Please check your configuration");
continue;
}
// Update the status.
status.setLastPathAdded(path);
rd = new UnicodeBOMReader(rd, config.getResourceCharset());
if (!firstPath && ((UnicodeBOMReader) rd).hasBOM()) {
((UnicodeBOMReader) rd).skipBOM();
} else {
firstPath = false;
}
IOUtils.copy(rd, bwriter, true);
// Add new line at the end if it doesn't exist
StringBuffer buffer = writer.getBuffer();
if (!buffer.toString().endsWith(StringUtils.STR_LINE_FEED)) {
buffer.append(StringUtils.STR_LINE_FEED);
}
// Do unitary postprocessing.
status.setProcessingType(BundleProcessingStatus.FILE_PROCESSING_TYPE);
bundleData.append(executeUnitaryPostProcessing(bundle, status, buffer, this.unitaryPostProcessor));
}
// Post process bundle as needed
store = executeBundlePostProcessing(bundle, status, bundleData);
} catch (IOException e) {
throw new BundlingProcessException(
"Unexpected IOException generating collected file [" + bundle.getId() + "].", e);
}
bundleContent.setContent(store);
return bundleContent;
}
|
java
|
private JoinableResourceBundleContent joinAndPostprocessBundle(JoinableResourceBundle bundle,
Map<String, String> variants, BundleProcessingStatus status) {
JoinableResourceBundleContent bundleContent = new JoinableResourceBundleContent();
StringBuffer bundleData = new StringBuffer();
StringBuffer store = null;
try {
boolean firstPath = true;
// Run through all the files belonging to the bundle
Iterator<BundlePath> pathIterator = null;
if (bundle.getInclusionPattern().isIncludeOnlyOnDebug()) {
pathIterator = bundle.getItemDebugPathList(variants).iterator();
} else {
pathIterator = bundle.getItemPathList(variants).iterator();
}
for (Iterator<BundlePath> it = pathIterator; it.hasNext();) {
// File is first created in memory using a stringwriter.
StringWriter writer = new StringWriter();
BufferedWriter bwriter = new BufferedWriter(writer);
String path = (String) it.next().getPath();
if (LOGGER.isDebugEnabled())
LOGGER.debug("Adding file [" + path + "] to bundle " + bundle.getId());
// Get a reader on the resource, with appropriate encoding
Reader rd = null;
try {
rd = resourceHandler.getResource(bundle, path, true);
} catch (ResourceNotFoundException e) {
// If a mapped file does not exist, a warning is issued and
// process continues normally.
LOGGER.warn("A mapped resource was not found: [" + path + "]. Please check your configuration");
continue;
}
// Update the status.
status.setLastPathAdded(path);
rd = new UnicodeBOMReader(rd, config.getResourceCharset());
if (!firstPath && ((UnicodeBOMReader) rd).hasBOM()) {
((UnicodeBOMReader) rd).skipBOM();
} else {
firstPath = false;
}
IOUtils.copy(rd, bwriter, true);
// Add new line at the end if it doesn't exist
StringBuffer buffer = writer.getBuffer();
if (!buffer.toString().endsWith(StringUtils.STR_LINE_FEED)) {
buffer.append(StringUtils.STR_LINE_FEED);
}
// Do unitary postprocessing.
status.setProcessingType(BundleProcessingStatus.FILE_PROCESSING_TYPE);
bundleData.append(executeUnitaryPostProcessing(bundle, status, buffer, this.unitaryPostProcessor));
}
// Post process bundle as needed
store = executeBundlePostProcessing(bundle, status, bundleData);
} catch (IOException e) {
throw new BundlingProcessException(
"Unexpected IOException generating collected file [" + bundle.getId() + "].", e);
}
bundleContent.setContent(store);
return bundleContent;
}
|
[
"private",
"JoinableResourceBundleContent",
"joinAndPostprocessBundle",
"(",
"JoinableResourceBundle",
"bundle",
",",
"Map",
"<",
"String",
",",
"String",
">",
"variants",
",",
"BundleProcessingStatus",
"status",
")",
"{",
"JoinableResourceBundleContent",
"bundleContent",
"=",
"new",
"JoinableResourceBundleContent",
"(",
")",
";",
"StringBuffer",
"bundleData",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"StringBuffer",
"store",
"=",
"null",
";",
"try",
"{",
"boolean",
"firstPath",
"=",
"true",
";",
"// Run through all the files belonging to the bundle",
"Iterator",
"<",
"BundlePath",
">",
"pathIterator",
"=",
"null",
";",
"if",
"(",
"bundle",
".",
"getInclusionPattern",
"(",
")",
".",
"isIncludeOnlyOnDebug",
"(",
")",
")",
"{",
"pathIterator",
"=",
"bundle",
".",
"getItemDebugPathList",
"(",
"variants",
")",
".",
"iterator",
"(",
")",
";",
"}",
"else",
"{",
"pathIterator",
"=",
"bundle",
".",
"getItemPathList",
"(",
"variants",
")",
".",
"iterator",
"(",
")",
";",
"}",
"for",
"(",
"Iterator",
"<",
"BundlePath",
">",
"it",
"=",
"pathIterator",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"// File is first created in memory using a stringwriter.",
"StringWriter",
"writer",
"=",
"new",
"StringWriter",
"(",
")",
";",
"BufferedWriter",
"bwriter",
"=",
"new",
"BufferedWriter",
"(",
"writer",
")",
";",
"String",
"path",
"=",
"(",
"String",
")",
"it",
".",
"next",
"(",
")",
".",
"getPath",
"(",
")",
";",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"LOGGER",
".",
"debug",
"(",
"\"Adding file [\"",
"+",
"path",
"+",
"\"] to bundle \"",
"+",
"bundle",
".",
"getId",
"(",
")",
")",
";",
"// Get a reader on the resource, with appropriate encoding",
"Reader",
"rd",
"=",
"null",
";",
"try",
"{",
"rd",
"=",
"resourceHandler",
".",
"getResource",
"(",
"bundle",
",",
"path",
",",
"true",
")",
";",
"}",
"catch",
"(",
"ResourceNotFoundException",
"e",
")",
"{",
"// If a mapped file does not exist, a warning is issued and",
"// process continues normally.",
"LOGGER",
".",
"warn",
"(",
"\"A mapped resource was not found: [\"",
"+",
"path",
"+",
"\"]. Please check your configuration\"",
")",
";",
"continue",
";",
"}",
"// Update the status.",
"status",
".",
"setLastPathAdded",
"(",
"path",
")",
";",
"rd",
"=",
"new",
"UnicodeBOMReader",
"(",
"rd",
",",
"config",
".",
"getResourceCharset",
"(",
")",
")",
";",
"if",
"(",
"!",
"firstPath",
"&&",
"(",
"(",
"UnicodeBOMReader",
")",
"rd",
")",
".",
"hasBOM",
"(",
")",
")",
"{",
"(",
"(",
"UnicodeBOMReader",
")",
"rd",
")",
".",
"skipBOM",
"(",
")",
";",
"}",
"else",
"{",
"firstPath",
"=",
"false",
";",
"}",
"IOUtils",
".",
"copy",
"(",
"rd",
",",
"bwriter",
",",
"true",
")",
";",
"// Add new line at the end if it doesn't exist",
"StringBuffer",
"buffer",
"=",
"writer",
".",
"getBuffer",
"(",
")",
";",
"if",
"(",
"!",
"buffer",
".",
"toString",
"(",
")",
".",
"endsWith",
"(",
"StringUtils",
".",
"STR_LINE_FEED",
")",
")",
"{",
"buffer",
".",
"append",
"(",
"StringUtils",
".",
"STR_LINE_FEED",
")",
";",
"}",
"// Do unitary postprocessing.",
"status",
".",
"setProcessingType",
"(",
"BundleProcessingStatus",
".",
"FILE_PROCESSING_TYPE",
")",
";",
"bundleData",
".",
"append",
"(",
"executeUnitaryPostProcessing",
"(",
"bundle",
",",
"status",
",",
"buffer",
",",
"this",
".",
"unitaryPostProcessor",
")",
")",
";",
"}",
"// Post process bundle as needed",
"store",
"=",
"executeBundlePostProcessing",
"(",
"bundle",
",",
"status",
",",
"bundleData",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Unexpected IOException generating collected file [\"",
"+",
"bundle",
".",
"getId",
"(",
")",
"+",
"\"].\"",
",",
"e",
")",
";",
"}",
"bundleContent",
".",
"setContent",
"(",
"store",
")",
";",
"return",
"bundleContent",
";",
"}"
] |
Reads all the members of a bundle and executes all associated
postprocessors.
@param bundle
the bundle
@param variants
the variant map
@param the
bundling processing status
@param the
flag indicating if we should process the bundle or not
@return the resource bundle content, where all postprocessors have been
executed
|
[
"Reads",
"all",
"the",
"members",
"of",
"a",
"bundle",
"and",
"executes",
"all",
"associated",
"postprocessors",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L1324-L1399
|
7,268 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.executeUnitaryPostProcessing
|
private StringBuffer executeUnitaryPostProcessing(JoinableResourceBundle bundle, BundleProcessingStatus status,
StringBuffer content, ResourceBundlePostProcessor defaultPostProcessor) {
StringBuffer bundleData = new StringBuffer();
status.setProcessingType(BundleProcessingStatus.FILE_PROCESSING_TYPE);
if (null != bundle.getUnitaryPostProcessor()) {
StringBuffer resourceData = bundle.getUnitaryPostProcessor().postProcessBundle(status, content);
bundleData.append(resourceData);
} else if (null != defaultPostProcessor) {
if (LOGGER.isDebugEnabled())
LOGGER.debug("POSTPROCESSING UNIT:" + status.getLastPathAdded());
StringBuffer resourceData = defaultPostProcessor.postProcessBundle(status, content);
bundleData.append(resourceData);
} else {
bundleData = content;
}
return bundleData;
}
|
java
|
private StringBuffer executeUnitaryPostProcessing(JoinableResourceBundle bundle, BundleProcessingStatus status,
StringBuffer content, ResourceBundlePostProcessor defaultPostProcessor) {
StringBuffer bundleData = new StringBuffer();
status.setProcessingType(BundleProcessingStatus.FILE_PROCESSING_TYPE);
if (null != bundle.getUnitaryPostProcessor()) {
StringBuffer resourceData = bundle.getUnitaryPostProcessor().postProcessBundle(status, content);
bundleData.append(resourceData);
} else if (null != defaultPostProcessor) {
if (LOGGER.isDebugEnabled())
LOGGER.debug("POSTPROCESSING UNIT:" + status.getLastPathAdded());
StringBuffer resourceData = defaultPostProcessor.postProcessBundle(status, content);
bundleData.append(resourceData);
} else {
bundleData = content;
}
return bundleData;
}
|
[
"private",
"StringBuffer",
"executeUnitaryPostProcessing",
"(",
"JoinableResourceBundle",
"bundle",
",",
"BundleProcessingStatus",
"status",
",",
"StringBuffer",
"content",
",",
"ResourceBundlePostProcessor",
"defaultPostProcessor",
")",
"{",
"StringBuffer",
"bundleData",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"status",
".",
"setProcessingType",
"(",
"BundleProcessingStatus",
".",
"FILE_PROCESSING_TYPE",
")",
";",
"if",
"(",
"null",
"!=",
"bundle",
".",
"getUnitaryPostProcessor",
"(",
")",
")",
"{",
"StringBuffer",
"resourceData",
"=",
"bundle",
".",
"getUnitaryPostProcessor",
"(",
")",
".",
"postProcessBundle",
"(",
"status",
",",
"content",
")",
";",
"bundleData",
".",
"append",
"(",
"resourceData",
")",
";",
"}",
"else",
"if",
"(",
"null",
"!=",
"defaultPostProcessor",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"LOGGER",
".",
"debug",
"(",
"\"POSTPROCESSING UNIT:\"",
"+",
"status",
".",
"getLastPathAdded",
"(",
")",
")",
";",
"StringBuffer",
"resourceData",
"=",
"defaultPostProcessor",
".",
"postProcessBundle",
"(",
"status",
",",
"content",
")",
";",
"bundleData",
".",
"append",
"(",
"resourceData",
")",
";",
"}",
"else",
"{",
"bundleData",
"=",
"content",
";",
"}",
"return",
"bundleData",
";",
"}"
] |
Executes the unitary resource post processing
@param bundle
the bundle
@param status
the bundle processing status
@param content
the content to process
@return the processed content
|
[
"Executes",
"the",
"unitary",
"resource",
"post",
"processing"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L1412-L1430
|
7,269 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
|
ResourceBundlesHandlerImpl.executeBundlePostProcessing
|
private StringBuffer executeBundlePostProcessing(JoinableResourceBundle bundle, BundleProcessingStatus status,
StringBuffer bundleData) {
StringBuffer store;
status.setProcessingType(BundleProcessingStatus.BUNDLE_PROCESSING_TYPE);
status.setLastPathAdded(bundle.getId());
if (null != bundle.getBundlePostProcessor())
store = bundle.getBundlePostProcessor().postProcessBundle(status, bundleData);
else if (null != this.postProcessor)
store = this.postProcessor.postProcessBundle(status, bundleData);
else
store = bundleData;
return store;
}
|
java
|
private StringBuffer executeBundlePostProcessing(JoinableResourceBundle bundle, BundleProcessingStatus status,
StringBuffer bundleData) {
StringBuffer store;
status.setProcessingType(BundleProcessingStatus.BUNDLE_PROCESSING_TYPE);
status.setLastPathAdded(bundle.getId());
if (null != bundle.getBundlePostProcessor())
store = bundle.getBundlePostProcessor().postProcessBundle(status, bundleData);
else if (null != this.postProcessor)
store = this.postProcessor.postProcessBundle(status, bundleData);
else
store = bundleData;
return store;
}
|
[
"private",
"StringBuffer",
"executeBundlePostProcessing",
"(",
"JoinableResourceBundle",
"bundle",
",",
"BundleProcessingStatus",
"status",
",",
"StringBuffer",
"bundleData",
")",
"{",
"StringBuffer",
"store",
";",
"status",
".",
"setProcessingType",
"(",
"BundleProcessingStatus",
".",
"BUNDLE_PROCESSING_TYPE",
")",
";",
"status",
".",
"setLastPathAdded",
"(",
"bundle",
".",
"getId",
"(",
")",
")",
";",
"if",
"(",
"null",
"!=",
"bundle",
".",
"getBundlePostProcessor",
"(",
")",
")",
"store",
"=",
"bundle",
".",
"getBundlePostProcessor",
"(",
")",
".",
"postProcessBundle",
"(",
"status",
",",
"bundleData",
")",
";",
"else",
"if",
"(",
"null",
"!=",
"this",
".",
"postProcessor",
")",
"store",
"=",
"this",
".",
"postProcessor",
".",
"postProcessBundle",
"(",
"status",
",",
"bundleData",
")",
";",
"else",
"store",
"=",
"bundleData",
";",
"return",
"store",
";",
"}"
] |
Execute the bundle post processing
@param bundle
the bundle
@param status
the status
@param bundleData
the bundle data
@return the processed content
|
[
"Execute",
"the",
"bundle",
"post",
"processing"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L1443-L1456
|
7,270 |
j-a-w-r/jawr-main-repo
|
jawr-dwr3.x/jawr-dwr3.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWR3BeanGenerator.java
|
DWR3BeanGenerator.getContainer
|
private Container getContainer(final GeneratorContext context) {
List<Container> containers = StartupUtil
.getAllPublishedContainers(context.getServletContext());
// TODO: here we assume there is only one DWR Servlet / Container ... we
// should find a way to math the container with the DWR mapping config
for (Container container : containers) {
return container;
}
throw new RuntimeException("FATAL: unable to find DWR Container!");
}
|
java
|
private Container getContainer(final GeneratorContext context) {
List<Container> containers = StartupUtil
.getAllPublishedContainers(context.getServletContext());
// TODO: here we assume there is only one DWR Servlet / Container ... we
// should find a way to math the container with the DWR mapping config
for (Container container : containers) {
return container;
}
throw new RuntimeException("FATAL: unable to find DWR Container!");
}
|
[
"private",
"Container",
"getContainer",
"(",
"final",
"GeneratorContext",
"context",
")",
"{",
"List",
"<",
"Container",
">",
"containers",
"=",
"StartupUtil",
".",
"getAllPublishedContainers",
"(",
"context",
".",
"getServletContext",
"(",
")",
")",
";",
"// TODO: here we assume there is only one DWR Servlet / Container ... we",
"// should find a way to math the container with the DWR mapping config",
"for",
"(",
"Container",
"container",
":",
"containers",
")",
"{",
"return",
"container",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"\"FATAL: unable to find DWR Container!\"",
")",
";",
"}"
] |
Get the DWR Container. If multiple DWR containers exist in the
ServletContext, the first found is returned.
@param context
The GeneratorContext
@return The DWR Container
|
[
"Get",
"the",
"DWR",
"Container",
".",
"If",
"multiple",
"DWR",
"containers",
"exist",
"in",
"the",
"ServletContext",
"the",
"first",
"found",
"is",
"returned",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr3.x/jawr-dwr3.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWR3BeanGenerator.java#L176-L185
|
7,271 |
j-a-w-r/jawr-main-repo
|
jawr-dwr3.x/jawr-dwr3.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWR3BeanGenerator.java
|
DWR3BeanGenerator.getInterfaceScript
|
private String getInterfaceScript(String scriptName,
final GeneratorContext context) throws IOException {
Container container = getContainer(context);
CreatorManager ctManager = (CreatorManager) container
.getBean(CreatorManager.class.getName());
if (ctManager.getCreator(scriptName, false) != null) {
InterfaceHandler handler = (InterfaceHandler) ContainerUtil
.getHandlerForUrlProperty(container, INTERFACE_HANDLER_URL);
return handler.generateInterfaceScript(context.getServletContext()
.getContextPath(), context.getConfig().getDwrMapping(),
scriptName);
} else
throw new IllegalArgumentException("The DWR bean named '"
+ scriptName
+ "' was not found in any DWR configuration instance.");
}
|
java
|
private String getInterfaceScript(String scriptName,
final GeneratorContext context) throws IOException {
Container container = getContainer(context);
CreatorManager ctManager = (CreatorManager) container
.getBean(CreatorManager.class.getName());
if (ctManager.getCreator(scriptName, false) != null) {
InterfaceHandler handler = (InterfaceHandler) ContainerUtil
.getHandlerForUrlProperty(container, INTERFACE_HANDLER_URL);
return handler.generateInterfaceScript(context.getServletContext()
.getContextPath(), context.getConfig().getDwrMapping(),
scriptName);
} else
throw new IllegalArgumentException("The DWR bean named '"
+ scriptName
+ "' was not found in any DWR configuration instance.");
}
|
[
"private",
"String",
"getInterfaceScript",
"(",
"String",
"scriptName",
",",
"final",
"GeneratorContext",
"context",
")",
"throws",
"IOException",
"{",
"Container",
"container",
"=",
"getContainer",
"(",
"context",
")",
";",
"CreatorManager",
"ctManager",
"=",
"(",
"CreatorManager",
")",
"container",
".",
"getBean",
"(",
"CreatorManager",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"ctManager",
".",
"getCreator",
"(",
"scriptName",
",",
"false",
")",
"!=",
"null",
")",
"{",
"InterfaceHandler",
"handler",
"=",
"(",
"InterfaceHandler",
")",
"ContainerUtil",
".",
"getHandlerForUrlProperty",
"(",
"container",
",",
"INTERFACE_HANDLER_URL",
")",
";",
"return",
"handler",
".",
"generateInterfaceScript",
"(",
"context",
".",
"getServletContext",
"(",
")",
".",
"getContextPath",
"(",
")",
",",
"context",
".",
"getConfig",
"(",
")",
".",
"getDwrMapping",
"(",
")",
",",
"scriptName",
")",
";",
"}",
"else",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The DWR bean named '\"",
"+",
"scriptName",
"+",
"\"' was not found in any DWR configuration instance.\"",
")",
";",
"}"
] |
Get a specific interface script
@param scriptName
The name of the script
@param context
The GeneratorContext
@return The script as a String
@throws IOException
|
[
"Get",
"a",
"specific",
"interface",
"script"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr3.x/jawr-dwr3.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWR3BeanGenerator.java#L197-L212
|
7,272 |
j-a-w-r/jawr-main-repo
|
jawr-dwr3.x/jawr-dwr3.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWR3BeanGenerator.java
|
DWR3BeanGenerator.getAllPublishedInterfaces
|
private String getAllPublishedInterfaces(final GeneratorContext context)
throws IOException {
StringBuilder sb = new StringBuilder();
Container container = getContainer(context);
// The creatormanager holds the list of beans
CreatorManager ctManager = (CreatorManager) container
.getBean(CreatorManager.class.getName());
if (null != ctManager) {
Collection<String> creators;
if (ctManager instanceof DefaultCreatorManager) {
DefaultCreatorManager creatorManager = (DefaultCreatorManager) ctManager;
boolean currentDebugValue = creatorManager.isDebug();
creatorManager.setDebug(true); // DWR will throw a
// SecurityException if not in
// debug mode ...
creators = ctManager.getCreatorNames(false);
creatorManager.setDebug(currentDebugValue);
} else {
log.warn("Getting creator names from an unknown CreatorManager. This may fail ...");
creators = ctManager.getCreatorNames(false);
}
List<String> creatorList = new ArrayList<>(creators);
Collections.sort(creatorList);
for (String name : creatorList) {
if (log.isDebugEnabled())
log.debug("_** mapping: generating found interface named: "
+ name);
InterfaceHandler handler = (InterfaceHandler) ContainerUtil
.getHandlerForUrlProperty(container,
INTERFACE_HANDLER_URL);
sb.append(handler.generateInterfaceScript(context
.getServletContext().getContextPath(), context
.getConfig().getDwrMapping(), name));
}
}
return sb.toString();
}
|
java
|
private String getAllPublishedInterfaces(final GeneratorContext context)
throws IOException {
StringBuilder sb = new StringBuilder();
Container container = getContainer(context);
// The creatormanager holds the list of beans
CreatorManager ctManager = (CreatorManager) container
.getBean(CreatorManager.class.getName());
if (null != ctManager) {
Collection<String> creators;
if (ctManager instanceof DefaultCreatorManager) {
DefaultCreatorManager creatorManager = (DefaultCreatorManager) ctManager;
boolean currentDebugValue = creatorManager.isDebug();
creatorManager.setDebug(true); // DWR will throw a
// SecurityException if not in
// debug mode ...
creators = ctManager.getCreatorNames(false);
creatorManager.setDebug(currentDebugValue);
} else {
log.warn("Getting creator names from an unknown CreatorManager. This may fail ...");
creators = ctManager.getCreatorNames(false);
}
List<String> creatorList = new ArrayList<>(creators);
Collections.sort(creatorList);
for (String name : creatorList) {
if (log.isDebugEnabled())
log.debug("_** mapping: generating found interface named: "
+ name);
InterfaceHandler handler = (InterfaceHandler) ContainerUtil
.getHandlerForUrlProperty(container,
INTERFACE_HANDLER_URL);
sb.append(handler.generateInterfaceScript(context
.getServletContext().getContextPath(), context
.getConfig().getDwrMapping(), name));
}
}
return sb.toString();
}
|
[
"private",
"String",
"getAllPublishedInterfaces",
"(",
"final",
"GeneratorContext",
"context",
")",
"throws",
"IOException",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Container",
"container",
"=",
"getContainer",
"(",
"context",
")",
";",
"// The creatormanager holds the list of beans",
"CreatorManager",
"ctManager",
"=",
"(",
"CreatorManager",
")",
"container",
".",
"getBean",
"(",
"CreatorManager",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"null",
"!=",
"ctManager",
")",
"{",
"Collection",
"<",
"String",
">",
"creators",
";",
"if",
"(",
"ctManager",
"instanceof",
"DefaultCreatorManager",
")",
"{",
"DefaultCreatorManager",
"creatorManager",
"=",
"(",
"DefaultCreatorManager",
")",
"ctManager",
";",
"boolean",
"currentDebugValue",
"=",
"creatorManager",
".",
"isDebug",
"(",
")",
";",
"creatorManager",
".",
"setDebug",
"(",
"true",
")",
";",
"// DWR will throw a",
"// SecurityException if not in",
"// debug mode ...",
"creators",
"=",
"ctManager",
".",
"getCreatorNames",
"(",
"false",
")",
";",
"creatorManager",
".",
"setDebug",
"(",
"currentDebugValue",
")",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"\"Getting creator names from an unknown CreatorManager. This may fail ...\"",
")",
";",
"creators",
"=",
"ctManager",
".",
"getCreatorNames",
"(",
"false",
")",
";",
"}",
"List",
"<",
"String",
">",
"creatorList",
"=",
"new",
"ArrayList",
"<>",
"(",
"creators",
")",
";",
"Collections",
".",
"sort",
"(",
"creatorList",
")",
";",
"for",
"(",
"String",
"name",
":",
"creatorList",
")",
"{",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"log",
".",
"debug",
"(",
"\"_** mapping: generating found interface named: \"",
"+",
"name",
")",
";",
"InterfaceHandler",
"handler",
"=",
"(",
"InterfaceHandler",
")",
"ContainerUtil",
".",
"getHandlerForUrlProperty",
"(",
"container",
",",
"INTERFACE_HANDLER_URL",
")",
";",
"sb",
".",
"append",
"(",
"handler",
".",
"generateInterfaceScript",
"(",
"context",
".",
"getServletContext",
"(",
")",
".",
"getContextPath",
"(",
")",
",",
"context",
".",
"getConfig",
"(",
")",
".",
"getDwrMapping",
"(",
")",
",",
"name",
")",
")",
";",
"}",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Get all interfaces in one script
@param context
The GeneratorContext
@return All interfaces scripts as a single string
@throws IOException
|
[
"Get",
"all",
"interfaces",
"in",
"one",
"script"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr3.x/jawr-dwr3.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWR3BeanGenerator.java#L222-L262
|
7,273 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/sass/vaadin/SassVaadinGenerator.java
|
SassVaadinGenerator.compile
|
protected String compile(JoinableResourceBundle bundle, String content, String path, GeneratorContext context) {
try {
JawrScssResolver scssResolver = new JawrScssResolver(bundle, rsHandler);
JawrScssStylesheet sheet = new JawrScssStylesheet(bundle, content, path, scssResolver,
context.getCharset());
sheet.compile(urlMode);
String parsedScss = sheet.printState();
addLinkedResources(path, context, scssResolver.getLinkedResources());
return parsedScss;
} catch (Exception e) {
throw new BundlingProcessException("Unable to generate content for resource path : '" + path + "'", e);
}
}
|
java
|
protected String compile(JoinableResourceBundle bundle, String content, String path, GeneratorContext context) {
try {
JawrScssResolver scssResolver = new JawrScssResolver(bundle, rsHandler);
JawrScssStylesheet sheet = new JawrScssStylesheet(bundle, content, path, scssResolver,
context.getCharset());
sheet.compile(urlMode);
String parsedScss = sheet.printState();
addLinkedResources(path, context, scssResolver.getLinkedResources());
return parsedScss;
} catch (Exception e) {
throw new BundlingProcessException("Unable to generate content for resource path : '" + path + "'", e);
}
}
|
[
"protected",
"String",
"compile",
"(",
"JoinableResourceBundle",
"bundle",
",",
"String",
"content",
",",
"String",
"path",
",",
"GeneratorContext",
"context",
")",
"{",
"try",
"{",
"JawrScssResolver",
"scssResolver",
"=",
"new",
"JawrScssResolver",
"(",
"bundle",
",",
"rsHandler",
")",
";",
"JawrScssStylesheet",
"sheet",
"=",
"new",
"JawrScssStylesheet",
"(",
"bundle",
",",
"content",
",",
"path",
",",
"scssResolver",
",",
"context",
".",
"getCharset",
"(",
")",
")",
";",
"sheet",
".",
"compile",
"(",
"urlMode",
")",
";",
"String",
"parsedScss",
"=",
"sheet",
".",
"printState",
"(",
")",
";",
"addLinkedResources",
"(",
"path",
",",
"context",
",",
"scssResolver",
".",
"getLinkedResources",
"(",
")",
")",
";",
"return",
"parsedScss",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Unable to generate content for resource path : '\"",
"+",
"path",
"+",
"\"'\"",
",",
"e",
")",
";",
"}",
"}"
] |
Compile the SASS source to a CSS source
@param bundle
the bundle
@param content
the resource content to compile
@param path
the compiled resource path
@param context
the generator context
@return the compiled CSS content
|
[
"Compile",
"the",
"SASS",
"source",
"to",
"a",
"CSS",
"source"
] |
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/css/sass/vaadin/SassVaadinGenerator.java#L165-L179
|
7,274 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/AbstractCSSGenerator.java
|
AbstractCSSGenerator.generateResourceForDebug
|
protected Reader generateResourceForDebug(Reader rd, GeneratorContext context) {
// Rewrite the image URL
StringWriter writer = new StringWriter();
try {
IOUtils.copy(rd, writer);
String content = rewriteUrl(context, writer.toString());
rd = new StringReader(content);
} catch (IOException e) {
throw new BundlingProcessException(e);
}
return rd;
}
|
java
|
protected Reader generateResourceForDebug(Reader rd, GeneratorContext context) {
// Rewrite the image URL
StringWriter writer = new StringWriter();
try {
IOUtils.copy(rd, writer);
String content = rewriteUrl(context, writer.toString());
rd = new StringReader(content);
} catch (IOException e) {
throw new BundlingProcessException(e);
}
return rd;
}
|
[
"protected",
"Reader",
"generateResourceForDebug",
"(",
"Reader",
"rd",
",",
"GeneratorContext",
"context",
")",
"{",
"// Rewrite the image URL",
"StringWriter",
"writer",
"=",
"new",
"StringWriter",
"(",
")",
";",
"try",
"{",
"IOUtils",
".",
"copy",
"(",
"rd",
",",
"writer",
")",
";",
"String",
"content",
"=",
"rewriteUrl",
"(",
"context",
",",
"writer",
".",
"toString",
"(",
")",
")",
";",
"rd",
"=",
"new",
"StringReader",
"(",
"content",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"e",
")",
";",
"}",
"return",
"rd",
";",
"}"
] |
Returns the resource in debug mode. Here an extra step is used to rewrite
the URL in debug mode
@param reader
the reader
@param context
the generator context
@return the reader
|
[
"Returns",
"the",
"resource",
"in",
"debug",
"mode",
".",
"Here",
"an",
"extra",
"step",
"is",
"used",
"to",
"rewrite",
"the",
"URL",
"in",
"debug",
"mode"
] |
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/AbstractCSSGenerator.java#L76-L89
|
7,275 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/AbstractCSSGenerator.java
|
AbstractCSSGenerator.rewriteUrl
|
protected String rewriteUrl(GeneratorContext context, String content) throws IOException {
JawrConfig jawrConfig = context.getConfig();
CssImageUrlRewriter rewriter = new CssImageUrlRewriter(jawrConfig);
String bundlePath = PathNormalizer.joinPaths(jawrConfig.getServletMapping(), ResourceGenerator.CSS_DEBUGPATH);
StringBuffer result = rewriter.rewriteUrl(context.getPath(), bundlePath, content);
return result.toString();
}
|
java
|
protected String rewriteUrl(GeneratorContext context, String content) throws IOException {
JawrConfig jawrConfig = context.getConfig();
CssImageUrlRewriter rewriter = new CssImageUrlRewriter(jawrConfig);
String bundlePath = PathNormalizer.joinPaths(jawrConfig.getServletMapping(), ResourceGenerator.CSS_DEBUGPATH);
StringBuffer result = rewriter.rewriteUrl(context.getPath(), bundlePath, content);
return result.toString();
}
|
[
"protected",
"String",
"rewriteUrl",
"(",
"GeneratorContext",
"context",
",",
"String",
"content",
")",
"throws",
"IOException",
"{",
"JawrConfig",
"jawrConfig",
"=",
"context",
".",
"getConfig",
"(",
")",
";",
"CssImageUrlRewriter",
"rewriter",
"=",
"new",
"CssImageUrlRewriter",
"(",
"jawrConfig",
")",
";",
"String",
"bundlePath",
"=",
"PathNormalizer",
".",
"joinPaths",
"(",
"jawrConfig",
".",
"getServletMapping",
"(",
")",
",",
"ResourceGenerator",
".",
"CSS_DEBUGPATH",
")",
";",
"StringBuffer",
"result",
"=",
"rewriter",
".",
"rewriteUrl",
"(",
"context",
".",
"getPath",
"(",
")",
",",
"bundlePath",
",",
"content",
")",
";",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Rewrite the URL for debug mode
@param context
the generator context
@param content
the content
@return the rewritten content
@throws IOException
if IOException occurs
|
[
"Rewrite",
"the",
"URL",
"for",
"debug",
"mode"
] |
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/AbstractCSSGenerator.java#L102-L110
|
7,276 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/AbstractCSSGenerator.java
|
AbstractCSSGenerator.getBinaryServletMapping
|
private String getBinaryServletMapping() {
String binaryServletMapping = null;
// Retrieve binary servlet mapping from the binary resource handler
BinaryResourcesHandler binaryRsHandler = (BinaryResourcesHandler) config.getContext()
.getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);
if (binaryRsHandler != null) {
binaryServletMapping = binaryRsHandler.getConfig().getServletMapping();
}
return binaryServletMapping;
}
|
java
|
private String getBinaryServletMapping() {
String binaryServletMapping = null;
// Retrieve binary servlet mapping from the binary resource handler
BinaryResourcesHandler binaryRsHandler = (BinaryResourcesHandler) config.getContext()
.getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);
if (binaryRsHandler != null) {
binaryServletMapping = binaryRsHandler.getConfig().getServletMapping();
}
return binaryServletMapping;
}
|
[
"private",
"String",
"getBinaryServletMapping",
"(",
")",
"{",
"String",
"binaryServletMapping",
"=",
"null",
";",
"// Retrieve binary servlet mapping from the binary resource handler",
"BinaryResourcesHandler",
"binaryRsHandler",
"=",
"(",
"BinaryResourcesHandler",
")",
"config",
".",
"getContext",
"(",
")",
".",
"getAttribute",
"(",
"JawrConstant",
".",
"BINARY_CONTEXT_ATTRIBUTE",
")",
";",
"if",
"(",
"binaryRsHandler",
"!=",
"null",
")",
"{",
"binaryServletMapping",
"=",
"binaryRsHandler",
".",
"getConfig",
"(",
")",
".",
"getServletMapping",
"(",
")",
";",
"}",
"return",
"binaryServletMapping",
";",
"}"
] |
Retrieves the binary servlet mapping
@return the binary servlet mapping or null if it doesn't exist
|
[
"Retrieves",
"the",
"binary",
"servlet",
"mapping"
] |
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/AbstractCSSGenerator.java#L175-L184
|
7,277 |
j-a-w-r/jawr-main-repo
|
jawr-grails/jawr-grails-plugin/src/java/net/jawr/web/resource/bundle/locale/message/grails/GrailsMessageBundleScriptCreator.java
|
GrailsMessageBundleScriptCreator.getBaseNames
|
public String[] getBaseNames(boolean warDeployed) {
String[] names = configParam.split(GrailsLocaleUtils.RESOURCE_BUNDLE_SEPARATOR);
List<String> baseNames = new ArrayList<String>();
for (String baseName : names) {
// Read the properties files to find out the available message keys. It
// is done differently
// for run-app or run-war style of runtimes.
boolean isPluginResoucePath = GrailsLocaleUtils
.isPluginResoucePath(baseName);
if (warDeployed) {
if (isPluginResoucePath) {
baseName = WEB_INF_DIR+rsReader.getRealResourcePath(baseName);
} else {
baseName = PROPERTIES_DIR
+ baseName.substring(baseName.lastIndexOf('.') + 1);
}
} else {
if (isPluginResoucePath) {
baseName = URI_ABSOLUTE_FILE_PREFIX
+ rsReader.getRealResourcePath(baseName);
} else {
baseName = URI_RELATIVE_FILE_PREFIX + baseName.replaceAll(REGEX_DOT_CHARACTER, JawrConstant.URL_SEPARATOR);
}
}
baseNames.add(baseName);
}
return baseNames.toArray(new String[] {});
}
|
java
|
public String[] getBaseNames(boolean warDeployed) {
String[] names = configParam.split(GrailsLocaleUtils.RESOURCE_BUNDLE_SEPARATOR);
List<String> baseNames = new ArrayList<String>();
for (String baseName : names) {
// Read the properties files to find out the available message keys. It
// is done differently
// for run-app or run-war style of runtimes.
boolean isPluginResoucePath = GrailsLocaleUtils
.isPluginResoucePath(baseName);
if (warDeployed) {
if (isPluginResoucePath) {
baseName = WEB_INF_DIR+rsReader.getRealResourcePath(baseName);
} else {
baseName = PROPERTIES_DIR
+ baseName.substring(baseName.lastIndexOf('.') + 1);
}
} else {
if (isPluginResoucePath) {
baseName = URI_ABSOLUTE_FILE_PREFIX
+ rsReader.getRealResourcePath(baseName);
} else {
baseName = URI_RELATIVE_FILE_PREFIX + baseName.replaceAll(REGEX_DOT_CHARACTER, JawrConstant.URL_SEPARATOR);
}
}
baseNames.add(baseName);
}
return baseNames.toArray(new String[] {});
}
|
[
"public",
"String",
"[",
"]",
"getBaseNames",
"(",
"boolean",
"warDeployed",
")",
"{",
"String",
"[",
"]",
"names",
"=",
"configParam",
".",
"split",
"(",
"GrailsLocaleUtils",
".",
"RESOURCE_BUNDLE_SEPARATOR",
")",
";",
"List",
"<",
"String",
">",
"baseNames",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"baseName",
":",
"names",
")",
"{",
"// Read the properties files to find out the available message keys. It",
"// is done differently",
"// for run-app or run-war style of runtimes.",
"boolean",
"isPluginResoucePath",
"=",
"GrailsLocaleUtils",
".",
"isPluginResoucePath",
"(",
"baseName",
")",
";",
"if",
"(",
"warDeployed",
")",
"{",
"if",
"(",
"isPluginResoucePath",
")",
"{",
"baseName",
"=",
"WEB_INF_DIR",
"+",
"rsReader",
".",
"getRealResourcePath",
"(",
"baseName",
")",
";",
"}",
"else",
"{",
"baseName",
"=",
"PROPERTIES_DIR",
"+",
"baseName",
".",
"substring",
"(",
"baseName",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"isPluginResoucePath",
")",
"{",
"baseName",
"=",
"URI_ABSOLUTE_FILE_PREFIX",
"+",
"rsReader",
".",
"getRealResourcePath",
"(",
"baseName",
")",
";",
"}",
"else",
"{",
"baseName",
"=",
"URI_RELATIVE_FILE_PREFIX",
"+",
"baseName",
".",
"replaceAll",
"(",
"REGEX_DOT_CHARACTER",
",",
"JawrConstant",
".",
"URL_SEPARATOR",
")",
";",
"}",
"}",
"baseNames",
".",
"add",
"(",
"baseName",
")",
";",
"}",
"return",
"baseNames",
".",
"toArray",
"(",
"new",
"String",
"[",
"]",
"{",
"}",
")",
";",
"}"
] |
Returns the basenames
@return the base names for the bundle resources
|
[
"Returns",
"the",
"basenames"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-grails/jawr-grails-plugin/src/java/net/jawr/web/resource/bundle/locale/message/grails/GrailsMessageBundleScriptCreator.java#L136-L172
|
7,278 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/global/postprocessor/BasicGlobalPostprocessorChainFactory.java
|
BasicGlobalPostprocessorChainFactory.buildProcessorByKey
|
@Override
protected AbstractChainedGlobalProcessor<GlobalPostProcessingContext> buildProcessorByKey(String key) {
AbstractChainedGlobalProcessor<GlobalPostProcessingContext> processor = null;
if (key.equals(JawrConstant.GLOBAL_GOOGLE_CLOSURE_POSTPROCESSOR_ID)) {
processor = new ClosureGlobalPostProcessor();
}
return processor;
}
|
java
|
@Override
protected AbstractChainedGlobalProcessor<GlobalPostProcessingContext> buildProcessorByKey(String key) {
AbstractChainedGlobalProcessor<GlobalPostProcessingContext> processor = null;
if (key.equals(JawrConstant.GLOBAL_GOOGLE_CLOSURE_POSTPROCESSOR_ID)) {
processor = new ClosureGlobalPostProcessor();
}
return processor;
}
|
[
"@",
"Override",
"protected",
"AbstractChainedGlobalProcessor",
"<",
"GlobalPostProcessingContext",
">",
"buildProcessorByKey",
"(",
"String",
"key",
")",
"{",
"AbstractChainedGlobalProcessor",
"<",
"GlobalPostProcessingContext",
">",
"processor",
"=",
"null",
";",
"if",
"(",
"key",
".",
"equals",
"(",
"JawrConstant",
".",
"GLOBAL_GOOGLE_CLOSURE_POSTPROCESSOR_ID",
")",
")",
"{",
"processor",
"=",
"new",
"ClosureGlobalPostProcessor",
"(",
")",
";",
"}",
"return",
"processor",
";",
"}"
] |
Build the global preprocessor from the ID given in parameter
@param key
the ID of the preprocessor
@return a global preprocessor
|
[
"Build",
"the",
"global",
"preprocessor",
"from",
"the",
"ID",
"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/factory/global/postprocessor/BasicGlobalPostprocessorChainFactory.java#L37-L47
|
7,279 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/preprocessor/css/smartsprites/CssSmartSpritesGlobalPreprocessor.java
|
CssSmartSpritesGlobalPreprocessor.updateBundlesDirtyState
|
private void updateBundlesDirtyState(List<JoinableResourceBundle> bundles,
CssSmartSpritesResourceReader cssSpriteResourceReader) {
for (JoinableResourceBundle bundle : bundles) {
List<BundlePath> bundlePaths = bundle.getItemPathList();
for (BundlePath bundlePath : bundlePaths) {
String path = bundlePath.getPath();
File stdFile = cssSpriteResourceReader.getGeneratedCssFile(path);
File bckFile = cssSpriteResourceReader.getBackupFile(path);
if (bckFile.exists()) {
try {
if (!FileUtils.contentEquals(stdFile, bckFile)) {
bundle.setDirty(true);
break;
}
} catch (IOException e) {
throw new BundlingProcessException("Issue while generating smartsprite bundle", e);
}
}
cssSpriteResourceReader.getResource(bundle, path);
}
}
}
|
java
|
private void updateBundlesDirtyState(List<JoinableResourceBundle> bundles,
CssSmartSpritesResourceReader cssSpriteResourceReader) {
for (JoinableResourceBundle bundle : bundles) {
List<BundlePath> bundlePaths = bundle.getItemPathList();
for (BundlePath bundlePath : bundlePaths) {
String path = bundlePath.getPath();
File stdFile = cssSpriteResourceReader.getGeneratedCssFile(path);
File bckFile = cssSpriteResourceReader.getBackupFile(path);
if (bckFile.exists()) {
try {
if (!FileUtils.contentEquals(stdFile, bckFile)) {
bundle.setDirty(true);
break;
}
} catch (IOException e) {
throw new BundlingProcessException("Issue while generating smartsprite bundle", e);
}
}
cssSpriteResourceReader.getResource(bundle, path);
}
}
}
|
[
"private",
"void",
"updateBundlesDirtyState",
"(",
"List",
"<",
"JoinableResourceBundle",
">",
"bundles",
",",
"CssSmartSpritesResourceReader",
"cssSpriteResourceReader",
")",
"{",
"for",
"(",
"JoinableResourceBundle",
"bundle",
":",
"bundles",
")",
"{",
"List",
"<",
"BundlePath",
">",
"bundlePaths",
"=",
"bundle",
".",
"getItemPathList",
"(",
")",
";",
"for",
"(",
"BundlePath",
"bundlePath",
":",
"bundlePaths",
")",
"{",
"String",
"path",
"=",
"bundlePath",
".",
"getPath",
"(",
")",
";",
"File",
"stdFile",
"=",
"cssSpriteResourceReader",
".",
"getGeneratedCssFile",
"(",
"path",
")",
";",
"File",
"bckFile",
"=",
"cssSpriteResourceReader",
".",
"getBackupFile",
"(",
"path",
")",
";",
"if",
"(",
"bckFile",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"FileUtils",
".",
"contentEquals",
"(",
"stdFile",
",",
"bckFile",
")",
")",
"{",
"bundle",
".",
"setDirty",
"(",
"true",
")",
";",
"break",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Issue while generating smartsprite bundle\"",
",",
"e",
")",
";",
"}",
"}",
"cssSpriteResourceReader",
".",
"getResource",
"(",
"bundle",
",",
"path",
")",
";",
"}",
"}",
"}"
] |
Update the bundles dirty state
@param bundles
the list of bundle
@param cssSpriteResourceReader
the css sprite resource reader
|
[
"Update",
"the",
"bundles",
"dirty",
"state"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/preprocessor/css/smartsprites/CssSmartSpritesGlobalPreprocessor.java#L114-L137
|
7,280 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/preprocessor/css/smartsprites/CssSmartSpritesGlobalPreprocessor.java
|
CssSmartSpritesGlobalPreprocessor.generateSprites
|
private void generateSprites(ResourceReaderHandler cssRsHandler, BinaryResourcesHandler binaryRsHandler,
Set<String> resourcePaths, JawrConfig jawrConfig, Charset charset) {
MessageLevel msgLevel = MessageLevel.valueOf(ERROR_LEVEL);
String sinkLevel = WARN_LEVEL;
if (LOGGER.isTraceEnabled() || LOGGER.isDebugEnabled() || LOGGER.isInfoEnabled()) { // logLevel.isGreaterOrEqual(Level.DEBUG)
msgLevel = MessageLevel.valueOf(INFO_LEVEL);
sinkLevel = INFO_LEVEL;
} else if (LOGGER.isWarnEnabled() || LOGGER.isErrorEnabled()) { // logLevel.isGreaterOrEqual(Level.WARN)
msgLevel = MessageLevel.valueOf(WARN_LEVEL);
sinkLevel = WARN_LEVEL;
}
MessageLog messageLog = new MessageLog(new MessageSink[] { new LogMessageSink(sinkLevel) });
SmartSpritesResourceHandler smartSpriteRsHandler = new SmartSpritesResourceHandler(cssRsHandler,
binaryRsHandler.getRsReaderHandler(), jawrConfig.getGeneratorRegistry(),
binaryRsHandler.getConfig().getGeneratorRegistry(), charset.toString(), messageLog);
smartSpriteRsHandler.setContextPath(jawrConfig.getProperty(JawrConstant.JAWR_CSS_URL_REWRITER_CONTEXT_PATH));
String outDir = cssRsHandler.getWorkingDirectory() + JawrConstant.CSS_SMARTSPRITES_TMP_DIR;
// Create temp directories
File tmpDir = new File(outDir);
if (!tmpDir.exists()) {
if (!tmpDir.mkdirs()) {
throw new BundlingProcessException("Impossible to create temporary directory : " + tmpDir);
}
} else {
// Copy to backup and clean temp directories
try {
File backupDir = new File(
cssRsHandler.getWorkingDirectory() + JawrConstant.SPRITE_BACKUP_GENERATED_CSS_DIR);
if (!backupDir.exists()) {
if (!backupDir.mkdirs()) {
throw new BundlingProcessException("Impossible to create temporary directory : " + backupDir);
}
}
FileUtils.copyDirectory(tmpDir, backupDir);
FileUtils.cleanDirectory(tmpDir);
} catch (IOException e) {
throw new BundlingProcessException("Impossible to clean temporary directory : " + outDir, e);
}
}
SmartSpritesParameters params = new SmartSpritesParameters("/", null, outDir, null, msgLevel, "",
PngDepth.valueOf("AUTO"), false, charset.toString(), true);
SpriteBuilder spriteBuilder = new SpriteBuilder(params, messageLog, smartSpriteRsHandler);
try {
spriteBuilder.buildSprites(resourcePaths);
} catch (IOException e) {
throw new BundlingProcessException("Unable to build sprites", e);
}
}
|
java
|
private void generateSprites(ResourceReaderHandler cssRsHandler, BinaryResourcesHandler binaryRsHandler,
Set<String> resourcePaths, JawrConfig jawrConfig, Charset charset) {
MessageLevel msgLevel = MessageLevel.valueOf(ERROR_LEVEL);
String sinkLevel = WARN_LEVEL;
if (LOGGER.isTraceEnabled() || LOGGER.isDebugEnabled() || LOGGER.isInfoEnabled()) { // logLevel.isGreaterOrEqual(Level.DEBUG)
msgLevel = MessageLevel.valueOf(INFO_LEVEL);
sinkLevel = INFO_LEVEL;
} else if (LOGGER.isWarnEnabled() || LOGGER.isErrorEnabled()) { // logLevel.isGreaterOrEqual(Level.WARN)
msgLevel = MessageLevel.valueOf(WARN_LEVEL);
sinkLevel = WARN_LEVEL;
}
MessageLog messageLog = new MessageLog(new MessageSink[] { new LogMessageSink(sinkLevel) });
SmartSpritesResourceHandler smartSpriteRsHandler = new SmartSpritesResourceHandler(cssRsHandler,
binaryRsHandler.getRsReaderHandler(), jawrConfig.getGeneratorRegistry(),
binaryRsHandler.getConfig().getGeneratorRegistry(), charset.toString(), messageLog);
smartSpriteRsHandler.setContextPath(jawrConfig.getProperty(JawrConstant.JAWR_CSS_URL_REWRITER_CONTEXT_PATH));
String outDir = cssRsHandler.getWorkingDirectory() + JawrConstant.CSS_SMARTSPRITES_TMP_DIR;
// Create temp directories
File tmpDir = new File(outDir);
if (!tmpDir.exists()) {
if (!tmpDir.mkdirs()) {
throw new BundlingProcessException("Impossible to create temporary directory : " + tmpDir);
}
} else {
// Copy to backup and clean temp directories
try {
File backupDir = new File(
cssRsHandler.getWorkingDirectory() + JawrConstant.SPRITE_BACKUP_GENERATED_CSS_DIR);
if (!backupDir.exists()) {
if (!backupDir.mkdirs()) {
throw new BundlingProcessException("Impossible to create temporary directory : " + backupDir);
}
}
FileUtils.copyDirectory(tmpDir, backupDir);
FileUtils.cleanDirectory(tmpDir);
} catch (IOException e) {
throw new BundlingProcessException("Impossible to clean temporary directory : " + outDir, e);
}
}
SmartSpritesParameters params = new SmartSpritesParameters("/", null, outDir, null, msgLevel, "",
PngDepth.valueOf("AUTO"), false, charset.toString(), true);
SpriteBuilder spriteBuilder = new SpriteBuilder(params, messageLog, smartSpriteRsHandler);
try {
spriteBuilder.buildSprites(resourcePaths);
} catch (IOException e) {
throw new BundlingProcessException("Unable to build sprites", e);
}
}
|
[
"private",
"void",
"generateSprites",
"(",
"ResourceReaderHandler",
"cssRsHandler",
",",
"BinaryResourcesHandler",
"binaryRsHandler",
",",
"Set",
"<",
"String",
">",
"resourcePaths",
",",
"JawrConfig",
"jawrConfig",
",",
"Charset",
"charset",
")",
"{",
"MessageLevel",
"msgLevel",
"=",
"MessageLevel",
".",
"valueOf",
"(",
"ERROR_LEVEL",
")",
";",
"String",
"sinkLevel",
"=",
"WARN_LEVEL",
";",
"if",
"(",
"LOGGER",
".",
"isTraceEnabled",
"(",
")",
"||",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
"||",
"LOGGER",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"// logLevel.isGreaterOrEqual(Level.DEBUG)",
"msgLevel",
"=",
"MessageLevel",
".",
"valueOf",
"(",
"INFO_LEVEL",
")",
";",
"sinkLevel",
"=",
"INFO_LEVEL",
";",
"}",
"else",
"if",
"(",
"LOGGER",
".",
"isWarnEnabled",
"(",
")",
"||",
"LOGGER",
".",
"isErrorEnabled",
"(",
")",
")",
"{",
"// logLevel.isGreaterOrEqual(Level.WARN)",
"msgLevel",
"=",
"MessageLevel",
".",
"valueOf",
"(",
"WARN_LEVEL",
")",
";",
"sinkLevel",
"=",
"WARN_LEVEL",
";",
"}",
"MessageLog",
"messageLog",
"=",
"new",
"MessageLog",
"(",
"new",
"MessageSink",
"[",
"]",
"{",
"new",
"LogMessageSink",
"(",
"sinkLevel",
")",
"}",
")",
";",
"SmartSpritesResourceHandler",
"smartSpriteRsHandler",
"=",
"new",
"SmartSpritesResourceHandler",
"(",
"cssRsHandler",
",",
"binaryRsHandler",
".",
"getRsReaderHandler",
"(",
")",
",",
"jawrConfig",
".",
"getGeneratorRegistry",
"(",
")",
",",
"binaryRsHandler",
".",
"getConfig",
"(",
")",
".",
"getGeneratorRegistry",
"(",
")",
",",
"charset",
".",
"toString",
"(",
")",
",",
"messageLog",
")",
";",
"smartSpriteRsHandler",
".",
"setContextPath",
"(",
"jawrConfig",
".",
"getProperty",
"(",
"JawrConstant",
".",
"JAWR_CSS_URL_REWRITER_CONTEXT_PATH",
")",
")",
";",
"String",
"outDir",
"=",
"cssRsHandler",
".",
"getWorkingDirectory",
"(",
")",
"+",
"JawrConstant",
".",
"CSS_SMARTSPRITES_TMP_DIR",
";",
"// Create temp directories",
"File",
"tmpDir",
"=",
"new",
"File",
"(",
"outDir",
")",
";",
"if",
"(",
"!",
"tmpDir",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"tmpDir",
".",
"mkdirs",
"(",
")",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Impossible to create temporary directory : \"",
"+",
"tmpDir",
")",
";",
"}",
"}",
"else",
"{",
"// Copy to backup and clean temp directories",
"try",
"{",
"File",
"backupDir",
"=",
"new",
"File",
"(",
"cssRsHandler",
".",
"getWorkingDirectory",
"(",
")",
"+",
"JawrConstant",
".",
"SPRITE_BACKUP_GENERATED_CSS_DIR",
")",
";",
"if",
"(",
"!",
"backupDir",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"backupDir",
".",
"mkdirs",
"(",
")",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Impossible to create temporary directory : \"",
"+",
"backupDir",
")",
";",
"}",
"}",
"FileUtils",
".",
"copyDirectory",
"(",
"tmpDir",
",",
"backupDir",
")",
";",
"FileUtils",
".",
"cleanDirectory",
"(",
"tmpDir",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Impossible to clean temporary directory : \"",
"+",
"outDir",
",",
"e",
")",
";",
"}",
"}",
"SmartSpritesParameters",
"params",
"=",
"new",
"SmartSpritesParameters",
"(",
"\"/\"",
",",
"null",
",",
"outDir",
",",
"null",
",",
"msgLevel",
",",
"\"\"",
",",
"PngDepth",
".",
"valueOf",
"(",
"\"AUTO\"",
")",
",",
"false",
",",
"charset",
".",
"toString",
"(",
")",
",",
"true",
")",
";",
"SpriteBuilder",
"spriteBuilder",
"=",
"new",
"SpriteBuilder",
"(",
"params",
",",
"messageLog",
",",
"smartSpriteRsHandler",
")",
";",
"try",
"{",
"spriteBuilder",
".",
"buildSprites",
"(",
"resourcePaths",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Unable to build sprites\"",
",",
"e",
")",
";",
"}",
"}"
] |
Generates the image sprites from the smartsprites annotation in the CSS,
rewrite the CSS files to references the generated sprites.
@param cssRsHandler
the css resourceHandler
@param binaryRsHandler
the binary resourceHandler
@param resourcePaths
the set of CSS resource paths to handle
@param jawrConfig
the Jawr config
@param charset
the charset
|
[
"Generates",
"the",
"image",
"sprites",
"from",
"the",
"smartsprites",
"annotation",
"in",
"the",
"CSS",
"rewrite",
"the",
"CSS",
"files",
"to",
"references",
"the",
"generated",
"sprites",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/preprocessor/css/smartsprites/CssSmartSpritesGlobalPreprocessor.java#L154-L211
|
7,281 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/preprocessor/css/smartsprites/CssSmartSpritesGlobalPreprocessor.java
|
CssSmartSpritesGlobalPreprocessor.getResourcePaths
|
private Set<String> getResourcePaths(List<JoinableResourceBundle> bundles) {
Set<String> resourcePaths = new HashSet<>();
for (JoinableResourceBundle bundle : bundles) {
for (BundlePath bundlePath : bundle.getItemPathList()) {
resourcePaths.add(bundlePath.getPath());
}
}
return resourcePaths;
}
|
java
|
private Set<String> getResourcePaths(List<JoinableResourceBundle> bundles) {
Set<String> resourcePaths = new HashSet<>();
for (JoinableResourceBundle bundle : bundles) {
for (BundlePath bundlePath : bundle.getItemPathList()) {
resourcePaths.add(bundlePath.getPath());
}
}
return resourcePaths;
}
|
[
"private",
"Set",
"<",
"String",
">",
"getResourcePaths",
"(",
"List",
"<",
"JoinableResourceBundle",
">",
"bundles",
")",
"{",
"Set",
"<",
"String",
">",
"resourcePaths",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"JoinableResourceBundle",
"bundle",
":",
"bundles",
")",
"{",
"for",
"(",
"BundlePath",
"bundlePath",
":",
"bundle",
".",
"getItemPathList",
"(",
")",
")",
"{",
"resourcePaths",
".",
"add",
"(",
"bundlePath",
".",
"getPath",
"(",
")",
")",
";",
"}",
"}",
"return",
"resourcePaths",
";",
"}"
] |
Returns the list of all CSS files defined in the bundles.
@param bundles
the list of bundle
@return the list of all CSS files defined in the bundles.
|
[
"Returns",
"the",
"list",
"of",
"all",
"CSS",
"files",
"defined",
"in",
"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/global/preprocessor/css/smartsprites/CssSmartSpritesGlobalPreprocessor.java#L220-L231
|
7,282 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/variant/VariantUtils.java
|
VariantUtils.getVariants
|
private static List<Map<String, String>> getVariants(Map<String, String> curVariant, String variantType,
Collection<String> variantList) {
List<Map<String, String>> variants = new ArrayList<>();
for (String variant : variantList) {
Map<String, String> map = new HashMap<>();
if (curVariant != null) {
map.putAll(curVariant);
}
map.put(variantType, variant);
variants.add(map);
}
return variants;
}
|
java
|
private static List<Map<String, String>> getVariants(Map<String, String> curVariant, String variantType,
Collection<String> variantList) {
List<Map<String, String>> variants = new ArrayList<>();
for (String variant : variantList) {
Map<String, String> map = new HashMap<>();
if (curVariant != null) {
map.putAll(curVariant);
}
map.put(variantType, variant);
variants.add(map);
}
return variants;
}
|
[
"private",
"static",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"getVariants",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"curVariant",
",",
"String",
"variantType",
",",
"Collection",
"<",
"String",
">",
"variantList",
")",
"{",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"variants",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"variant",
":",
"variantList",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"curVariant",
"!=",
"null",
")",
"{",
"map",
".",
"putAll",
"(",
"curVariant",
")",
";",
"}",
"map",
".",
"put",
"(",
"variantType",
",",
"variant",
")",
";",
"variants",
".",
"add",
"(",
"map",
")",
";",
"}",
"return",
"variants",
";",
"}"
] |
Returns the list of variant maps, which are initialized with the current
map values and each element of the list contains an element of the
variant list with the variant type as key
@param curVariant
the current variant map
@param variantType
the variant type
@param variantList
the variant list
@return the list of variant maps
|
[
"Returns",
"the",
"list",
"of",
"variant",
"maps",
"which",
"are",
"initialized",
"with",
"the",
"current",
"map",
"values",
"and",
"each",
"element",
"of",
"the",
"list",
"contains",
"an",
"element",
"of",
"the",
"variant",
"list",
"with",
"the",
"variant",
"type",
"as",
"key"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/variant/VariantUtils.java#L81-L94
|
7,283 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/variant/VariantUtils.java
|
VariantUtils.getVariantKeys
|
private static List<String> getVariantKeys(String variantKeyPrefix, Collection<String> variants) {
List<String> variantKeys = new ArrayList<>();
for (String variant : variants) {
if (variant == null) {
variant = "";
}
if (variantKeyPrefix == null) {
variantKeys.add(variant);
} else {
variantKeys.add(variantKeyPrefix + variant);
}
}
return variantKeys;
}
|
java
|
private static List<String> getVariantKeys(String variantKeyPrefix, Collection<String> variants) {
List<String> variantKeys = new ArrayList<>();
for (String variant : variants) {
if (variant == null) {
variant = "";
}
if (variantKeyPrefix == null) {
variantKeys.add(variant);
} else {
variantKeys.add(variantKeyPrefix + variant);
}
}
return variantKeys;
}
|
[
"private",
"static",
"List",
"<",
"String",
">",
"getVariantKeys",
"(",
"String",
"variantKeyPrefix",
",",
"Collection",
"<",
"String",
">",
"variants",
")",
"{",
"List",
"<",
"String",
">",
"variantKeys",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"variant",
":",
"variants",
")",
"{",
"if",
"(",
"variant",
"==",
"null",
")",
"{",
"variant",
"=",
"\"\"",
";",
"}",
"if",
"(",
"variantKeyPrefix",
"==",
"null",
")",
"{",
"variantKeys",
".",
"add",
"(",
"variant",
")",
";",
"}",
"else",
"{",
"variantKeys",
".",
"add",
"(",
"variantKeyPrefix",
"+",
"variant",
")",
";",
"}",
"}",
"return",
"variantKeys",
";",
"}"
] |
Returns the variant keys
@param variantKeyPrefix
the variant key prefix
@param variants
The variants
|
[
"Returns",
"the",
"variant",
"keys"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/variant/VariantUtils.java#L167-L182
|
7,284 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/variant/VariantUtils.java
|
VariantUtils.getVariantKey
|
public static String getVariantKey(Map<String, String> variants) {
String variantKey = "";
if (variants != null) {
variantKey = getVariantKey(variants, variants.keySet());
}
return variantKey;
}
|
java
|
public static String getVariantKey(Map<String, String> variants) {
String variantKey = "";
if (variants != null) {
variantKey = getVariantKey(variants, variants.keySet());
}
return variantKey;
}
|
[
"public",
"static",
"String",
"getVariantKey",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"variants",
")",
"{",
"String",
"variantKey",
"=",
"\"\"",
";",
"if",
"(",
"variants",
"!=",
"null",
")",
"{",
"variantKey",
"=",
"getVariantKey",
"(",
"variants",
",",
"variants",
".",
"keySet",
"(",
")",
")",
";",
"}",
"return",
"variantKey",
";",
"}"
] |
Returns the variant key from the variants given in parameter
@param variants
the variants
@return the variant key
|
[
"Returns",
"the",
"variant",
"key",
"from",
"the",
"variants",
"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/variant/VariantUtils.java#L191-L199
|
7,285 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/variant/VariantUtils.java
|
VariantUtils.getVariantKey
|
public static String getVariantKey(Map<String, String> curVariants, Set<String> variantTypes) {
String variantKey = "";
if (curVariants != null && variantTypes != null) {
Map<String, String> tempVariants = new TreeMap<>(curVariants);
StringBuilder variantKeyBuf = new StringBuilder();
for (Entry<String, String> entry : tempVariants.entrySet()) {
if (variantTypes.contains(entry.getKey())) {
String value = entry.getValue();
if (value == null) {
value = "";
}
variantKeyBuf.append(value + JawrConstant.VARIANT_SEPARATOR_CHAR);
}
}
variantKey = variantKeyBuf.toString();
if (StringUtils.isNotEmpty(variantKey)
&& variantKey.charAt(variantKey.length() - 1) == JawrConstant.VARIANT_SEPARATOR_CHAR) {
variantKey = variantKey.substring(0, variantKey.length() - 1);
}
}
return variantKey;
}
|
java
|
public static String getVariantKey(Map<String, String> curVariants, Set<String> variantTypes) {
String variantKey = "";
if (curVariants != null && variantTypes != null) {
Map<String, String> tempVariants = new TreeMap<>(curVariants);
StringBuilder variantKeyBuf = new StringBuilder();
for (Entry<String, String> entry : tempVariants.entrySet()) {
if (variantTypes.contains(entry.getKey())) {
String value = entry.getValue();
if (value == null) {
value = "";
}
variantKeyBuf.append(value + JawrConstant.VARIANT_SEPARATOR_CHAR);
}
}
variantKey = variantKeyBuf.toString();
if (StringUtils.isNotEmpty(variantKey)
&& variantKey.charAt(variantKey.length() - 1) == JawrConstant.VARIANT_SEPARATOR_CHAR) {
variantKey = variantKey.substring(0, variantKey.length() - 1);
}
}
return variantKey;
}
|
[
"public",
"static",
"String",
"getVariantKey",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"curVariants",
",",
"Set",
"<",
"String",
">",
"variantTypes",
")",
"{",
"String",
"variantKey",
"=",
"\"\"",
";",
"if",
"(",
"curVariants",
"!=",
"null",
"&&",
"variantTypes",
"!=",
"null",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"tempVariants",
"=",
"new",
"TreeMap",
"<>",
"(",
"curVariants",
")",
";",
"StringBuilder",
"variantKeyBuf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"tempVariants",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"variantTypes",
".",
"contains",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
")",
"{",
"String",
"value",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"\"\"",
";",
"}",
"variantKeyBuf",
".",
"append",
"(",
"value",
"+",
"JawrConstant",
".",
"VARIANT_SEPARATOR_CHAR",
")",
";",
"}",
"}",
"variantKey",
"=",
"variantKeyBuf",
".",
"toString",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"variantKey",
")",
"&&",
"variantKey",
".",
"charAt",
"(",
"variantKey",
".",
"length",
"(",
")",
"-",
"1",
")",
"==",
"JawrConstant",
".",
"VARIANT_SEPARATOR_CHAR",
")",
"{",
"variantKey",
"=",
"variantKey",
".",
"substring",
"(",
"0",
",",
"variantKey",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"}",
"return",
"variantKey",
";",
"}"
] |
Resolves a registered path from a locale key, using the same algorithm
used to locate ResourceBundles.
@param curVariants
the current variant map
@param variantTypes
the list of variant types
@return the variant key to use
|
[
"Resolves",
"a",
"registered",
"path",
"from",
"a",
"locale",
"key",
"using",
"the",
"same",
"algorithm",
"used",
"to",
"locate",
"ResourceBundles",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/variant/VariantUtils.java#L211-L236
|
7,286 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/variant/VariantUtils.java
|
VariantUtils.getVariantBundleName
|
public static String getVariantBundleName(String bundleName, String variantKey, boolean iGeneratedResource) {
String newName = bundleName;
if (StringUtils.isNotEmpty(variantKey)) {
int idxSeparator = bundleName.lastIndexOf('.');
if (!iGeneratedResource && idxSeparator != -1) {
newName = bundleName.substring(0, idxSeparator);
newName += JawrConstant.VARIANT_SEPARATOR_CHAR + variantKey;
newName += bundleName.substring(idxSeparator);
} else {
newName += JawrConstant.VARIANT_SEPARATOR_CHAR + variantKey;
}
}
return newName;
}
|
java
|
public static String getVariantBundleName(String bundleName, String variantKey, boolean iGeneratedResource) {
String newName = bundleName;
if (StringUtils.isNotEmpty(variantKey)) {
int idxSeparator = bundleName.lastIndexOf('.');
if (!iGeneratedResource && idxSeparator != -1) {
newName = bundleName.substring(0, idxSeparator);
newName += JawrConstant.VARIANT_SEPARATOR_CHAR + variantKey;
newName += bundleName.substring(idxSeparator);
} else {
newName += JawrConstant.VARIANT_SEPARATOR_CHAR + variantKey;
}
}
return newName;
}
|
[
"public",
"static",
"String",
"getVariantBundleName",
"(",
"String",
"bundleName",
",",
"String",
"variantKey",
",",
"boolean",
"iGeneratedResource",
")",
"{",
"String",
"newName",
"=",
"bundleName",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"variantKey",
")",
")",
"{",
"int",
"idxSeparator",
"=",
"bundleName",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"!",
"iGeneratedResource",
"&&",
"idxSeparator",
"!=",
"-",
"1",
")",
"{",
"newName",
"=",
"bundleName",
".",
"substring",
"(",
"0",
",",
"idxSeparator",
")",
";",
"newName",
"+=",
"JawrConstant",
".",
"VARIANT_SEPARATOR_CHAR",
"+",
"variantKey",
";",
"newName",
"+=",
"bundleName",
".",
"substring",
"(",
"idxSeparator",
")",
";",
"}",
"else",
"{",
"newName",
"+=",
"JawrConstant",
".",
"VARIANT_SEPARATOR_CHAR",
"+",
"variantKey",
";",
"}",
"}",
"return",
"newName",
";",
"}"
] |
Get the bundle name taking in account the variant key
@param bundleName
the bundle name
@param variantKey
the variant key
@param iGeneratedResource
the flag indicating if it's a generated resource
@return the variant bundle name
|
[
"Get",
"the",
"bundle",
"name",
"taking",
"in",
"account",
"the",
"variant",
"key"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/variant/VariantUtils.java#L249-L264
|
7,287 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/variant/VariantUtils.java
|
VariantUtils.getVariantBundleName
|
public static String getVariantBundleName(String bundleName, Map<String, String> variants,
boolean isGeneratedResource) {
String variantKey = getVariantKey(variants);
return getVariantBundleName(bundleName, variantKey, isGeneratedResource);
}
|
java
|
public static String getVariantBundleName(String bundleName, Map<String, String> variants,
boolean isGeneratedResource) {
String variantKey = getVariantKey(variants);
return getVariantBundleName(bundleName, variantKey, isGeneratedResource);
}
|
[
"public",
"static",
"String",
"getVariantBundleName",
"(",
"String",
"bundleName",
",",
"Map",
"<",
"String",
",",
"String",
">",
"variants",
",",
"boolean",
"isGeneratedResource",
")",
"{",
"String",
"variantKey",
"=",
"getVariantKey",
"(",
"variants",
")",
";",
"return",
"getVariantBundleName",
"(",
"bundleName",
",",
"variantKey",
",",
"isGeneratedResource",
")",
";",
"}"
] |
Returns the bundle name from the variants given in parameter
@param bundleName
the original bundle name
@param variants
the map of variant
@param isGeneratedResource
the flag indicating if it's a generated resource or not
@return the variant bundle name
|
[
"Returns",
"the",
"bundle",
"name",
"from",
"the",
"variants",
"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/variant/VariantUtils.java#L277-L282
|
7,288 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/variant/VariantUtils.java
|
VariantUtils.concatVariants
|
public static Map<String, VariantSet> concatVariants(Map<String, VariantSet> variantSet1,
Map<String, VariantSet> variantSet2) {
Map<String, VariantSet> result = new HashMap<>();
if (!isEmpty(variantSet1) && isEmpty(variantSet2)) {
result.putAll(variantSet1);
} else if (isEmpty(variantSet1) && !isEmpty(variantSet2)) {
result.putAll(variantSet2);
} else if (!isEmpty(variantSet1) && !isEmpty(variantSet2)) {
Set<String> keySet = new HashSet<>();
keySet.addAll(variantSet1.keySet());
keySet.addAll(variantSet2.keySet());
for (String variantType : keySet) {
VariantSet variants1 = variantSet1.get(variantType);
VariantSet variants2 = variantSet2.get(variantType);
Set<String> variants = new HashSet<>();
String defaultVariant = null;
if (variants1 != null && variants2 != null && !variants1.hasSameDefaultVariant(variants2)) {
throw new BundlingProcessException("For the variant type '" + variantType
+ "', the variant sets defined in your bundles don't have the same default value.");
}
if (variants1 != null) {
variants.addAll(variants1);
defaultVariant = variants1.getDefaultVariant();
}
if (variants2 != null) {
variants.addAll(variants2);
defaultVariant = variants2.getDefaultVariant();
}
VariantSet variantSet = new VariantSet(variantType, defaultVariant, variants);
result.put(variantType, variantSet);
}
}
return result;
}
|
java
|
public static Map<String, VariantSet> concatVariants(Map<String, VariantSet> variantSet1,
Map<String, VariantSet> variantSet2) {
Map<String, VariantSet> result = new HashMap<>();
if (!isEmpty(variantSet1) && isEmpty(variantSet2)) {
result.putAll(variantSet1);
} else if (isEmpty(variantSet1) && !isEmpty(variantSet2)) {
result.putAll(variantSet2);
} else if (!isEmpty(variantSet1) && !isEmpty(variantSet2)) {
Set<String> keySet = new HashSet<>();
keySet.addAll(variantSet1.keySet());
keySet.addAll(variantSet2.keySet());
for (String variantType : keySet) {
VariantSet variants1 = variantSet1.get(variantType);
VariantSet variants2 = variantSet2.get(variantType);
Set<String> variants = new HashSet<>();
String defaultVariant = null;
if (variants1 != null && variants2 != null && !variants1.hasSameDefaultVariant(variants2)) {
throw new BundlingProcessException("For the variant type '" + variantType
+ "', the variant sets defined in your bundles don't have the same default value.");
}
if (variants1 != null) {
variants.addAll(variants1);
defaultVariant = variants1.getDefaultVariant();
}
if (variants2 != null) {
variants.addAll(variants2);
defaultVariant = variants2.getDefaultVariant();
}
VariantSet variantSet = new VariantSet(variantType, defaultVariant, variants);
result.put(variantType, variantSet);
}
}
return result;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"concatVariants",
"(",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"variantSet1",
",",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"variantSet2",
")",
"{",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"result",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"!",
"isEmpty",
"(",
"variantSet1",
")",
"&&",
"isEmpty",
"(",
"variantSet2",
")",
")",
"{",
"result",
".",
"putAll",
"(",
"variantSet1",
")",
";",
"}",
"else",
"if",
"(",
"isEmpty",
"(",
"variantSet1",
")",
"&&",
"!",
"isEmpty",
"(",
"variantSet2",
")",
")",
"{",
"result",
".",
"putAll",
"(",
"variantSet2",
")",
";",
"}",
"else",
"if",
"(",
"!",
"isEmpty",
"(",
"variantSet1",
")",
"&&",
"!",
"isEmpty",
"(",
"variantSet2",
")",
")",
"{",
"Set",
"<",
"String",
">",
"keySet",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"keySet",
".",
"addAll",
"(",
"variantSet1",
".",
"keySet",
"(",
")",
")",
";",
"keySet",
".",
"addAll",
"(",
"variantSet2",
".",
"keySet",
"(",
")",
")",
";",
"for",
"(",
"String",
"variantType",
":",
"keySet",
")",
"{",
"VariantSet",
"variants1",
"=",
"variantSet1",
".",
"get",
"(",
"variantType",
")",
";",
"VariantSet",
"variants2",
"=",
"variantSet2",
".",
"get",
"(",
"variantType",
")",
";",
"Set",
"<",
"String",
">",
"variants",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"String",
"defaultVariant",
"=",
"null",
";",
"if",
"(",
"variants1",
"!=",
"null",
"&&",
"variants2",
"!=",
"null",
"&&",
"!",
"variants1",
".",
"hasSameDefaultVariant",
"(",
"variants2",
")",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"For the variant type '\"",
"+",
"variantType",
"+",
"\"', the variant sets defined in your bundles don't have the same default value.\"",
")",
";",
"}",
"if",
"(",
"variants1",
"!=",
"null",
")",
"{",
"variants",
".",
"addAll",
"(",
"variants1",
")",
";",
"defaultVariant",
"=",
"variants1",
".",
"getDefaultVariant",
"(",
")",
";",
"}",
"if",
"(",
"variants2",
"!=",
"null",
")",
"{",
"variants",
".",
"addAll",
"(",
"variants2",
")",
";",
"defaultVariant",
"=",
"variants2",
".",
"getDefaultVariant",
"(",
")",
";",
"}",
"VariantSet",
"variantSet",
"=",
"new",
"VariantSet",
"(",
"variantType",
",",
"defaultVariant",
",",
"variants",
")",
";",
"result",
".",
"put",
"(",
"variantType",
",",
"variantSet",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Concatenates 2 map of variant sets.
@param variantSet1
the first map
@param variantSet2
the second map
@return the concatenated variant map
|
[
"Concatenates",
"2",
"map",
"of",
"variant",
"sets",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/variant/VariantUtils.java#L293-L332
|
7,289 |
j-a-w-r/jawr-main-repo
|
jawr-tools/jawr-ant/src/main/java/net/jawr/ant/BundleTask.java
|
BundleTask.cleanDirectory
|
public void cleanDirectory( final File directory )
throws IOException
{
if ( !directory.exists() )
{
final String message = directory + " does not exist";
throw new IllegalArgumentException( message );
}
if ( !directory.isDirectory() )
{
final String message = directory + " is not a directory";
throw new IllegalArgumentException( message );
}
Delete deleteTask = new Delete();
deleteTask.setProject(getProject());
deleteTask.setDir(directory);
deleteTask.execute();
if(!directory.exists()){
directory.mkdirs();
}
}
|
java
|
public void cleanDirectory( final File directory )
throws IOException
{
if ( !directory.exists() )
{
final String message = directory + " does not exist";
throw new IllegalArgumentException( message );
}
if ( !directory.isDirectory() )
{
final String message = directory + " is not a directory";
throw new IllegalArgumentException( message );
}
Delete deleteTask = new Delete();
deleteTask.setProject(getProject());
deleteTask.setDir(directory);
deleteTask.execute();
if(!directory.exists()){
directory.mkdirs();
}
}
|
[
"public",
"void",
"cleanDirectory",
"(",
"final",
"File",
"directory",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"directory",
".",
"exists",
"(",
")",
")",
"{",
"final",
"String",
"message",
"=",
"directory",
"+",
"\" does not exist\"",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
")",
";",
"}",
"if",
"(",
"!",
"directory",
".",
"isDirectory",
"(",
")",
")",
"{",
"final",
"String",
"message",
"=",
"directory",
"+",
"\" is not a directory\"",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
")",
";",
"}",
"Delete",
"deleteTask",
"=",
"new",
"Delete",
"(",
")",
";",
"deleteTask",
".",
"setProject",
"(",
"getProject",
"(",
")",
")",
";",
"deleteTask",
".",
"setDir",
"(",
"directory",
")",
";",
"deleteTask",
".",
"execute",
"(",
")",
";",
"if",
"(",
"!",
"directory",
".",
"exists",
"(",
")",
")",
"{",
"directory",
".",
"mkdirs",
"(",
")",
";",
"}",
"}"
] |
Clean a directory without deleting it.
|
[
"Clean",
"a",
"directory",
"without",
"deleting",
"it",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-ant/src/main/java/net/jawr/ant/BundleTask.java#L204-L227
|
7,290 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java
|
ClosureGlobalPostProcessor.getClosureCompilerArgs
|
private String[] getClosureCompilerArgs(GlobalPostProcessingContext ctx, List<JoinableResourceBundle> tmpBundles,
Map<String, String> resultBundlePathMapping) {
List<String> args = new ArrayList<>();
JawrConfig config = ctx.getJawrConfig();
List<JoinableResourceBundle> bundles = new ArrayList<>(tmpBundles);
// Handle All closure parameters defined in Jawr config
initCompilerClosureArgumentsFromConfig(args, config);
String excludedBundlesProp = config.getProperty(JAWR_JS_CLOSURE_BUNDLES_EXCLUDED, "");
List<String> excludedBundles = Arrays
.asList(excludedBundlesProp.replaceAll(" ", "").split(MODULE_DEPENDENCIES_SEPARATOR));
// handle user specified modules
Map<String, JoinableResourceBundle> bundleMap = new HashMap<>();
for (JoinableResourceBundle bundle : bundles) {
if (!excludedBundles.contains(bundle.getName())) {
bundleMap.put(bundle.getName(), bundle);
}
}
String modules = config.getProperty(JAWR_JS_CLOSURE_MODULES);
List<String> depModulesArgs = new ArrayList<>();
List<String> globalBundleDependencies = getGlobalBundleDependencies(ctx, excludedBundles);
// Initialize the modules arguments
initModulesArgs(resultBundlePathMapping, args, bundles, bundleMap, modules, depModulesArgs,
globalBundleDependencies);
// handle the other bundles
for (JoinableResourceBundle bundle : bundles) {
if (!excludedBundles.contains(bundle.getName())) {
generateBundleModuleArgs(args, bundleMap, resultBundlePathMapping, bundle, globalBundleDependencies);
}
}
// Add dependency modules args after to conform to dependency definition
// of closure args
args.addAll(depModulesArgs);
if (LOGGER.isDebugEnabled()) {
StringBuilder strArg = new StringBuilder();
for (String arg : args) {
strArg.append(arg).append(" ");
}
LOGGER.debug("Closure Compiler Args : " + strArg.toString());
}
return args.toArray(new String[] {});
}
|
java
|
private String[] getClosureCompilerArgs(GlobalPostProcessingContext ctx, List<JoinableResourceBundle> tmpBundles,
Map<String, String> resultBundlePathMapping) {
List<String> args = new ArrayList<>();
JawrConfig config = ctx.getJawrConfig();
List<JoinableResourceBundle> bundles = new ArrayList<>(tmpBundles);
// Handle All closure parameters defined in Jawr config
initCompilerClosureArgumentsFromConfig(args, config);
String excludedBundlesProp = config.getProperty(JAWR_JS_CLOSURE_BUNDLES_EXCLUDED, "");
List<String> excludedBundles = Arrays
.asList(excludedBundlesProp.replaceAll(" ", "").split(MODULE_DEPENDENCIES_SEPARATOR));
// handle user specified modules
Map<String, JoinableResourceBundle> bundleMap = new HashMap<>();
for (JoinableResourceBundle bundle : bundles) {
if (!excludedBundles.contains(bundle.getName())) {
bundleMap.put(bundle.getName(), bundle);
}
}
String modules = config.getProperty(JAWR_JS_CLOSURE_MODULES);
List<String> depModulesArgs = new ArrayList<>();
List<String> globalBundleDependencies = getGlobalBundleDependencies(ctx, excludedBundles);
// Initialize the modules arguments
initModulesArgs(resultBundlePathMapping, args, bundles, bundleMap, modules, depModulesArgs,
globalBundleDependencies);
// handle the other bundles
for (JoinableResourceBundle bundle : bundles) {
if (!excludedBundles.contains(bundle.getName())) {
generateBundleModuleArgs(args, bundleMap, resultBundlePathMapping, bundle, globalBundleDependencies);
}
}
// Add dependency modules args after to conform to dependency definition
// of closure args
args.addAll(depModulesArgs);
if (LOGGER.isDebugEnabled()) {
StringBuilder strArg = new StringBuilder();
for (String arg : args) {
strArg.append(arg).append(" ");
}
LOGGER.debug("Closure Compiler Args : " + strArg.toString());
}
return args.toArray(new String[] {});
}
|
[
"private",
"String",
"[",
"]",
"getClosureCompilerArgs",
"(",
"GlobalPostProcessingContext",
"ctx",
",",
"List",
"<",
"JoinableResourceBundle",
">",
"tmpBundles",
",",
"Map",
"<",
"String",
",",
"String",
">",
"resultBundlePathMapping",
")",
"{",
"List",
"<",
"String",
">",
"args",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"JawrConfig",
"config",
"=",
"ctx",
".",
"getJawrConfig",
"(",
")",
";",
"List",
"<",
"JoinableResourceBundle",
">",
"bundles",
"=",
"new",
"ArrayList",
"<>",
"(",
"tmpBundles",
")",
";",
"// Handle All closure parameters defined in Jawr config",
"initCompilerClosureArgumentsFromConfig",
"(",
"args",
",",
"config",
")",
";",
"String",
"excludedBundlesProp",
"=",
"config",
".",
"getProperty",
"(",
"JAWR_JS_CLOSURE_BUNDLES_EXCLUDED",
",",
"\"\"",
")",
";",
"List",
"<",
"String",
">",
"excludedBundles",
"=",
"Arrays",
".",
"asList",
"(",
"excludedBundlesProp",
".",
"replaceAll",
"(",
"\" \"",
",",
"\"\"",
")",
".",
"split",
"(",
"MODULE_DEPENDENCIES_SEPARATOR",
")",
")",
";",
"// handle user specified modules",
"Map",
"<",
"String",
",",
"JoinableResourceBundle",
">",
"bundleMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"JoinableResourceBundle",
"bundle",
":",
"bundles",
")",
"{",
"if",
"(",
"!",
"excludedBundles",
".",
"contains",
"(",
"bundle",
".",
"getName",
"(",
")",
")",
")",
"{",
"bundleMap",
".",
"put",
"(",
"bundle",
".",
"getName",
"(",
")",
",",
"bundle",
")",
";",
"}",
"}",
"String",
"modules",
"=",
"config",
".",
"getProperty",
"(",
"JAWR_JS_CLOSURE_MODULES",
")",
";",
"List",
"<",
"String",
">",
"depModulesArgs",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"String",
">",
"globalBundleDependencies",
"=",
"getGlobalBundleDependencies",
"(",
"ctx",
",",
"excludedBundles",
")",
";",
"// Initialize the modules arguments",
"initModulesArgs",
"(",
"resultBundlePathMapping",
",",
"args",
",",
"bundles",
",",
"bundleMap",
",",
"modules",
",",
"depModulesArgs",
",",
"globalBundleDependencies",
")",
";",
"// handle the other bundles",
"for",
"(",
"JoinableResourceBundle",
"bundle",
":",
"bundles",
")",
"{",
"if",
"(",
"!",
"excludedBundles",
".",
"contains",
"(",
"bundle",
".",
"getName",
"(",
")",
")",
")",
"{",
"generateBundleModuleArgs",
"(",
"args",
",",
"bundleMap",
",",
"resultBundlePathMapping",
",",
"bundle",
",",
"globalBundleDependencies",
")",
";",
"}",
"}",
"// Add dependency modules args after to conform to dependency definition",
"// of closure args",
"args",
".",
"addAll",
"(",
"depModulesArgs",
")",
";",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"StringBuilder",
"strArg",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"String",
"arg",
":",
"args",
")",
"{",
"strArg",
".",
"append",
"(",
"arg",
")",
".",
"append",
"(",
"\" \"",
")",
";",
"}",
"LOGGER",
".",
"debug",
"(",
"\"Closure Compiler Args : \"",
"+",
"strArg",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"args",
".",
"toArray",
"(",
"new",
"String",
"[",
"]",
"{",
"}",
")",
";",
"}"
] |
Returns the closure compiler arguments
@param ctx
the global processing context
@param tmpBundles
the bundles
@param resultBundlePathMapping
the object which defines the mapping between the bundle name
and the bundle path
@return
|
[
"Returns",
"the",
"closure",
"compiler",
"arguments"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java#L244-L295
|
7,291 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java
|
ClosureGlobalPostProcessor.getGlobalBundleDependencies
|
private List<String> getGlobalBundleDependencies(GlobalPostProcessingContext ctx, List<String> excludedBundles) {
List<JoinableResourceBundle> globalBundles = getRsBundlesHandler(ctx).getGlobalBundles();
List<String> globalBundleDependencies = new ArrayList<>();
for (JoinableResourceBundle globalBundle : globalBundles) {
if (!excludedBundles.contains(globalBundle.getName())) {
globalBundleDependencies.add(globalBundle.getName());
}
}
return globalBundleDependencies;
}
|
java
|
private List<String> getGlobalBundleDependencies(GlobalPostProcessingContext ctx, List<String> excludedBundles) {
List<JoinableResourceBundle> globalBundles = getRsBundlesHandler(ctx).getGlobalBundles();
List<String> globalBundleDependencies = new ArrayList<>();
for (JoinableResourceBundle globalBundle : globalBundles) {
if (!excludedBundles.contains(globalBundle.getName())) {
globalBundleDependencies.add(globalBundle.getName());
}
}
return globalBundleDependencies;
}
|
[
"private",
"List",
"<",
"String",
">",
"getGlobalBundleDependencies",
"(",
"GlobalPostProcessingContext",
"ctx",
",",
"List",
"<",
"String",
">",
"excludedBundles",
")",
"{",
"List",
"<",
"JoinableResourceBundle",
">",
"globalBundles",
"=",
"getRsBundlesHandler",
"(",
"ctx",
")",
".",
"getGlobalBundles",
"(",
")",
";",
"List",
"<",
"String",
">",
"globalBundleDependencies",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"JoinableResourceBundle",
"globalBundle",
":",
"globalBundles",
")",
"{",
"if",
"(",
"!",
"excludedBundles",
".",
"contains",
"(",
"globalBundle",
".",
"getName",
"(",
")",
")",
")",
"{",
"globalBundleDependencies",
".",
"add",
"(",
"globalBundle",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"return",
"globalBundleDependencies",
";",
"}"
] |
Returns the global bundle dependencies
@param ctx
the context
@param excludedBundles
the excluded bundles
@return the global bundle dependencies
|
[
"Returns",
"the",
"global",
"bundle",
"dependencies"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java#L306-L315
|
7,292 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java
|
ClosureGlobalPostProcessor.initCompilerClosureArgumentsFromConfig
|
private void initCompilerClosureArgumentsFromConfig(List<String> args, JawrConfig config) {
Set<Entry<Object, Object>> entrySet = config.getConfigProperties().entrySet();
for (Entry<Object, Object> propEntry : entrySet) {
String key = (String) propEntry.getKey();
if (key.startsWith(JAWR_JS_CLOSURE_PREFIX) && !JAWR_JS_CLOSURE_SPECIFIC_PROPERTIES.contains(key)) {
String compilerArgName = key.substring(JAWR_JS_CLOSURE_PREFIX.length());
checkCompilerArgumentName(compilerArgName);
String compilerArgValue = (String) propEntry.getValue();
compilerArgValue = getCompilerArgValue(compilerArgName, compilerArgValue);
args.add(CLOSURE_ARGUMENT_NAME_PREFIX + compilerArgName);
args.add(propEntry.getValue().toString());
}
}
// Add default compilation level argument
if (!args.contains(COMPILATION_LEVEL_ARG)) {
args.add(COMPILATION_LEVEL_ARG);
args.add(WHITESPACE_ONLY_COMPILATION_LEVEL);
}
// Add default level warning argument if not defined
if (!args.contains(WARNING_LEVEL_ARG)) {
args.add(WARNING_LEVEL_ARG);
args.add(VERBOSE_WARNING_LEVEL);
}
}
|
java
|
private void initCompilerClosureArgumentsFromConfig(List<String> args, JawrConfig config) {
Set<Entry<Object, Object>> entrySet = config.getConfigProperties().entrySet();
for (Entry<Object, Object> propEntry : entrySet) {
String key = (String) propEntry.getKey();
if (key.startsWith(JAWR_JS_CLOSURE_PREFIX) && !JAWR_JS_CLOSURE_SPECIFIC_PROPERTIES.contains(key)) {
String compilerArgName = key.substring(JAWR_JS_CLOSURE_PREFIX.length());
checkCompilerArgumentName(compilerArgName);
String compilerArgValue = (String) propEntry.getValue();
compilerArgValue = getCompilerArgValue(compilerArgName, compilerArgValue);
args.add(CLOSURE_ARGUMENT_NAME_PREFIX + compilerArgName);
args.add(propEntry.getValue().toString());
}
}
// Add default compilation level argument
if (!args.contains(COMPILATION_LEVEL_ARG)) {
args.add(COMPILATION_LEVEL_ARG);
args.add(WHITESPACE_ONLY_COMPILATION_LEVEL);
}
// Add default level warning argument if not defined
if (!args.contains(WARNING_LEVEL_ARG)) {
args.add(WARNING_LEVEL_ARG);
args.add(VERBOSE_WARNING_LEVEL);
}
}
|
[
"private",
"void",
"initCompilerClosureArgumentsFromConfig",
"(",
"List",
"<",
"String",
">",
"args",
",",
"JawrConfig",
"config",
")",
"{",
"Set",
"<",
"Entry",
"<",
"Object",
",",
"Object",
">",
">",
"entrySet",
"=",
"config",
".",
"getConfigProperties",
"(",
")",
".",
"entrySet",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"Object",
",",
"Object",
">",
"propEntry",
":",
"entrySet",
")",
"{",
"String",
"key",
"=",
"(",
"String",
")",
"propEntry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"key",
".",
"startsWith",
"(",
"JAWR_JS_CLOSURE_PREFIX",
")",
"&&",
"!",
"JAWR_JS_CLOSURE_SPECIFIC_PROPERTIES",
".",
"contains",
"(",
"key",
")",
")",
"{",
"String",
"compilerArgName",
"=",
"key",
".",
"substring",
"(",
"JAWR_JS_CLOSURE_PREFIX",
".",
"length",
"(",
")",
")",
";",
"checkCompilerArgumentName",
"(",
"compilerArgName",
")",
";",
"String",
"compilerArgValue",
"=",
"(",
"String",
")",
"propEntry",
".",
"getValue",
"(",
")",
";",
"compilerArgValue",
"=",
"getCompilerArgValue",
"(",
"compilerArgName",
",",
"compilerArgValue",
")",
";",
"args",
".",
"add",
"(",
"CLOSURE_ARGUMENT_NAME_PREFIX",
"+",
"compilerArgName",
")",
";",
"args",
".",
"add",
"(",
"propEntry",
".",
"getValue",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"// Add default compilation level argument",
"if",
"(",
"!",
"args",
".",
"contains",
"(",
"COMPILATION_LEVEL_ARG",
")",
")",
"{",
"args",
".",
"add",
"(",
"COMPILATION_LEVEL_ARG",
")",
";",
"args",
".",
"add",
"(",
"WHITESPACE_ONLY_COMPILATION_LEVEL",
")",
";",
"}",
"// Add default level warning argument if not defined",
"if",
"(",
"!",
"args",
".",
"contains",
"(",
"WARNING_LEVEL_ARG",
")",
")",
"{",
"args",
".",
"add",
"(",
"WARNING_LEVEL_ARG",
")",
";",
"args",
".",
"add",
"(",
"VERBOSE_WARNING_LEVEL",
")",
";",
"}",
"}"
] |
Initialize the closure argument from the Jawr config
@param args
the arguments
@param config
the Jawr config
|
[
"Initialize",
"the",
"closure",
"argument",
"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/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java#L325-L351
|
7,293 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java
|
ClosureGlobalPostProcessor.getCompilerArgValue
|
private String getCompilerArgValue(String compilerArgName, String compilerArgValue) {
if (compilerArgName.equals(COMPILATION_LEVEL)) {
if (!ADVANCED_OPTIMIZATIONS_COMPILATION_LEVEL.equalsIgnoreCase(compilerArgValue)
&& !WHITESPACE_ONLY_COMPILATION_LEVEL.equalsIgnoreCase(compilerArgValue)
&& !SIMPLE_OPTIMIZATIONS_COMPILATION_LEVEL.equalsIgnoreCase(compilerArgValue)) {
if (StringUtils.isNotEmpty(compilerArgValue)) {
LOGGER.debug("Closure compilation level defined in config '" + compilerArgValue
+ "' is not part of the available "
+ "ones [WHITESPACE_ONLY, SIMPLE_OPTIMIZATIONS, ADVANCED_OPTIMIZATIONS");
}
compilerArgValue = WHITESPACE_ONLY_COMPILATION_LEVEL;
}
LOGGER.debug("Closure compilation level used : " + compilerArgValue);
}
return compilerArgValue;
}
|
java
|
private String getCompilerArgValue(String compilerArgName, String compilerArgValue) {
if (compilerArgName.equals(COMPILATION_LEVEL)) {
if (!ADVANCED_OPTIMIZATIONS_COMPILATION_LEVEL.equalsIgnoreCase(compilerArgValue)
&& !WHITESPACE_ONLY_COMPILATION_LEVEL.equalsIgnoreCase(compilerArgValue)
&& !SIMPLE_OPTIMIZATIONS_COMPILATION_LEVEL.equalsIgnoreCase(compilerArgValue)) {
if (StringUtils.isNotEmpty(compilerArgValue)) {
LOGGER.debug("Closure compilation level defined in config '" + compilerArgValue
+ "' is not part of the available "
+ "ones [WHITESPACE_ONLY, SIMPLE_OPTIMIZATIONS, ADVANCED_OPTIMIZATIONS");
}
compilerArgValue = WHITESPACE_ONLY_COMPILATION_LEVEL;
}
LOGGER.debug("Closure compilation level used : " + compilerArgValue);
}
return compilerArgValue;
}
|
[
"private",
"String",
"getCompilerArgValue",
"(",
"String",
"compilerArgName",
",",
"String",
"compilerArgValue",
")",
"{",
"if",
"(",
"compilerArgName",
".",
"equals",
"(",
"COMPILATION_LEVEL",
")",
")",
"{",
"if",
"(",
"!",
"ADVANCED_OPTIMIZATIONS_COMPILATION_LEVEL",
".",
"equalsIgnoreCase",
"(",
"compilerArgValue",
")",
"&&",
"!",
"WHITESPACE_ONLY_COMPILATION_LEVEL",
".",
"equalsIgnoreCase",
"(",
"compilerArgValue",
")",
"&&",
"!",
"SIMPLE_OPTIMIZATIONS_COMPILATION_LEVEL",
".",
"equalsIgnoreCase",
"(",
"compilerArgValue",
")",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"compilerArgValue",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Closure compilation level defined in config '\"",
"+",
"compilerArgValue",
"+",
"\"' is not part of the available \"",
"+",
"\"ones [WHITESPACE_ONLY, SIMPLE_OPTIMIZATIONS, ADVANCED_OPTIMIZATIONS\"",
")",
";",
"}",
"compilerArgValue",
"=",
"WHITESPACE_ONLY_COMPILATION_LEVEL",
";",
"}",
"LOGGER",
".",
"debug",
"(",
"\"Closure compilation level used : \"",
"+",
"compilerArgValue",
")",
";",
"}",
"return",
"compilerArgValue",
";",
"}"
] |
Returns the compiler argument value
@param compilerArgName
the compiler argument name
@param compilerArgValue
the compiler argument name
@return the compiler argument value
|
[
"Returns",
"the",
"compiler",
"argument",
"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/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java#L436-L454
|
7,294 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java
|
ClosureGlobalPostProcessor.generateBundleModuleArgs
|
private void generateBundleModuleArgs(List<String> args, Map<String, JoinableResourceBundle> bundleMap,
Map<String, String> resultBundleMapping, JoinableResourceBundle bundle, List<String> dependencies) {
Set<String> bundleDependencies = getClosureModuleDependencies(bundle, dependencies);
// Generate a module for each bundle variant
Map<String, VariantSet> bundleVariants = bundle.getVariants();
List<Map<String, String>> variants = VariantUtils.getAllVariants(bundleVariants);
// Add default variant
if (variants.isEmpty()) {
variants.add(null);
}
for (Map<String, String> variant : variants) {
String jsFile = VariantUtils.getVariantBundleName(bundle.getId(), variant, false);
String moduleName = VariantUtils.getVariantBundleName(bundle.getName(), variant, false);
resultBundleMapping.put(moduleName, jsFile);
StringBuilder moduleArg = new StringBuilder();
moduleArg.append(moduleName + ":1:");
for (String dep : bundleDependencies) {
// Check module dependencies
checkBundleName(dep, bundleMap);
JoinableResourceBundle dependencyBundle = bundleMap.get(dep);
// Generate a module for each bundle variant
List<String> depVariantKeys = VariantUtils
.getAllVariantKeysFromFixedVariants(dependencyBundle.getVariants(), variant);
for (String depVariantKey : depVariantKeys) {
String depBundleName = VariantUtils.getVariantBundleName(dep, depVariantKey, false);
moduleArg.append(depBundleName);
moduleArg.append(MODULE_DEPENDENCIES_SEPARATOR);
}
}
moduleArg.append(JAWR_ROOT_MODULE_NAME);
addModuleArg(jsFile, moduleName, args, moduleArg);
}
}
|
java
|
private void generateBundleModuleArgs(List<String> args, Map<String, JoinableResourceBundle> bundleMap,
Map<String, String> resultBundleMapping, JoinableResourceBundle bundle, List<String> dependencies) {
Set<String> bundleDependencies = getClosureModuleDependencies(bundle, dependencies);
// Generate a module for each bundle variant
Map<String, VariantSet> bundleVariants = bundle.getVariants();
List<Map<String, String>> variants = VariantUtils.getAllVariants(bundleVariants);
// Add default variant
if (variants.isEmpty()) {
variants.add(null);
}
for (Map<String, String> variant : variants) {
String jsFile = VariantUtils.getVariantBundleName(bundle.getId(), variant, false);
String moduleName = VariantUtils.getVariantBundleName(bundle.getName(), variant, false);
resultBundleMapping.put(moduleName, jsFile);
StringBuilder moduleArg = new StringBuilder();
moduleArg.append(moduleName + ":1:");
for (String dep : bundleDependencies) {
// Check module dependencies
checkBundleName(dep, bundleMap);
JoinableResourceBundle dependencyBundle = bundleMap.get(dep);
// Generate a module for each bundle variant
List<String> depVariantKeys = VariantUtils
.getAllVariantKeysFromFixedVariants(dependencyBundle.getVariants(), variant);
for (String depVariantKey : depVariantKeys) {
String depBundleName = VariantUtils.getVariantBundleName(dep, depVariantKey, false);
moduleArg.append(depBundleName);
moduleArg.append(MODULE_DEPENDENCIES_SEPARATOR);
}
}
moduleArg.append(JAWR_ROOT_MODULE_NAME);
addModuleArg(jsFile, moduleName, args, moduleArg);
}
}
|
[
"private",
"void",
"generateBundleModuleArgs",
"(",
"List",
"<",
"String",
">",
"args",
",",
"Map",
"<",
"String",
",",
"JoinableResourceBundle",
">",
"bundleMap",
",",
"Map",
"<",
"String",
",",
"String",
">",
"resultBundleMapping",
",",
"JoinableResourceBundle",
"bundle",
",",
"List",
"<",
"String",
">",
"dependencies",
")",
"{",
"Set",
"<",
"String",
">",
"bundleDependencies",
"=",
"getClosureModuleDependencies",
"(",
"bundle",
",",
"dependencies",
")",
";",
"// Generate a module for each bundle variant",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"bundleVariants",
"=",
"bundle",
".",
"getVariants",
"(",
")",
";",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"variants",
"=",
"VariantUtils",
".",
"getAllVariants",
"(",
"bundleVariants",
")",
";",
"// Add default variant",
"if",
"(",
"variants",
".",
"isEmpty",
"(",
")",
")",
"{",
"variants",
".",
"add",
"(",
"null",
")",
";",
"}",
"for",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"variant",
":",
"variants",
")",
"{",
"String",
"jsFile",
"=",
"VariantUtils",
".",
"getVariantBundleName",
"(",
"bundle",
".",
"getId",
"(",
")",
",",
"variant",
",",
"false",
")",
";",
"String",
"moduleName",
"=",
"VariantUtils",
".",
"getVariantBundleName",
"(",
"bundle",
".",
"getName",
"(",
")",
",",
"variant",
",",
"false",
")",
";",
"resultBundleMapping",
".",
"put",
"(",
"moduleName",
",",
"jsFile",
")",
";",
"StringBuilder",
"moduleArg",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"moduleArg",
".",
"append",
"(",
"moduleName",
"+",
"\":1:\"",
")",
";",
"for",
"(",
"String",
"dep",
":",
"bundleDependencies",
")",
"{",
"// Check module dependencies",
"checkBundleName",
"(",
"dep",
",",
"bundleMap",
")",
";",
"JoinableResourceBundle",
"dependencyBundle",
"=",
"bundleMap",
".",
"get",
"(",
"dep",
")",
";",
"// Generate a module for each bundle variant",
"List",
"<",
"String",
">",
"depVariantKeys",
"=",
"VariantUtils",
".",
"getAllVariantKeysFromFixedVariants",
"(",
"dependencyBundle",
".",
"getVariants",
"(",
")",
",",
"variant",
")",
";",
"for",
"(",
"String",
"depVariantKey",
":",
"depVariantKeys",
")",
"{",
"String",
"depBundleName",
"=",
"VariantUtils",
".",
"getVariantBundleName",
"(",
"dep",
",",
"depVariantKey",
",",
"false",
")",
";",
"moduleArg",
".",
"append",
"(",
"depBundleName",
")",
";",
"moduleArg",
".",
"append",
"(",
"MODULE_DEPENDENCIES_SEPARATOR",
")",
";",
"}",
"}",
"moduleArg",
".",
"append",
"(",
"JAWR_ROOT_MODULE_NAME",
")",
";",
"addModuleArg",
"(",
"jsFile",
",",
"moduleName",
",",
"args",
",",
"moduleArg",
")",
";",
"}",
"}"
] |
Generates the bundle module arguments for the closure compiler
@param args
the current list of arguments
@param bundleMap
the bundle map
@param resultBundleMapping
the result bundle mapping
@param bundle
the current bundle
@param dependencies
the dependencies
|
[
"Generates",
"the",
"bundle",
"module",
"arguments",
"for",
"the",
"closure",
"compiler"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java#L470-L512
|
7,295 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java
|
ClosureGlobalPostProcessor.addModuleArg
|
protected void addModuleArg(String jsFile, String moduleName, List<String> args, StringBuilder moduleArg) {
int argIdx = 0;
for (Iterator<String> iterArg = args.iterator(); iterArg.hasNext(); argIdx++) {
String arg = iterArg.next();
if (arg.equals(JS_ARG)) {
iterArg.next();
arg = iterArg.next();
argIdx += 2;
}
if (arg.equals(MODULE_ARG)) {
arg = iterArg.next();
argIdx++;
Matcher matcher = MODULE_ARG_PATTERN.matcher(arg);
if (matcher.find()) {
String dep = matcher.group(1);
if (dep != null) {
List<String> moduleDependencies = Arrays.asList(dep.split(MODULE_DEPENDENCIES_SEPARATOR));
if (moduleDependencies.contains(moduleName)) {
break;
}
}
} else {
throw new BundlingProcessException(
"There were an error in the generation of the module dependencies.");
}
}
}
args.add(argIdx++, JS_ARG);
args.add(argIdx++, jsFile);
args.add(argIdx++, MODULE_ARG);
args.add(argIdx++, moduleArg.toString());
}
|
java
|
protected void addModuleArg(String jsFile, String moduleName, List<String> args, StringBuilder moduleArg) {
int argIdx = 0;
for (Iterator<String> iterArg = args.iterator(); iterArg.hasNext(); argIdx++) {
String arg = iterArg.next();
if (arg.equals(JS_ARG)) {
iterArg.next();
arg = iterArg.next();
argIdx += 2;
}
if (arg.equals(MODULE_ARG)) {
arg = iterArg.next();
argIdx++;
Matcher matcher = MODULE_ARG_PATTERN.matcher(arg);
if (matcher.find()) {
String dep = matcher.group(1);
if (dep != null) {
List<String> moduleDependencies = Arrays.asList(dep.split(MODULE_DEPENDENCIES_SEPARATOR));
if (moduleDependencies.contains(moduleName)) {
break;
}
}
} else {
throw new BundlingProcessException(
"There were an error in the generation of the module dependencies.");
}
}
}
args.add(argIdx++, JS_ARG);
args.add(argIdx++, jsFile);
args.add(argIdx++, MODULE_ARG);
args.add(argIdx++, moduleArg.toString());
}
|
[
"protected",
"void",
"addModuleArg",
"(",
"String",
"jsFile",
",",
"String",
"moduleName",
",",
"List",
"<",
"String",
">",
"args",
",",
"StringBuilder",
"moduleArg",
")",
"{",
"int",
"argIdx",
"=",
"0",
";",
"for",
"(",
"Iterator",
"<",
"String",
">",
"iterArg",
"=",
"args",
".",
"iterator",
"(",
")",
";",
"iterArg",
".",
"hasNext",
"(",
")",
";",
"argIdx",
"++",
")",
"{",
"String",
"arg",
"=",
"iterArg",
".",
"next",
"(",
")",
";",
"if",
"(",
"arg",
".",
"equals",
"(",
"JS_ARG",
")",
")",
"{",
"iterArg",
".",
"next",
"(",
")",
";",
"arg",
"=",
"iterArg",
".",
"next",
"(",
")",
";",
"argIdx",
"+=",
"2",
";",
"}",
"if",
"(",
"arg",
".",
"equals",
"(",
"MODULE_ARG",
")",
")",
"{",
"arg",
"=",
"iterArg",
".",
"next",
"(",
")",
";",
"argIdx",
"++",
";",
"Matcher",
"matcher",
"=",
"MODULE_ARG_PATTERN",
".",
"matcher",
"(",
"arg",
")",
";",
"if",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"String",
"dep",
"=",
"matcher",
".",
"group",
"(",
"1",
")",
";",
"if",
"(",
"dep",
"!=",
"null",
")",
"{",
"List",
"<",
"String",
">",
"moduleDependencies",
"=",
"Arrays",
".",
"asList",
"(",
"dep",
".",
"split",
"(",
"MODULE_DEPENDENCIES_SEPARATOR",
")",
")",
";",
"if",
"(",
"moduleDependencies",
".",
"contains",
"(",
"moduleName",
")",
")",
"{",
"break",
";",
"}",
"}",
"}",
"else",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"There were an error in the generation of the module dependencies.\"",
")",
";",
"}",
"}",
"}",
"args",
".",
"add",
"(",
"argIdx",
"++",
",",
"JS_ARG",
")",
";",
"args",
".",
"add",
"(",
"argIdx",
"++",
",",
"jsFile",
")",
";",
"args",
".",
"add",
"(",
"argIdx",
"++",
",",
"MODULE_ARG",
")",
";",
"args",
".",
"add",
"(",
"argIdx",
"++",
",",
"moduleArg",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Adds the module argument taking in account the module dependencies
@param jsFile
the bundle js file
@param moduleName
the module name
@param args
the list of arguments to update
@param moduleArg
the module argument to add
|
[
"Adds",
"the",
"module",
"argument",
"taking",
"in",
"account",
"the",
"module",
"dependencies"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java#L526-L558
|
7,296 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java
|
ClosureGlobalPostProcessor.getClosureModuleDependencies
|
private Set<String> getClosureModuleDependencies(JoinableResourceBundle bundle, List<String> dependencies) {
Set<String> bundleDependencies = new HashSet<>();
if (bundle.getDependencies() != null) {
for (JoinableResourceBundle depBundle : bundle.getDependencies()) {
bundleDependencies.add(depBundle.getName());
}
}
for (String depBundleName : dependencies) {
if (bundle.getInclusionPattern().isGlobal() && depBundleName.equals(bundle.getName())) {
break;
} else {
bundleDependencies.add(depBundleName);
}
}
return bundleDependencies;
}
|
java
|
private Set<String> getClosureModuleDependencies(JoinableResourceBundle bundle, List<String> dependencies) {
Set<String> bundleDependencies = new HashSet<>();
if (bundle.getDependencies() != null) {
for (JoinableResourceBundle depBundle : bundle.getDependencies()) {
bundleDependencies.add(depBundle.getName());
}
}
for (String depBundleName : dependencies) {
if (bundle.getInclusionPattern().isGlobal() && depBundleName.equals(bundle.getName())) {
break;
} else {
bundleDependencies.add(depBundleName);
}
}
return bundleDependencies;
}
|
[
"private",
"Set",
"<",
"String",
">",
"getClosureModuleDependencies",
"(",
"JoinableResourceBundle",
"bundle",
",",
"List",
"<",
"String",
">",
"dependencies",
")",
"{",
"Set",
"<",
"String",
">",
"bundleDependencies",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"if",
"(",
"bundle",
".",
"getDependencies",
"(",
")",
"!=",
"null",
")",
"{",
"for",
"(",
"JoinableResourceBundle",
"depBundle",
":",
"bundle",
".",
"getDependencies",
"(",
")",
")",
"{",
"bundleDependencies",
".",
"add",
"(",
"depBundle",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"for",
"(",
"String",
"depBundleName",
":",
"dependencies",
")",
"{",
"if",
"(",
"bundle",
".",
"getInclusionPattern",
"(",
")",
".",
"isGlobal",
"(",
")",
"&&",
"depBundleName",
".",
"equals",
"(",
"bundle",
".",
"getName",
"(",
")",
")",
")",
"{",
"break",
";",
"}",
"else",
"{",
"bundleDependencies",
".",
"add",
"(",
"depBundleName",
")",
";",
"}",
"}",
"return",
"bundleDependencies",
";",
"}"
] |
Returns the module bundle dependency from the bundle dependency and the
declared dependencies
@param bundle
the bundle
@param dependencies
the declared dependencies
@return the list of the module dependency
|
[
"Returns",
"the",
"module",
"bundle",
"dependency",
"from",
"the",
"bundle",
"dependency",
"and",
"the",
"declared",
"dependencies"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java#L570-L587
|
7,297 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java
|
ClosureGlobalPostProcessor.checkBundleName
|
private void checkBundleName(String bundleName, Map<String, JoinableResourceBundle> bundleMap) {
if (!JAWR_ROOT_MODULE_NAME.equals(bundleName)) {
boolean moduleExist = bundleMap.get(bundleName) != null;
if (!moduleExist) {
throw new BundlingProcessException("The bundle name '" + bundleName
+ "' defined in 'jawr.js.closure.modules' is not defined in the configuration. Please check your configuration.");
}
}
}
|
java
|
private void checkBundleName(String bundleName, Map<String, JoinableResourceBundle> bundleMap) {
if (!JAWR_ROOT_MODULE_NAME.equals(bundleName)) {
boolean moduleExist = bundleMap.get(bundleName) != null;
if (!moduleExist) {
throw new BundlingProcessException("The bundle name '" + bundleName
+ "' defined in 'jawr.js.closure.modules' is not defined in the configuration. Please check your configuration.");
}
}
}
|
[
"private",
"void",
"checkBundleName",
"(",
"String",
"bundleName",
",",
"Map",
"<",
"String",
",",
"JoinableResourceBundle",
">",
"bundleMap",
")",
"{",
"if",
"(",
"!",
"JAWR_ROOT_MODULE_NAME",
".",
"equals",
"(",
"bundleName",
")",
")",
"{",
"boolean",
"moduleExist",
"=",
"bundleMap",
".",
"get",
"(",
"bundleName",
")",
"!=",
"null",
";",
"if",
"(",
"!",
"moduleExist",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"The bundle name '\"",
"+",
"bundleName",
"+",
"\"' defined in 'jawr.js.closure.modules' is not defined in the configuration. Please check your configuration.\"",
")",
";",
"}",
"}",
"}"
] |
Checks the bundle name
@param bundleName
the bundle name
@param bundleMap
the bundle map
|
[
"Checks",
"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/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java#L597-L605
|
7,298 |
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(InputStream input, Writer writer) throws IOException {
copy(new InputStreamReader(input), writer);
}
|
java
|
public static void copy(InputStream input, Writer writer) throws IOException {
copy(new InputStreamReader(input), writer);
}
|
[
"public",
"static",
"void",
"copy",
"(",
"InputStream",
"input",
",",
"Writer",
"writer",
")",
"throws",
"IOException",
"{",
"copy",
"(",
"new",
"InputStreamReader",
"(",
"input",
")",
",",
"writer",
")",
";",
"}"
] |
Writes all the contents of an InputStream to a Writer.
@param input
the input stream to read from
@param writer
the writer to write to
@throws java.io.IOException
if an IOExcption occurs
|
[
"Writes",
"all",
"the",
"contents",
"of",
"an",
"InputStream",
"to",
"a",
"Writer",
"."
] |
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#L104-L106
|
7,299 |
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(InputStream input, OutputStream output, boolean closeStreams) throws IOException {
try {
copy(input, output);
} finally {
if (closeStreams) {
close(input);
close(output);
}
}
}
|
java
|
public static void copy(InputStream input, OutputStream output, boolean closeStreams) throws IOException {
try {
copy(input, output);
} finally {
if (closeStreams) {
close(input);
close(output);
}
}
}
|
[
"public",
"static",
"void",
"copy",
"(",
"InputStream",
"input",
",",
"OutputStream",
"output",
",",
"boolean",
"closeStreams",
")",
"throws",
"IOException",
"{",
"try",
"{",
"copy",
"(",
"input",
",",
"output",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"closeStreams",
")",
"{",
"close",
"(",
"input",
")",
";",
"close",
"(",
"output",
")",
";",
"}",
"}",
"}"
] |
Writes all the contents of an InputStream to an OutputStream.
@param input
the input stream to read from
@param output
the output stream to write to
@param closeStreams
the flag indicating if the stream must be close at the end,
even if an exception occurs
@throws java.io.IOException
if an IOExcption occurs
|
[
"Writes",
"all",
"the",
"contents",
"of",
"an",
"InputStream",
"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#L121-L130
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.