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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
32,500 | grails/grails-core | grails-encoder/src/main/groovy/org/grails/encoder/DefaultEncodingStateRegistry.java | DefaultEncodingStateRegistry.isPreviousEncoderSafeOrEqual | public static boolean isPreviousEncoderSafeOrEqual(Encoder encoderToApply, Encoder previousEncoder) {
return previousEncoder == encoderToApply || !encoderToApply.isApplyToSafelyEncoded() && previousEncoder.isSafe() && encoderToApply.isSafe()
|| previousEncoder.getCodecIdentifier().isEquivalent(encoderToApply.getCodecIdentifier());
} | java | public static boolean isPreviousEncoderSafeOrEqual(Encoder encoderToApply, Encoder previousEncoder) {
return previousEncoder == encoderToApply || !encoderToApply.isApplyToSafelyEncoded() && previousEncoder.isSafe() && encoderToApply.isSafe()
|| previousEncoder.getCodecIdentifier().isEquivalent(encoderToApply.getCodecIdentifier());
} | [
"public",
"static",
"boolean",
"isPreviousEncoderSafeOrEqual",
"(",
"Encoder",
"encoderToApply",
",",
"Encoder",
"previousEncoder",
")",
"{",
"return",
"previousEncoder",
"==",
"encoderToApply",
"||",
"!",
"encoderToApply",
".",
"isApplyToSafelyEncoded",
"(",
")",
"&&",... | Checks if is previous encoder is already "safe", equal or equivalent
@param encoderToApply
the encoder to apply
@param previousEncoder
the previous encoder
@return true, if previous encoder is already "safe", equal or equivalent | [
"Checks",
"if",
"is",
"previous",
"encoder",
"is",
"already",
"safe",
"equal",
"or",
"equivalent"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-encoder/src/main/groovy/org/grails/encoder/DefaultEncodingStateRegistry.java#L125-L128 |
32,501 | grails/grails-core | grails-bootstrap/src/main/groovy/org/grails/io/support/GrailsResourceUtils.java | GrailsResourceUtils.isDomainClass | public static boolean isDomainClass(URL url) {
if (url == null) return false;
return KNOWN_DOMAIN_CLASSES.get(url.getFile());
} | java | public static boolean isDomainClass(URL url) {
if (url == null) return false;
return KNOWN_DOMAIN_CLASSES.get(url.getFile());
} | [
"public",
"static",
"boolean",
"isDomainClass",
"(",
"URL",
"url",
")",
"{",
"if",
"(",
"url",
"==",
"null",
")",
"return",
"false",
";",
"return",
"KNOWN_DOMAIN_CLASSES",
".",
"get",
"(",
"url",
".",
"getFile",
"(",
")",
")",
";",
"}"
] | Checks whether the file referenced by the given url is a domain class
@param url The URL instance
@return true if it is a domain class | [
"Checks",
"whether",
"the",
"file",
"referenced",
"by",
"the",
"given",
"url",
"is",
"a",
"domain",
"class"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-bootstrap/src/main/groovy/org/grails/io/support/GrailsResourceUtils.java#L217-L220 |
32,502 | grails/grails-core | grails-bootstrap/src/main/groovy/org/grails/io/support/GrailsResourceUtils.java | GrailsResourceUtils.getClassNameForClassFile | public static String getClassNameForClassFile(String rootDir, String path) {
path = path.replace("/", ".");
path = path.replace('\\', '.');
path = path.substring(0, path.length() - CLASS_EXTENSION.length());
if (rootDir != null) {
path = path.substring(rootDir.length());
}
return path;
} | java | public static String getClassNameForClassFile(String rootDir, String path) {
path = path.replace("/", ".");
path = path.replace('\\', '.');
path = path.substring(0, path.length() - CLASS_EXTENSION.length());
if (rootDir != null) {
path = path.substring(rootDir.length());
}
return path;
} | [
"public",
"static",
"String",
"getClassNameForClassFile",
"(",
"String",
"rootDir",
",",
"String",
"path",
")",
"{",
"path",
"=",
"path",
".",
"replace",
"(",
"\"/\"",
",",
"\".\"",
")",
";",
"path",
"=",
"path",
".",
"replace",
"(",
"'",
"'",
",",
"'"... | Returns the class name for a compiled class file
@param path The path to check
@return The class name or null if it doesn't exist | [
"Returns",
"the",
"class",
"name",
"for",
"a",
"compiled",
"class",
"file"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-bootstrap/src/main/groovy/org/grails/io/support/GrailsResourceUtils.java#L305-L313 |
32,503 | grails/grails-core | grails-bootstrap/src/main/groovy/org/grails/io/support/GrailsResourceUtils.java | GrailsResourceUtils.isGrailsResource | public static boolean isGrailsResource(Resource r) {
try {
String file = r.getURL().getFile();
return isGrailsPath(file) || file.endsWith("GrailsPlugin.groovy");
}
catch (IOException e) {
return false;
}
} | java | public static boolean isGrailsResource(Resource r) {
try {
String file = r.getURL().getFile();
return isGrailsPath(file) || file.endsWith("GrailsPlugin.groovy");
}
catch (IOException e) {
return false;
}
} | [
"public",
"static",
"boolean",
"isGrailsResource",
"(",
"Resource",
"r",
")",
"{",
"try",
"{",
"String",
"file",
"=",
"r",
".",
"getURL",
"(",
")",
".",
"getFile",
"(",
")",
";",
"return",
"isGrailsPath",
"(",
"file",
")",
"||",
"file",
".",
"endsWith"... | Checks whether the specific resources is a Grails resource. A Grails resource is a Groovy or Java class under the grails-app directory
@param r The resource to check
@return True if it is a Grails resource | [
"Checks",
"whether",
"the",
"specific",
"resources",
"is",
"a",
"Grails",
"resource",
".",
"A",
"Grails",
"resource",
"is",
"a",
"Groovy",
"or",
"Java",
"class",
"under",
"the",
"grails",
"-",
"app",
"directory"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-bootstrap/src/main/groovy/org/grails/io/support/GrailsResourceUtils.java#L714-L722 |
32,504 | grails/grails-core | grails-bootstrap/src/main/groovy/org/grails/io/support/GrailsResourceUtils.java | GrailsResourceUtils.getPathFromBaseDir | public static String getPathFromBaseDir(String path) {
int i = path.indexOf("grails-app/");
if(i > -1 ) {
return path.substring(i + 11);
}
else {
try {
File baseDir = BuildSettings.BASE_DIR;
String basePath = baseDir != null ? baseDir.getCanonicalPath() : null;
if(basePath != null) {
String canonicalPath = new File(path).getCanonicalPath();
return canonicalPath.substring(basePath.length()+1);
}
} catch (IOException e) {
// ignore
}
}
return null;
} | java | public static String getPathFromBaseDir(String path) {
int i = path.indexOf("grails-app/");
if(i > -1 ) {
return path.substring(i + 11);
}
else {
try {
File baseDir = BuildSettings.BASE_DIR;
String basePath = baseDir != null ? baseDir.getCanonicalPath() : null;
if(basePath != null) {
String canonicalPath = new File(path).getCanonicalPath();
return canonicalPath.substring(basePath.length()+1);
}
} catch (IOException e) {
// ignore
}
}
return null;
} | [
"public",
"static",
"String",
"getPathFromBaseDir",
"(",
"String",
"path",
")",
"{",
"int",
"i",
"=",
"path",
".",
"indexOf",
"(",
"\"grails-app/\"",
")",
";",
"if",
"(",
"i",
">",
"-",
"1",
")",
"{",
"return",
"path",
".",
"substring",
"(",
"i",
"+"... | Gets the path relative to the project base directory.
Input: /usr/joe/project/grails-app/conf/BootStrap.groovy
Output: grails-app/conf/BootStrap.groovy
@param path The path
@return The path relative to the base directory or null if it can't be established | [
"Gets",
"the",
"path",
"relative",
"to",
"the",
"project",
"base",
"directory",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-bootstrap/src/main/groovy/org/grails/io/support/GrailsResourceUtils.java#L861-L879 |
32,505 | grails/grails-core | grails-bootstrap/src/main/groovy/org/grails/io/support/GrailsResourceUtils.java | GrailsResourceUtils.appendPiecesForUri | public static String appendPiecesForUri(String... pieces) {
if (pieces==null || pieces.length==0) return "";
// join parts && strip double slashes
StringBuilder builder = new StringBuilder(16 * pieces.length);
char previous = 0;
for (int i=0; i < pieces.length;i++) {
String piece = pieces[i];
if (piece != null && piece.length() > 0) {
for (int j=0, maxlen=piece.length();j < maxlen;j++) {
char current=piece.charAt(j);
if (!(previous=='/' && current=='/')) {
builder.append(current);
previous = current;
}
}
if (i + 1 < pieces.length && previous != '/') {
builder.append('/');
previous='/';
}
}
}
return builder.toString();
} | java | public static String appendPiecesForUri(String... pieces) {
if (pieces==null || pieces.length==0) return "";
// join parts && strip double slashes
StringBuilder builder = new StringBuilder(16 * pieces.length);
char previous = 0;
for (int i=0; i < pieces.length;i++) {
String piece = pieces[i];
if (piece != null && piece.length() > 0) {
for (int j=0, maxlen=piece.length();j < maxlen;j++) {
char current=piece.charAt(j);
if (!(previous=='/' && current=='/')) {
builder.append(current);
previous = current;
}
}
if (i + 1 < pieces.length && previous != '/') {
builder.append('/');
previous='/';
}
}
}
return builder.toString();
} | [
"public",
"static",
"String",
"appendPiecesForUri",
"(",
"String",
"...",
"pieces",
")",
"{",
"if",
"(",
"pieces",
"==",
"null",
"||",
"pieces",
".",
"length",
"==",
"0",
")",
"return",
"\"\"",
";",
"// join parts && strip double slashes",
"StringBuilder",
"buil... | Takes any number of Strings and appends them into a uri, making
sure that a forward slash is inserted between each piece and
making sure that no duplicate slashes are in the uri
<pre>
Input: ""
Output: ""
Input: "/alpha", "/beta", "/gamma"
Output: "/alpha/beta/gamma
Input: "/alpha/, "/beta/", "/gamma"
Output: "/alpha/beta/gamma
Input: "/alpha/", "/beta/", "/gamma/"
Output "/alpha/beta/gamma/
Input: "alpha", "beta", "gamma"
Output: "alpha/beta/gamma
</pre>
@param pieces Strings to concatenate together into a uri
@return a uri | [
"Takes",
"any",
"number",
"of",
"Strings",
"and",
"appends",
"them",
"into",
"a",
"uri",
"making",
"sure",
"that",
"a",
"forward",
"slash",
"is",
"inserted",
"between",
"each",
"piece",
"and",
"making",
"sure",
"that",
"no",
"duplicate",
"slashes",
"are",
... | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-bootstrap/src/main/groovy/org/grails/io/support/GrailsResourceUtils.java#L926-L949 |
32,506 | grails/grails-core | grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java | DefaultGrailsApplication.initArtefactHandlers | @SuppressWarnings( "deprecation" )
protected void initArtefactHandlers() {
List<ArtefactHandler> additionalArtefactHandlers = GrailsFactoriesLoader.loadFactories(ArtefactHandler.class, getClassLoader());
for (ArtefactHandler artefactHandler : additionalArtefactHandlers) {
registerArtefactHandler(artefactHandler);
}
updateArtefactHandlers();
} | java | @SuppressWarnings( "deprecation" )
protected void initArtefactHandlers() {
List<ArtefactHandler> additionalArtefactHandlers = GrailsFactoriesLoader.loadFactories(ArtefactHandler.class, getClassLoader());
for (ArtefactHandler artefactHandler : additionalArtefactHandlers) {
registerArtefactHandler(artefactHandler);
}
updateArtefactHandlers();
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"protected",
"void",
"initArtefactHandlers",
"(",
")",
"{",
"List",
"<",
"ArtefactHandler",
">",
"additionalArtefactHandlers",
"=",
"GrailsFactoriesLoader",
".",
"loadFactories",
"(",
"ArtefactHandler",
".",
"class",... | Initialises the default set of ArtefactHandler instances.
@see grails.core.ArtefactHandler | [
"Initialises",
"the",
"default",
"set",
"of",
"ArtefactHandler",
"instances",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java#L216-L226 |
32,507 | grails/grails-core | grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java | DefaultGrailsApplication.configureLoadedClasses | protected void configureLoadedClasses(Class<?>[] classes) {
initArtefactHandlers();
artefactInfo.clear();
allArtefactClasses.clear();
allArtefactClassesArray = null;
allClasses = classes;
// first load the domain classes
log.debug("Going to inspect artefact classes.");
MetaClassRegistry metaClassRegistry = GroovySystem.getMetaClassRegistry();
for (final Class<?> theClass : classes) {
log.debug("Inspecting [" + theClass.getName() + "]");
// start fresh
metaClassRegistry.removeMetaClass(theClass);
if (allArtefactClasses.contains(theClass)) {
continue;
}
// check what kind of artefact it is and add to corrent data structure
for (ArtefactHandler artefactHandler : artefactHandlers) {
if (artefactHandler.isArtefact(theClass)) {
log.debug("Adding artefact " + theClass + " of kind " + artefactHandler.getType());
GrailsClass gclass = addArtefact(artefactHandler.getType(), theClass);
// Also maintain set of all artefacts (!= all classes loaded)
allArtefactClasses.add(theClass);
// Update per-artefact cache
DefaultArtefactInfo info = getArtefactInfo(artefactHandler.getType(), true);
info.addGrailsClass(gclass);
break;
}
}
}
refreshArtefactGrailsClassCaches();
allArtefactClassesArray = allArtefactClasses.toArray(new Class[allArtefactClasses.size()]);
// Tell all artefact handlers to init now we've worked out which classes are which artefacts
for (ArtefactHandler artefactHandler : artefactHandlers) {
initializeArtefacts(artefactHandler);
}
} | java | protected void configureLoadedClasses(Class<?>[] classes) {
initArtefactHandlers();
artefactInfo.clear();
allArtefactClasses.clear();
allArtefactClassesArray = null;
allClasses = classes;
// first load the domain classes
log.debug("Going to inspect artefact classes.");
MetaClassRegistry metaClassRegistry = GroovySystem.getMetaClassRegistry();
for (final Class<?> theClass : classes) {
log.debug("Inspecting [" + theClass.getName() + "]");
// start fresh
metaClassRegistry.removeMetaClass(theClass);
if (allArtefactClasses.contains(theClass)) {
continue;
}
// check what kind of artefact it is and add to corrent data structure
for (ArtefactHandler artefactHandler : artefactHandlers) {
if (artefactHandler.isArtefact(theClass)) {
log.debug("Adding artefact " + theClass + " of kind " + artefactHandler.getType());
GrailsClass gclass = addArtefact(artefactHandler.getType(), theClass);
// Also maintain set of all artefacts (!= all classes loaded)
allArtefactClasses.add(theClass);
// Update per-artefact cache
DefaultArtefactInfo info = getArtefactInfo(artefactHandler.getType(), true);
info.addGrailsClass(gclass);
break;
}
}
}
refreshArtefactGrailsClassCaches();
allArtefactClassesArray = allArtefactClasses.toArray(new Class[allArtefactClasses.size()]);
// Tell all artefact handlers to init now we've worked out which classes are which artefacts
for (ArtefactHandler artefactHandler : artefactHandlers) {
initializeArtefacts(artefactHandler);
}
} | [
"protected",
"void",
"configureLoadedClasses",
"(",
"Class",
"<",
"?",
">",
"[",
"]",
"classes",
")",
"{",
"initArtefactHandlers",
"(",
")",
";",
"artefactInfo",
".",
"clear",
"(",
")",
";",
"allArtefactClasses",
".",
"clear",
"(",
")",
";",
"allArtefactClas... | Configures the loaded classes within the GrailsApplication instance using the
registered ArtefactHandler instances.
@param classes The classes to configure | [
"Configures",
"the",
"loaded",
"classes",
"within",
"the",
"GrailsApplication",
"instance",
"using",
"the",
"registered",
"ArtefactHandler",
"instances",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java#L254-L299 |
32,508 | grails/grails-core | grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java | DefaultGrailsApplication.getArtefactCount | protected int getArtefactCount(String artefactType) {
ArtefactInfo info = getArtefactInfo(artefactType);
return info == null ? 0 : info.getClasses().length;
} | java | protected int getArtefactCount(String artefactType) {
ArtefactInfo info = getArtefactInfo(artefactType);
return info == null ? 0 : info.getClasses().length;
} | [
"protected",
"int",
"getArtefactCount",
"(",
"String",
"artefactType",
")",
"{",
"ArtefactInfo",
"info",
"=",
"getArtefactInfo",
"(",
"artefactType",
")",
";",
"return",
"info",
"==",
"null",
"?",
"0",
":",
"info",
".",
"getClasses",
"(",
")",
".",
"length",... | Retrieves the number of artefacts registered for the given artefactType as defined by the ArtefactHandler.
@param artefactType The type of the artefact as defined by the ArtefactHandler
@return The number of registered artefacts | [
"Retrieves",
"the",
"number",
"of",
"artefacts",
"registered",
"for",
"the",
"given",
"artefactType",
"as",
"defined",
"by",
"the",
"ArtefactHandler",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java#L342-L345 |
32,509 | grails/grails-core | grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java | DefaultGrailsApplication.getClassForName | public Class<?> getClassForName(String className) {
if (!StringUtils.hasText(className)) {
return null;
}
for (Class<?> c : allClasses) {
if (c.getName().equals(className)) {
return c;
}
}
return null;
} | java | public Class<?> getClassForName(String className) {
if (!StringUtils.hasText(className)) {
return null;
}
for (Class<?> c : allClasses) {
if (c.getName().equals(className)) {
return c;
}
}
return null;
} | [
"public",
"Class",
"<",
"?",
">",
"getClassForName",
"(",
"String",
"className",
")",
"{",
"if",
"(",
"!",
"StringUtils",
".",
"hasText",
"(",
"className",
")",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"Class",
"<",
"?",
">",
"c",
":",
"al... | Retrieves a class from the GrailsApplication for the given name.
@param className The class name
@return Either the Class instance or null if it doesn't exist | [
"Retrieves",
"a",
"class",
"from",
"the",
"GrailsApplication",
"for",
"the",
"given",
"name",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java#L362-L373 |
32,510 | grails/grails-core | grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java | DefaultGrailsApplication.isArtefact | public boolean isArtefact(@SuppressWarnings("rawtypes") Class theClazz) {
String className = theClazz.getName();
for (Class<?> artefactClass : allArtefactClasses) {
if (className.equals(artefactClass.getName())) {
return true;
}
}
return false;
} | java | public boolean isArtefact(@SuppressWarnings("rawtypes") Class theClazz) {
String className = theClazz.getName();
for (Class<?> artefactClass : allArtefactClasses) {
if (className.equals(artefactClass.getName())) {
return true;
}
}
return false;
} | [
"public",
"boolean",
"isArtefact",
"(",
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"Class",
"theClazz",
")",
"{",
"String",
"className",
"=",
"theClazz",
".",
"getName",
"(",
")",
";",
"for",
"(",
"Class",
"<",
"?",
">",
"artefactClass",
":",
"allA... | Returns true if the given class is an artefact identified by one of the registered
ArtefactHandler instances. Uses class name equality to handle class reloading
@param theClazz The class to check
@return true if it is an artefact | [
"Returns",
"true",
"if",
"the",
"given",
"class",
"is",
"an",
"artefact",
"identified",
"by",
"one",
"of",
"the",
"registered",
"ArtefactHandler",
"instances",
".",
"Uses",
"class",
"name",
"equality",
"to",
"handle",
"class",
"reloading"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java#L417-L425 |
32,511 | grails/grails-core | grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java | DefaultGrailsApplication.isArtefactOfType | public boolean isArtefactOfType(String artefactType, @SuppressWarnings("rawtypes") Class theClazz) {
ArtefactHandler handler = artefactHandlersByName.get(artefactType);
if (handler == null) {
throw new GrailsConfigurationException(
"Unable to locate arefact handler for specified type: " + artefactType);
}
return handler.isArtefact(theClazz);
} | java | public boolean isArtefactOfType(String artefactType, @SuppressWarnings("rawtypes") Class theClazz) {
ArtefactHandler handler = artefactHandlersByName.get(artefactType);
if (handler == null) {
throw new GrailsConfigurationException(
"Unable to locate arefact handler for specified type: " + artefactType);
}
return handler.isArtefact(theClazz);
} | [
"public",
"boolean",
"isArtefactOfType",
"(",
"String",
"artefactType",
",",
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"Class",
"theClazz",
")",
"{",
"ArtefactHandler",
"handler",
"=",
"artefactHandlersByName",
".",
"get",
"(",
"artefactType",
")",
";",
"... | Returns true if the specified class is of the given artefact type as defined by the ArtefactHandler.
@param artefactType The type of the artefact
@param theClazz The class
@return true if it is of the specified artefactType
@see grails.core.ArtefactHandler | [
"Returns",
"true",
"if",
"the",
"specified",
"class",
"is",
"of",
"the",
"given",
"artefact",
"type",
"as",
"defined",
"by",
"the",
"ArtefactHandler",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java#L435-L443 |
32,512 | grails/grails-core | grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java | DefaultGrailsApplication.getArtefact | public GrailsClass getArtefact(String artefactType, String name) {
ArtefactInfo info = getArtefactInfo(artefactType);
return info == null ? null : info.getGrailsClass(name);
} | java | public GrailsClass getArtefact(String artefactType, String name) {
ArtefactInfo info = getArtefactInfo(artefactType);
return info == null ? null : info.getGrailsClass(name);
} | [
"public",
"GrailsClass",
"getArtefact",
"(",
"String",
"artefactType",
",",
"String",
"name",
")",
"{",
"ArtefactInfo",
"info",
"=",
"getArtefactInfo",
"(",
"artefactType",
")",
";",
"return",
"info",
"==",
"null",
"?",
"null",
":",
"info",
".",
"getGrailsClas... | Retrieves an artefact for the given type and name.
@param artefactType The artefact type as defined by a registered ArtefactHandler
@param name The name of the class
@return A GrailsClass instance or null if none could be found for the given artefactType and name | [
"Retrieves",
"an",
"artefact",
"for",
"the",
"given",
"type",
"and",
"name",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java#L464-L467 |
32,513 | grails/grails-core | grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java | DefaultGrailsApplication.addArtefact | public GrailsClass addArtefact(String artefactType, GrailsClass artefactGrailsClass) {
ArtefactHandler handler = artefactHandlersByName.get(artefactType);
if (handler.isArtefactGrailsClass(artefactGrailsClass)) {
// Store the GrailsClass in cache
DefaultArtefactInfo info = getArtefactInfo(artefactType, true);
info.addGrailsClass(artefactGrailsClass);
info.updateComplete();
initializeArtefacts(artefactType);
return artefactGrailsClass;
}
throw new GrailsConfigurationException("Cannot add " + artefactType + " class [" +
artefactGrailsClass + "]. It is not a " + artefactType + "!");
} | java | public GrailsClass addArtefact(String artefactType, GrailsClass artefactGrailsClass) {
ArtefactHandler handler = artefactHandlersByName.get(artefactType);
if (handler.isArtefactGrailsClass(artefactGrailsClass)) {
// Store the GrailsClass in cache
DefaultArtefactInfo info = getArtefactInfo(artefactType, true);
info.addGrailsClass(artefactGrailsClass);
info.updateComplete();
initializeArtefacts(artefactType);
return artefactGrailsClass;
}
throw new GrailsConfigurationException("Cannot add " + artefactType + " class [" +
artefactGrailsClass + "]. It is not a " + artefactType + "!");
} | [
"public",
"GrailsClass",
"addArtefact",
"(",
"String",
"artefactType",
",",
"GrailsClass",
"artefactGrailsClass",
")",
"{",
"ArtefactHandler",
"handler",
"=",
"artefactHandlersByName",
".",
"get",
"(",
"artefactType",
")",
";",
"if",
"(",
"handler",
".",
"isArtefact... | Adds an artefact of the given type for the given GrailsClass.
@param artefactType The type of the artefact as defined by a ArtefactHandler instance
@param artefactGrailsClass A GrailsClass instance that matches the type defined by the ArtefactHandler
@return The GrailsClass if successful or null if it couldn't be added
@throws GrailsConfigurationException If the specified GrailsClass is not the same as the type defined by the ArtefactHandler
@see grails.core.ArtefactHandler | [
"Adds",
"an",
"artefact",
"of",
"the",
"given",
"type",
"for",
"the",
"given",
"GrailsClass",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java#L516-L531 |
32,514 | grails/grails-core | grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java | DefaultGrailsApplication.registerArtefactHandler | public void registerArtefactHandler(ArtefactHandler handler) {
GrailsApplicationAwareBeanPostProcessor.processAwareInterfaces(this, handler);
artefactHandlersByName.put(handler.getType(), handler);
updateArtefactHandlers();
} | java | public void registerArtefactHandler(ArtefactHandler handler) {
GrailsApplicationAwareBeanPostProcessor.processAwareInterfaces(this, handler);
artefactHandlersByName.put(handler.getType(), handler);
updateArtefactHandlers();
} | [
"public",
"void",
"registerArtefactHandler",
"(",
"ArtefactHandler",
"handler",
")",
"{",
"GrailsApplicationAwareBeanPostProcessor",
".",
"processAwareInterfaces",
"(",
"this",
",",
"handler",
")",
";",
"artefactHandlersByName",
".",
"put",
"(",
"handler",
".",
"getType... | Registers a new ArtefactHandler that is responsible for identifying and managing a
particular artefact type that is defined by some convention.
@param handler The ArtefactHandler to regster | [
"Registers",
"a",
"new",
"ArtefactHandler",
"that",
"is",
"responsible",
"for",
"identifying",
"and",
"managing",
"a",
"particular",
"artefact",
"type",
"that",
"is",
"defined",
"by",
"some",
"convention",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java#L539-L543 |
32,515 | grails/grails-core | grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java | DefaultGrailsApplication.initializeArtefacts | protected void initializeArtefacts(ArtefactHandler handler) {
if (handler == null) {
return;
}
ArtefactInfo info = getArtefactInfo(handler.getType());
// Only init those that have data
if (info != null) {
//System.out.println("Initialising artefacts of kind " + handler.getType() + " with registered artefacts" + info.getGrailsClassesByName());
handler.initialize(info);
}
} | java | protected void initializeArtefacts(ArtefactHandler handler) {
if (handler == null) {
return;
}
ArtefactInfo info = getArtefactInfo(handler.getType());
// Only init those that have data
if (info != null) {
//System.out.println("Initialising artefacts of kind " + handler.getType() + " with registered artefacts" + info.getGrailsClassesByName());
handler.initialize(info);
}
} | [
"protected",
"void",
"initializeArtefacts",
"(",
"ArtefactHandler",
"handler",
")",
"{",
"if",
"(",
"handler",
"==",
"null",
")",
"{",
"return",
";",
"}",
"ArtefactInfo",
"info",
"=",
"getArtefactInfo",
"(",
"handler",
".",
"getType",
"(",
")",
")",
";",
"... | Re-initialize the artefacts of the specified type. This gives handlers a chance to update caches etc.
@param handler The handler to register | [
"Re",
"-",
"initialize",
"the",
"artefacts",
"of",
"the",
"specified",
"type",
".",
"This",
"gives",
"handlers",
"a",
"chance",
"to",
"update",
"caches",
"etc",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java#L583-L594 |
32,516 | grails/grails-core | grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java | DefaultGrailsApplication.getArtefactInfo | protected DefaultArtefactInfo getArtefactInfo(String artefactType, boolean create) {
DefaultArtefactInfo cache = (DefaultArtefactInfo) artefactInfo.get(artefactType);
if (cache == null && create) {
cache = new DefaultArtefactInfo();
artefactInfo.put(artefactType, cache);
cache.updateComplete();
}
return cache;
} | java | protected DefaultArtefactInfo getArtefactInfo(String artefactType, boolean create) {
DefaultArtefactInfo cache = (DefaultArtefactInfo) artefactInfo.get(artefactType);
if (cache == null && create) {
cache = new DefaultArtefactInfo();
artefactInfo.put(artefactType, cache);
cache.updateComplete();
}
return cache;
} | [
"protected",
"DefaultArtefactInfo",
"getArtefactInfo",
"(",
"String",
"artefactType",
",",
"boolean",
"create",
")",
"{",
"DefaultArtefactInfo",
"cache",
"=",
"(",
"DefaultArtefactInfo",
")",
"artefactInfo",
".",
"get",
"(",
"artefactType",
")",
";",
"if",
"(",
"c... | Get or create the cache of classes for the specified artefact type.
@param artefactType The name of an artefact type
@param create Set to true if you want non-existent caches to be created
@return The cache of classes for the type, or null if no cache exists and create is false | [
"Get",
"or",
"create",
"the",
"cache",
"of",
"classes",
"for",
"the",
"specified",
"artefact",
"type",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java#L603-L611 |
32,517 | grails/grails-core | grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java | DefaultGrailsApplication.getProperty | @Override
public Object getProperty(String propertyName) {
// look for getXXXXClasses
final Matcher match = GETCLASSESPROP_PATTERN.matcher(propertyName);
// find match
match.find();
if (match.matches()) {
String artefactName = GrailsNameUtils.getClassNameRepresentation(match.group(1));
if (artefactHandlersByName.containsKey(artefactName)) {
return getArtefacts(artefactName);
}
}
return super.getProperty(propertyName);
} | java | @Override
public Object getProperty(String propertyName) {
// look for getXXXXClasses
final Matcher match = GETCLASSESPROP_PATTERN.matcher(propertyName);
// find match
match.find();
if (match.matches()) {
String artefactName = GrailsNameUtils.getClassNameRepresentation(match.group(1));
if (artefactHandlersByName.containsKey(artefactName)) {
return getArtefacts(artefactName);
}
}
return super.getProperty(propertyName);
} | [
"@",
"Override",
"public",
"Object",
"getProperty",
"(",
"String",
"propertyName",
")",
"{",
"// look for getXXXXClasses",
"final",
"Matcher",
"match",
"=",
"GETCLASSESPROP_PATTERN",
".",
"matcher",
"(",
"propertyName",
")",
";",
"// find match",
"match",
".",
"find... | Override property access and hit on xxxxClasses to return class arrays of artefacts.
@param propertyName The name of the property, if it ends in *Classes then match and invoke internal ArtefactHandler
@return All the artifacts or delegate to super.getProperty | [
"Override",
"property",
"access",
"and",
"hit",
"on",
"xxxxClasses",
"to",
"return",
"class",
"arrays",
"of",
"artefacts",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java#L690-L703 |
32,518 | grails/grails-core | grails-core/src/main/groovy/grails/core/DefaultArtefactInfo.java | DefaultArtefactInfo.updateComplete | public synchronized void updateComplete() {
grailsClassesByName = Collections.unmodifiableMap(grailsClassesByName);
classesByName = Collections.unmodifiableMap(classesByName);
grailsClassesArray = grailsClasses.toArray(new GrailsClass[grailsClasses.size()]);
// Make classes array
classes = classesByName.values().toArray(new Class[classesByName.size()]);
} | java | public synchronized void updateComplete() {
grailsClassesByName = Collections.unmodifiableMap(grailsClassesByName);
classesByName = Collections.unmodifiableMap(classesByName);
grailsClassesArray = grailsClasses.toArray(new GrailsClass[grailsClasses.size()]);
// Make classes array
classes = classesByName.values().toArray(new Class[classesByName.size()]);
} | [
"public",
"synchronized",
"void",
"updateComplete",
"(",
")",
"{",
"grailsClassesByName",
"=",
"Collections",
".",
"unmodifiableMap",
"(",
"grailsClassesByName",
")",
";",
"classesByName",
"=",
"Collections",
".",
"unmodifiableMap",
"(",
"classesByName",
")",
";",
"... | Refresh the arrays generated from the maps. | [
"Refresh",
"the",
"arrays",
"generated",
"from",
"the",
"maps",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/core/DefaultArtefactInfo.java#L83-L90 |
32,519 | grails/grails-core | grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/UrlMappingUtils.java | UrlMappingUtils.lookupUrlMappings | public static UrlMappingsHolder lookupUrlMappings(ServletContext servletContext) {
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
return (UrlMappingsHolder)wac.getBean(UrlMappingsHolder.BEAN_ID);
} | java | public static UrlMappingsHolder lookupUrlMappings(ServletContext servletContext) {
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
return (UrlMappingsHolder)wac.getBean(UrlMappingsHolder.BEAN_ID);
} | [
"public",
"static",
"UrlMappingsHolder",
"lookupUrlMappings",
"(",
"ServletContext",
"servletContext",
")",
"{",
"WebApplicationContext",
"wac",
"=",
"WebApplicationContextUtils",
".",
"getRequiredWebApplicationContext",
"(",
"servletContext",
")",
";",
"return",
"(",
"UrlM... | Looks up the UrlMappingsHolder instance
@return The UrlMappingsHolder
@param servletContext The ServletContext object | [
"Looks",
"up",
"the",
"UrlMappingsHolder",
"instance"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/UrlMappingUtils.java#L89-L92 |
32,520 | grails/grails-core | grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/UrlMappingUtils.java | UrlMappingUtils.resolveView | public static View resolveView(HttpServletRequest request, UrlMappingInfo info, String viewName, ViewResolver viewResolver) throws Exception {
String controllerName = info.getControllerName();
return WebUtils.resolveView(request, viewName, controllerName, viewResolver);
} | java | public static View resolveView(HttpServletRequest request, UrlMappingInfo info, String viewName, ViewResolver viewResolver) throws Exception {
String controllerName = info.getControllerName();
return WebUtils.resolveView(request, viewName, controllerName, viewResolver);
} | [
"public",
"static",
"View",
"resolveView",
"(",
"HttpServletRequest",
"request",
",",
"UrlMappingInfo",
"info",
",",
"String",
"viewName",
",",
"ViewResolver",
"viewResolver",
")",
"throws",
"Exception",
"{",
"String",
"controllerName",
"=",
"info",
".",
"getControl... | Resolves a view for the given view and UrlMappingInfo instance
@param request The request
@param info The info
@param viewName The view name
@param viewResolver The view resolver
@return The view or null
@throws Exception | [
"Resolves",
"a",
"view",
"for",
"the",
"given",
"view",
"and",
"UrlMappingInfo",
"instance"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/UrlMappingUtils.java#L104-L107 |
32,521 | grails/grails-core | grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/UrlMappingUtils.java | UrlMappingUtils.forwardRequestForUrlMappingInfo | @SuppressWarnings({ "unchecked", "rawtypes" })
public static String forwardRequestForUrlMappingInfo(HttpServletRequest request,
HttpServletResponse response, UrlMappingInfo info, Map<String, Object> model, boolean includeParams) throws ServletException, IOException {
String forwardUrl = buildDispatchUrlForMapping(info, includeParams);
for (Map.Entry<String, Object> entry : model.entrySet()) {
request.setAttribute(entry.getKey(), entry.getValue());
}
//populateParamsForMapping(info);
RequestDispatcher dispatcher = request.getRequestDispatcher(forwardUrl);
// Clear the request attributes that affect view rendering. Otherwise
// whatever we forward to may render the wrong thing! Note that we
// don't care about the return value because we're delegating
// responsibility for rendering the response.
final GrailsWebRequest webRequest = GrailsWebRequest.lookup(request);
webRequest.removeAttribute(GrailsApplicationAttributes.MODEL_AND_VIEW, 0);
info.configure(webRequest);
webRequest.removeAttribute(GrailsApplicationAttributes.GRAILS_CONTROLLER_CLASS_AVAILABLE, WebRequest.SCOPE_REQUEST);
webRequest.removeAttribute(UrlMappingsHandlerMapping.MATCHED_REQUEST, WebRequest.SCOPE_REQUEST);
webRequest.removeAttribute("grailsWebRequestFilter" + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX, WebRequest.SCOPE_REQUEST);
dispatcher.forward(request, response);
return forwardUrl;
} | java | @SuppressWarnings({ "unchecked", "rawtypes" })
public static String forwardRequestForUrlMappingInfo(HttpServletRequest request,
HttpServletResponse response, UrlMappingInfo info, Map<String, Object> model, boolean includeParams) throws ServletException, IOException {
String forwardUrl = buildDispatchUrlForMapping(info, includeParams);
for (Map.Entry<String, Object> entry : model.entrySet()) {
request.setAttribute(entry.getKey(), entry.getValue());
}
//populateParamsForMapping(info);
RequestDispatcher dispatcher = request.getRequestDispatcher(forwardUrl);
// Clear the request attributes that affect view rendering. Otherwise
// whatever we forward to may render the wrong thing! Note that we
// don't care about the return value because we're delegating
// responsibility for rendering the response.
final GrailsWebRequest webRequest = GrailsWebRequest.lookup(request);
webRequest.removeAttribute(GrailsApplicationAttributes.MODEL_AND_VIEW, 0);
info.configure(webRequest);
webRequest.removeAttribute(GrailsApplicationAttributes.GRAILS_CONTROLLER_CLASS_AVAILABLE, WebRequest.SCOPE_REQUEST);
webRequest.removeAttribute(UrlMappingsHandlerMapping.MATCHED_REQUEST, WebRequest.SCOPE_REQUEST);
webRequest.removeAttribute("grailsWebRequestFilter" + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX, WebRequest.SCOPE_REQUEST);
dispatcher.forward(request, response);
return forwardUrl;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"static",
"String",
"forwardRequestForUrlMappingInfo",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"UrlMappingInfo",
"info",
",",
"Map",
... | Forwards a request for the given UrlMappingInfo object and model
@param request The request
@param response The response
@param info The UrlMappingInfo object
@param model The Model
@param includeParams Whether to include any request parameters
@return The URI forwarded too
@throws javax.servlet.ServletException Thrown when an error occurs executing the forward
@throws java.io.IOException Thrown when an error occurs executing the forward | [
"Forwards",
"a",
"request",
"for",
"the",
"given",
"UrlMappingInfo",
"object",
"and",
"model"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/UrlMappingUtils.java#L218-L242 |
32,522 | grails/grails-core | grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/UrlMappingUtils.java | UrlMappingUtils.includeForUrlMappingInfo | @SuppressWarnings({ "unchecked", "rawtypes" })
public static IncludedContent includeForUrlMappingInfo(HttpServletRequest request,
HttpServletResponse response, UrlMappingInfo info, Map model, LinkGenerator linkGenerator) {
final String includeUrl = buildDispatchUrlForMapping(info, true, linkGenerator);
return includeForUrlMappingInfoHelper(includeUrl, request, response, info, model);
} | java | @SuppressWarnings({ "unchecked", "rawtypes" })
public static IncludedContent includeForUrlMappingInfo(HttpServletRequest request,
HttpServletResponse response, UrlMappingInfo info, Map model, LinkGenerator linkGenerator) {
final String includeUrl = buildDispatchUrlForMapping(info, true, linkGenerator);
return includeForUrlMappingInfoHelper(includeUrl, request, response, info, model);
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"static",
"IncludedContent",
"includeForUrlMappingInfo",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"UrlMappingInfo",
"info",
",",
"Map",... | Include whatever the given UrlMappingInfo maps to within the current response
@param request The request
@param response The response
@param info The UrlMappingInfo
@param model The model
@param linkGenerator allows for reverse url mapping
@return The included content | [
"Include",
"whatever",
"the",
"given",
"UrlMappingInfo",
"maps",
"to",
"within",
"the",
"current",
"response"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/UrlMappingUtils.java#L274-L281 |
32,523 | grails/grails-core | grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/UrlMappingUtils.java | UrlMappingUtils.includeForUrl | @SuppressWarnings({ "unchecked", "rawtypes" })
public static IncludedContent includeForUrl(String includeUrl, HttpServletRequest request,
HttpServletResponse response, Map model) {
RequestDispatcher dispatcher = request.getRequestDispatcher(includeUrl);
HttpServletResponse wrapped = WrappedResponseHolder.getWrappedResponse();
response = wrapped != null ? wrapped : response;
WebUtils.exposeIncludeRequestAttributes(request);
Map toRestore = WebUtils.exposeRequestAttributesAndReturnOldValues(request, model);
final GrailsWebRequest webRequest = GrailsWebRequest.lookup(request);
final boolean hasPreviousWebRequest = webRequest != null;
final Object previousControllerClass = hasPreviousWebRequest ? webRequest.getAttribute(GrailsApplicationAttributes.GRAILS_CONTROLLER_CLASS_AVAILABLE, WebRequest.SCOPE_REQUEST) : null;
final Object previousMatchedRequest = hasPreviousWebRequest ? webRequest.getAttribute(UrlMappingsHandlerMapping.MATCHED_REQUEST, WebRequest.SCOPE_REQUEST) : null;
try {
if (hasPreviousWebRequest) {
webRequest.removeAttribute(GrailsApplicationAttributes.GRAILS_CONTROLLER_CLASS_AVAILABLE, WebRequest.SCOPE_REQUEST);
webRequest.removeAttribute(UrlMappingsHandlerMapping.MATCHED_REQUEST, WebRequest.SCOPE_REQUEST);
webRequest.removeAttribute("grailsWebRequestFilter" + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX, WebRequest.SCOPE_REQUEST);
}
final IncludeResponseWrapper responseWrapper = new IncludeResponseWrapper(response);
try {
WrappedResponseHolder.setWrappedResponse(responseWrapper);
WebUtils.clearGrailsWebRequest();
dispatcher.include(request, responseWrapper);
if (responseWrapper.getRedirectURL()!=null) {
return new IncludedContent(responseWrapper.getRedirectURL());
}
return new IncludedContent(responseWrapper.getContentType(), responseWrapper.getContent());
}
finally {
if (hasPreviousWebRequest) {
WebUtils.storeGrailsWebRequest(webRequest);
if (webRequest.isActive()) {
webRequest.setAttribute(GrailsApplicationAttributes.GRAILS_CONTROLLER_CLASS_AVAILABLE, previousControllerClass,WebRequest.SCOPE_REQUEST);
webRequest.setAttribute(UrlMappingsHandlerMapping.MATCHED_REQUEST,previousMatchedRequest, WebRequest.SCOPE_REQUEST);
}
}
WrappedResponseHolder.setWrappedResponse(wrapped);
}
}
catch (Exception e) {
throw new ControllerExecutionException("Unable to execute include: " + e.getMessage(), e);
}
finally {
WebUtils.cleanupIncludeRequestAttributes(request, toRestore);
}
} | java | @SuppressWarnings({ "unchecked", "rawtypes" })
public static IncludedContent includeForUrl(String includeUrl, HttpServletRequest request,
HttpServletResponse response, Map model) {
RequestDispatcher dispatcher = request.getRequestDispatcher(includeUrl);
HttpServletResponse wrapped = WrappedResponseHolder.getWrappedResponse();
response = wrapped != null ? wrapped : response;
WebUtils.exposeIncludeRequestAttributes(request);
Map toRestore = WebUtils.exposeRequestAttributesAndReturnOldValues(request, model);
final GrailsWebRequest webRequest = GrailsWebRequest.lookup(request);
final boolean hasPreviousWebRequest = webRequest != null;
final Object previousControllerClass = hasPreviousWebRequest ? webRequest.getAttribute(GrailsApplicationAttributes.GRAILS_CONTROLLER_CLASS_AVAILABLE, WebRequest.SCOPE_REQUEST) : null;
final Object previousMatchedRequest = hasPreviousWebRequest ? webRequest.getAttribute(UrlMappingsHandlerMapping.MATCHED_REQUEST, WebRequest.SCOPE_REQUEST) : null;
try {
if (hasPreviousWebRequest) {
webRequest.removeAttribute(GrailsApplicationAttributes.GRAILS_CONTROLLER_CLASS_AVAILABLE, WebRequest.SCOPE_REQUEST);
webRequest.removeAttribute(UrlMappingsHandlerMapping.MATCHED_REQUEST, WebRequest.SCOPE_REQUEST);
webRequest.removeAttribute("grailsWebRequestFilter" + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX, WebRequest.SCOPE_REQUEST);
}
final IncludeResponseWrapper responseWrapper = new IncludeResponseWrapper(response);
try {
WrappedResponseHolder.setWrappedResponse(responseWrapper);
WebUtils.clearGrailsWebRequest();
dispatcher.include(request, responseWrapper);
if (responseWrapper.getRedirectURL()!=null) {
return new IncludedContent(responseWrapper.getRedirectURL());
}
return new IncludedContent(responseWrapper.getContentType(), responseWrapper.getContent());
}
finally {
if (hasPreviousWebRequest) {
WebUtils.storeGrailsWebRequest(webRequest);
if (webRequest.isActive()) {
webRequest.setAttribute(GrailsApplicationAttributes.GRAILS_CONTROLLER_CLASS_AVAILABLE, previousControllerClass,WebRequest.SCOPE_REQUEST);
webRequest.setAttribute(UrlMappingsHandlerMapping.MATCHED_REQUEST,previousMatchedRequest, WebRequest.SCOPE_REQUEST);
}
}
WrappedResponseHolder.setWrappedResponse(wrapped);
}
}
catch (Exception e) {
throw new ControllerExecutionException("Unable to execute include: " + e.getMessage(), e);
}
finally {
WebUtils.cleanupIncludeRequestAttributes(request, toRestore);
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"static",
"IncludedContent",
"includeForUrl",
"(",
"String",
"includeUrl",
",",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"Map",
"model",
... | Includes the given URL returning the resulting content as a String
@param includeUrl The URL to include
@param request The request
@param response The response
@param model The model
@return The content | [
"Includes",
"the",
"given",
"URL",
"returning",
"the",
"resulting",
"content",
"as",
"a",
"String"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/UrlMappingUtils.java#L357-L407 |
32,524 | grails/grails-core | grails-core/src/main/groovy/org/grails/plugins/BinaryGrailsPlugin.java | BinaryGrailsPlugin.getResource | public Resource getResource(String path) {
final Resource descriptorResource = descriptor.getResource();
try {
Resource resource = descriptorResource.createRelative("static" + path);
if (resource.exists()) {
return resource;
}
} catch (IOException e) {
return null;
}
return null;
} | java | public Resource getResource(String path) {
final Resource descriptorResource = descriptor.getResource();
try {
Resource resource = descriptorResource.createRelative("static" + path);
if (resource.exists()) {
return resource;
}
} catch (IOException e) {
return null;
}
return null;
} | [
"public",
"Resource",
"getResource",
"(",
"String",
"path",
")",
"{",
"final",
"Resource",
"descriptorResource",
"=",
"descriptor",
".",
"getResource",
"(",
")",
";",
"try",
"{",
"Resource",
"resource",
"=",
"descriptorResource",
".",
"createRelative",
"(",
"\"s... | Resolves a static resource contained within this binary plugin
@param path The relative path to the static resource
@return The resource or null if it doesn't exist | [
"Resolves",
"a",
"static",
"resource",
"contained",
"within",
"this",
"binary",
"plugin"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/plugins/BinaryGrailsPlugin.java#L202-L214 |
32,525 | grails/grails-core | grails-core/src/main/groovy/org/grails/plugins/BinaryGrailsPlugin.java | BinaryGrailsPlugin.getProperties | public Properties getProperties(final Locale locale) {
Resource url = this.baseResourcesResource;
Properties properties = null;
if(url != null) {
StaticResourceLoader resourceLoader = new StaticResourceLoader();
resourceLoader.setBaseResource(url);
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(resourceLoader);
try {
// first load all properties
Resource[] resources = resolver.getResources('*' + PROPERTIES_EXTENSION);
resources = resources.length > 0 ? filterResources(resources, locale) : resources;
if(resources.length > 0) {
properties = new Properties();
// message bundles are locale specific. The more underscores the locale has the more specific the locale
// so we order by the number of underscores present so that the most specific appears
Arrays.sort(resources, (o1, o2) -> {
String f1 = o1.getFilename();
String f2 = o2.getFilename();
int firstUnderscoreCount = StringUtils.countOccurrencesOf(f1, "_");
int secondUnderscoreCount = StringUtils.countOccurrencesOf(f2, "_");
if(firstUnderscoreCount == secondUnderscoreCount) {
return 0;
}
else {
return firstUnderscoreCount > secondUnderscoreCount ? 1 : -1;
}
});
loadFromResources(properties, resources);
}
} catch (IOException e) {
return null;
}
}
return properties;
} | java | public Properties getProperties(final Locale locale) {
Resource url = this.baseResourcesResource;
Properties properties = null;
if(url != null) {
StaticResourceLoader resourceLoader = new StaticResourceLoader();
resourceLoader.setBaseResource(url);
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(resourceLoader);
try {
// first load all properties
Resource[] resources = resolver.getResources('*' + PROPERTIES_EXTENSION);
resources = resources.length > 0 ? filterResources(resources, locale) : resources;
if(resources.length > 0) {
properties = new Properties();
// message bundles are locale specific. The more underscores the locale has the more specific the locale
// so we order by the number of underscores present so that the most specific appears
Arrays.sort(resources, (o1, o2) -> {
String f1 = o1.getFilename();
String f2 = o2.getFilename();
int firstUnderscoreCount = StringUtils.countOccurrencesOf(f1, "_");
int secondUnderscoreCount = StringUtils.countOccurrencesOf(f2, "_");
if(firstUnderscoreCount == secondUnderscoreCount) {
return 0;
}
else {
return firstUnderscoreCount > secondUnderscoreCount ? 1 : -1;
}
});
loadFromResources(properties, resources);
}
} catch (IOException e) {
return null;
}
}
return properties;
} | [
"public",
"Properties",
"getProperties",
"(",
"final",
"Locale",
"locale",
")",
"{",
"Resource",
"url",
"=",
"this",
".",
"baseResourcesResource",
";",
"Properties",
"properties",
"=",
"null",
";",
"if",
"(",
"url",
"!=",
"null",
")",
"{",
"StaticResourceLoade... | Obtains all properties for this binary plugin for the given locale.
Note this method does not cache so clients should in general cache the results of this method.
@param locale The locale
@return The properties or null if non exist | [
"Obtains",
"all",
"properties",
"for",
"this",
"binary",
"plugin",
"for",
"the",
"given",
"locale",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/plugins/BinaryGrailsPlugin.java#L224-L262 |
32,526 | grails/grails-core | grails-core/src/main/groovy/org/grails/plugins/BinaryGrailsPlugin.java | BinaryGrailsPlugin.resolveView | public Class resolveView(String viewName) {
// this is a workaround for GRAILS-9234; in that scenario the viewName will be
// "/WEB-INF/grails-app/views/plugins/plugin9234-0.1/junk/_book.gsp" with the
// extra "/plugins/plugin9234-0.1". I'm not sure if that's needed elsewhere, so
// removing it here for the lookup
String extraPath = "/plugins/" + getName() + '-' + getVersion() + '/';
viewName = viewName.replace(extraPath, "/");
return precompiledViewMap.get(viewName);
} | java | public Class resolveView(String viewName) {
// this is a workaround for GRAILS-9234; in that scenario the viewName will be
// "/WEB-INF/grails-app/views/plugins/plugin9234-0.1/junk/_book.gsp" with the
// extra "/plugins/plugin9234-0.1". I'm not sure if that's needed elsewhere, so
// removing it here for the lookup
String extraPath = "/plugins/" + getName() + '-' + getVersion() + '/';
viewName = viewName.replace(extraPath, "/");
return precompiledViewMap.get(viewName);
} | [
"public",
"Class",
"resolveView",
"(",
"String",
"viewName",
")",
"{",
"// this is a workaround for GRAILS-9234; in that scenario the viewName will be",
"// \"/WEB-INF/grails-app/views/plugins/plugin9234-0.1/junk/_book.gsp\" with the",
"// extra \"/plugins/plugin9234-0.1\". I'm not sure if that'... | Resolves a view for the given view name.
@param viewName The view name
@return The view class which is a subclass of GroovyPage | [
"Resolves",
"a",
"view",
"for",
"the",
"given",
"view",
"name",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/plugins/BinaryGrailsPlugin.java#L311-L321 |
32,527 | grails/grails-core | grails-bootstrap/src/main/groovy/grails/util/CollectionUtils.java | CollectionUtils.getOrCreateChildMap | public static Map getOrCreateChildMap(Map parent, String key) {
Object o = parent.get(key);
if(o instanceof Map) {
return (Map)o;
}
return new LinkedHashMap();
} | java | public static Map getOrCreateChildMap(Map parent, String key) {
Object o = parent.get(key);
if(o instanceof Map) {
return (Map)o;
}
return new LinkedHashMap();
} | [
"public",
"static",
"Map",
"getOrCreateChildMap",
"(",
"Map",
"parent",
",",
"String",
"key",
")",
"{",
"Object",
"o",
"=",
"parent",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"o",
"instanceof",
"Map",
")",
"{",
"return",
"(",
"Map",
")",
"o",
"... | Gets a child map of the given parent map or returns an empty map if it doesn't exist
@param parent The parent map
@param key The key that holds the child map
@return The child map | [
"Gets",
"a",
"child",
"map",
"of",
"the",
"given",
"parent",
"map",
"or",
"returns",
"an",
"empty",
"map",
"if",
"it",
"doesn",
"t",
"exist"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-bootstrap/src/main/groovy/grails/util/CollectionUtils.java#L70-L76 |
32,528 | grails/grails-core | grails-core/src/main/groovy/org/grails/core/DefaultGrailsServiceClass.java | DefaultGrailsServiceClass.getDatasource | public String getDatasource() {
if (datasourceName == null) {
CharSequence name = getStaticPropertyValue(DATA_SOURCE, CharSequence.class);
datasourceName = name == null ? null : name.toString();
if (datasourceName == null) {
datasourceName = DEFAULT_DATA_SOURCE;
}
}
return datasourceName;
} | java | public String getDatasource() {
if (datasourceName == null) {
CharSequence name = getStaticPropertyValue(DATA_SOURCE, CharSequence.class);
datasourceName = name == null ? null : name.toString();
if (datasourceName == null) {
datasourceName = DEFAULT_DATA_SOURCE;
}
}
return datasourceName;
} | [
"public",
"String",
"getDatasource",
"(",
")",
"{",
"if",
"(",
"datasourceName",
"==",
"null",
")",
"{",
"CharSequence",
"name",
"=",
"getStaticPropertyValue",
"(",
"DATA_SOURCE",
",",
"CharSequence",
".",
"class",
")",
";",
"datasourceName",
"=",
"name",
"=="... | If service is transactional then get data source will always apply
@return name of data source | [
"If",
"service",
"is",
"transactional",
"then",
"get",
"data",
"source",
"will",
"always",
"apply"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/core/DefaultGrailsServiceClass.java#L47-L57 |
32,529 | grails/grails-core | grails-core/src/main/groovy/org/grails/plugins/BasePluginFilter.java | BasePluginFilter.isDependentOn | protected boolean isDependentOn(GrailsPlugin plugin, String pluginName) {
// check if toCompare depends on the current plugin
String[] dependencyNames = plugin.getDependencyNames();
for (int i = 0; i < dependencyNames.length; i++) {
final String dependencyName = dependencyNames[i];
if (pluginName.equals(dependencyName)) {
return true;
// we've establish that p does depend on plugin, so we can
// break from this loop
}
}
return false;
} | java | protected boolean isDependentOn(GrailsPlugin plugin, String pluginName) {
// check if toCompare depends on the current plugin
String[] dependencyNames = plugin.getDependencyNames();
for (int i = 0; i < dependencyNames.length; i++) {
final String dependencyName = dependencyNames[i];
if (pluginName.equals(dependencyName)) {
return true;
// we've establish that p does depend on plugin, so we can
// break from this loop
}
}
return false;
} | [
"protected",
"boolean",
"isDependentOn",
"(",
"GrailsPlugin",
"plugin",
",",
"String",
"pluginName",
")",
"{",
"// check if toCompare depends on the current plugin",
"String",
"[",
"]",
"dependencyNames",
"=",
"plugin",
".",
"getDependencyNames",
"(",
")",
";",
"for",
... | Checks whether a plugin is dependent on another plugin with the specified
name
@param plugin
the plugin to compare
@param pluginName
the name to compare against
@return true if <code>plugin</code> depends on <code>pluginName</code> | [
"Checks",
"whether",
"a",
"plugin",
"is",
"dependent",
"on",
"another",
"plugin",
"with",
"the",
"specified",
"name"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/plugins/BasePluginFilter.java#L134-L150 |
32,530 | grails/grails-core | grails-core/src/main/groovy/org/grails/plugins/BasePluginFilter.java | BasePluginFilter.buildExplicitlyNamedList | private void buildExplicitlyNamedList() {
// each plugin must either be in included set or must be a dependent of
// included set
for (GrailsPlugin plugin : originalPlugins) {
// find explicitly included plugins
String name = plugin.getName();
if (suppliedNames.contains(name)) {
explicitlyNamedPlugins.add(plugin);
addedNames.add(name);
}
}
} | java | private void buildExplicitlyNamedList() {
// each plugin must either be in included set or must be a dependent of
// included set
for (GrailsPlugin plugin : originalPlugins) {
// find explicitly included plugins
String name = plugin.getName();
if (suppliedNames.contains(name)) {
explicitlyNamedPlugins.add(plugin);
addedNames.add(name);
}
}
} | [
"private",
"void",
"buildExplicitlyNamedList",
"(",
")",
"{",
"// each plugin must either be in included set or must be a dependent of",
"// included set",
"for",
"(",
"GrailsPlugin",
"plugin",
":",
"originalPlugins",
")",
"{",
"// find explicitly included plugins",
"String",
"na... | Returns the sublist of the supplied set who are explicitly named, either
as included or excluded plugins
@return a sublist containing the elements of the original list
corresponding with the explicitlyNamed items as passed into the
constructor | [
"Returns",
"the",
"sublist",
"of",
"the",
"supplied",
"set",
"who",
"are",
"explicitly",
"named",
"either",
"as",
"included",
"or",
"excluded",
"plugins"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/plugins/BasePluginFilter.java#L160-L173 |
32,531 | grails/grails-core | grails-core/src/main/groovy/org/grails/plugins/BasePluginFilter.java | BasePluginFilter.buildNameMap | private void buildNameMap() {
nameMap = new HashMap<String, GrailsPlugin>();
for (GrailsPlugin plugin : originalPlugins) {
nameMap.put(plugin.getName(), plugin);
}
} | java | private void buildNameMap() {
nameMap = new HashMap<String, GrailsPlugin>();
for (GrailsPlugin plugin : originalPlugins) {
nameMap.put(plugin.getName(), plugin);
}
} | [
"private",
"void",
"buildNameMap",
"(",
")",
"{",
"nameMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"GrailsPlugin",
">",
"(",
")",
";",
"for",
"(",
"GrailsPlugin",
"plugin",
":",
"originalPlugins",
")",
"{",
"nameMap",
".",
"put",
"(",
"plugin",
".",... | Builds a name to plugin map from the original list of plugins supplied | [
"Builds",
"a",
"name",
"to",
"plugin",
"map",
"from",
"the",
"original",
"list",
"of",
"plugins",
"supplied"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/plugins/BasePluginFilter.java#L179-L184 |
32,532 | grails/grails-core | grails-core/src/main/groovy/org/grails/plugins/BasePluginFilter.java | BasePluginFilter.registerDependency | @SuppressWarnings({"unchecked", "rawtypes"})
protected void registerDependency(List additionalList, GrailsPlugin plugin) {
if (!addedNames.contains(plugin.getName())) {
addedNames.add(plugin.getName());
additionalList.add(plugin);
addPluginDependencies(additionalList, plugin);
}
} | java | @SuppressWarnings({"unchecked", "rawtypes"})
protected void registerDependency(List additionalList, GrailsPlugin plugin) {
if (!addedNames.contains(plugin.getName())) {
addedNames.add(plugin.getName());
additionalList.add(plugin);
addPluginDependencies(additionalList, plugin);
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"protected",
"void",
"registerDependency",
"(",
"List",
"additionalList",
",",
"GrailsPlugin",
"plugin",
")",
"{",
"if",
"(",
"!",
"addedNames",
".",
"contains",
"(",
"plugin",
... | Adds a plugin to the additional if this hasn't happened already | [
"Adds",
"a",
"plugin",
"to",
"the",
"additional",
"if",
"this",
"hasn",
"t",
"happened",
"already"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/plugins/BasePluginFilter.java#L189-L196 |
32,533 | grails/grails-core | grails-encoder/src/main/groovy/org/grails/charsequences/CharSequences.java | CharSequences.canUseOriginalForSubSequence | public static boolean canUseOriginalForSubSequence(CharSequence str, int start, int count) {
if (start != 0) return false;
final Class<?> csqClass = str.getClass();
return (csqClass == String.class || csqClass == StringBuilder.class || csqClass == StringBuffer.class) && count == str.length();
} | java | public static boolean canUseOriginalForSubSequence(CharSequence str, int start, int count) {
if (start != 0) return false;
final Class<?> csqClass = str.getClass();
return (csqClass == String.class || csqClass == StringBuilder.class || csqClass == StringBuffer.class) && count == str.length();
} | [
"public",
"static",
"boolean",
"canUseOriginalForSubSequence",
"(",
"CharSequence",
"str",
",",
"int",
"start",
",",
"int",
"count",
")",
"{",
"if",
"(",
"start",
"!=",
"0",
")",
"return",
"false",
";",
"final",
"Class",
"<",
"?",
">",
"csqClass",
"=",
"... | Checks if start == 0 and count == length of CharSequence
It does this check only for String, StringBuilder and StringBuffer classes which have a fast way to check length
Calculating length on GStringImpl requires building the result which is costly.
This helper method is to avoid calling length on other that String, StringBuilder and StringBuffer classes
when checking if the input CharSequence instance is already the same as the requested sub sequence
@param str CharSequence input
@param start start index
@param count length on sub sequence
@return true if input is String, StringBuilder or StringBuffer class, start is 0 and count is length of input sequence | [
"Checks",
"if",
"start",
"==",
"0",
"and",
"count",
"==",
"length",
"of",
"CharSequence",
"It",
"does",
"this",
"check",
"only",
"for",
"String",
"StringBuilder",
"and",
"StringBuffer",
"classes",
"which",
"have",
"a",
"fast",
"way",
"to",
"check",
"length"
... | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-encoder/src/main/groovy/org/grails/charsequences/CharSequences.java#L62-L66 |
32,534 | grails/grails-core | grails-encoder/src/main/groovy/org/grails/charsequences/CharSequences.java | CharSequences.writeCharSequence | public static void writeCharSequence(Writer target, CharSequence csq, int start, int end) throws IOException {
final Class<?> csqClass = csq.getClass();
if (csqClass == String.class) {
target.write((String)csq, start, end - start);
}
else if (csqClass == StringBuffer.class) {
char[] buf = new char[end - start];
((StringBuffer)csq).getChars(start, end, buf, 0);
target.write(buf);
}
else if (csqClass == StringBuilder.class) {
char[] buf = new char[end - start];
((StringBuilder)csq).getChars(start, end, buf, 0);
target.write(buf);
}
else if (csq instanceof CharArrayAccessible) {
char[] buf = new char[end - start];
((CharArrayAccessible)csq).getChars(start, end, buf, 0);
target.write(buf);
}
else {
String str = csq.subSequence(start, end).toString();
target.write(str, 0, str.length());
}
} | java | public static void writeCharSequence(Writer target, CharSequence csq, int start, int end) throws IOException {
final Class<?> csqClass = csq.getClass();
if (csqClass == String.class) {
target.write((String)csq, start, end - start);
}
else if (csqClass == StringBuffer.class) {
char[] buf = new char[end - start];
((StringBuffer)csq).getChars(start, end, buf, 0);
target.write(buf);
}
else if (csqClass == StringBuilder.class) {
char[] buf = new char[end - start];
((StringBuilder)csq).getChars(start, end, buf, 0);
target.write(buf);
}
else if (csq instanceof CharArrayAccessible) {
char[] buf = new char[end - start];
((CharArrayAccessible)csq).getChars(start, end, buf, 0);
target.write(buf);
}
else {
String str = csq.subSequence(start, end).toString();
target.write(str, 0, str.length());
}
} | [
"public",
"static",
"void",
"writeCharSequence",
"(",
"Writer",
"target",
",",
"CharSequence",
"csq",
",",
"int",
"start",
",",
"int",
"end",
")",
"throws",
"IOException",
"{",
"final",
"Class",
"<",
"?",
">",
"csqClass",
"=",
"csq",
".",
"getClass",
"(",
... | Writes a CharSequence instance in the most optimal way to the target writer
@param target writer
@param csq source CharSequence instance
@param start start/offset index
@param end end index + 1
@throws IOException | [
"Writes",
"a",
"CharSequence",
"instance",
"in",
"the",
"most",
"optimal",
"way",
"to",
"the",
"target",
"writer"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-encoder/src/main/groovy/org/grails/charsequences/CharSequences.java#L86-L110 |
32,535 | grails/grails-core | grails-encoder/src/main/groovy/org/grails/charsequences/CharSequences.java | CharSequences.getChars | public static void getChars(CharSequence csq, int srcBegin, int srcEnd, char dst[], int dstBegin) {
final Class<?> csqClass = csq.getClass();
if (csqClass == String.class) {
((String)csq).getChars(srcBegin, srcEnd, dst, dstBegin);
}
else if (csqClass == StringBuffer.class) {
((StringBuffer)csq).getChars(srcBegin, srcEnd, dst, dstBegin);
}
else if (csqClass == StringBuilder.class) {
((StringBuilder)csq).getChars(srcBegin, srcEnd, dst, dstBegin);
}
else if (csq instanceof CharArrayAccessible) {
((CharArrayAccessible)csq).getChars(srcBegin, srcEnd, dst, dstBegin);
}
else {
String str = csq.subSequence(srcBegin, srcEnd).toString();
str.getChars(0, str.length(), dst, dstBegin);
}
} | java | public static void getChars(CharSequence csq, int srcBegin, int srcEnd, char dst[], int dstBegin) {
final Class<?> csqClass = csq.getClass();
if (csqClass == String.class) {
((String)csq).getChars(srcBegin, srcEnd, dst, dstBegin);
}
else if (csqClass == StringBuffer.class) {
((StringBuffer)csq).getChars(srcBegin, srcEnd, dst, dstBegin);
}
else if (csqClass == StringBuilder.class) {
((StringBuilder)csq).getChars(srcBegin, srcEnd, dst, dstBegin);
}
else if (csq instanceof CharArrayAccessible) {
((CharArrayAccessible)csq).getChars(srcBegin, srcEnd, dst, dstBegin);
}
else {
String str = csq.subSequence(srcBegin, srcEnd).toString();
str.getChars(0, str.length(), dst, dstBegin);
}
} | [
"public",
"static",
"void",
"getChars",
"(",
"CharSequence",
"csq",
",",
"int",
"srcBegin",
",",
"int",
"srcEnd",
",",
"char",
"dst",
"[",
"]",
",",
"int",
"dstBegin",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"csqClass",
"=",
"csq",
".",
"getClass",
... | Provides an optimized way to copy CharSequence content to target array.
Uses getChars method available on String, StringBuilder and StringBuffer classes.
Characters are copied from the source sequence <code>csq</code> into the
destination character array <code>dst</code>. The first character to
be copied is at index <code>srcBegin</code>; the last character to
be copied is at index <code>srcEnd-1</code>. The total number of
characters to be copied is <code>srcEnd-srcBegin</code>. The
characters are copied into the subarray of <code>dst</code> starting
at index <code>dstBegin</code> and ending at index:
<p><blockquote><pre>
dstbegin + (srcEnd-srcBegin) - 1
</pre></blockquote>
@param csq the source CharSequence instance.
@param srcBegin start copying at this offset.
@param srcEnd stop copying at this offset.
@param dst the array to copy the data into.
@param dstBegin offset into <code>dst</code>.
@throws NullPointerException if <code>dst</code> is
<code>null</code>.
@throws IndexOutOfBoundsException if any of the following is true:
<ul>
<li><code>srcBegin</code> is negative
<li><code>dstBegin</code> is negative
<li>the <code>srcBegin</code> argument is greater than
the <code>srcEnd</code> argument.
<li><code>srcEnd</code> is greater than
<code>this.length()</code>.
<li><code>dstBegin+srcEnd-srcBegin</code> is greater than
<code>dst.length</code>
</ul> | [
"Provides",
"an",
"optimized",
"way",
"to",
"copy",
"CharSequence",
"content",
"to",
"target",
"array",
".",
"Uses",
"getChars",
"method",
"available",
"on",
"String",
"StringBuilder",
"and",
"StringBuffer",
"classes",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-encoder/src/main/groovy/org/grails/charsequences/CharSequences.java#L150-L168 |
32,536 | grails/grails-core | grails-shell/src/main/groovy/org/grails/cli/interactive/completers/SortedAggregateCompleter.java | SortedAggregateCompleter.complete | public int complete(final String buffer, final int cursor, final List<CharSequence> candidates) {
// buffer could be null
checkNotNull(candidates);
List<Completion> completions = new ArrayList<Completion>(completers.size());
// Run each completer, saving its completion results
int max = -1;
for (Completer completer : completers) {
Completion completion = new Completion(candidates);
completion.complete(completer, buffer, cursor);
// Compute the max cursor position
max = Math.max(max, completion.cursor);
completions.add(completion);
}
SortedSet<CharSequence> allCandidates = new TreeSet<>();
// Append candidates from completions which have the same cursor position as max
for (Completion completion : completions) {
if (completion.cursor == max) {
allCandidates.addAll(completion.candidates);
}
}
candidates.addAll(allCandidates);
return max;
} | java | public int complete(final String buffer, final int cursor, final List<CharSequence> candidates) {
// buffer could be null
checkNotNull(candidates);
List<Completion> completions = new ArrayList<Completion>(completers.size());
// Run each completer, saving its completion results
int max = -1;
for (Completer completer : completers) {
Completion completion = new Completion(candidates);
completion.complete(completer, buffer, cursor);
// Compute the max cursor position
max = Math.max(max, completion.cursor);
completions.add(completion);
}
SortedSet<CharSequence> allCandidates = new TreeSet<>();
// Append candidates from completions which have the same cursor position as max
for (Completion completion : completions) {
if (completion.cursor == max) {
allCandidates.addAll(completion.candidates);
}
}
candidates.addAll(allCandidates);
return max;
} | [
"public",
"int",
"complete",
"(",
"final",
"String",
"buffer",
",",
"final",
"int",
"cursor",
",",
"final",
"List",
"<",
"CharSequence",
">",
"candidates",
")",
"{",
"// buffer could be null",
"checkNotNull",
"(",
"candidates",
")",
";",
"List",
"<",
"Completi... | Perform a completion operation across all aggregated completers.
@see Completer#complete(String, int, java.util.List)
@return the highest completion return value from all completers | [
"Perform",
"a",
"completion",
"operation",
"across",
"all",
"aggregated",
"completers",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-shell/src/main/groovy/org/grails/cli/interactive/completers/SortedAggregateCompleter.java#L75-L105 |
32,537 | grails/grails-core | grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/CachingLinkGenerator.java | CachingLinkGenerator.appendMapKey | protected void appendMapKey(StringBuilder buffer, Map<String, Object> params) {
if (params==null || params.isEmpty()) {
buffer.append(EMPTY_MAP_STRING);
buffer.append(OPENING_BRACKET);
} else {
buffer.append(OPENING_BRACKET);
Map map = new LinkedHashMap<>(params);
final String requestControllerName = getRequestStateLookupStrategy().getControllerName();
if (map.get(UrlMapping.ACTION) != null && map.get(UrlMapping.CONTROLLER) == null && map.get(RESOURCE_PREFIX) == null) {
Object action = map.remove(UrlMapping.ACTION);
map.put(UrlMapping.CONTROLLER, requestControllerName);
map.put(UrlMapping.ACTION, action);
}
if (map.get(UrlMapping.NAMESPACE) == null && map.get(UrlMapping.CONTROLLER) == requestControllerName) {
String namespace = getRequestStateLookupStrategy().getControllerNamespace();
if (GrailsStringUtils.isNotEmpty(namespace)) {
map.put(UrlMapping.NAMESPACE, namespace);
}
}
boolean first = true;
for (Object o : map.entrySet()) {
Map.Entry entry = (Map.Entry) o;
Object value = entry.getValue();
if (value == null) continue;
first = appendCommaIfNotFirst(buffer, first);
Object key = entry.getKey();
if (RESOURCE_PREFIX.equals(key)) {
value = getCacheKeyValueForResource(value);
}
appendKeyValue(buffer, map, key, value);
}
}
buffer.append(CLOSING_BRACKET);
} | java | protected void appendMapKey(StringBuilder buffer, Map<String, Object> params) {
if (params==null || params.isEmpty()) {
buffer.append(EMPTY_MAP_STRING);
buffer.append(OPENING_BRACKET);
} else {
buffer.append(OPENING_BRACKET);
Map map = new LinkedHashMap<>(params);
final String requestControllerName = getRequestStateLookupStrategy().getControllerName();
if (map.get(UrlMapping.ACTION) != null && map.get(UrlMapping.CONTROLLER) == null && map.get(RESOURCE_PREFIX) == null) {
Object action = map.remove(UrlMapping.ACTION);
map.put(UrlMapping.CONTROLLER, requestControllerName);
map.put(UrlMapping.ACTION, action);
}
if (map.get(UrlMapping.NAMESPACE) == null && map.get(UrlMapping.CONTROLLER) == requestControllerName) {
String namespace = getRequestStateLookupStrategy().getControllerNamespace();
if (GrailsStringUtils.isNotEmpty(namespace)) {
map.put(UrlMapping.NAMESPACE, namespace);
}
}
boolean first = true;
for (Object o : map.entrySet()) {
Map.Entry entry = (Map.Entry) o;
Object value = entry.getValue();
if (value == null) continue;
first = appendCommaIfNotFirst(buffer, first);
Object key = entry.getKey();
if (RESOURCE_PREFIX.equals(key)) {
value = getCacheKeyValueForResource(value);
}
appendKeyValue(buffer, map, key, value);
}
}
buffer.append(CLOSING_BRACKET);
} | [
"protected",
"void",
"appendMapKey",
"(",
"StringBuilder",
"buffer",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"params",
")",
"{",
"if",
"(",
"params",
"==",
"null",
"||",
"params",
".",
"isEmpty",
"(",
")",
")",
"{",
"buffer",
".",
"append",
"(",... | Based on DGM toMapString, but with StringBuilder instead of StringBuffer | [
"Based",
"on",
"DGM",
"toMapString",
"but",
"with",
"StringBuilder",
"instead",
"of",
"StringBuffer"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/CachingLinkGenerator.java#L94-L127 |
32,538 | grails/grails-core | grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/RegexUrlMapping.java | RegexUrlMapping.convertToRegex | protected Pattern convertToRegex(String url) {
Pattern regex;
String pattern = null;
try {
// Escape any characters that have special meaning in regular expressions,
// such as '.' and '+'.
pattern = url.replace(".", "\\.");
pattern = pattern.replace("+", "\\+");
int lastSlash = pattern.lastIndexOf('/');
String urlRoot = lastSlash > -1 ? pattern.substring(0, lastSlash) : pattern;
String urlEnd = lastSlash > -1 ? pattern.substring(lastSlash, pattern.length()) : "";
// Now replace "*" with "[^/]" and "**" with ".*".
pattern = "^" + urlRoot
.replace("(\\.(*))", "(\\.[^/]+)?")
.replaceAll("([^\\*])\\*([^\\*])", "$1[^/]+?$2")
.replaceAll("([^\\*])\\*$", "$1[^/]+?")
.replaceAll("\\*\\*", ".*");
if("/(*)(\\.(*))".equals(urlEnd)) {
// shortcut this common special case which will
// happen any time a URL mapping ends with a pattern like
// /$someVariable(.$someExtension)
pattern += "/([^/]+)\\.([^/.]+)?";
} else {
pattern += urlEnd
.replace("(\\.(*))", "(\\.[^/]+)?")
.replaceAll("([^\\*])\\*([^\\*])", "$1[^/]+?$2")
.replaceAll("([^\\*])\\*$", "$1[^/]+?")
.replaceAll("\\*\\*", ".*")
.replaceAll("\\(\\[\\^\\/\\]\\+\\)\\\\\\.", "([^/.]+?)\\\\.")
.replaceAll("\\(\\[\\^\\/\\]\\+\\)\\?\\\\\\.", "([^/.]+?)\\?\\\\.")
;
}
pattern += "/??$";
regex = Pattern.compile(pattern);
}
catch (PatternSyntaxException pse) {
throw new UrlMappingException("Error evaluating mapping for pattern [" + pattern +
"] from Grails URL mappings: " + pse.getMessage(), pse);
}
return regex;
} | java | protected Pattern convertToRegex(String url) {
Pattern regex;
String pattern = null;
try {
// Escape any characters that have special meaning in regular expressions,
// such as '.' and '+'.
pattern = url.replace(".", "\\.");
pattern = pattern.replace("+", "\\+");
int lastSlash = pattern.lastIndexOf('/');
String urlRoot = lastSlash > -1 ? pattern.substring(0, lastSlash) : pattern;
String urlEnd = lastSlash > -1 ? pattern.substring(lastSlash, pattern.length()) : "";
// Now replace "*" with "[^/]" and "**" with ".*".
pattern = "^" + urlRoot
.replace("(\\.(*))", "(\\.[^/]+)?")
.replaceAll("([^\\*])\\*([^\\*])", "$1[^/]+?$2")
.replaceAll("([^\\*])\\*$", "$1[^/]+?")
.replaceAll("\\*\\*", ".*");
if("/(*)(\\.(*))".equals(urlEnd)) {
// shortcut this common special case which will
// happen any time a URL mapping ends with a pattern like
// /$someVariable(.$someExtension)
pattern += "/([^/]+)\\.([^/.]+)?";
} else {
pattern += urlEnd
.replace("(\\.(*))", "(\\.[^/]+)?")
.replaceAll("([^\\*])\\*([^\\*])", "$1[^/]+?$2")
.replaceAll("([^\\*])\\*$", "$1[^/]+?")
.replaceAll("\\*\\*", ".*")
.replaceAll("\\(\\[\\^\\/\\]\\+\\)\\\\\\.", "([^/.]+?)\\\\.")
.replaceAll("\\(\\[\\^\\/\\]\\+\\)\\?\\\\\\.", "([^/.]+?)\\?\\\\.")
;
}
pattern += "/??$";
regex = Pattern.compile(pattern);
}
catch (PatternSyntaxException pse) {
throw new UrlMappingException("Error evaluating mapping for pattern [" + pattern +
"] from Grails URL mappings: " + pse.getMessage(), pse);
}
return regex;
} | [
"protected",
"Pattern",
"convertToRegex",
"(",
"String",
"url",
")",
"{",
"Pattern",
"regex",
";",
"String",
"pattern",
"=",
"null",
";",
"try",
"{",
"// Escape any characters that have special meaning in regular expressions,",
"// such as '.' and '+'.",
"pattern",
"=",
"... | Converts a Grails URL provides via the UrlMappingData interface to a regular expression.
@param url The URL to convert
@return A regex Pattern objet | [
"Converts",
"a",
"Grails",
"URL",
"provides",
"via",
"the",
"UrlMappingData",
"interface",
"to",
"a",
"regular",
"expression",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/RegexUrlMapping.java#L216-L261 |
32,539 | grails/grails-core | grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/RegexUrlMapping.java | RegexUrlMapping.match | public UrlMappingInfo match(String uri) {
for (Pattern pattern : patterns) {
Matcher m = pattern.matcher(uri);
if (m.matches()) {
UrlMappingInfo urlInfo = createUrlMappingInfo(uri, m);
if (urlInfo != null) {
return urlInfo;
}
}
}
return null;
} | java | public UrlMappingInfo match(String uri) {
for (Pattern pattern : patterns) {
Matcher m = pattern.matcher(uri);
if (m.matches()) {
UrlMappingInfo urlInfo = createUrlMappingInfo(uri, m);
if (urlInfo != null) {
return urlInfo;
}
}
}
return null;
} | [
"public",
"UrlMappingInfo",
"match",
"(",
"String",
"uri",
")",
"{",
"for",
"(",
"Pattern",
"pattern",
":",
"patterns",
")",
"{",
"Matcher",
"m",
"=",
"pattern",
".",
"matcher",
"(",
"uri",
")",
";",
"if",
"(",
"m",
".",
"matches",
"(",
")",
")",
"... | Matches the given URI and returns a DefaultUrlMappingInfo instance or null
@param uri The URI to match
@return A UrlMappingInfo instance or null
@see grails.web.mapping.UrlMappingInfo | [
"Matches",
"the",
"given",
"URI",
"and",
"returns",
"a",
"DefaultUrlMappingInfo",
"instance",
"or",
"null"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/RegexUrlMapping.java#L270-L281 |
32,540 | grails/grails-core | grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/RegexUrlMapping.java | RegexUrlMapping.createRuntimeConstraintEvaluator | private Object createRuntimeConstraintEvaluator(final String name, ConstrainedProperty[] constraints) {
if (constraints == null) return null;
for (ConstrainedProperty constraint : constraints) {
if (constraint.getPropertyName().equals(name)) {
return new Closure(this) {
private static final long serialVersionUID = -2404119898659287216L;
@Override
public Object call(Object... objects) {
GrailsWebRequest webRequest = (GrailsWebRequest) RequestContextHolder.currentRequestAttributes();
return webRequest.getParams().get(name);
}
};
}
}
return null;
} | java | private Object createRuntimeConstraintEvaluator(final String name, ConstrainedProperty[] constraints) {
if (constraints == null) return null;
for (ConstrainedProperty constraint : constraints) {
if (constraint.getPropertyName().equals(name)) {
return new Closure(this) {
private static final long serialVersionUID = -2404119898659287216L;
@Override
public Object call(Object... objects) {
GrailsWebRequest webRequest = (GrailsWebRequest) RequestContextHolder.currentRequestAttributes();
return webRequest.getParams().get(name);
}
};
}
}
return null;
} | [
"private",
"Object",
"createRuntimeConstraintEvaluator",
"(",
"final",
"String",
"name",
",",
"ConstrainedProperty",
"[",
"]",
"constraints",
")",
"{",
"if",
"(",
"constraints",
"==",
"null",
")",
"return",
"null",
";",
"for",
"(",
"ConstrainedProperty",
"constrai... | This method will look for a constraint for the given name and return a closure that when executed will
attempt to evaluate its value from the bound request parameters at runtime.
@param name The name of the constrained property
@param constraints The array of current ConstrainedProperty instances
@return Either a Closure or null | [
"This",
"method",
"will",
"look",
"for",
"a",
"constraint",
"for",
"the",
"given",
"name",
"and",
"return",
"a",
"closure",
"that",
"when",
"executed",
"will",
"attempt",
"to",
"evaluate",
"its",
"value",
"from",
"the",
"bound",
"request",
"parameters",
"at"... | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/RegexUrlMapping.java#L700-L717 |
32,541 | grails/grails-core | grails-core/src/main/groovy/org/grails/spring/RuntimeSpringConfigUtilities.java | RuntimeSpringConfigUtilities.doLoadSpringGroovyResources | private static void doLoadSpringGroovyResources(RuntimeSpringConfiguration config, GrailsApplication application,
GenericApplicationContext context) {
loadExternalSpringConfig(config, application);
if (context != null) {
springGroovyResourcesBeanBuilder.registerBeans(context);
}
} | java | private static void doLoadSpringGroovyResources(RuntimeSpringConfiguration config, GrailsApplication application,
GenericApplicationContext context) {
loadExternalSpringConfig(config, application);
if (context != null) {
springGroovyResourcesBeanBuilder.registerBeans(context);
}
} | [
"private",
"static",
"void",
"doLoadSpringGroovyResources",
"(",
"RuntimeSpringConfiguration",
"config",
",",
"GrailsApplication",
"application",
",",
"GenericApplicationContext",
"context",
")",
"{",
"loadExternalSpringConfig",
"(",
"config",
",",
"application",
")",
";",
... | Attempt to load the beans defined by a BeanBuilder DSL closure in "resources.groovy".
@param config
@param context | [
"Attempt",
"to",
"load",
"the",
"beans",
"defined",
"by",
"a",
"BeanBuilder",
"DSL",
"closure",
"in",
"resources",
".",
"groovy",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/spring/RuntimeSpringConfigUtilities.java#L57-L63 |
32,542 | grails/grails-core | grails-core/src/main/groovy/org/grails/spring/RuntimeSpringConfigUtilities.java | RuntimeSpringConfigUtilities.loadExternalSpringConfig | public static void loadExternalSpringConfig(RuntimeSpringConfiguration config, final GrailsApplication application) {
if (springGroovyResourcesBeanBuilder == null) {
try {
Class<?> groovySpringResourcesClass = null;
try {
groovySpringResourcesClass = ClassUtils.forName(SPRING_RESOURCES_CLASS,
application.getClassLoader());
}
catch (ClassNotFoundException e) {
// ignore
}
if (groovySpringResourcesClass != null) {
reloadSpringResourcesConfig(config, application, groovySpringResourcesClass);
}
}
catch (Exception ex) {
LOG.error("[RuntimeConfiguration] Unable to load beans from resources.groovy", ex);
}
}
else {
if (!springGroovyResourcesBeanBuilder.getSpringConfig().equals(config)) {
springGroovyResourcesBeanBuilder.registerBeans(config);
}
}
} | java | public static void loadExternalSpringConfig(RuntimeSpringConfiguration config, final GrailsApplication application) {
if (springGroovyResourcesBeanBuilder == null) {
try {
Class<?> groovySpringResourcesClass = null;
try {
groovySpringResourcesClass = ClassUtils.forName(SPRING_RESOURCES_CLASS,
application.getClassLoader());
}
catch (ClassNotFoundException e) {
// ignore
}
if (groovySpringResourcesClass != null) {
reloadSpringResourcesConfig(config, application, groovySpringResourcesClass);
}
}
catch (Exception ex) {
LOG.error("[RuntimeConfiguration] Unable to load beans from resources.groovy", ex);
}
}
else {
if (!springGroovyResourcesBeanBuilder.getSpringConfig().equals(config)) {
springGroovyResourcesBeanBuilder.registerBeans(config);
}
}
} | [
"public",
"static",
"void",
"loadExternalSpringConfig",
"(",
"RuntimeSpringConfiguration",
"config",
",",
"final",
"GrailsApplication",
"application",
")",
"{",
"if",
"(",
"springGroovyResourcesBeanBuilder",
"==",
"null",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
">"... | Loads any external Spring configuration into the given RuntimeSpringConfiguration object.
@param config The config instance | [
"Loads",
"any",
"external",
"Spring",
"configuration",
"into",
"the",
"given",
"RuntimeSpringConfiguration",
"object",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/spring/RuntimeSpringConfigUtilities.java#L69-L93 |
32,543 | grails/grails-core | grails-core/src/main/groovy/org/grails/spring/context/support/PluginAwareResourceBundleMessageSource.java | PluginAwareResourceBundleMessageSource.resolveCodeWithoutArgumentsFromPlugins | protected String resolveCodeWithoutArgumentsFromPlugins(String code, Locale locale) {
if (pluginCacheMillis < 0) {
PropertiesHolder propHolder = getMergedPluginProperties(locale);
String result = propHolder.getProperty(code);
if (result != null) {
return result;
}
}
else {
String result = findCodeInBinaryPlugins(code, locale);
if (result != null) return result;
}
return null;
} | java | protected String resolveCodeWithoutArgumentsFromPlugins(String code, Locale locale) {
if (pluginCacheMillis < 0) {
PropertiesHolder propHolder = getMergedPluginProperties(locale);
String result = propHolder.getProperty(code);
if (result != null) {
return result;
}
}
else {
String result = findCodeInBinaryPlugins(code, locale);
if (result != null) return result;
}
return null;
} | [
"protected",
"String",
"resolveCodeWithoutArgumentsFromPlugins",
"(",
"String",
"code",
",",
"Locale",
"locale",
")",
"{",
"if",
"(",
"pluginCacheMillis",
"<",
"0",
")",
"{",
"PropertiesHolder",
"propHolder",
"=",
"getMergedPluginProperties",
"(",
"locale",
")",
";"... | Attempts to resolve a String for the code from the list of plugin base names
@param code The code
@param locale The locale
@return a MessageFormat | [
"Attempts",
"to",
"resolve",
"a",
"String",
"for",
"the",
"code",
"from",
"the",
"list",
"of",
"plugin",
"base",
"names"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/spring/context/support/PluginAwareResourceBundleMessageSource.java#L195-L209 |
32,544 | grails/grails-core | grails-core/src/main/groovy/org/grails/spring/context/support/PluginAwareResourceBundleMessageSource.java | PluginAwareResourceBundleMessageSource.resolveCodeFromPlugins | protected MessageFormat resolveCodeFromPlugins(String code, Locale locale) {
if (pluginCacheMillis < 0) {
PropertiesHolder propHolder = getMergedPluginProperties(locale);
MessageFormat result = propHolder.getMessageFormat(code, locale);
if (result != null) {
return result;
}
}
else {
MessageFormat result = findMessageFormatInBinaryPlugins(code, locale);
if (result != null) return result;
}
return null;
} | java | protected MessageFormat resolveCodeFromPlugins(String code, Locale locale) {
if (pluginCacheMillis < 0) {
PropertiesHolder propHolder = getMergedPluginProperties(locale);
MessageFormat result = propHolder.getMessageFormat(code, locale);
if (result != null) {
return result;
}
}
else {
MessageFormat result = findMessageFormatInBinaryPlugins(code, locale);
if (result != null) return result;
}
return null;
} | [
"protected",
"MessageFormat",
"resolveCodeFromPlugins",
"(",
"String",
"code",
",",
"Locale",
"locale",
")",
"{",
"if",
"(",
"pluginCacheMillis",
"<",
"0",
")",
"{",
"PropertiesHolder",
"propHolder",
"=",
"getMergedPluginProperties",
"(",
"locale",
")",
";",
"Mess... | Attempts to resolve a MessageFormat for the code from the list of plugin base names
@param code The code
@param locale The locale
@return a MessageFormat | [
"Attempts",
"to",
"resolve",
"a",
"MessageFormat",
"for",
"the",
"code",
"from",
"the",
"list",
"of",
"plugin",
"base",
"names"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/spring/context/support/PluginAwareResourceBundleMessageSource.java#L252-L265 |
32,545 | grails/grails-core | grails-core/src/main/groovy/org/grails/plugins/AbstractGrailsPluginManager.java | AbstractGrailsPluginManager.doRuntimeConfiguration | public void doRuntimeConfiguration(RuntimeSpringConfiguration springConfig) {
ApplicationContext context = springConfig.getUnrefreshedApplicationContext();
AutowireCapableBeanFactory autowireCapableBeanFactory = context.getAutowireCapableBeanFactory();
if(autowireCapableBeanFactory instanceof ConfigurableListableBeanFactory) {
ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory)autowireCapableBeanFactory;
ConversionService existingConversionService = beanFactory.getConversionService();
ConverterRegistry converterRegistry;
if(existingConversionService == null) {
GenericConversionService conversionService = new GenericConversionService();
converterRegistry = conversionService;
beanFactory.setConversionService(conversionService);
}
else {
converterRegistry = (ConverterRegistry)existingConversionService;
}
converterRegistry.addConverter(new Converter<NavigableMap.NullSafeNavigator, Object>() {
@Override
public Object convert(NavigableMap.NullSafeNavigator source) {
return null;
}
});
}
checkInitialised();
for (GrailsPlugin plugin : pluginList) {
if (plugin.supportsCurrentScopeAndEnvironment() && plugin.isEnabled(context.getEnvironment().getActiveProfiles())) {
plugin.doWithRuntimeConfiguration(springConfig);
}
}
} | java | public void doRuntimeConfiguration(RuntimeSpringConfiguration springConfig) {
ApplicationContext context = springConfig.getUnrefreshedApplicationContext();
AutowireCapableBeanFactory autowireCapableBeanFactory = context.getAutowireCapableBeanFactory();
if(autowireCapableBeanFactory instanceof ConfigurableListableBeanFactory) {
ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory)autowireCapableBeanFactory;
ConversionService existingConversionService = beanFactory.getConversionService();
ConverterRegistry converterRegistry;
if(existingConversionService == null) {
GenericConversionService conversionService = new GenericConversionService();
converterRegistry = conversionService;
beanFactory.setConversionService(conversionService);
}
else {
converterRegistry = (ConverterRegistry)existingConversionService;
}
converterRegistry.addConverter(new Converter<NavigableMap.NullSafeNavigator, Object>() {
@Override
public Object convert(NavigableMap.NullSafeNavigator source) {
return null;
}
});
}
checkInitialised();
for (GrailsPlugin plugin : pluginList) {
if (plugin.supportsCurrentScopeAndEnvironment() && plugin.isEnabled(context.getEnvironment().getActiveProfiles())) {
plugin.doWithRuntimeConfiguration(springConfig);
}
}
} | [
"public",
"void",
"doRuntimeConfiguration",
"(",
"RuntimeSpringConfiguration",
"springConfig",
")",
"{",
"ApplicationContext",
"context",
"=",
"springConfig",
".",
"getUnrefreshedApplicationContext",
"(",
")",
";",
"AutowireCapableBeanFactory",
"autowireCapableBeanFactory",
"="... | Base implementation that simply goes through the list of plugins and calls doWithRuntimeConfiguration on each
@param springConfig The RuntimeSpringConfiguration instance | [
"Base",
"implementation",
"that",
"simply",
"goes",
"through",
"the",
"list",
"of",
"plugins",
"and",
"calls",
"doWithRuntimeConfiguration",
"on",
"each"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/plugins/AbstractGrailsPluginManager.java#L140-L169 |
32,546 | grails/grails-core | grails-core/src/main/groovy/org/grails/plugins/AbstractGrailsPluginManager.java | AbstractGrailsPluginManager.doRuntimeConfiguration | public void doRuntimeConfiguration(String pluginName, RuntimeSpringConfiguration springConfig) {
checkInitialised();
GrailsPlugin plugin = getGrailsPlugin(pluginName);
if (plugin == null) {
throw new PluginException("Plugin [" + pluginName + "] not found");
}
if (!plugin.supportsCurrentScopeAndEnvironment()) {
return;
}
if(!plugin.isEnabled(applicationContext.getEnvironment().getActiveProfiles())) return;
String[] dependencyNames = plugin.getDependencyNames();
doRuntimeConfigurationForDependencies(dependencyNames, springConfig);
String[] loadAfters = plugin.getLoadAfterNames();
for (String name : loadAfters) {
GrailsPlugin current = getGrailsPlugin(name);
if (current != null) {
current.doWithRuntimeConfiguration(springConfig);
}
}
plugin.doWithRuntimeConfiguration(springConfig);
} | java | public void doRuntimeConfiguration(String pluginName, RuntimeSpringConfiguration springConfig) {
checkInitialised();
GrailsPlugin plugin = getGrailsPlugin(pluginName);
if (plugin == null) {
throw new PluginException("Plugin [" + pluginName + "] not found");
}
if (!plugin.supportsCurrentScopeAndEnvironment()) {
return;
}
if(!plugin.isEnabled(applicationContext.getEnvironment().getActiveProfiles())) return;
String[] dependencyNames = plugin.getDependencyNames();
doRuntimeConfigurationForDependencies(dependencyNames, springConfig);
String[] loadAfters = plugin.getLoadAfterNames();
for (String name : loadAfters) {
GrailsPlugin current = getGrailsPlugin(name);
if (current != null) {
current.doWithRuntimeConfiguration(springConfig);
}
}
plugin.doWithRuntimeConfiguration(springConfig);
} | [
"public",
"void",
"doRuntimeConfiguration",
"(",
"String",
"pluginName",
",",
"RuntimeSpringConfiguration",
"springConfig",
")",
"{",
"checkInitialised",
"(",
")",
";",
"GrailsPlugin",
"plugin",
"=",
"getGrailsPlugin",
"(",
"pluginName",
")",
";",
"if",
"(",
"plugin... | Base implementation that will perform runtime configuration for the specified plugin name. | [
"Base",
"implementation",
"that",
"will",
"perform",
"runtime",
"configuration",
"for",
"the",
"specified",
"plugin",
"name",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/plugins/AbstractGrailsPluginManager.java#L174-L197 |
32,547 | grails/grails-core | grails-core/src/main/groovy/org/grails/plugins/AbstractGrailsPluginManager.java | AbstractGrailsPluginManager.doPostProcessing | public void doPostProcessing(ApplicationContext ctx) {
checkInitialised();
for (GrailsPlugin plugin : pluginList) {
if(isPluginDisabledForProfile(plugin)) continue;
if (plugin.supportsCurrentScopeAndEnvironment()) {
plugin.doWithApplicationContext(ctx);
}
}
} | java | public void doPostProcessing(ApplicationContext ctx) {
checkInitialised();
for (GrailsPlugin plugin : pluginList) {
if(isPluginDisabledForProfile(plugin)) continue;
if (plugin.supportsCurrentScopeAndEnvironment()) {
plugin.doWithApplicationContext(ctx);
}
}
} | [
"public",
"void",
"doPostProcessing",
"(",
"ApplicationContext",
"ctx",
")",
"{",
"checkInitialised",
"(",
")",
";",
"for",
"(",
"GrailsPlugin",
"plugin",
":",
"pluginList",
")",
"{",
"if",
"(",
"isPluginDisabledForProfile",
"(",
"plugin",
")",
")",
"continue",
... | Base implementation that will simply go through each plugin and call doWithApplicationContext on each. | [
"Base",
"implementation",
"that",
"will",
"simply",
"go",
"through",
"each",
"plugin",
"and",
"call",
"doWithApplicationContext",
"on",
"each",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/plugins/AbstractGrailsPluginManager.java#L218-L226 |
32,548 | grails/grails-core | grails-encoder/src/main/groovy/org/grails/buffer/GrailsPrintWriter.java | GrailsPrintWriter.flush | @Override
public synchronized void flush() {
if (trouble) {
return;
}
if (isDestinationActivated()) {
try {
getOut().flush();
}
catch (IOException e) {
handleIOException(e);
}
}
} | java | @Override
public synchronized void flush() {
if (trouble) {
return;
}
if (isDestinationActivated()) {
try {
getOut().flush();
}
catch (IOException e) {
handleIOException(e);
}
}
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"flush",
"(",
")",
"{",
"if",
"(",
"trouble",
")",
"{",
"return",
";",
"}",
"if",
"(",
"isDestinationActivated",
"(",
")",
")",
"{",
"try",
"{",
"getOut",
"(",
")",
".",
"flush",
"(",
")",
";",
"}"... | Flush the stream.
@see #checkError() | [
"Flush",
"the",
"stream",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-encoder/src/main/groovy/org/grails/buffer/GrailsPrintWriter.java#L163-L177 |
32,549 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java | WebUtils.lookupHandlerInterceptors | public static HandlerInterceptor[] lookupHandlerInterceptors(ServletContext servletContext) {
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
final Collection<HandlerInterceptor> allHandlerInterceptors = new ArrayList<HandlerInterceptor>();
WebRequestInterceptor[] webRequestInterceptors = lookupWebRequestInterceptors(servletContext);
for (WebRequestInterceptor webRequestInterceptor : webRequestInterceptors) {
allHandlerInterceptors.add(new WebRequestHandlerInterceptorAdapter(webRequestInterceptor));
}
final Collection<HandlerInterceptor> handlerInterceptors = wac.getBeansOfType(HandlerInterceptor.class).values();
allHandlerInterceptors.addAll(handlerInterceptors);
return allHandlerInterceptors.toArray(new HandlerInterceptor[allHandlerInterceptors.size()]);
} | java | public static HandlerInterceptor[] lookupHandlerInterceptors(ServletContext servletContext) {
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
final Collection<HandlerInterceptor> allHandlerInterceptors = new ArrayList<HandlerInterceptor>();
WebRequestInterceptor[] webRequestInterceptors = lookupWebRequestInterceptors(servletContext);
for (WebRequestInterceptor webRequestInterceptor : webRequestInterceptors) {
allHandlerInterceptors.add(new WebRequestHandlerInterceptorAdapter(webRequestInterceptor));
}
final Collection<HandlerInterceptor> handlerInterceptors = wac.getBeansOfType(HandlerInterceptor.class).values();
allHandlerInterceptors.addAll(handlerInterceptors);
return allHandlerInterceptors.toArray(new HandlerInterceptor[allHandlerInterceptors.size()]);
} | [
"public",
"static",
"HandlerInterceptor",
"[",
"]",
"lookupHandlerInterceptors",
"(",
"ServletContext",
"servletContext",
")",
"{",
"WebApplicationContext",
"wac",
"=",
"WebApplicationContextUtils",
".",
"getRequiredWebApplicationContext",
"(",
"servletContext",
")",
";",
"... | Looks up all of the HandlerInterceptor instances registered for the application
@param servletContext The ServletContext instance
@return An array of HandlerInterceptor instances | [
"Looks",
"up",
"all",
"of",
"the",
"HandlerInterceptor",
"instances",
"registered",
"for",
"the",
"application"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java#L100-L113 |
32,550 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java | WebUtils.lookupWebRequestInterceptors | public static WebRequestInterceptor[] lookupWebRequestInterceptors(ServletContext servletContext) {
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
final Collection<WebRequestInterceptor> webRequestInterceptors = wac.getBeansOfType(WebRequestInterceptor.class).values();
return webRequestInterceptors.toArray(new WebRequestInterceptor[webRequestInterceptors.size()]);
} | java | public static WebRequestInterceptor[] lookupWebRequestInterceptors(ServletContext servletContext) {
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
final Collection<WebRequestInterceptor> webRequestInterceptors = wac.getBeansOfType(WebRequestInterceptor.class).values();
return webRequestInterceptors.toArray(new WebRequestInterceptor[webRequestInterceptors.size()]);
} | [
"public",
"static",
"WebRequestInterceptor",
"[",
"]",
"lookupWebRequestInterceptors",
"(",
"ServletContext",
"servletContext",
")",
"{",
"WebApplicationContext",
"wac",
"=",
"WebApplicationContextUtils",
".",
"getRequiredWebApplicationContext",
"(",
"servletContext",
")",
";... | Looks up all of the WebRequestInterceptor instances registered with the application
@param servletContext The ServletContext instance
@return An array of WebRequestInterceptor instances | [
"Looks",
"up",
"all",
"of",
"the",
"WebRequestInterceptor",
"instances",
"registered",
"with",
"the",
"application"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java#L121-L126 |
32,551 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java | WebUtils.findApplicationContext | public static ApplicationContext findApplicationContext(ServletContext servletContext) {
if(servletContext == null) {
return ContextLoader.getCurrentWebApplicationContext();
}
return WebApplicationContextUtils.getWebApplicationContext(servletContext);
} | java | public static ApplicationContext findApplicationContext(ServletContext servletContext) {
if(servletContext == null) {
return ContextLoader.getCurrentWebApplicationContext();
}
return WebApplicationContextUtils.getWebApplicationContext(servletContext);
} | [
"public",
"static",
"ApplicationContext",
"findApplicationContext",
"(",
"ServletContext",
"servletContext",
")",
"{",
"if",
"(",
"servletContext",
"==",
"null",
")",
"{",
"return",
"ContextLoader",
".",
"getCurrentWebApplicationContext",
"(",
")",
";",
"}",
"return",... | Locates the ApplicationContext, returns null if not found
@param servletContext The servlet context
@return The ApplicationContext | [
"Locates",
"the",
"ApplicationContext",
"returns",
"null",
"if",
"not",
"found"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java#L175-L180 |
32,552 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java | WebUtils.resolveView | public static View resolveView(HttpServletRequest request, String viewName, String controllerName, ViewResolver viewResolver) throws Exception {
GrailsWebRequest webRequest = GrailsWebRequest.lookup(request);
Locale locale = webRequest != null ? webRequest.getLocale() : Locale.getDefault() ;
return viewResolver.resolveViewName(addViewPrefix(viewName, controllerName), locale);
} | java | public static View resolveView(HttpServletRequest request, String viewName, String controllerName, ViewResolver viewResolver) throws Exception {
GrailsWebRequest webRequest = GrailsWebRequest.lookup(request);
Locale locale = webRequest != null ? webRequest.getLocale() : Locale.getDefault() ;
return viewResolver.resolveViewName(addViewPrefix(viewName, controllerName), locale);
} | [
"public",
"static",
"View",
"resolveView",
"(",
"HttpServletRequest",
"request",
",",
"String",
"viewName",
",",
"String",
"controllerName",
",",
"ViewResolver",
"viewResolver",
")",
"throws",
"Exception",
"{",
"GrailsWebRequest",
"webRequest",
"=",
"GrailsWebRequest",
... | Resolves a view for the given view name and controller name
@param request The request
@param viewName The view name
@param controllerName The controller name
@param viewResolver The resolver
@return A View or null
@throws Exception Thrown if an error occurs | [
"Resolves",
"a",
"view",
"for",
"the",
"given",
"view",
"name",
"and",
"controller",
"name"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java#L191-L195 |
32,553 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java | WebUtils.exposeRequestAttributeIfNotPresent | private static void exposeRequestAttributeIfNotPresent(ServletRequest request, String name, Object value) {
if (request.getAttribute(name) == null) {
request.setAttribute(name, value);
}
} | java | private static void exposeRequestAttributeIfNotPresent(ServletRequest request, String name, Object value) {
if (request.getAttribute(name) == null) {
request.setAttribute(name, value);
}
} | [
"private",
"static",
"void",
"exposeRequestAttributeIfNotPresent",
"(",
"ServletRequest",
"request",
",",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"request",
".",
"getAttribute",
"(",
"name",
")",
"==",
"null",
")",
"{",
"request",
".",
... | Expose the specified request attribute if not already present.
@param request current servlet request
@param name the name of the attribute
@param value the suggested value of the attribute | [
"Expose",
"the",
"specified",
"request",
"attribute",
"if",
"not",
"already",
"present",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java#L277-L281 |
32,554 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java | WebUtils.fromQueryString | @SuppressWarnings({ "unchecked", "rawtypes" })
public static Map<String, Object> fromQueryString(String queryString) {
Map<String, Object> result = new LinkedHashMap<String, Object>();
if (queryString.startsWith("?")) queryString = queryString.substring(1);
String[] pairs = queryString.split("&");
for (String pair : pairs) {
int i = pair.indexOf('=');
if (i > -1) {
try {
String name = URLDecoder.decode(pair.substring(0, i), "UTF-8");
String value = URLDecoder.decode(pair.substring(i+1, pair.length()), "UTF-8");
Object current = result.get(name);
if (current instanceof List) {
((List)current).add(value);
}
else if (current != null) {
List multi = new ArrayList();
multi.add(current);
multi.add(value);
result.put(name, multi);
}
else {
result.put(name, value);
}
} catch (UnsupportedEncodingException e) {
// ignore
}
}
}
return result;
} | java | @SuppressWarnings({ "unchecked", "rawtypes" })
public static Map<String, Object> fromQueryString(String queryString) {
Map<String, Object> result = new LinkedHashMap<String, Object>();
if (queryString.startsWith("?")) queryString = queryString.substring(1);
String[] pairs = queryString.split("&");
for (String pair : pairs) {
int i = pair.indexOf('=');
if (i > -1) {
try {
String name = URLDecoder.decode(pair.substring(0, i), "UTF-8");
String value = URLDecoder.decode(pair.substring(i+1, pair.length()), "UTF-8");
Object current = result.get(name);
if (current instanceof List) {
((List)current).add(value);
}
else if (current != null) {
List multi = new ArrayList();
multi.add(current);
multi.add(value);
result.put(name, multi);
}
else {
result.put(name, value);
}
} catch (UnsupportedEncodingException e) {
// ignore
}
}
}
return result;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"fromQueryString",
"(",
"String",
"queryString",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
... | Takes a query string and returns the results as a map where the values are either a single entry or a list of values
@param queryString The query String
@return A map | [
"Takes",
"a",
"query",
"string",
"and",
"returns",
"the",
"results",
"as",
"a",
"map",
"where",
"the",
"values",
"are",
"either",
"a",
"single",
"entry",
"or",
"a",
"list",
"of",
"values"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java#L289-L323 |
32,555 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java | WebUtils.toQueryString | @SuppressWarnings("rawtypes")
public static String toQueryString(Map params, String encoding) throws UnsupportedEncodingException {
if (encoding == null) encoding = "UTF-8";
StringBuilder queryString = new StringBuilder("?");
for (Iterator i = params.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
boolean hasMore = i.hasNext();
boolean wasAppended = appendEntry(entry, queryString, encoding, "");
if (hasMore && wasAppended) queryString.append('&');
}
return queryString.toString();
} | java | @SuppressWarnings("rawtypes")
public static String toQueryString(Map params, String encoding) throws UnsupportedEncodingException {
if (encoding == null) encoding = "UTF-8";
StringBuilder queryString = new StringBuilder("?");
for (Iterator i = params.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
boolean hasMore = i.hasNext();
boolean wasAppended = appendEntry(entry, queryString, encoding, "");
if (hasMore && wasAppended) queryString.append('&');
}
return queryString.toString();
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"static",
"String",
"toQueryString",
"(",
"Map",
"params",
",",
"String",
"encoding",
")",
"throws",
"UnsupportedEncodingException",
"{",
"if",
"(",
"encoding",
"==",
"null",
")",
"encoding",
"=",
"\"U... | Converts the given params into a query string started with ?
@param params The params
@param encoding The encoding to use
@return The query string
@throws UnsupportedEncodingException If the given encoding is not supported | [
"Converts",
"the",
"given",
"params",
"into",
"a",
"query",
"string",
"started",
"with",
"?"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java#L332-L344 |
32,556 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java | WebUtils.areFileExtensionsEnabled | @SuppressWarnings("rawtypes")
public static boolean areFileExtensionsEnabled() {
Config config = GrailsWebUtil.currentApplication().getConfig();
return config.getProperty(ENABLE_FILE_EXTENSIONS, Boolean.class, true);
} | java | @SuppressWarnings("rawtypes")
public static boolean areFileExtensionsEnabled() {
Config config = GrailsWebUtil.currentApplication().getConfig();
return config.getProperty(ENABLE_FILE_EXTENSIONS, Boolean.class, true);
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"static",
"boolean",
"areFileExtensionsEnabled",
"(",
")",
"{",
"Config",
"config",
"=",
"GrailsWebUtil",
".",
"currentApplication",
"(",
")",
".",
"getConfig",
"(",
")",
";",
"return",
"config",
".",
... | Returns the value of the "grails.mime.file.extensions" setting configured in application.groovy
@return true if file extensions are enabled | [
"Returns",
"the",
"value",
"of",
"the",
"grails",
".",
"mime",
".",
"file",
".",
"extensions",
"setting",
"configured",
"in",
"application",
".",
"groovy"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java#L427-L431 |
32,557 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java | WebUtils.storeGrailsWebRequest | public static void storeGrailsWebRequest(GrailsWebRequest webRequest) {
RequestContextHolder.setRequestAttributes(webRequest);
webRequest.getRequest().setAttribute(GrailsApplicationAttributes.WEB_REQUEST, webRequest);
} | java | public static void storeGrailsWebRequest(GrailsWebRequest webRequest) {
RequestContextHolder.setRequestAttributes(webRequest);
webRequest.getRequest().setAttribute(GrailsApplicationAttributes.WEB_REQUEST, webRequest);
} | [
"public",
"static",
"void",
"storeGrailsWebRequest",
"(",
"GrailsWebRequest",
"webRequest",
")",
"{",
"RequestContextHolder",
".",
"setRequestAttributes",
"(",
"webRequest",
")",
";",
"webRequest",
".",
"getRequest",
"(",
")",
".",
"setAttribute",
"(",
"GrailsApplicat... | Helper method to store the given GrailsWebRequest for the current
request. Ensures consistency between RequestContextHolder and the
relevant request attribute. This is the preferred means of updating
the current web request. | [
"Helper",
"method",
"to",
"store",
"the",
"given",
"GrailsWebRequest",
"for",
"the",
"current",
"request",
".",
"Ensures",
"consistency",
"between",
"RequestContextHolder",
"and",
"the",
"relevant",
"request",
"attribute",
".",
"This",
"is",
"the",
"preferred",
"m... | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java#L455-L458 |
32,558 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java | WebUtils.clearGrailsWebRequest | public static void clearGrailsWebRequest() {
RequestAttributes reqAttrs = RequestContextHolder.getRequestAttributes();
if (reqAttrs != null) {
// First remove the web request from the HTTP request attributes.
GrailsWebRequest webRequest = (GrailsWebRequest) reqAttrs;
webRequest.getRequest().removeAttribute(GrailsApplicationAttributes.WEB_REQUEST);
// Now remove it from RequestContextHolder.
RequestContextHolder.resetRequestAttributes();
}
} | java | public static void clearGrailsWebRequest() {
RequestAttributes reqAttrs = RequestContextHolder.getRequestAttributes();
if (reqAttrs != null) {
// First remove the web request from the HTTP request attributes.
GrailsWebRequest webRequest = (GrailsWebRequest) reqAttrs;
webRequest.getRequest().removeAttribute(GrailsApplicationAttributes.WEB_REQUEST);
// Now remove it from RequestContextHolder.
RequestContextHolder.resetRequestAttributes();
}
} | [
"public",
"static",
"void",
"clearGrailsWebRequest",
"(",
")",
"{",
"RequestAttributes",
"reqAttrs",
"=",
"RequestContextHolder",
".",
"getRequestAttributes",
"(",
")",
";",
"if",
"(",
"reqAttrs",
"!=",
"null",
")",
"{",
"// First remove the web request from the HTTP re... | Removes any GrailsWebRequest instance from the current request. | [
"Removes",
"any",
"GrailsWebRequest",
"instance",
"from",
"the",
"current",
"request",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java#L463-L473 |
32,559 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java | WebUtils.getForwardURI | public static String getForwardURI(HttpServletRequest request) {
String result = (String) request.getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE);
if (GrailsStringUtils.isBlank(result)) result = request.getRequestURI();
return result;
} | java | public static String getForwardURI(HttpServletRequest request) {
String result = (String) request.getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE);
if (GrailsStringUtils.isBlank(result)) result = request.getRequestURI();
return result;
} | [
"public",
"static",
"String",
"getForwardURI",
"(",
"HttpServletRequest",
"request",
")",
"{",
"String",
"result",
"=",
"(",
"String",
")",
"request",
".",
"getAttribute",
"(",
"WebUtils",
".",
"FORWARD_REQUEST_URI_ATTRIBUTE",
")",
";",
"if",
"(",
"GrailsStringUti... | Obtains the forwardURI from the request, since Grails uses a forwarding technique for URL mappings. The actual
request URI is held within a request attribute
@param request The request
@return The forward URI | [
"Obtains",
"the",
"forwardURI",
"from",
"the",
"request",
"since",
"Grails",
"uses",
"a",
"forwarding",
"technique",
"for",
"URL",
"mappings",
".",
"The",
"actual",
"request",
"URI",
"is",
"held",
"within",
"a",
"request",
"attribute"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java#L482-L486 |
32,560 | grails/grails-core | grails-encoder/src/main/groovy/org/grails/buffer/StreamCharBuffer.java | StreamCharBuffer.methodMissing | public Object methodMissing(String name, Object args) {
String str = this.toString();
return InvokerHelper.invokeMethod(str, name, args);
} | java | public Object methodMissing(String name, Object args) {
String str = this.toString();
return InvokerHelper.invokeMethod(str, name, args);
} | [
"public",
"Object",
"methodMissing",
"(",
"String",
"name",
",",
"Object",
"args",
")",
"{",
"String",
"str",
"=",
"this",
".",
"toString",
"(",
")",
";",
"return",
"InvokerHelper",
".",
"invokeMethod",
"(",
"str",
",",
"name",
",",
"args",
")",
";",
"... | Delegates methodMissing to String object
@param name The name of the method
@param args The arguments
@return The return value | [
"Delegates",
"methodMissing",
"to",
"String",
"object"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-encoder/src/main/groovy/org/grails/buffer/StreamCharBuffer.java#L2910-L2913 |
32,561 | grails/grails-core | grails-bootstrap/src/main/groovy/org/grails/io/support/AbstractFileResolvingResource.java | AbstractFileResolvingResource.getFile | public File getFile() throws IOException {
URL url = getURL();
return GrailsResourceUtils.getFile(url, getDescription());
} | java | public File getFile() throws IOException {
URL url = getURL();
return GrailsResourceUtils.getFile(url, getDescription());
} | [
"public",
"File",
"getFile",
"(",
")",
"throws",
"IOException",
"{",
"URL",
"url",
"=",
"getURL",
"(",
")",
";",
"return",
"GrailsResourceUtils",
".",
"getFile",
"(",
"url",
",",
"getDescription",
"(",
")",
")",
";",
"}"
] | This implementation returns a File reference for the underlying class path
resource, provided that it refers to a file in the file system. | [
"This",
"implementation",
"returns",
"a",
"File",
"reference",
"for",
"the",
"underlying",
"class",
"path",
"resource",
"provided",
"that",
"it",
"refers",
"to",
"a",
"file",
"in",
"the",
"file",
"system",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-bootstrap/src/main/groovy/org/grails/io/support/AbstractFileResolvingResource.java#L42-L45 |
32,562 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/json/JSONArray.java | JSONArray.put | public JSONArray put(int index, double value) throws JSONException {
put(index, Double.valueOf(value));
return this;
} | java | public JSONArray put(int index, double value) throws JSONException {
put(index, Double.valueOf(value));
return this;
} | [
"public",
"JSONArray",
"put",
"(",
"int",
"index",
",",
"double",
"value",
")",
"throws",
"JSONException",
"{",
"put",
"(",
"index",
",",
"Double",
".",
"valueOf",
"(",
"value",
")",
")",
";",
"return",
"this",
";",
"}"
] | Put or replace a double value. If the index is greater than the length of
the JSONArray, then null elements will be added as necessary to pad
it out.
@param index The subscript.
@param value A double value.
@return this
@throws JSONException If the index is negative or if the value is
not finite. | [
"Put",
"or",
"replace",
"a",
"double",
"value",
".",
"If",
"the",
"index",
"is",
"greater",
"than",
"the",
"length",
"of",
"the",
"JSONArray",
"then",
"null",
"elements",
"will",
"be",
"added",
"as",
"necessary",
"to",
"pad",
"it",
"out",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/json/JSONArray.java#L688-L691 |
32,563 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/json/JSONArray.java | JSONArray.put | public JSONArray put(int index, int value) throws JSONException {
put(index, Integer.valueOf(value));
return this;
} | java | public JSONArray put(int index, int value) throws JSONException {
put(index, Integer.valueOf(value));
return this;
} | [
"public",
"JSONArray",
"put",
"(",
"int",
"index",
",",
"int",
"value",
")",
"throws",
"JSONException",
"{",
"put",
"(",
"index",
",",
"Integer",
".",
"valueOf",
"(",
"value",
")",
")",
";",
"return",
"this",
";",
"}"
] | Put or replace an int value. If the index is greater than the length of
the JSONArray, then null elements will be added as necessary to pad
it out.
@param index The subscript.
@param value An int value.
@return this
@throws JSONException If the index is negative. | [
"Put",
"or",
"replace",
"an",
"int",
"value",
".",
"If",
"the",
"index",
"is",
"greater",
"than",
"the",
"length",
"of",
"the",
"JSONArray",
"then",
"null",
"elements",
"will",
"be",
"added",
"as",
"necessary",
"to",
"pad",
"it",
"out",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/json/JSONArray.java#L704-L707 |
32,564 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/json/JSONArray.java | JSONArray.put | public JSONArray put(int index, long value) throws JSONException {
put(index, Long.valueOf(value));
return this;
} | java | public JSONArray put(int index, long value) throws JSONException {
put(index, Long.valueOf(value));
return this;
} | [
"public",
"JSONArray",
"put",
"(",
"int",
"index",
",",
"long",
"value",
")",
"throws",
"JSONException",
"{",
"put",
"(",
"index",
",",
"Long",
".",
"valueOf",
"(",
"value",
")",
")",
";",
"return",
"this",
";",
"}"
] | Put or replace a long value. If the index is greater than the length of
the JSONArray, then null elements will be added as necessary to pad
it out.
@param index The subscript.
@param value A long value.
@return this
@throws JSONException If the index is negative. | [
"Put",
"or",
"replace",
"a",
"long",
"value",
".",
"If",
"the",
"index",
"is",
"greater",
"than",
"the",
"length",
"of",
"the",
"JSONArray",
"then",
"null",
"elements",
"will",
"be",
"added",
"as",
"necessary",
"to",
"pad",
"it",
"out",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/json/JSONArray.java#L720-L723 |
32,565 | grails/grails-core | grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java | AbstractTypeConvertingMap.getChar | public Character getChar(String name) {
Object o = get(name);
if (o instanceof Character) {
return (Character)o;
}
if (o != null) {
String string = o.toString();
if (string != null && string.length() == 1) {
return string.charAt(0);
}
}
return null;
} | java | public Character getChar(String name) {
Object o = get(name);
if (o instanceof Character) {
return (Character)o;
}
if (o != null) {
String string = o.toString();
if (string != null && string.length() == 1) {
return string.charAt(0);
}
}
return null;
} | [
"public",
"Character",
"getChar",
"(",
"String",
"name",
")",
"{",
"Object",
"o",
"=",
"get",
"(",
"name",
")",
";",
"if",
"(",
"o",
"instanceof",
"Character",
")",
"{",
"return",
"(",
"Character",
")",
"o",
";",
"}",
"if",
"(",
"o",
"!=",
"null",
... | Helper method for obtaining Character value from parameter
@param name The name of the parameter
@return The Character value or null if there isn't one | [
"Helper",
"method",
"for",
"obtaining",
"Character",
"value",
"from",
"parameter"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java#L142-L155 |
32,566 | grails/grails-core | grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java | AbstractTypeConvertingMap.getLong | public Long getLong(String name) {
Object o = get(name);
if (o instanceof Number) {
return ((Number)o).longValue();
}
if (o != null) {
try {
return Long.parseLong(o.toString());
}
catch (NumberFormatException e) {}
}
return null;
} | java | public Long getLong(String name) {
Object o = get(name);
if (o instanceof Number) {
return ((Number)o).longValue();
}
if (o != null) {
try {
return Long.parseLong(o.toString());
}
catch (NumberFormatException e) {}
}
return null;
} | [
"public",
"Long",
"getLong",
"(",
"String",
"name",
")",
"{",
"Object",
"o",
"=",
"get",
"(",
"name",
")",
";",
"if",
"(",
"o",
"instanceof",
"Number",
")",
"{",
"return",
"(",
"(",
"Number",
")",
"o",
")",
".",
"longValue",
"(",
")",
";",
"}",
... | Helper method for obtaining long value from parameter
@param name The name of the parameter
@return The long value or null if there isn't one | [
"Helper",
"method",
"for",
"obtaining",
"long",
"value",
"from",
"parameter"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java#L201-L214 |
32,567 | grails/grails-core | grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java | AbstractTypeConvertingMap.getShort | public Short getShort(String name) {
Object o = get(name);
if (o instanceof Number) {
return ((Number)o).shortValue();
}
if (o != null) {
try {
String string = o.toString();
if (string != null) {
return Short.parseShort(string);
}
}
catch (NumberFormatException e) {}
}
return null;
} | java | public Short getShort(String name) {
Object o = get(name);
if (o instanceof Number) {
return ((Number)o).shortValue();
}
if (o != null) {
try {
String string = o.toString();
if (string != null) {
return Short.parseShort(string);
}
}
catch (NumberFormatException e) {}
}
return null;
} | [
"public",
"Short",
"getShort",
"(",
"String",
"name",
")",
"{",
"Object",
"o",
"=",
"get",
"(",
"name",
")",
";",
"if",
"(",
"o",
"instanceof",
"Number",
")",
"{",
"return",
"(",
"(",
"Number",
")",
"o",
")",
".",
"shortValue",
"(",
")",
";",
"}"... | Helper method for obtaining short value from parameter
@param name The name of the parameter
@return The short value or null if there isn't one | [
"Helper",
"method",
"for",
"obtaining",
"short",
"value",
"from",
"parameter"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java#L229-L245 |
32,568 | grails/grails-core | grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java | AbstractTypeConvertingMap.getDouble | public Double getDouble(String name) {
Object o = get(name);
if (o instanceof Number) {
return ((Number)o).doubleValue();
}
if (o != null) {
try {
String string = o.toString();
if (string != null) {
return Double.parseDouble(string);
}
}
catch (NumberFormatException e) {}
}
return null;
} | java | public Double getDouble(String name) {
Object o = get(name);
if (o instanceof Number) {
return ((Number)o).doubleValue();
}
if (o != null) {
try {
String string = o.toString();
if (string != null) {
return Double.parseDouble(string);
}
}
catch (NumberFormatException e) {}
}
return null;
} | [
"public",
"Double",
"getDouble",
"(",
"String",
"name",
")",
"{",
"Object",
"o",
"=",
"get",
"(",
"name",
")",
";",
"if",
"(",
"o",
"instanceof",
"Number",
")",
"{",
"return",
"(",
"(",
"Number",
")",
"o",
")",
".",
"doubleValue",
"(",
")",
";",
... | Helper method for obtaining double value from parameter
@param name The name of the parameter
@return The double value or null if there isn't one | [
"Helper",
"method",
"for",
"obtaining",
"double",
"value",
"from",
"parameter"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java#L260-L276 |
32,569 | grails/grails-core | grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java | AbstractTypeConvertingMap.getFloat | public Float getFloat(String name) {
Object o = get(name);
if (o instanceof Number) {
return ((Number)o).floatValue();
}
if (o != null) {
try {
String string = o.toString();
if (string != null) {
return Float.parseFloat(string);
}
}
catch (NumberFormatException e) {}
}
return null;
} | java | public Float getFloat(String name) {
Object o = get(name);
if (o instanceof Number) {
return ((Number)o).floatValue();
}
if (o != null) {
try {
String string = o.toString();
if (string != null) {
return Float.parseFloat(string);
}
}
catch (NumberFormatException e) {}
}
return null;
} | [
"public",
"Float",
"getFloat",
"(",
"String",
"name",
")",
"{",
"Object",
"o",
"=",
"get",
"(",
"name",
")",
";",
"if",
"(",
"o",
"instanceof",
"Number",
")",
"{",
"return",
"(",
"(",
"Number",
")",
"o",
")",
".",
"floatValue",
"(",
")",
";",
"}"... | Helper method for obtaining float value from parameter
@param name The name of the parameter
@return The double value or null if there isn't one | [
"Helper",
"method",
"for",
"obtaining",
"float",
"value",
"from",
"parameter"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java#L291-L307 |
32,570 | grails/grails-core | grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java | AbstractTypeConvertingMap.getBoolean | public Boolean getBoolean(String name) {
Object o = get(name);
if (o instanceof Boolean) {
return (Boolean)o;
}
if (o != null) {
try {
String string = o.toString();
if (string != null) {
return GrailsStringUtils.toBoolean(string);
}
}
catch (Exception e) {}
}
return null;
} | java | public Boolean getBoolean(String name) {
Object o = get(name);
if (o instanceof Boolean) {
return (Boolean)o;
}
if (o != null) {
try {
String string = o.toString();
if (string != null) {
return GrailsStringUtils.toBoolean(string);
}
}
catch (Exception e) {}
}
return null;
} | [
"public",
"Boolean",
"getBoolean",
"(",
"String",
"name",
")",
"{",
"Object",
"o",
"=",
"get",
"(",
"name",
")",
";",
"if",
"(",
"o",
"instanceof",
"Boolean",
")",
"{",
"return",
"(",
"Boolean",
")",
"o",
";",
"}",
"if",
"(",
"o",
"!=",
"null",
"... | Helper method for obtaining boolean value from parameter
@param name The name of the parameter
@return The boolean value or null if there isn't one | [
"Helper",
"method",
"for",
"obtaining",
"boolean",
"value",
"from",
"parameter"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java#L322-L338 |
32,571 | grails/grails-core | grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java | AbstractTypeConvertingMap.getDate | public Date getDate(String name, String format) {
Object value = get(name);
if (value instanceof Date) {
return (Date)value;
}
if (value != null) {
try {
return new SimpleDateFormat(format).parse(value.toString());
} catch (ParseException e) {
// ignore
}
}
return null;
} | java | public Date getDate(String name, String format) {
Object value = get(name);
if (value instanceof Date) {
return (Date)value;
}
if (value != null) {
try {
return new SimpleDateFormat(format).parse(value.toString());
} catch (ParseException e) {
// ignore
}
}
return null;
} | [
"public",
"Date",
"getDate",
"(",
"String",
"name",
",",
"String",
"format",
")",
"{",
"Object",
"value",
"=",
"get",
"(",
"name",
")",
";",
"if",
"(",
"value",
"instanceof",
"Date",
")",
"{",
"return",
"(",
"Date",
")",
"value",
";",
"}",
"if",
"(... | Obtains a date from the parameter using the given format
@param name The name
@param format The format
@return The date or null | [
"Obtains",
"a",
"date",
"from",
"the",
"parameter",
"using",
"the",
"given",
"format"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java#L365-L379 |
32,572 | grails/grails-core | grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java | AbstractTypeConvertingMap.date | public Date date(String name, Collection<String> formats) {
return getDate(name, formats);
} | java | public Date date(String name, Collection<String> formats) {
return getDate(name, formats);
} | [
"public",
"Date",
"date",
"(",
"String",
"name",
",",
"Collection",
"<",
"String",
">",
"formats",
")",
"{",
"return",
"getDate",
"(",
"name",
",",
"formats",
")",
";",
"}"
] | Obtains a date for the given parameter name and format
@param name The name of the parameter
@param formats The formats
@return The date object or null if it cannot be parsed | [
"Obtains",
"a",
"date",
"for",
"the",
"given",
"parameter",
"name",
"and",
"format"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java#L409-L411 |
32,573 | grails/grails-core | grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java | AbstractTypeConvertingMap.getList | public List getList(String name) {
Object paramValues = get(name);
if (paramValues == null) {
return Collections.emptyList();
}
if (paramValues.getClass().isArray()) {
return Arrays.asList((Object[])paramValues);
}
if (paramValues instanceof Collection) {
return new ArrayList((Collection)paramValues);
}
return Collections.singletonList(paramValues);
} | java | public List getList(String name) {
Object paramValues = get(name);
if (paramValues == null) {
return Collections.emptyList();
}
if (paramValues.getClass().isArray()) {
return Arrays.asList((Object[])paramValues);
}
if (paramValues instanceof Collection) {
return new ArrayList((Collection)paramValues);
}
return Collections.singletonList(paramValues);
} | [
"public",
"List",
"getList",
"(",
"String",
"name",
")",
"{",
"Object",
"paramValues",
"=",
"get",
"(",
"name",
")",
";",
"if",
"(",
"paramValues",
"==",
"null",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"if",
"(",
"par... | Helper method for obtaining a list of values from parameter
@param name The name of the parameter
@return A list of values | [
"Helper",
"method",
"for",
"obtaining",
"a",
"list",
"of",
"values",
"from",
"parameter"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/AbstractTypeConvertingMap.java#L426-L438 |
32,574 | grails/grails-core | grails-plugin-validation/src/main/groovy/grails/validation/DefaultASTValidateableHelper.java | DefaultASTValidateableHelper.getPropertiesToEnsureConstraintsFor | protected Map<String, ClassNode> getPropertiesToEnsureConstraintsFor(final ClassNode classNode) {
final Map<String, ClassNode> fieldsToConstrain = new HashMap<String, ClassNode>();
final List<FieldNode> allFields = classNode.getFields();
for (final FieldNode field : allFields) {
if (!field.isStatic()) {
final PropertyNode property = classNode.getProperty(field.getName());
if(property != null) {
fieldsToConstrain.put(field.getName(), field.getType());
}
}
}
final Map<String, MethodNode> declaredMethodsMap = classNode.getDeclaredMethodsMap();
for (Entry<String, MethodNode> methodEntry : declaredMethodsMap.entrySet()) {
final MethodNode value = methodEntry.getValue();
if (!value.isStatic() && value.isPublic() && classNode.equals(value.getDeclaringClass()) && value.getLineNumber() > 0) {
Parameter[] parameters = value.getParameters();
if (parameters == null || parameters.length == 0) {
final String methodName = value.getName();
if (methodName.startsWith("get")) {
final ClassNode returnType = value.getReturnType();
final String restOfMethodName = methodName.substring(3);
final String propertyName = GrailsNameUtils.getPropertyName(restOfMethodName);
fieldsToConstrain.put(propertyName, returnType);
}
}
}
}
final ClassNode superClass = classNode.getSuperClass();
if (!superClass.equals(new ClassNode(Object.class))) {
fieldsToConstrain.putAll(getPropertiesToEnsureConstraintsFor(superClass));
}
return fieldsToConstrain;
} | java | protected Map<String, ClassNode> getPropertiesToEnsureConstraintsFor(final ClassNode classNode) {
final Map<String, ClassNode> fieldsToConstrain = new HashMap<String, ClassNode>();
final List<FieldNode> allFields = classNode.getFields();
for (final FieldNode field : allFields) {
if (!field.isStatic()) {
final PropertyNode property = classNode.getProperty(field.getName());
if(property != null) {
fieldsToConstrain.put(field.getName(), field.getType());
}
}
}
final Map<String, MethodNode> declaredMethodsMap = classNode.getDeclaredMethodsMap();
for (Entry<String, MethodNode> methodEntry : declaredMethodsMap.entrySet()) {
final MethodNode value = methodEntry.getValue();
if (!value.isStatic() && value.isPublic() && classNode.equals(value.getDeclaringClass()) && value.getLineNumber() > 0) {
Parameter[] parameters = value.getParameters();
if (parameters == null || parameters.length == 0) {
final String methodName = value.getName();
if (methodName.startsWith("get")) {
final ClassNode returnType = value.getReturnType();
final String restOfMethodName = methodName.substring(3);
final String propertyName = GrailsNameUtils.getPropertyName(restOfMethodName);
fieldsToConstrain.put(propertyName, returnType);
}
}
}
}
final ClassNode superClass = classNode.getSuperClass();
if (!superClass.equals(new ClassNode(Object.class))) {
fieldsToConstrain.putAll(getPropertiesToEnsureConstraintsFor(superClass));
}
return fieldsToConstrain;
} | [
"protected",
"Map",
"<",
"String",
",",
"ClassNode",
">",
"getPropertiesToEnsureConstraintsFor",
"(",
"final",
"ClassNode",
"classNode",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"ClassNode",
">",
"fieldsToConstrain",
"=",
"new",
"HashMap",
"<",
"String",
",... | Retrieves a Map describing all of the properties which need to be constrained for the class
represented by classNode. The keys in the Map will be property names and the values are the
type of the corresponding property.
@param classNode the class to inspect
@return a Map describing all of the properties which need to be constrained | [
"Retrieves",
"a",
"Map",
"describing",
"all",
"of",
"the",
"properties",
"which",
"need",
"to",
"be",
"constrained",
"for",
"the",
"class",
"represented",
"by",
"classNode",
".",
"The",
"keys",
"in",
"the",
"Map",
"will",
"be",
"property",
"names",
"and",
... | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-plugin-validation/src/main/groovy/grails/validation/DefaultASTValidateableHelper.java#L177-L211 |
32,575 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.implementsZeroArgMethod | public static boolean implementsZeroArgMethod(ClassNode classNode, String methodName) {
MethodNode method = classNode.getDeclaredMethod(methodName, Parameter.EMPTY_ARRAY);
return method != null && (method.isPublic() || method.isProtected()) && !method.isAbstract();
} | java | public static boolean implementsZeroArgMethod(ClassNode classNode, String methodName) {
MethodNode method = classNode.getDeclaredMethod(methodName, Parameter.EMPTY_ARRAY);
return method != null && (method.isPublic() || method.isProtected()) && !method.isAbstract();
} | [
"public",
"static",
"boolean",
"implementsZeroArgMethod",
"(",
"ClassNode",
"classNode",
",",
"String",
"methodName",
")",
"{",
"MethodNode",
"method",
"=",
"classNode",
".",
"getDeclaredMethod",
"(",
"methodName",
",",
"Parameter",
".",
"EMPTY_ARRAY",
")",
";",
"... | Tests whether the ClasNode implements the specified method name.
@param classNode The ClassNode
@param methodName The method name
@return true if it does implement the method | [
"Tests",
"whether",
"the",
"ClasNode",
"implements",
"the",
"specified",
"method",
"name",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L163-L166 |
32,576 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.createArgumentListFromParameters | public static ArgumentListExpression createArgumentListFromParameters(Parameter[] parameterTypes, boolean thisAsFirstArgument, Map<String, ClassNode> genericsPlaceholders) {
ArgumentListExpression arguments = new ArgumentListExpression();
if (thisAsFirstArgument) {
arguments.addExpression(new VariableExpression("this"));
}
for (Parameter parameterType : parameterTypes) {
arguments.addExpression(new VariableExpression(parameterType.getName(), replaceGenericsPlaceholders(parameterType.getType(), genericsPlaceholders)));
}
return arguments;
} | java | public static ArgumentListExpression createArgumentListFromParameters(Parameter[] parameterTypes, boolean thisAsFirstArgument, Map<String, ClassNode> genericsPlaceholders) {
ArgumentListExpression arguments = new ArgumentListExpression();
if (thisAsFirstArgument) {
arguments.addExpression(new VariableExpression("this"));
}
for (Parameter parameterType : parameterTypes) {
arguments.addExpression(new VariableExpression(parameterType.getName(), replaceGenericsPlaceholders(parameterType.getType(), genericsPlaceholders)));
}
return arguments;
} | [
"public",
"static",
"ArgumentListExpression",
"createArgumentListFromParameters",
"(",
"Parameter",
"[",
"]",
"parameterTypes",
",",
"boolean",
"thisAsFirstArgument",
",",
"Map",
"<",
"String",
",",
"ClassNode",
">",
"genericsPlaceholders",
")",
"{",
"ArgumentListExpressi... | Creates an argument list from the given parameter types.
@param parameterTypes The parameter types
@param thisAsFirstArgument Whether to include a reference to 'this' as the first argument
@param genericsPlaceholders
@return the arguments | [
"Creates",
"an",
"argument",
"list",
"from",
"the",
"given",
"parameter",
"types",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L333-L344 |
32,577 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.getRemainingParameterTypes | public static Parameter[] getRemainingParameterTypes(Parameter[] parameters) {
if (parameters.length == 0) {
return GrailsArtefactClassInjector.ZERO_PARAMETERS;
}
Parameter[] newParameters = new Parameter[parameters.length - 1];
System.arraycopy(parameters, 1, newParameters, 0, parameters.length - 1);
return newParameters;
} | java | public static Parameter[] getRemainingParameterTypes(Parameter[] parameters) {
if (parameters.length == 0) {
return GrailsArtefactClassInjector.ZERO_PARAMETERS;
}
Parameter[] newParameters = new Parameter[parameters.length - 1];
System.arraycopy(parameters, 1, newParameters, 0, parameters.length - 1);
return newParameters;
} | [
"public",
"static",
"Parameter",
"[",
"]",
"getRemainingParameterTypes",
"(",
"Parameter",
"[",
"]",
"parameters",
")",
"{",
"if",
"(",
"parameters",
".",
"length",
"==",
"0",
")",
"{",
"return",
"GrailsArtefactClassInjector",
".",
"ZERO_PARAMETERS",
";",
"}",
... | Gets the remaining parameters excluding the first parameter in the given list
@param parameters The parameters
@return A new array with the first parameter removed | [
"Gets",
"the",
"remaining",
"parameters",
"excluding",
"the",
"first",
"parameter",
"in",
"the",
"given",
"list"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L352-L360 |
32,578 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.addDelegateStaticMethod | public static MethodNode addDelegateStaticMethod(ClassNode classNode, MethodNode delegateMethod) {
ClassExpression classExpression = new ClassExpression(delegateMethod.getDeclaringClass());
return addDelegateStaticMethod(classExpression, classNode, delegateMethod);
} | java | public static MethodNode addDelegateStaticMethod(ClassNode classNode, MethodNode delegateMethod) {
ClassExpression classExpression = new ClassExpression(delegateMethod.getDeclaringClass());
return addDelegateStaticMethod(classExpression, classNode, delegateMethod);
} | [
"public",
"static",
"MethodNode",
"addDelegateStaticMethod",
"(",
"ClassNode",
"classNode",
",",
"MethodNode",
"delegateMethod",
")",
"{",
"ClassExpression",
"classExpression",
"=",
"new",
"ClassExpression",
"(",
"delegateMethod",
".",
"getDeclaringClass",
"(",
")",
")"... | Adds a static method call to given class node that delegates to the given method
@param classNode The class node
@param delegateMethod The delegate method
@return The added method node or null if it couldn't be added | [
"Adds",
"a",
"static",
"method",
"call",
"to",
"given",
"class",
"node",
"that",
"delegates",
"to",
"the",
"given",
"method"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L369-L372 |
32,579 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.addDelegateConstructor | public static ConstructorNode addDelegateConstructor(ClassNode classNode, MethodNode constructorMethod, Map<String, ClassNode> genericsPlaceholders) {
BlockStatement constructorBody = new BlockStatement();
Parameter[] constructorParams = getRemainingParameterTypes(constructorMethod.getParameters());
ArgumentListExpression arguments = createArgumentListFromParameters(constructorParams, true, genericsPlaceholders);
MethodCallExpression constructCallExpression = new MethodCallExpression(
new ClassExpression(constructorMethod.getDeclaringClass()), "initialize", arguments);
constructCallExpression.setMethodTarget(constructorMethod);
ExpressionStatement constructorInitExpression = new ExpressionStatement(constructCallExpression);
if (constructorParams.length > 0) {
constructorBody.addStatement(new ExpressionStatement(new ConstructorCallExpression(ClassNode.THIS, GrailsArtefactClassInjector.ZERO_ARGS)));
}
constructorBody.addStatement(constructorInitExpression);
if (constructorParams.length == 0) {
// handle default constructor
ConstructorNode constructorNode = getDefaultConstructor(classNode);
if (constructorNode != null) {
List<AnnotationNode> annotations = constructorNode.getAnnotations(new ClassNode(GrailsDelegatingConstructor.class));
if (annotations.size() == 0) {
Statement existingBodyCode = constructorNode.getCode();
if (existingBodyCode instanceof BlockStatement) {
((BlockStatement) existingBodyCode).addStatement(constructorInitExpression);
}
else {
constructorNode.setCode(constructorBody);
}
}
} else {
constructorNode = new ConstructorNode(Modifier.PUBLIC, constructorBody);
classNode.addConstructor(constructorNode);
}
constructorNode.addAnnotation(new AnnotationNode(new ClassNode(GrailsDelegatingConstructor.class)));
return constructorNode;
}
else {
// create new constructor, restoring default constructor if there is none
ConstructorNode cn = findConstructor(classNode, constructorParams);
if (cn == null) {
cn = new ConstructorNode(Modifier.PUBLIC, copyParameters(constructorParams, genericsPlaceholders), null, constructorBody);
classNode.addConstructor(cn);
}
else {
List<AnnotationNode> annotations = cn.getAnnotations(new ClassNode(GrailsDelegatingConstructor.class));
if (annotations.size() == 0) {
Statement code = cn.getCode();
constructorBody.addStatement(code);
cn.setCode(constructorBody);
}
}
ConstructorNode defaultConstructor = getDefaultConstructor(classNode);
if (defaultConstructor == null) {
// add empty
classNode.addConstructor(new ConstructorNode(Modifier.PUBLIC, new BlockStatement()));
}
cn.addAnnotation(new AnnotationNode(new ClassNode(GrailsDelegatingConstructor.class)));
return cn;
}
} | java | public static ConstructorNode addDelegateConstructor(ClassNode classNode, MethodNode constructorMethod, Map<String, ClassNode> genericsPlaceholders) {
BlockStatement constructorBody = new BlockStatement();
Parameter[] constructorParams = getRemainingParameterTypes(constructorMethod.getParameters());
ArgumentListExpression arguments = createArgumentListFromParameters(constructorParams, true, genericsPlaceholders);
MethodCallExpression constructCallExpression = new MethodCallExpression(
new ClassExpression(constructorMethod.getDeclaringClass()), "initialize", arguments);
constructCallExpression.setMethodTarget(constructorMethod);
ExpressionStatement constructorInitExpression = new ExpressionStatement(constructCallExpression);
if (constructorParams.length > 0) {
constructorBody.addStatement(new ExpressionStatement(new ConstructorCallExpression(ClassNode.THIS, GrailsArtefactClassInjector.ZERO_ARGS)));
}
constructorBody.addStatement(constructorInitExpression);
if (constructorParams.length == 0) {
// handle default constructor
ConstructorNode constructorNode = getDefaultConstructor(classNode);
if (constructorNode != null) {
List<AnnotationNode> annotations = constructorNode.getAnnotations(new ClassNode(GrailsDelegatingConstructor.class));
if (annotations.size() == 0) {
Statement existingBodyCode = constructorNode.getCode();
if (existingBodyCode instanceof BlockStatement) {
((BlockStatement) existingBodyCode).addStatement(constructorInitExpression);
}
else {
constructorNode.setCode(constructorBody);
}
}
} else {
constructorNode = new ConstructorNode(Modifier.PUBLIC, constructorBody);
classNode.addConstructor(constructorNode);
}
constructorNode.addAnnotation(new AnnotationNode(new ClassNode(GrailsDelegatingConstructor.class)));
return constructorNode;
}
else {
// create new constructor, restoring default constructor if there is none
ConstructorNode cn = findConstructor(classNode, constructorParams);
if (cn == null) {
cn = new ConstructorNode(Modifier.PUBLIC, copyParameters(constructorParams, genericsPlaceholders), null, constructorBody);
classNode.addConstructor(cn);
}
else {
List<AnnotationNode> annotations = cn.getAnnotations(new ClassNode(GrailsDelegatingConstructor.class));
if (annotations.size() == 0) {
Statement code = cn.getCode();
constructorBody.addStatement(code);
cn.setCode(constructorBody);
}
}
ConstructorNode defaultConstructor = getDefaultConstructor(classNode);
if (defaultConstructor == null) {
// add empty
classNode.addConstructor(new ConstructorNode(Modifier.PUBLIC, new BlockStatement()));
}
cn.addAnnotation(new AnnotationNode(new ClassNode(GrailsDelegatingConstructor.class)));
return cn;
}
} | [
"public",
"static",
"ConstructorNode",
"addDelegateConstructor",
"(",
"ClassNode",
"classNode",
",",
"MethodNode",
"constructorMethod",
",",
"Map",
"<",
"String",
",",
"ClassNode",
">",
"genericsPlaceholders",
")",
"{",
"BlockStatement",
"constructorBody",
"=",
"new",
... | Adds or modifies an existing constructor to delegate to the
given static constructor method for initialization logic.
@param classNode The class node
@param constructorMethod The constructor static method | [
"Adds",
"or",
"modifies",
"an",
"existing",
"constructor",
"to",
"delegate",
"to",
"the",
"given",
"static",
"constructor",
"method",
"for",
"initialization",
"logic",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L443-L502 |
32,580 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.findConstructor | public static ConstructorNode findConstructor(ClassNode classNode,Parameter[] constructorParams) {
List<ConstructorNode> declaredConstructors = classNode.getDeclaredConstructors();
for (ConstructorNode declaredConstructor : declaredConstructors) {
if (parametersEqual(constructorParams, declaredConstructor.getParameters())) {
return declaredConstructor;
}
}
return null;
} | java | public static ConstructorNode findConstructor(ClassNode classNode,Parameter[] constructorParams) {
List<ConstructorNode> declaredConstructors = classNode.getDeclaredConstructors();
for (ConstructorNode declaredConstructor : declaredConstructors) {
if (parametersEqual(constructorParams, declaredConstructor.getParameters())) {
return declaredConstructor;
}
}
return null;
} | [
"public",
"static",
"ConstructorNode",
"findConstructor",
"(",
"ClassNode",
"classNode",
",",
"Parameter",
"[",
"]",
"constructorParams",
")",
"{",
"List",
"<",
"ConstructorNode",
">",
"declaredConstructors",
"=",
"classNode",
".",
"getDeclaredConstructors",
"(",
")",... | Finds a constructor for the given class node and parameter types
@param classNode The class node
@param constructorParams The parameter types
@return The located constructor or null | [
"Finds",
"a",
"constructor",
"for",
"the",
"given",
"class",
"node",
"and",
"parameter",
"types"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L511-L519 |
32,581 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.getDefaultConstructor | public static ConstructorNode getDefaultConstructor(ClassNode classNode) {
for (ConstructorNode cons : classNode.getDeclaredConstructors()) {
if (cons.getParameters().length == 0) {
return cons;
}
}
return null;
} | java | public static ConstructorNode getDefaultConstructor(ClassNode classNode) {
for (ConstructorNode cons : classNode.getDeclaredConstructors()) {
if (cons.getParameters().length == 0) {
return cons;
}
}
return null;
} | [
"public",
"static",
"ConstructorNode",
"getDefaultConstructor",
"(",
"ClassNode",
"classNode",
")",
"{",
"for",
"(",
"ConstructorNode",
"cons",
":",
"classNode",
".",
"getDeclaredConstructors",
"(",
")",
")",
"{",
"if",
"(",
"cons",
".",
"getParameters",
"(",
")... | Obtains the default constructor for the given class node.
@param classNode The class node
@return The default constructor or null if there isn't one | [
"Obtains",
"the",
"default",
"constructor",
"for",
"the",
"given",
"class",
"node",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L544-L551 |
32,582 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.isAssignableFrom | public static boolean isAssignableFrom(ClassNode superClass, ClassNode childClass) {
ClassNode currentSuper = childClass;
while (currentSuper != null) {
if (currentSuper.equals(superClass)) {
return true;
}
currentSuper = currentSuper.getSuperClass();
}
return false;
} | java | public static boolean isAssignableFrom(ClassNode superClass, ClassNode childClass) {
ClassNode currentSuper = childClass;
while (currentSuper != null) {
if (currentSuper.equals(superClass)) {
return true;
}
currentSuper = currentSuper.getSuperClass();
}
return false;
} | [
"public",
"static",
"boolean",
"isAssignableFrom",
"(",
"ClassNode",
"superClass",
",",
"ClassNode",
"childClass",
")",
"{",
"ClassNode",
"currentSuper",
"=",
"childClass",
";",
"while",
"(",
"currentSuper",
"!=",
"null",
")",
"{",
"if",
"(",
"currentSuper",
"."... | Determines if the class or interface represented by the superClass
argument is either the same as, or is a superclass or superinterface of,
the class or interface represented by the specified subClass parameter.
@param superClass The super class to check
@param childClass The sub class the check
@return true if the childClass is either equal to or a sub class of the specified superClass | [
"Determines",
"if",
"the",
"class",
"or",
"interface",
"represented",
"by",
"the",
"superClass",
"argument",
"is",
"either",
"the",
"same",
"as",
"or",
"is",
"a",
"superclass",
"or",
"superinterface",
"of",
"the",
"class",
"or",
"interface",
"represented",
"by... | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L655-L665 |
32,583 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.addExpressionToAnnotationMember | public static void addExpressionToAnnotationMember(AnnotationNode annotationNode, String memberName, Expression expression) {
Expression exclude = annotationNode.getMember(memberName);
if(exclude instanceof ListExpression) {
((ListExpression)exclude).addExpression(expression);
}
else if(exclude != null) {
ListExpression list = new ListExpression();
list.addExpression(exclude);
list.addExpression(expression);
annotationNode.setMember(memberName, list);
}
else {
annotationNode.setMember(memberName, expression);
}
} | java | public static void addExpressionToAnnotationMember(AnnotationNode annotationNode, String memberName, Expression expression) {
Expression exclude = annotationNode.getMember(memberName);
if(exclude instanceof ListExpression) {
((ListExpression)exclude).addExpression(expression);
}
else if(exclude != null) {
ListExpression list = new ListExpression();
list.addExpression(exclude);
list.addExpression(expression);
annotationNode.setMember(memberName, list);
}
else {
annotationNode.setMember(memberName, expression);
}
} | [
"public",
"static",
"void",
"addExpressionToAnnotationMember",
"(",
"AnnotationNode",
"annotationNode",
",",
"String",
"memberName",
",",
"Expression",
"expression",
")",
"{",
"Expression",
"exclude",
"=",
"annotationNode",
".",
"getMember",
"(",
"memberName",
")",
";... | Adds the given expression as a member of the given annotation
@param annotationNode The annotation node
@param memberName The name of the member
@param expression The expression | [
"Adds",
"the",
"given",
"expression",
"as",
"a",
"member",
"of",
"the",
"given",
"annotation"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L794-L808 |
32,584 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.addEnhancedAnnotation | public static AnnotationNode addEnhancedAnnotation(final ClassNode classNode, final String... enhancedFor) {
final AnnotationNode enhancedAnnotationNode;
final List<AnnotationNode> annotations = classNode.getAnnotations(ENHANCED_CLASS_NODE);
if (annotations.isEmpty()) {
enhancedAnnotationNode = new AnnotationNode(ENHANCED_CLASS_NODE);
String grailsVersion = getGrailsVersion();
if(grailsVersion == null) {
grailsVersion = System.getProperty("grails.version");
}
if(grailsVersion != null) {
enhancedAnnotationNode.setMember("version", new ConstantExpression(grailsVersion));
}
classNode.addAnnotation(enhancedAnnotationNode);
} else {
enhancedAnnotationNode = annotations.get(0);
}
if(enhancedFor != null && enhancedFor.length > 0) {
ListExpression enhancedForArray = (ListExpression) enhancedAnnotationNode.getMember("enhancedFor");
if(enhancedForArray == null) {
enhancedForArray = new ListExpression();
enhancedAnnotationNode.setMember("enhancedFor", enhancedForArray);
}
final List<Expression> featureNameExpressions = enhancedForArray.getExpressions();
for(final String feature : enhancedFor) {
boolean exists = false;
for(Expression expression : featureNameExpressions) {
if(expression instanceof ConstantExpression && feature.equals(((ConstantExpression)expression).getValue())) {
exists = true;
break;
}
}
if(!exists) {
featureNameExpressions.add(new ConstantExpression(feature));
}
}
}
return enhancedAnnotationNode;
} | java | public static AnnotationNode addEnhancedAnnotation(final ClassNode classNode, final String... enhancedFor) {
final AnnotationNode enhancedAnnotationNode;
final List<AnnotationNode> annotations = classNode.getAnnotations(ENHANCED_CLASS_NODE);
if (annotations.isEmpty()) {
enhancedAnnotationNode = new AnnotationNode(ENHANCED_CLASS_NODE);
String grailsVersion = getGrailsVersion();
if(grailsVersion == null) {
grailsVersion = System.getProperty("grails.version");
}
if(grailsVersion != null) {
enhancedAnnotationNode.setMember("version", new ConstantExpression(grailsVersion));
}
classNode.addAnnotation(enhancedAnnotationNode);
} else {
enhancedAnnotationNode = annotations.get(0);
}
if(enhancedFor != null && enhancedFor.length > 0) {
ListExpression enhancedForArray = (ListExpression) enhancedAnnotationNode.getMember("enhancedFor");
if(enhancedForArray == null) {
enhancedForArray = new ListExpression();
enhancedAnnotationNode.setMember("enhancedFor", enhancedForArray);
}
final List<Expression> featureNameExpressions = enhancedForArray.getExpressions();
for(final String feature : enhancedFor) {
boolean exists = false;
for(Expression expression : featureNameExpressions) {
if(expression instanceof ConstantExpression && feature.equals(((ConstantExpression)expression).getValue())) {
exists = true;
break;
}
}
if(!exists) {
featureNameExpressions.add(new ConstantExpression(feature));
}
}
}
return enhancedAnnotationNode;
} | [
"public",
"static",
"AnnotationNode",
"addEnhancedAnnotation",
"(",
"final",
"ClassNode",
"classNode",
",",
"final",
"String",
"...",
"enhancedFor",
")",
"{",
"final",
"AnnotationNode",
"enhancedAnnotationNode",
";",
"final",
"List",
"<",
"AnnotationNode",
">",
"annot... | Add the grails.artefact.Enhanced annotation to classNode if it does not already exist and ensure that
all of the features in the enhancedFor array are represented in the enhancedFor attribute of the
Enhanced annnotation
@param classNode the class to add the Enhanced annotation to
@param enhancedFor an array of feature names to include in the enhancedFor attribute of the annotation
@return the AnnotationNode associated with the Enhanced annotation for classNode
@see Enhanced | [
"Add",
"the",
"grails",
".",
"artefact",
".",
"Enhanced",
"annotation",
"to",
"classNode",
"if",
"it",
"does",
"not",
"already",
"exist",
"and",
"ensure",
"that",
"all",
"of",
"the",
"features",
"in",
"the",
"enhancedFor",
"array",
"are",
"represented",
"in"... | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L880-L919 |
32,585 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.hasAnnotation | public static boolean hasAnnotation(final ClassNode classNode, final Class<? extends Annotation> annotationClass) {
return !classNode.getAnnotations(new ClassNode(annotationClass)).isEmpty();
} | java | public static boolean hasAnnotation(final ClassNode classNode, final Class<? extends Annotation> annotationClass) {
return !classNode.getAnnotations(new ClassNode(annotationClass)).isEmpty();
} | [
"public",
"static",
"boolean",
"hasAnnotation",
"(",
"final",
"ClassNode",
"classNode",
",",
"final",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationClass",
")",
"{",
"return",
"!",
"classNode",
".",
"getAnnotations",
"(",
"new",
"ClassNode",
"(",
... | Returns true if classNode is marked with annotationClass
@param classNode A ClassNode to inspect
@param annotationClass an annotation to look for
@return true if classNode is marked with annotationClass, otherwise false | [
"Returns",
"true",
"if",
"classNode",
"is",
"marked",
"with",
"annotationClass"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L945-L947 |
32,586 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.hasAnnotation | public static boolean hasAnnotation(final MethodNode methodNode, final Class<? extends Annotation> annotationClass) {
return !methodNode.getAnnotations(new ClassNode(annotationClass)).isEmpty();
} | java | public static boolean hasAnnotation(final MethodNode methodNode, final Class<? extends Annotation> annotationClass) {
return !methodNode.getAnnotations(new ClassNode(annotationClass)).isEmpty();
} | [
"public",
"static",
"boolean",
"hasAnnotation",
"(",
"final",
"MethodNode",
"methodNode",
",",
"final",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationClass",
")",
"{",
"return",
"!",
"methodNode",
".",
"getAnnotations",
"(",
"new",
"ClassNode",
"("... | Returns true if MethodNode is marked with annotationClass
@param methodNode A MethodNode to inspect
@param annotationClass an annotation to look for
@return true if classNode is marked with annotationClass, otherwise false | [
"Returns",
"true",
"if",
"MethodNode",
"is",
"marked",
"with",
"annotationClass"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L955-L957 |
32,587 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.getAssocationMap | public static Map<String, ClassNode> getAssocationMap(ClassNode classNode, String associationType) {
PropertyNode property = classNode.getProperty(associationType);
Map<String, ClassNode> associationMap = new HashMap<String, ClassNode>();
if (property != null && property.isStatic()) {
Expression e = property.getInitialExpression();
if (e instanceof MapExpression) {
MapExpression me = (MapExpression) e;
for (MapEntryExpression mee : me.getMapEntryExpressions()) {
String key = mee.getKeyExpression().getText();
Expression valueExpression = mee.getValueExpression();
if (valueExpression instanceof ClassExpression) {
associationMap.put(key, valueExpression.getType());
}
}
}
}
return associationMap;
} | java | public static Map<String, ClassNode> getAssocationMap(ClassNode classNode, String associationType) {
PropertyNode property = classNode.getProperty(associationType);
Map<String, ClassNode> associationMap = new HashMap<String, ClassNode>();
if (property != null && property.isStatic()) {
Expression e = property.getInitialExpression();
if (e instanceof MapExpression) {
MapExpression me = (MapExpression) e;
for (MapEntryExpression mee : me.getMapEntryExpressions()) {
String key = mee.getKeyExpression().getText();
Expression valueExpression = mee.getValueExpression();
if (valueExpression instanceof ClassExpression) {
associationMap.put(key, valueExpression.getType());
}
}
}
}
return associationMap;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"ClassNode",
">",
"getAssocationMap",
"(",
"ClassNode",
"classNode",
",",
"String",
"associationType",
")",
"{",
"PropertyNode",
"property",
"=",
"classNode",
".",
"getProperty",
"(",
"associationType",
")",
";",
"M... | Returns a map containing the names and types of the given association type. eg. GrailsDomainClassProperty.HAS_MANY
@param classNode The target class ndoe
@param associationType The associationType
@return A map | [
"Returns",
"a",
"map",
"containing",
"the",
"names",
"and",
"types",
"of",
"the",
"given",
"association",
"type",
".",
"eg",
".",
"GrailsDomainClassProperty",
".",
"HAS_MANY"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L1082-L1099 |
32,588 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.isSubclassOf | public static boolean isSubclassOf(ClassNode classNode, String parentClassName) {
ClassNode currentSuper = classNode.getSuperClass();
while (currentSuper != null && !currentSuper.getName().equals(OBJECT_CLASS)) {
if (currentSuper.getName().equals(parentClassName)) return true;
currentSuper = currentSuper.getSuperClass();
}
return false;
} | java | public static boolean isSubclassOf(ClassNode classNode, String parentClassName) {
ClassNode currentSuper = classNode.getSuperClass();
while (currentSuper != null && !currentSuper.getName().equals(OBJECT_CLASS)) {
if (currentSuper.getName().equals(parentClassName)) return true;
currentSuper = currentSuper.getSuperClass();
}
return false;
} | [
"public",
"static",
"boolean",
"isSubclassOf",
"(",
"ClassNode",
"classNode",
",",
"String",
"parentClassName",
")",
"{",
"ClassNode",
"currentSuper",
"=",
"classNode",
".",
"getSuperClass",
"(",
")",
";",
"while",
"(",
"currentSuper",
"!=",
"null",
"&&",
"!",
... | Returns true if the given class name is a parent class of the given class
@param classNode The class node
@param parentClassName the parent class name
@return True if it is a subclass | [
"Returns",
"true",
"if",
"the",
"given",
"class",
"name",
"is",
"a",
"parent",
"class",
"of",
"the",
"given",
"class"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L1148-L1155 |
32,589 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.buildSetPropertyExpression | public static MethodCallExpression buildSetPropertyExpression(final Expression objectExpression, final String propertyName, final ClassNode targetClassNode, final Expression valueExpression) {
String methodName = "set" + MetaClassHelper.capitalize(propertyName);
MethodCallExpression methodCallExpression = new MethodCallExpression(objectExpression, methodName, new ArgumentListExpression(valueExpression));
MethodNode setterMethod = targetClassNode.getSetterMethod(methodName);
if(setterMethod != null) {
methodCallExpression.setMethodTarget(setterMethod);
}
return methodCallExpression;
} | java | public static MethodCallExpression buildSetPropertyExpression(final Expression objectExpression, final String propertyName, final ClassNode targetClassNode, final Expression valueExpression) {
String methodName = "set" + MetaClassHelper.capitalize(propertyName);
MethodCallExpression methodCallExpression = new MethodCallExpression(objectExpression, methodName, new ArgumentListExpression(valueExpression));
MethodNode setterMethod = targetClassNode.getSetterMethod(methodName);
if(setterMethod != null) {
methodCallExpression.setMethodTarget(setterMethod);
}
return methodCallExpression;
} | [
"public",
"static",
"MethodCallExpression",
"buildSetPropertyExpression",
"(",
"final",
"Expression",
"objectExpression",
",",
"final",
"String",
"propertyName",
",",
"final",
"ClassNode",
"targetClassNode",
",",
"final",
"Expression",
"valueExpression",
")",
"{",
"String... | Build static direct call to setter of a property
@param objectExpression
@param propertyName
@param targetClassNode
@param valueExpression
@return The method call expression | [
"Build",
"static",
"direct",
"call",
"to",
"setter",
"of",
"a",
"property"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L1333-L1341 |
32,590 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.buildPutMapExpression | public static MethodCallExpression buildPutMapExpression(final Expression objectExpression, final String keyName, final Expression valueExpression) {
return applyDefaultMethodTarget(new MethodCallExpression(objectExpression, "put", new ArgumentListExpression(new ConstantExpression(keyName), valueExpression)), Map.class);
} | java | public static MethodCallExpression buildPutMapExpression(final Expression objectExpression, final String keyName, final Expression valueExpression) {
return applyDefaultMethodTarget(new MethodCallExpression(objectExpression, "put", new ArgumentListExpression(new ConstantExpression(keyName), valueExpression)), Map.class);
} | [
"public",
"static",
"MethodCallExpression",
"buildPutMapExpression",
"(",
"final",
"Expression",
"objectExpression",
",",
"final",
"String",
"keyName",
",",
"final",
"Expression",
"valueExpression",
")",
"{",
"return",
"applyDefaultMethodTarget",
"(",
"new",
"MethodCallEx... | Build static direct call to put entry in Map
@param objectExpression
@param keyName
@param valueExpression
@return The method call expression | [
"Build",
"static",
"direct",
"call",
"to",
"put",
"entry",
"in",
"Map"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L1351-L1353 |
32,591 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.buildGetMapExpression | public static MethodCallExpression buildGetMapExpression(final Expression objectExpression, final String keyName) {
return applyDefaultMethodTarget(new MethodCallExpression(objectExpression, "get", new ArgumentListExpression(new ConstantExpression(keyName))), Map.class);
} | java | public static MethodCallExpression buildGetMapExpression(final Expression objectExpression, final String keyName) {
return applyDefaultMethodTarget(new MethodCallExpression(objectExpression, "get", new ArgumentListExpression(new ConstantExpression(keyName))), Map.class);
} | [
"public",
"static",
"MethodCallExpression",
"buildGetMapExpression",
"(",
"final",
"Expression",
"objectExpression",
",",
"final",
"String",
"keyName",
")",
"{",
"return",
"applyDefaultMethodTarget",
"(",
"new",
"MethodCallExpression",
"(",
"objectExpression",
",",
"\"get... | Build static direct call to get entry from Map
@param objectExpression
@param keyName
@return The method call expression | [
"Build",
"static",
"direct",
"call",
"to",
"get",
"entry",
"from",
"Map"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L1362-L1364 |
32,592 | grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.getSourceUrl | public static URL getSourceUrl(SourceUnit source) {
URL url = null;
final String filename = source.getName();
if(filename==null) {
return null;
}
Resource resource = new FileSystemResource(filename);
if (resource.exists()) {
try {
url = resource.getURL();
} catch (IOException e) {
// ignore
}
}
return url;
} | java | public static URL getSourceUrl(SourceUnit source) {
URL url = null;
final String filename = source.getName();
if(filename==null) {
return null;
}
Resource resource = new FileSystemResource(filename);
if (resource.exists()) {
try {
url = resource.getURL();
} catch (IOException e) {
// ignore
}
}
return url;
} | [
"public",
"static",
"URL",
"getSourceUrl",
"(",
"SourceUnit",
"source",
")",
"{",
"URL",
"url",
"=",
"null",
";",
"final",
"String",
"filename",
"=",
"source",
".",
"getName",
"(",
")",
";",
"if",
"(",
"filename",
"==",
"null",
")",
"{",
"return",
"nul... | Find URL of SourceUnit
source.getSource().getURI() fails in Groovy-Eclipse compiler
@param source
@return URL of SourceUnit | [
"Find",
"URL",
"of",
"SourceUnit"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L1488-L1504 |
32,593 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/json/JSONWriter.java | JSONWriter.value | public JSONWriter value(Number number) {
return number != null ? append(number.toString()) : valueNull();
} | java | public JSONWriter value(Number number) {
return number != null ? append(number.toString()) : valueNull();
} | [
"public",
"JSONWriter",
"value",
"(",
"Number",
"number",
")",
"{",
"return",
"number",
"!=",
"null",
"?",
"append",
"(",
"number",
".",
"toString",
"(",
")",
")",
":",
"valueNull",
"(",
")",
";",
"}"
] | Append a number value
@param number
@return | [
"Append",
"a",
"number",
"value"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/json/JSONWriter.java#L327-L329 |
32,594 | grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/json/JSONWriter.java | JSONWriter.value | public JSONWriter value(Object o) {
return o != null ? append(new QuotedWritable(o)) : valueNull();
} | java | public JSONWriter value(Object o) {
return o != null ? append(new QuotedWritable(o)) : valueNull();
} | [
"public",
"JSONWriter",
"value",
"(",
"Object",
"o",
")",
"{",
"return",
"o",
"!=",
"null",
"?",
"append",
"(",
"new",
"QuotedWritable",
"(",
"o",
")",
")",
":",
"valueNull",
"(",
")",
";",
"}"
] | Append an object value.
@param o The object to append. It can be null, or a Boolean, Number,
String, JSONObject, or JSONArray.
@return this | [
"Append",
"an",
"object",
"value",
"."
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/json/JSONWriter.java#L352-L354 |
32,595 | grails/grails-core | grails-web-databinding/src/main/groovy/grails/web/databinding/DataBindingUtils.java | DataBindingUtils.assignBidirectionalAssociations | public static void assignBidirectionalAssociations(Object object, Map source, PersistentEntity persistentEntity) {
if (source == null) {
return;
}
for (Object key : source.keySet()) {
String propertyName = key.toString();
if (propertyName.indexOf('.') > -1) {
propertyName = propertyName.substring(0, propertyName.indexOf('.'));
}
PersistentProperty prop = persistentEntity.getPropertyByName(propertyName);
if (prop != null && prop instanceof OneToOne && ((OneToOne) prop).isBidirectional()) {
Object val = source.get(key);
PersistentProperty otherSide = ((OneToOne) prop).getInverseSide();
if (val != null && otherSide != null) {
MetaClass mc = GroovySystem.getMetaClassRegistry().getMetaClass(val.getClass());
try {
mc.setProperty(val, otherSide.getName(), object);
}
catch (Exception e) {
// ignore
}
}
}
}
} | java | public static void assignBidirectionalAssociations(Object object, Map source, PersistentEntity persistentEntity) {
if (source == null) {
return;
}
for (Object key : source.keySet()) {
String propertyName = key.toString();
if (propertyName.indexOf('.') > -1) {
propertyName = propertyName.substring(0, propertyName.indexOf('.'));
}
PersistentProperty prop = persistentEntity.getPropertyByName(propertyName);
if (prop != null && prop instanceof OneToOne && ((OneToOne) prop).isBidirectional()) {
Object val = source.get(key);
PersistentProperty otherSide = ((OneToOne) prop).getInverseSide();
if (val != null && otherSide != null) {
MetaClass mc = GroovySystem.getMetaClassRegistry().getMetaClass(val.getClass());
try {
mc.setProperty(val, otherSide.getName(), object);
}
catch (Exception e) {
// ignore
}
}
}
}
} | [
"public",
"static",
"void",
"assignBidirectionalAssociations",
"(",
"Object",
"object",
",",
"Map",
"source",
",",
"PersistentEntity",
"persistentEntity",
")",
"{",
"if",
"(",
"source",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"Object",
"key",
... | Associations both sides of any bidirectional relationships found in the object and source map to bind
@param object The object
@param source The source map
@param persistentEntity The PersistentEntity for the object | [
"Associations",
"both",
"sides",
"of",
"any",
"bidirectional",
"relationships",
"found",
"in",
"the",
"object",
"and",
"source",
"map",
"to",
"bind"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-databinding/src/main/groovy/grails/web/databinding/DataBindingUtils.java#L74-L101 |
32,596 | grails/grails-core | grails-web-databinding/src/main/groovy/grails/web/databinding/DataBindingUtils.java | DataBindingUtils.bindToCollection | public static <T> void bindToCollection(final Class<T> targetType, final Collection<T> collectionToPopulate, final CollectionDataBindingSource collectionBindingSource) throws InstantiationException, IllegalAccessException {
final GrailsApplication application = Holders.findApplication();
PersistentEntity entity = null;
if (application != null) {
try {
entity = application.getMappingContext().getPersistentEntity(targetType.getClass().getName());
} catch (GrailsConfigurationException e) {
//no-op
}
}
final List<DataBindingSource> dataBindingSources = collectionBindingSource.getDataBindingSources();
for(final DataBindingSource dataBindingSource : dataBindingSources) {
final T newObject = targetType.newInstance();
bindObjectToDomainInstance(entity, newObject, dataBindingSource, getBindingIncludeList(newObject), Collections.emptyList(), null);
collectionToPopulate.add(newObject);
}
} | java | public static <T> void bindToCollection(final Class<T> targetType, final Collection<T> collectionToPopulate, final CollectionDataBindingSource collectionBindingSource) throws InstantiationException, IllegalAccessException {
final GrailsApplication application = Holders.findApplication();
PersistentEntity entity = null;
if (application != null) {
try {
entity = application.getMappingContext().getPersistentEntity(targetType.getClass().getName());
} catch (GrailsConfigurationException e) {
//no-op
}
}
final List<DataBindingSource> dataBindingSources = collectionBindingSource.getDataBindingSources();
for(final DataBindingSource dataBindingSource : dataBindingSources) {
final T newObject = targetType.newInstance();
bindObjectToDomainInstance(entity, newObject, dataBindingSource, getBindingIncludeList(newObject), Collections.emptyList(), null);
collectionToPopulate.add(newObject);
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"bindToCollection",
"(",
"final",
"Class",
"<",
"T",
">",
"targetType",
",",
"final",
"Collection",
"<",
"T",
">",
"collectionToPopulate",
",",
"final",
"CollectionDataBindingSource",
"collectionBindingSource",
")",
"thro... | For each DataBindingSource provided by collectionBindingSource a new instance of targetType is created,
data binding is imposed on that instance with the DataBindingSource and the instance is added to the end of
collectionToPopulate
@param targetType The type of objects to create, must be a concrete class
@param collectionToPopulate A collection to populate with new instances of targetType
@param collectionBindingSource A CollectionDataBindingSource
@since 2.3 | [
"For",
"each",
"DataBindingSource",
"provided",
"by",
"collectionBindingSource",
"a",
"new",
"instance",
"of",
"targetType",
"is",
"created",
"data",
"binding",
"is",
"imposed",
"on",
"that",
"instance",
"with",
"the",
"DataBindingSource",
"and",
"the",
"instance",
... | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-databinding/src/main/groovy/grails/web/databinding/DataBindingUtils.java#L164-L180 |
32,597 | grails/grails-core | grails-core/src/main/groovy/org/grails/core/DefaultGrailsControllerClass.java | DefaultGrailsControllerClass.invoke | @Override
public Object invoke(Object controller, String action) throws Throwable {
if(action == null) action = this.defaultActionName;
ActionInvoker handle = actions.get(action);
if(handle == null) throw new IllegalArgumentException("Invalid action name: " + action);
return handle.invoke(controller);
} | java | @Override
public Object invoke(Object controller, String action) throws Throwable {
if(action == null) action = this.defaultActionName;
ActionInvoker handle = actions.get(action);
if(handle == null) throw new IllegalArgumentException("Invalid action name: " + action);
return handle.invoke(controller);
} | [
"@",
"Override",
"public",
"Object",
"invoke",
"(",
"Object",
"controller",
",",
"String",
"action",
")",
"throws",
"Throwable",
"{",
"if",
"(",
"action",
"==",
"null",
")",
"action",
"=",
"this",
".",
"defaultActionName",
";",
"ActionInvoker",
"handle",
"="... | Invokes the controller action for the given name on the given controller instance
@param controller The controller instance
@param action The action name
@return The result of the action
@throws Throwable | [
"Invokes",
"the",
"controller",
"action",
"for",
"the",
"given",
"name",
"on",
"the",
"given",
"controller",
"instance"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/core/DefaultGrailsControllerClass.java#L183-L189 |
32,598 | grails/grails-core | grails-web/src/main/groovy/org/grails/web/servlet/context/GrailsConfigUtils.java | GrailsConfigUtils.isConfigTrue | public static boolean isConfigTrue(GrailsApplication application, String propertyName) {
return application.getConfig().getProperty(propertyName, Boolean.class, false);
} | java | public static boolean isConfigTrue(GrailsApplication application, String propertyName) {
return application.getConfig().getProperty(propertyName, Boolean.class, false);
} | [
"public",
"static",
"boolean",
"isConfigTrue",
"(",
"GrailsApplication",
"application",
",",
"String",
"propertyName",
")",
"{",
"return",
"application",
".",
"getConfig",
"(",
")",
".",
"getProperty",
"(",
"propertyName",
",",
"Boolean",
".",
"class",
",",
"fal... | Checks if a Config parameter is true or a System property with the same name is true
@param application
@param propertyName
@return true if the Config parameter is true or the System property with the same name is true | [
"Checks",
"if",
"a",
"Config",
"parameter",
"is",
"true",
"or",
"a",
"System",
"property",
"with",
"the",
"same",
"name",
"is",
"true"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web/src/main/groovy/org/grails/web/servlet/context/GrailsConfigUtils.java#L117-L119 |
32,599 | grails/grails-core | grails-core/src/main/groovy/org/grails/spring/context/support/ReloadableResourceBundleMessageSource.java | ReloadableResourceBundleMessageSource.getBundleCodes | public Set<String> getBundleCodes(Locale locale,String...basenames){
List<String> validBaseNames = getValidBasenames(basenames);
Set<String> codes = new HashSet<>();
for(String basename: validBaseNames){
List<Pair<String, Resource>> filenamesAndResources = calculateAllFilenames(basename,locale);
for (Pair<String, Resource> filenameAndResource : filenamesAndResources) {
if(filenameAndResource.getbValue() != null) {
PropertiesHolder propHolder = getProperties(filenameAndResource.getaValue(), filenameAndResource.getbValue());
codes.addAll(propHolder.getProperties().stringPropertyNames());
}
}
}
return codes;
} | java | public Set<String> getBundleCodes(Locale locale,String...basenames){
List<String> validBaseNames = getValidBasenames(basenames);
Set<String> codes = new HashSet<>();
for(String basename: validBaseNames){
List<Pair<String, Resource>> filenamesAndResources = calculateAllFilenames(basename,locale);
for (Pair<String, Resource> filenameAndResource : filenamesAndResources) {
if(filenameAndResource.getbValue() != null) {
PropertiesHolder propHolder = getProperties(filenameAndResource.getaValue(), filenameAndResource.getbValue());
codes.addAll(propHolder.getProperties().stringPropertyNames());
}
}
}
return codes;
} | [
"public",
"Set",
"<",
"String",
">",
"getBundleCodes",
"(",
"Locale",
"locale",
",",
"String",
"...",
"basenames",
")",
"{",
"List",
"<",
"String",
">",
"validBaseNames",
"=",
"getValidBasenames",
"(",
"basenames",
")",
";",
"Set",
"<",
"String",
">",
"cod... | Retrieves all codes from one or multiple basenames
@param locale the locale
@param basenames the basenames of the bundle
@return a list with all codes from valid registered bundles | [
"Retrieves",
"all",
"codes",
"from",
"one",
"or",
"multiple",
"basenames"
] | c0b08aa995b0297143b75d05642abba8cb7b4122 | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/spring/context/support/ReloadableResourceBundleMessageSource.java#L159-L173 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.