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 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFRow.java | DBFRow.getFloat | public float getFloat(int columnIndex) {
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return 0.0f;
}
if (fieldValue instanceof Number) {
return ((Number) fieldValue).floatValue();
}
throw new DBFException("Unsupported type for Number at column:" + columnIndex + " "
+ fieldValue.getClass().getCanonicalName());
} | java | public float getFloat(int columnIndex) {
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return 0.0f;
}
if (fieldValue instanceof Number) {
return ((Number) fieldValue).floatValue();
}
throw new DBFException("Unsupported type for Number at column:" + columnIndex + " "
+ fieldValue.getClass().getCanonicalName());
} | [
"public",
"float",
"getFloat",
"(",
"int",
"columnIndex",
")",
"{",
"Object",
"fieldValue",
"=",
"data",
"[",
"columnIndex",
"]",
";",
"if",
"(",
"fieldValue",
"==",
"null",
")",
"{",
"return",
"0.0f",
";",
"}",
"if",
"(",
"fieldValue",
"instanceof",
"Nu... | Reads the data as Float
@param columnIndex
columnIndex
@return the data as Float | [
"Reads",
"the",
"data",
"as",
"Float"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFRow.java#L291-L301 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFRow.java | DBFRow.getInt | public int getInt(int columnIndex) {
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return 0;
}
if (fieldValue instanceof Number) {
return ((Number) fieldValue).intValue();
}
throw new DBFException("Unsupported type for Number at column:" + columnIndex + " "
+ fieldValue.getClass().getCanonicalName());
} | java | public int getInt(int columnIndex) {
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return 0;
}
if (fieldValue instanceof Number) {
return ((Number) fieldValue).intValue();
}
throw new DBFException("Unsupported type for Number at column:" + columnIndex + " "
+ fieldValue.getClass().getCanonicalName());
} | [
"public",
"int",
"getInt",
"(",
"int",
"columnIndex",
")",
"{",
"Object",
"fieldValue",
"=",
"data",
"[",
"columnIndex",
"]",
";",
"if",
"(",
"fieldValue",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"fieldValue",
"instanceof",
"Number",
... | Reads the data as int
@param columnIndex
columnIndex
@return the data as int | [
"Reads",
"the",
"data",
"as",
"int"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFRow.java#L321-L331 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFRow.java | DBFRow.getLong | public long getLong(int columnIndex) {
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return 0;
}
if (fieldValue instanceof Number) {
return ((Number) fieldValue).longValue();
}
throw new DBFException("Unsupported type for Number at column:" + columnIndex + " "
+ fieldValue.getClass().getCanonicalName());
} | java | public long getLong(int columnIndex) {
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return 0;
}
if (fieldValue instanceof Number) {
return ((Number) fieldValue).longValue();
}
throw new DBFException("Unsupported type for Number at column:" + columnIndex + " "
+ fieldValue.getClass().getCanonicalName());
} | [
"public",
"long",
"getLong",
"(",
"int",
"columnIndex",
")",
"{",
"Object",
"fieldValue",
"=",
"data",
"[",
"columnIndex",
"]",
";",
"if",
"(",
"fieldValue",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"fieldValue",
"instanceof",
"Number"... | Reads the data as long
@param columnIndex
columnIndex
@return the data as long | [
"Reads",
"the",
"data",
"as",
"long"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFRow.java#L351-L361 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/Utils.java | Utils.textPadding | @Deprecated
public static byte[] textPadding(String text, String characterSetName, int length, int alignment, byte paddingByte)
throws UnsupportedEncodingException {
DBFAlignment align = DBFAlignment.RIGHT;
if (alignment == ALIGN_LEFT) {
align = DBFAlignment.LEFT;
}
return textPadding(text, characterSetName, length, align, paddingByte);
} | java | @Deprecated
public static byte[] textPadding(String text, String characterSetName, int length, int alignment, byte paddingByte)
throws UnsupportedEncodingException {
DBFAlignment align = DBFAlignment.RIGHT;
if (alignment == ALIGN_LEFT) {
align = DBFAlignment.LEFT;
}
return textPadding(text, characterSetName, length, align, paddingByte);
} | [
"@",
"Deprecated",
"public",
"static",
"byte",
"[",
"]",
"textPadding",
"(",
"String",
"text",
",",
"String",
"characterSetName",
",",
"int",
"length",
",",
"int",
"alignment",
",",
"byte",
"paddingByte",
")",
"throws",
"UnsupportedEncodingException",
"{",
"DBFA... | Text is truncated if exceed field capacity. Uses spaces as padding
@param text the text to write
@param characterSetName The charset to use
@param length field length
@param alignment where to align the data
@param paddingByte the byte to use for padding
@return byte[] to store in the file
@throws UnsupportedEncodingException if characterSetName doesn't exists
@deprecated Use {@link DBFUtils#textPadding(String, Charset, int, DBFAlignment, byte)} | [
"Text",
"is",
"truncated",
"if",
"exceed",
"field",
"capacity",
".",
"Uses",
"spaces",
"as",
"padding"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/Utils.java#L264-L273 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/Utils.java | Utils.textPadding | @Deprecated
public static byte[] textPadding(String text, String characterSetName, int length, DBFAlignment alignment, byte paddingByte)
throws UnsupportedEncodingException {
return textPadding(text, Charset.forName(characterSetName), length, alignment, paddingByte);
} | java | @Deprecated
public static byte[] textPadding(String text, String characterSetName, int length, DBFAlignment alignment, byte paddingByte)
throws UnsupportedEncodingException {
return textPadding(text, Charset.forName(characterSetName), length, alignment, paddingByte);
} | [
"@",
"Deprecated",
"public",
"static",
"byte",
"[",
"]",
"textPadding",
"(",
"String",
"text",
",",
"String",
"characterSetName",
",",
"int",
"length",
",",
"DBFAlignment",
"alignment",
",",
"byte",
"paddingByte",
")",
"throws",
"UnsupportedEncodingException",
"{"... | Obtais the data to store in file for a text field.
Text is truncated if exceed field capacity
@param text the text to write
@param characterSetName The charset to use
@param length field length
@param alignment where to align the data
@param paddingByte the byte to use for padding
@return byte[] to store in the file
@throws UnsupportedEncodingException if characterSetName doesn't exists
@deprecated Use {@link DBFUtils#textPadding(String, Charset, int, DBFAlignment, byte)} | [
"Obtais",
"the",
"data",
"to",
"store",
"in",
"file",
"for",
"a",
"text",
"field",
".",
"Text",
"is",
"truncated",
"if",
"exceed",
"field",
"capacity"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/Utils.java#L323-L327 | train |
joinfaces/joinfaces | joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/tomcat/JsfTomcatApplicationListener.java | JsfTomcatApplicationListener.getTomcatRuntime | TomcatRuntime getTomcatRuntime(WebResourceRoot resources) {
TomcatRuntime result = null;
if (isUberJar(resources)) {
result = TomcatRuntime.UBER_JAR;
}
else if (isUberWar(resources)) {
result = TomcatRuntime.UBER_WAR;
}
else if (isTesting(resources)) {
result = TomcatRuntime.TEST;
}
else if (isUnpackagedJar(resources)) {
result = TomcatRuntime.UNPACKAGED_JAR;
}
return result;
} | java | TomcatRuntime getTomcatRuntime(WebResourceRoot resources) {
TomcatRuntime result = null;
if (isUberJar(resources)) {
result = TomcatRuntime.UBER_JAR;
}
else if (isUberWar(resources)) {
result = TomcatRuntime.UBER_WAR;
}
else if (isTesting(resources)) {
result = TomcatRuntime.TEST;
}
else if (isUnpackagedJar(resources)) {
result = TomcatRuntime.UNPACKAGED_JAR;
}
return result;
} | [
"TomcatRuntime",
"getTomcatRuntime",
"(",
"WebResourceRoot",
"resources",
")",
"{",
"TomcatRuntime",
"result",
"=",
"null",
";",
"if",
"(",
"isUberJar",
"(",
"resources",
")",
")",
"{",
"result",
"=",
"TomcatRuntime",
".",
"UBER_JAR",
";",
"}",
"else",
"if",
... | Inform tomcat runtime setup. UNPACKAGED_WAR not covered yet.
@param resources of the tomcat
@return tomcat runtime | [
"Inform",
"tomcat",
"runtime",
"setup",
".",
"UNPACKAGED_WAR",
"not",
"covered",
"yet",
"."
] | c9fc811a9eaf695820951f2c04715297dd1e6d66 | https://github.com/joinfaces/joinfaces/blob/c9fc811a9eaf695820951f2c04715297dd1e6d66/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/tomcat/JsfTomcatApplicationListener.java#L122-L139 | train |
joinfaces/joinfaces | joinfaces-tools/joinfaces-scan-tools/src/main/java/org/joinfaces/tools/ScanResultHandler.java | ScanResultHandler.writeClassList | protected void writeClassList(File file, Collection<String> classNames) throws IOException {
File baseDir = file.getParentFile();
if (baseDir.isDirectory() || baseDir.mkdirs()) {
Files.write(file.toPath(), classNames, StandardCharsets.UTF_8);
}
else {
throw new IOException(baseDir + " does not exist and could not be created");
}
} | java | protected void writeClassList(File file, Collection<String> classNames) throws IOException {
File baseDir = file.getParentFile();
if (baseDir.isDirectory() || baseDir.mkdirs()) {
Files.write(file.toPath(), classNames, StandardCharsets.UTF_8);
}
else {
throw new IOException(baseDir + " does not exist and could not be created");
}
} | [
"protected",
"void",
"writeClassList",
"(",
"File",
"file",
",",
"Collection",
"<",
"String",
">",
"classNames",
")",
"throws",
"IOException",
"{",
"File",
"baseDir",
"=",
"file",
".",
"getParentFile",
"(",
")",
";",
"if",
"(",
"baseDir",
".",
"isDirectory",... | Helper method which writes a list of class names to the given file.
@param file The target file in which the class names should be written.
@param classNames The class names which should be written in the target file.
@throws IOException when the class names could not be written to the target file. | [
"Helper",
"method",
"which",
"writes",
"a",
"list",
"of",
"class",
"names",
"to",
"the",
"given",
"file",
"."
] | c9fc811a9eaf695820951f2c04715297dd1e6d66 | https://github.com/joinfaces/joinfaces/blob/c9fc811a9eaf695820951f2c04715297dd1e6d66/joinfaces-tools/joinfaces-scan-tools/src/main/java/org/joinfaces/tools/ScanResultHandler.java#L58-L67 | train |
joinfaces/joinfaces | joinfaces-tools/joinfaces-scan-tools/src/main/java/org/joinfaces/tools/ScanResultHandler.java | ScanResultHandler.writeClassMap | protected void writeClassMap(File file, Map<String, ? extends Collection<String>> classMap) throws IOException {
File baseDir = file.getParentFile();
if (baseDir.isDirectory() || baseDir.mkdirs()) {
//noinspection CharsetObjectCanBeUsed
try (PrintWriter printWriter = new PrintWriter(file, "UTF-8")) {
classMap.forEach((key, value) -> {
printWriter.print(key);
printWriter.print("=");
printWriter.println(String.join(",", value));
});
}
}
else {
throw new IOException(baseDir + " does not exist and could not be created");
}
} | java | protected void writeClassMap(File file, Map<String, ? extends Collection<String>> classMap) throws IOException {
File baseDir = file.getParentFile();
if (baseDir.isDirectory() || baseDir.mkdirs()) {
//noinspection CharsetObjectCanBeUsed
try (PrintWriter printWriter = new PrintWriter(file, "UTF-8")) {
classMap.forEach((key, value) -> {
printWriter.print(key);
printWriter.print("=");
printWriter.println(String.join(",", value));
});
}
}
else {
throw new IOException(baseDir + " does not exist and could not be created");
}
} | [
"protected",
"void",
"writeClassMap",
"(",
"File",
"file",
",",
"Map",
"<",
"String",
",",
"?",
"extends",
"Collection",
"<",
"String",
">",
">",
"classMap",
")",
"throws",
"IOException",
"{",
"File",
"baseDir",
"=",
"file",
".",
"getParentFile",
"(",
")",... | Helper method which writes a map of class names to the given file.
@param file The target file in which the class names should be written.
@param classMap The class names which should be written in the target file.
@throws IOException when the class names could not be written to the target file. | [
"Helper",
"method",
"which",
"writes",
"a",
"map",
"of",
"class",
"names",
"to",
"the",
"given",
"file",
"."
] | c9fc811a9eaf695820951f2c04715297dd1e6d66 | https://github.com/joinfaces/joinfaces/blob/c9fc811a9eaf695820951f2c04715297dd1e6d66/joinfaces-tools/joinfaces-scan-tools/src/main/java/org/joinfaces/tools/ScanResultHandler.java#L76-L93 | train |
joinfaces/joinfaces | joinfaces-security-taglib/src/main/java/org/joinfaces/security/FaceletsTagUtils.java | FaceletsTagUtils.areAllGranted | public static boolean areAllGranted(String authorities) throws IOException {
AuthorizeFaceletsTag authorizeTag = new AuthorizeFaceletsTag();
authorizeTag.setIfAllGranted(authorities);
return authorizeTag.authorize();
} | java | public static boolean areAllGranted(String authorities) throws IOException {
AuthorizeFaceletsTag authorizeTag = new AuthorizeFaceletsTag();
authorizeTag.setIfAllGranted(authorities);
return authorizeTag.authorize();
} | [
"public",
"static",
"boolean",
"areAllGranted",
"(",
"String",
"authorities",
")",
"throws",
"IOException",
"{",
"AuthorizeFaceletsTag",
"authorizeTag",
"=",
"new",
"AuthorizeFaceletsTag",
"(",
")",
";",
"authorizeTag",
".",
"setIfAllGranted",
"(",
"authorities",
")",... | Returns true if the user has all of of the given authorities.
@param authorities a comma-separated list of user authorities.
@return computation if the user has all of of the given authorities
@throws IOException io exception | [
"Returns",
"true",
"if",
"the",
"user",
"has",
"all",
"of",
"of",
"the",
"given",
"authorities",
"."
] | c9fc811a9eaf695820951f2c04715297dd1e6d66 | https://github.com/joinfaces/joinfaces/blob/c9fc811a9eaf695820951f2c04715297dd1e6d66/joinfaces-security-taglib/src/main/java/org/joinfaces/security/FaceletsTagUtils.java#L38-L42 | train |
joinfaces/joinfaces | joinfaces-security-taglib/src/main/java/org/joinfaces/security/FaceletsTagUtils.java | FaceletsTagUtils.areAnyGranted | public static boolean areAnyGranted(String authorities) throws IOException {
AuthorizeFaceletsTag authorizeTag = new AuthorizeFaceletsTag();
authorizeTag.setIfAnyGranted(authorities);
return authorizeTag.authorize();
} | java | public static boolean areAnyGranted(String authorities) throws IOException {
AuthorizeFaceletsTag authorizeTag = new AuthorizeFaceletsTag();
authorizeTag.setIfAnyGranted(authorities);
return authorizeTag.authorize();
} | [
"public",
"static",
"boolean",
"areAnyGranted",
"(",
"String",
"authorities",
")",
"throws",
"IOException",
"{",
"AuthorizeFaceletsTag",
"authorizeTag",
"=",
"new",
"AuthorizeFaceletsTag",
"(",
")",
";",
"authorizeTag",
".",
"setIfAnyGranted",
"(",
"authorities",
")",... | Returns true if the user has any of the given authorities.
@param authorities a comma-separated list of user authorities.
@return computation if the user has any of the given authorities.
@throws IOException io exception | [
"Returns",
"true",
"if",
"the",
"user",
"has",
"any",
"of",
"the",
"given",
"authorities",
"."
] | c9fc811a9eaf695820951f2c04715297dd1e6d66 | https://github.com/joinfaces/joinfaces/blob/c9fc811a9eaf695820951f2c04715297dd1e6d66/joinfaces-security-taglib/src/main/java/org/joinfaces/security/FaceletsTagUtils.java#L51-L55 | train |
joinfaces/joinfaces | joinfaces-security-taglib/src/main/java/org/joinfaces/security/FaceletsTagUtils.java | FaceletsTagUtils.areNotGranted | public static boolean areNotGranted(String authorities) throws IOException {
AuthorizeFaceletsTag authorizeTag = new AuthorizeFaceletsTag();
authorizeTag.setIfNotGranted(authorities);
return authorizeTag.authorize();
} | java | public static boolean areNotGranted(String authorities) throws IOException {
AuthorizeFaceletsTag authorizeTag = new AuthorizeFaceletsTag();
authorizeTag.setIfNotGranted(authorities);
return authorizeTag.authorize();
} | [
"public",
"static",
"boolean",
"areNotGranted",
"(",
"String",
"authorities",
")",
"throws",
"IOException",
"{",
"AuthorizeFaceletsTag",
"authorizeTag",
"=",
"new",
"AuthorizeFaceletsTag",
"(",
")",
";",
"authorizeTag",
".",
"setIfNotGranted",
"(",
"authorities",
")",... | Returns true if the user does not have any of the given authorities.
@param authorities a comma-separated list of user authorities.
@return computation if the user does not have any of the given authorities.
@throws IOException io exception | [
"Returns",
"true",
"if",
"the",
"user",
"does",
"not",
"have",
"any",
"of",
"the",
"given",
"authorities",
"."
] | c9fc811a9eaf695820951f2c04715297dd1e6d66 | https://github.com/joinfaces/joinfaces/blob/c9fc811a9eaf695820951f2c04715297dd1e6d66/joinfaces-security-taglib/src/main/java/org/joinfaces/security/FaceletsTagUtils.java#L64-L68 | train |
joinfaces/joinfaces | joinfaces-security-taglib/src/main/java/org/joinfaces/security/FaceletsTagUtils.java | FaceletsTagUtils.isAllowed | public static boolean isAllowed(String url, String method) throws IOException {
AuthorizeFaceletsTag authorizeTag = new AuthorizeFaceletsTag();
authorizeTag.setUrl(url);
authorizeTag.setMethod(method);
return authorizeTag.authorizeUsingUrlCheck();
} | java | public static boolean isAllowed(String url, String method) throws IOException {
AuthorizeFaceletsTag authorizeTag = new AuthorizeFaceletsTag();
authorizeTag.setUrl(url);
authorizeTag.setMethod(method);
return authorizeTag.authorizeUsingUrlCheck();
} | [
"public",
"static",
"boolean",
"isAllowed",
"(",
"String",
"url",
",",
"String",
"method",
")",
"throws",
"IOException",
"{",
"AuthorizeFaceletsTag",
"authorizeTag",
"=",
"new",
"AuthorizeFaceletsTag",
"(",
")",
";",
"authorizeTag",
".",
"setUrl",
"(",
"url",
")... | Returns true if the user is allowed to access the given URL and HTTP
method combination. The HTTP method is optional and case insensitive.
@param url to be accessed.
@param method to be called.
@return computation if the user is allowed to access the given URL and HTTP method.
@throws IOException io exception | [
"Returns",
"true",
"if",
"the",
"user",
"is",
"allowed",
"to",
"access",
"the",
"given",
"URL",
"and",
"HTTP",
"method",
"combination",
".",
"The",
"HTTP",
"method",
"is",
"optional",
"and",
"case",
"insensitive",
"."
] | c9fc811a9eaf695820951f2c04715297dd1e6d66 | https://github.com/joinfaces/joinfaces/blob/c9fc811a9eaf695820951f2c04715297dd1e6d66/joinfaces-security-taglib/src/main/java/org/joinfaces/security/FaceletsTagUtils.java#L78-L83 | train |
joinfaces/joinfaces | joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/scopemapping/CustomScopeAnnotationConfigurer.java | CustomScopeAnnotationConfigurer.registerJsfCdiToSpring | private void registerJsfCdiToSpring(BeanDefinition definition) {
if (definition instanceof AnnotatedBeanDefinition) {
AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
String scopeName = null;
// firstly check whether bean is defined via configuration
if (annDef.getFactoryMethodMetadata() != null) {
scopeName = deduceScopeName(annDef.getFactoryMethodMetadata());
}
else {
// fallback to type
scopeName = deduceScopeName(annDef.getMetadata());
}
if (scopeName != null) {
definition.setScope(scopeName);
log.debug("{} - Scope({})", definition.getBeanClassName(), scopeName.toUpperCase());
}
}
} | java | private void registerJsfCdiToSpring(BeanDefinition definition) {
if (definition instanceof AnnotatedBeanDefinition) {
AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
String scopeName = null;
// firstly check whether bean is defined via configuration
if (annDef.getFactoryMethodMetadata() != null) {
scopeName = deduceScopeName(annDef.getFactoryMethodMetadata());
}
else {
// fallback to type
scopeName = deduceScopeName(annDef.getMetadata());
}
if (scopeName != null) {
definition.setScope(scopeName);
log.debug("{} - Scope({})", definition.getBeanClassName(), scopeName.toUpperCase());
}
}
} | [
"private",
"void",
"registerJsfCdiToSpring",
"(",
"BeanDefinition",
"definition",
")",
"{",
"if",
"(",
"definition",
"instanceof",
"AnnotatedBeanDefinition",
")",
"{",
"AnnotatedBeanDefinition",
"annDef",
"=",
"(",
"AnnotatedBeanDefinition",
")",
"definition",
";",
"Str... | Checks how is bean defined and deduces scope name from JSF CDI annotations.
@param definition beanDefinition | [
"Checks",
"how",
"is",
"bean",
"defined",
"and",
"deduces",
"scope",
"name",
"from",
"JSF",
"CDI",
"annotations",
"."
] | c9fc811a9eaf695820951f2c04715297dd1e6d66 | https://github.com/joinfaces/joinfaces/blob/c9fc811a9eaf695820951f2c04715297dd1e6d66/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/scopemapping/CustomScopeAnnotationConfigurer.java#L69-L90 | train |
cqframework/clinical_quality_language | Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/Cql2ElmVisitor.java | Cql2ElmVisitor.getPropertyPath | private String getPropertyPath(Expression reference, String alias) {
if (reference instanceof Property) {
Property property = (Property)reference;
if (alias.equals(property.getScope())) {
return property.getPath();
}
else if (property.getSource() != null) {
String subPath = getPropertyPath(property.getSource(), alias);
if (subPath != null) {
return String.format("%s.%s", subPath, property.getPath());
}
}
}
return null;
} | java | private String getPropertyPath(Expression reference, String alias) {
if (reference instanceof Property) {
Property property = (Property)reference;
if (alias.equals(property.getScope())) {
return property.getPath();
}
else if (property.getSource() != null) {
String subPath = getPropertyPath(property.getSource(), alias);
if (subPath != null) {
return String.format("%s.%s", subPath, property.getPath());
}
}
}
return null;
} | [
"private",
"String",
"getPropertyPath",
"(",
"Expression",
"reference",
",",
"String",
"alias",
")",
"{",
"if",
"(",
"reference",
"instanceof",
"Property",
")",
"{",
"Property",
"property",
"=",
"(",
"Property",
")",
"reference",
";",
"if",
"(",
"alias",
"."... | Collapse a property path expression back to it's qualified form for use as the path attribute of the retrieve.
@param reference the <code>Expression</code> to collapse
@param alias the alias of the <code>Retrieve</code> in the query.
@return The collapsed path
operands (or sub-operands) were modified; <code>false</code> otherwise. | [
"Collapse",
"a",
"property",
"path",
"expression",
"back",
"to",
"it",
"s",
"qualified",
"form",
"for",
"use",
"as",
"the",
"path",
"attribute",
"of",
"the",
"retrieve",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/Cql2ElmVisitor.java#L3058-L3073 | train |
cqframework/clinical_quality_language | Src/java/model/src/main/java/org/hl7/cql/model/DataType.java | DataType.isCompatibleWith | public boolean isCompatibleWith(DataType other) {
// A type is compatible with a choice type if it is a subtype of one of the choice types
if (other instanceof ChoiceType) {
for (DataType choice : ((ChoiceType)other).getTypes()) {
if (this.isSubTypeOf(choice)) {
return true;
}
}
}
return this.equals(other); // Any data type is compatible with itself
} | java | public boolean isCompatibleWith(DataType other) {
// A type is compatible with a choice type if it is a subtype of one of the choice types
if (other instanceof ChoiceType) {
for (DataType choice : ((ChoiceType)other).getTypes()) {
if (this.isSubTypeOf(choice)) {
return true;
}
}
}
return this.equals(other); // Any data type is compatible with itself
} | [
"public",
"boolean",
"isCompatibleWith",
"(",
"DataType",
"other",
")",
"{",
"// A type is compatible with a choice type if it is a subtype of one of the choice types",
"if",
"(",
"other",
"instanceof",
"ChoiceType",
")",
"{",
"for",
"(",
"DataType",
"choice",
":",
"(",
"... | literal to any other type, or casting a class to an equivalent tuple. | [
"literal",
"to",
"any",
"other",
"type",
"or",
"casting",
"a",
"class",
"to",
"an",
"equivalent",
"tuple",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/model/src/main/java/org/hl7/cql/model/DataType.java#L62-L73 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitTypeSpecifier | public T visitTypeSpecifier(TypeSpecifier elm, C context) {
if (elm instanceof NamedTypeSpecifier) return visitNamedTypeSpecifier((NamedTypeSpecifier)elm, context);
else if (elm instanceof IntervalTypeSpecifier) return visitIntervalTypeSpecifier((IntervalTypeSpecifier)elm, context);
else if (elm instanceof ListTypeSpecifier) return visitListTypeSpecifier((ListTypeSpecifier)elm, context);
else if (elm instanceof TupleTypeSpecifier) return visitTupleTypeSpecifier((TupleTypeSpecifier)elm, context);
else return null;
} | java | public T visitTypeSpecifier(TypeSpecifier elm, C context) {
if (elm instanceof NamedTypeSpecifier) return visitNamedTypeSpecifier((NamedTypeSpecifier)elm, context);
else if (elm instanceof IntervalTypeSpecifier) return visitIntervalTypeSpecifier((IntervalTypeSpecifier)elm, context);
else if (elm instanceof ListTypeSpecifier) return visitListTypeSpecifier((ListTypeSpecifier)elm, context);
else if (elm instanceof TupleTypeSpecifier) return visitTupleTypeSpecifier((TupleTypeSpecifier)elm, context);
else return null;
} | [
"public",
"T",
"visitTypeSpecifier",
"(",
"TypeSpecifier",
"elm",
",",
"C",
"context",
")",
"{",
"if",
"(",
"elm",
"instanceof",
"NamedTypeSpecifier",
")",
"return",
"visitNamedTypeSpecifier",
"(",
"(",
"NamedTypeSpecifier",
")",
"elm",
",",
"context",
")",
";",... | Visit a TypeSpecifier. This method will be called for every
node in the tree that is a descendant of the TypeSpecifier type.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"TypeSpecifier",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"descendant",
"of",
"the",
"TypeSpecifier",
"type",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L43-L49 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitIntervalTypeSpecifier | public T visitIntervalTypeSpecifier(IntervalTypeSpecifier elm, C context) {
visitElement(elm.getPointType(), context);
return null;
} | java | public T visitIntervalTypeSpecifier(IntervalTypeSpecifier elm, C context) {
visitElement(elm.getPointType(), context);
return null;
} | [
"public",
"T",
"visitIntervalTypeSpecifier",
"(",
"IntervalTypeSpecifier",
"elm",
",",
"C",
"context",
")",
"{",
"visitElement",
"(",
"elm",
".",
"getPointType",
"(",
")",
",",
"context",
")",
";",
"return",
"null",
";",
"}"
] | Visit a IntervalTypeSpecifier. This method will be called for
every node in the tree that is a IntervalTypeSpecifier.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"IntervalTypeSpecifier",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"IntervalTypeSpecifier",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L71-L74 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitListTypeSpecifier | public T visitListTypeSpecifier(ListTypeSpecifier elm, C context) {
visitElement(elm.getElementType(), context);
return null;
} | java | public T visitListTypeSpecifier(ListTypeSpecifier elm, C context) {
visitElement(elm.getElementType(), context);
return null;
} | [
"public",
"T",
"visitListTypeSpecifier",
"(",
"ListTypeSpecifier",
"elm",
",",
"C",
"context",
")",
"{",
"visitElement",
"(",
"elm",
".",
"getElementType",
"(",
")",
",",
"context",
")",
";",
"return",
"null",
";",
"}"
] | Visit a ListTypeSpecifier. This method will be called for
every node in the tree that is a ListTypeSpecifier.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"ListTypeSpecifier",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"ListTypeSpecifier",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L84-L87 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitTupleElementDefinition | public T visitTupleElementDefinition(TupleElementDefinition elm, C context) {
visitElement(elm.getType(), context);
return null;
} | java | public T visitTupleElementDefinition(TupleElementDefinition elm, C context) {
visitElement(elm.getType(), context);
return null;
} | [
"public",
"T",
"visitTupleElementDefinition",
"(",
"TupleElementDefinition",
"elm",
",",
"C",
"context",
")",
"{",
"visitElement",
"(",
"elm",
".",
"getType",
"(",
")",
",",
"context",
")",
";",
"return",
"null",
";",
"}"
] | Visit a TupleElementDefinition. This method will be called for
every node in the tree that is a TupleElementDefinition.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"TupleElementDefinition",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"TupleElementDefinition",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L97-L100 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitTupleTypeSpecifier | public T visitTupleTypeSpecifier(TupleTypeSpecifier elm, C context) {
for (TupleElementDefinition element : elm.getElement()) {
visitElement(element, context);
}
return null;
} | java | public T visitTupleTypeSpecifier(TupleTypeSpecifier elm, C context) {
for (TupleElementDefinition element : elm.getElement()) {
visitElement(element, context);
}
return null;
} | [
"public",
"T",
"visitTupleTypeSpecifier",
"(",
"TupleTypeSpecifier",
"elm",
",",
"C",
"context",
")",
"{",
"for",
"(",
"TupleElementDefinition",
"element",
":",
"elm",
".",
"getElement",
"(",
")",
")",
"{",
"visitElement",
"(",
"element",
",",
"context",
")",
... | Visit a TupleTypeSpecifier. This method will be called for
every node in the tree that is a TupleTypeSpecifier.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"TupleTypeSpecifier",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"TupleTypeSpecifier",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L110-L115 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitTernaryExpression | public T visitTernaryExpression(TernaryExpression elm, C context) {
for (Expression element : elm.getOperand()) {
visitElement(element, context);
}
return null;
} | java | public T visitTernaryExpression(TernaryExpression elm, C context) {
for (Expression element : elm.getOperand()) {
visitElement(element, context);
}
return null;
} | [
"public",
"T",
"visitTernaryExpression",
"(",
"TernaryExpression",
"elm",
",",
"C",
"context",
")",
"{",
"for",
"(",
"Expression",
"element",
":",
"elm",
".",
"getOperand",
"(",
")",
")",
"{",
"visitElement",
"(",
"element",
",",
"context",
")",
";",
"}",
... | Visit a TernaryExpression. This method will be called for
every node in the tree that is a TernaryExpression.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"TernaryExpression",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"TernaryExpression",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L284-L289 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitNaryExpression | public T visitNaryExpression(NaryExpression elm, C context) {
if (elm instanceof Coalesce) return visitCoalesce((Coalesce)elm, context);
else if (elm instanceof Concatenate) return visitConcatenate((Concatenate)elm, context);
else if (elm instanceof Except) return visitExcept((Except)elm, context);
else if (elm instanceof Intersect) return visitIntersect((Intersect)elm, context);
else if (elm instanceof Union) return visitUnion((Union)elm, context);
else return null;
} | java | public T visitNaryExpression(NaryExpression elm, C context) {
if (elm instanceof Coalesce) return visitCoalesce((Coalesce)elm, context);
else if (elm instanceof Concatenate) return visitConcatenate((Concatenate)elm, context);
else if (elm instanceof Except) return visitExcept((Except)elm, context);
else if (elm instanceof Intersect) return visitIntersect((Intersect)elm, context);
else if (elm instanceof Union) return visitUnion((Union)elm, context);
else return null;
} | [
"public",
"T",
"visitNaryExpression",
"(",
"NaryExpression",
"elm",
",",
"C",
"context",
")",
"{",
"if",
"(",
"elm",
"instanceof",
"Coalesce",
")",
"return",
"visitCoalesce",
"(",
"(",
"Coalesce",
")",
"elm",
",",
"context",
")",
";",
"else",
"if",
"(",
... | Visit a NaryExpression. This method will be called for
every node in the tree that is a NaryExpression.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"NaryExpression",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"NaryExpression",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L299-L306 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitExpressionDef | public T visitExpressionDef(ExpressionDef elm, C context) {
visitElement(elm.getExpression(), context);
return null;
} | java | public T visitExpressionDef(ExpressionDef elm, C context) {
visitElement(elm.getExpression(), context);
return null;
} | [
"public",
"T",
"visitExpressionDef",
"(",
"ExpressionDef",
"elm",
",",
"C",
"context",
")",
"{",
"visitElement",
"(",
"elm",
".",
"getExpression",
"(",
")",
",",
"context",
")",
";",
"return",
"null",
";",
"}"
] | Visit a ExpressionDef. This method will be called for
every node in the tree that is a ExpressionDef.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"ExpressionDef",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"ExpressionDef",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L316-L319 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitFunctionDef | public T visitFunctionDef(FunctionDef elm, C context) {
for (OperandDef element : elm.getOperand()) {
visitElement(element, context);
}
visitElement(elm.getExpression(), context);
return null;
} | java | public T visitFunctionDef(FunctionDef elm, C context) {
for (OperandDef element : elm.getOperand()) {
visitElement(element, context);
}
visitElement(elm.getExpression(), context);
return null;
} | [
"public",
"T",
"visitFunctionDef",
"(",
"FunctionDef",
"elm",
",",
"C",
"context",
")",
"{",
"for",
"(",
"OperandDef",
"element",
":",
"elm",
".",
"getOperand",
"(",
")",
")",
"{",
"visitElement",
"(",
"element",
",",
"context",
")",
";",
"}",
"visitElem... | Visit a FunctionDef. This method will be called for
every node in the tree that is a FunctionDef.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"FunctionDef",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"FunctionDef",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L329-L335 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitFunctionRef | public T visitFunctionRef(FunctionRef elm, C context) {
for (Expression element : elm.getOperand()) {
visitElement(element, context);
}
return null;
} | java | public T visitFunctionRef(FunctionRef elm, C context) {
for (Expression element : elm.getOperand()) {
visitElement(element, context);
}
return null;
} | [
"public",
"T",
"visitFunctionRef",
"(",
"FunctionRef",
"elm",
",",
"C",
"context",
")",
"{",
"for",
"(",
"Expression",
"element",
":",
"elm",
".",
"getOperand",
"(",
")",
")",
"{",
"visitElement",
"(",
"element",
",",
"context",
")",
";",
"}",
"return",
... | Visit a FunctionRef. This method will be called for
every node in the tree that is a FunctionRef.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"FunctionRef",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"FunctionRef",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L357-L362 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitParameterDef | public T visitParameterDef(ParameterDef elm, C context) {
if (elm.getParameterTypeSpecifier() != null) {
visitElement(elm.getParameterTypeSpecifier(), context);
}
if (elm.getDefault() != null) {
visitElement(elm.getDefault(), context);
}
return null;
} | java | public T visitParameterDef(ParameterDef elm, C context) {
if (elm.getParameterTypeSpecifier() != null) {
visitElement(elm.getParameterTypeSpecifier(), context);
}
if (elm.getDefault() != null) {
visitElement(elm.getDefault(), context);
}
return null;
} | [
"public",
"T",
"visitParameterDef",
"(",
"ParameterDef",
"elm",
",",
"C",
"context",
")",
"{",
"if",
"(",
"elm",
".",
"getParameterTypeSpecifier",
"(",
")",
"!=",
"null",
")",
"{",
"visitElement",
"(",
"elm",
".",
"getParameterTypeSpecifier",
"(",
")",
",",
... | Visit a ParameterDef. This method will be called for
every node in the tree that is a ParameterDef.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"ParameterDef",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"ParameterDef",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L372-L382 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitOperandDef | public T visitOperandDef(OperandDef elm, C context) {
if (elm.getOperandTypeSpecifier() != null) {
visitElement(elm.getOperandTypeSpecifier(), context);
}
return null;
} | java | public T visitOperandDef(OperandDef elm, C context) {
if (elm.getOperandTypeSpecifier() != null) {
visitElement(elm.getOperandTypeSpecifier(), context);
}
return null;
} | [
"public",
"T",
"visitOperandDef",
"(",
"OperandDef",
"elm",
",",
"C",
"context",
")",
"{",
"if",
"(",
"elm",
".",
"getOperandTypeSpecifier",
"(",
")",
"!=",
"null",
")",
"{",
"visitElement",
"(",
"elm",
".",
"getOperandTypeSpecifier",
"(",
")",
",",
"conte... | Visit a OperandDef. This method will be called for
every node in the tree that is a OperandDef.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"OperandDef",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"OperandDef",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L404-L409 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitTupleElement | public T visitTupleElement(TupleElement elm, C context) {
visitElement(elm.getValue(), context);
return null;
} | java | public T visitTupleElement(TupleElement elm, C context) {
visitElement(elm.getValue(), context);
return null;
} | [
"public",
"T",
"visitTupleElement",
"(",
"TupleElement",
"elm",
",",
"C",
"context",
")",
"{",
"visitElement",
"(",
"elm",
".",
"getValue",
"(",
")",
",",
"context",
")",
";",
"return",
"null",
";",
"}"
] | Visit a TupleElement. This method will be called for
every node in the tree that is a TupleElement.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"TupleElement",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"TupleElement",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L455-L458 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitTuple | public T visitTuple(Tuple elm, C context) {
for (TupleElement element : elm.getElement()) {
visitTupleElement(element, context);
}
return null;
} | java | public T visitTuple(Tuple elm, C context) {
for (TupleElement element : elm.getElement()) {
visitTupleElement(element, context);
}
return null;
} | [
"public",
"T",
"visitTuple",
"(",
"Tuple",
"elm",
",",
"C",
"context",
")",
"{",
"for",
"(",
"TupleElement",
"element",
":",
"elm",
".",
"getElement",
"(",
")",
")",
"{",
"visitTupleElement",
"(",
"element",
",",
"context",
")",
";",
"}",
"return",
"nu... | Visit a Tuple. This method will be called for
every node in the tree that is a Tuple.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"Tuple",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"Tuple",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L468-L473 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitInstanceElement | public T visitInstanceElement(InstanceElement elm, C context) {
visitElement(elm.getValue(), context);
return null;
} | java | public T visitInstanceElement(InstanceElement elm, C context) {
visitElement(elm.getValue(), context);
return null;
} | [
"public",
"T",
"visitInstanceElement",
"(",
"InstanceElement",
"elm",
",",
"C",
"context",
")",
"{",
"visitElement",
"(",
"elm",
".",
"getValue",
"(",
")",
",",
"context",
")",
";",
"return",
"null",
";",
"}"
] | Visit a InstanceElement. This method will be called for
every node in the tree that is a InstanceElement.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"InstanceElement",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"InstanceElement",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L483-L486 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitInstance | public T visitInstance(Instance elm, C context) {
for (InstanceElement element : elm.getElement()) {
visitInstanceElement(element, context);
}
return null;
} | java | public T visitInstance(Instance elm, C context) {
for (InstanceElement element : elm.getElement()) {
visitInstanceElement(element, context);
}
return null;
} | [
"public",
"T",
"visitInstance",
"(",
"Instance",
"elm",
",",
"C",
"context",
")",
"{",
"for",
"(",
"InstanceElement",
"element",
":",
"elm",
".",
"getElement",
"(",
")",
")",
"{",
"visitInstanceElement",
"(",
"element",
",",
"context",
")",
";",
"}",
"re... | Visit a Instance. This method will be called for
every node in the tree that is a Instance.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"Instance",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"Instance",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L496-L501 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitInterval | public T visitInterval(Interval elm, C context) {
if (elm.getLow() != null) {
visitElement(elm.getLow(), context);
}
if (elm.getLowClosedExpression() != null) {
visitElement(elm.getLowClosedExpression(), context);
}
if (elm.getHigh() != null) {
visitElement(elm.getHigh(), context);
}
if (elm.getHighClosedExpression() != null) {
visitElement(elm.getHighClosedExpression(), context);
}
return null;
} | java | public T visitInterval(Interval elm, C context) {
if (elm.getLow() != null) {
visitElement(elm.getLow(), context);
}
if (elm.getLowClosedExpression() != null) {
visitElement(elm.getLowClosedExpression(), context);
}
if (elm.getHigh() != null) {
visitElement(elm.getHigh(), context);
}
if (elm.getHighClosedExpression() != null) {
visitElement(elm.getHighClosedExpression(), context);
}
return null;
} | [
"public",
"T",
"visitInterval",
"(",
"Interval",
"elm",
",",
"C",
"context",
")",
"{",
"if",
"(",
"elm",
".",
"getLow",
"(",
")",
"!=",
"null",
")",
"{",
"visitElement",
"(",
"elm",
".",
"getLow",
"(",
")",
",",
"context",
")",
";",
"}",
"if",
"(... | Visit a Interval. This method will be called for
every node in the tree that is a Interval.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"Interval",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"Interval",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L511-L525 | train |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitList | public T visitList(List elm, C context) {
if (elm.getTypeSpecifier() != null) {
visitElement(elm.getTypeSpecifier(), context);
}
for (Expression element : elm.getElement()) {
visitElement(element, context);
}
return null;
} | java | public T visitList(List elm, C context) {
if (elm.getTypeSpecifier() != null) {
visitElement(elm.getTypeSpecifier(), context);
}
for (Expression element : elm.getElement()) {
visitElement(element, context);
}
return null;
} | [
"public",
"T",
"visitList",
"(",
"List",
"elm",
",",
"C",
"context",
")",
"{",
"if",
"(",
"elm",
".",
"getTypeSpecifier",
"(",
")",
"!=",
"null",
")",
"{",
"visitElement",
"(",
"elm",
".",
"getTypeSpecifier",
"(",
")",
",",
"context",
")",
";",
"}",
... | Visit a List. This method will be called for
every node in the tree that is a List.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"List",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"List",
"."
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L535-L543 | train |
cqframework/clinical_quality_language | Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/LibraryBuilder.java | LibraryBuilder.recordParsingException | public void recordParsingException(CqlTranslatorException e) {
addException(e);
if (shouldReport(e.getSeverity())) {
CqlToElmError err = af.createCqlToElmError();
err.setMessage(e.getMessage());
err.setErrorType(e instanceof CqlSyntaxException ? ErrorType.SYNTAX : (e instanceof CqlSemanticException ? ErrorType.SEMANTIC : ErrorType.INTERNAL));
err.setErrorSeverity(toErrorSeverity(e.getSeverity()));
if (e.getLocator() != null) {
err.setStartLine(e.getLocator().getStartLine());
err.setEndLine(e.getLocator().getEndLine());
err.setStartChar(e.getLocator().getStartChar());
err.setEndChar(e.getLocator().getEndChar());
}
if (e.getCause() != null && e.getCause() instanceof CqlTranslatorIncludeException) {
CqlTranslatorIncludeException incEx = (CqlTranslatorIncludeException) e.getCause();
err.setTargetIncludeLibraryId(incEx.getLibraryId());
err.setTargetIncludeLibraryVersionId(incEx.getVersionId());
err.setErrorType(ErrorType.INCLUDE);
}
library.getAnnotation().add(err);
}
} | java | public void recordParsingException(CqlTranslatorException e) {
addException(e);
if (shouldReport(e.getSeverity())) {
CqlToElmError err = af.createCqlToElmError();
err.setMessage(e.getMessage());
err.setErrorType(e instanceof CqlSyntaxException ? ErrorType.SYNTAX : (e instanceof CqlSemanticException ? ErrorType.SEMANTIC : ErrorType.INTERNAL));
err.setErrorSeverity(toErrorSeverity(e.getSeverity()));
if (e.getLocator() != null) {
err.setStartLine(e.getLocator().getStartLine());
err.setEndLine(e.getLocator().getEndLine());
err.setStartChar(e.getLocator().getStartChar());
err.setEndChar(e.getLocator().getEndChar());
}
if (e.getCause() != null && e.getCause() instanceof CqlTranslatorIncludeException) {
CqlTranslatorIncludeException incEx = (CqlTranslatorIncludeException) e.getCause();
err.setTargetIncludeLibraryId(incEx.getLibraryId());
err.setTargetIncludeLibraryVersionId(incEx.getVersionId());
err.setErrorType(ErrorType.INCLUDE);
}
library.getAnnotation().add(err);
}
} | [
"public",
"void",
"recordParsingException",
"(",
"CqlTranslatorException",
"e",
")",
"{",
"addException",
"(",
"e",
")",
";",
"if",
"(",
"shouldReport",
"(",
"e",
".",
"getSeverity",
"(",
")",
")",
")",
"{",
"CqlToElmError",
"err",
"=",
"af",
".",
"createC... | Record any errors while parsing in both the list of errors but also in the library
itself so they can be processed easily by a remote client
@param e the exception to record | [
"Record",
"any",
"errors",
"while",
"parsing",
"in",
"both",
"the",
"list",
"of",
"errors",
"but",
"also",
"in",
"the",
"library",
"itself",
"so",
"they",
"can",
"be",
"processed",
"easily",
"by",
"a",
"remote",
"client"
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/LibraryBuilder.java#L405-L427 | train |
cqframework/clinical_quality_language | Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/SystemFunctionResolver.java | SystemFunctionResolver.resolveCalculateAge | private CalculateAge resolveCalculateAge(Expression e, DateTimePrecision p) {
CalculateAge operator = of.createCalculateAge()
.withPrecision(p)
.withOperand(e);
builder.resolveUnaryCall("System", "CalculateAge", operator);
return operator;
} | java | private CalculateAge resolveCalculateAge(Expression e, DateTimePrecision p) {
CalculateAge operator = of.createCalculateAge()
.withPrecision(p)
.withOperand(e);
builder.resolveUnaryCall("System", "CalculateAge", operator);
return operator;
} | [
"private",
"CalculateAge",
"resolveCalculateAge",
"(",
"Expression",
"e",
",",
"DateTimePrecision",
"p",
")",
"{",
"CalculateAge",
"operator",
"=",
"of",
".",
"createCalculateAge",
"(",
")",
".",
"withPrecision",
"(",
"p",
")",
".",
"withOperand",
"(",
"e",
")... | Age-Related Function Support | [
"Age",
"-",
"Related",
"Function",
"Support"
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/SystemFunctionResolver.java#L352-L359 | train |
cqframework/clinical_quality_language | Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/SystemFunctionResolver.java | SystemFunctionResolver.resolveRound | private Round resolveRound(FunctionRef fun) {
if (fun.getOperand().isEmpty() || fun.getOperand().size() > 2) {
throw new IllegalArgumentException("Could not resolve call to system operator Round. Expected 1 or 2 arguments.");
}
final Round round = of.createRound().withOperand(fun.getOperand().get(0));
if (fun.getOperand().size() == 2) {
round.setPrecision(fun.getOperand().get(1));
}
builder.resolveCall("System", "Round", new RoundInvocation(round));
return round;
} | java | private Round resolveRound(FunctionRef fun) {
if (fun.getOperand().isEmpty() || fun.getOperand().size() > 2) {
throw new IllegalArgumentException("Could not resolve call to system operator Round. Expected 1 or 2 arguments.");
}
final Round round = of.createRound().withOperand(fun.getOperand().get(0));
if (fun.getOperand().size() == 2) {
round.setPrecision(fun.getOperand().get(1));
}
builder.resolveCall("System", "Round", new RoundInvocation(round));
return round;
} | [
"private",
"Round",
"resolveRound",
"(",
"FunctionRef",
"fun",
")",
"{",
"if",
"(",
"fun",
".",
"getOperand",
"(",
")",
".",
"isEmpty",
"(",
")",
"||",
"fun",
".",
"getOperand",
"(",
")",
".",
"size",
"(",
")",
">",
"2",
")",
"{",
"throw",
"new",
... | Arithmetic Function Support | [
"Arithmetic",
"Function",
"Support"
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/SystemFunctionResolver.java#L402-L412 | train |
cqframework/clinical_quality_language | Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/SystemFunctionResolver.java | SystemFunctionResolver.resolveDateTime | private DateTime resolveDateTime(FunctionRef fun) {
final DateTime dt = of.createDateTime();
DateTimeInvocation.setDateTimeFieldsFromOperands(dt, fun.getOperand());
builder.resolveCall("System", "DateTime", new DateTimeInvocation(dt));
return dt;
} | java | private DateTime resolveDateTime(FunctionRef fun) {
final DateTime dt = of.createDateTime();
DateTimeInvocation.setDateTimeFieldsFromOperands(dt, fun.getOperand());
builder.resolveCall("System", "DateTime", new DateTimeInvocation(dt));
return dt;
} | [
"private",
"DateTime",
"resolveDateTime",
"(",
"FunctionRef",
"fun",
")",
"{",
"final",
"DateTime",
"dt",
"=",
"of",
".",
"createDateTime",
"(",
")",
";",
"DateTimeInvocation",
".",
"setDateTimeFieldsFromOperands",
"(",
"dt",
",",
"fun",
".",
"getOperand",
"(",
... | DateTime Function Support | [
"DateTime",
"Function",
"Support"
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/SystemFunctionResolver.java#L416-L421 | train |
cqframework/clinical_quality_language | Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/SystemFunctionResolver.java | SystemFunctionResolver.resolveIndexOf | private IndexOf resolveIndexOf(FunctionRef fun) {
checkNumberOfOperands(fun, 2);
final IndexOf indexOf = of.createIndexOf();
indexOf.setSource(fun.getOperand().get(0));
indexOf.setElement(fun.getOperand().get(1));
builder.resolveCall("System", "IndexOf", new IndexOfInvocation(indexOf));
return indexOf;
} | java | private IndexOf resolveIndexOf(FunctionRef fun) {
checkNumberOfOperands(fun, 2);
final IndexOf indexOf = of.createIndexOf();
indexOf.setSource(fun.getOperand().get(0));
indexOf.setElement(fun.getOperand().get(1));
builder.resolveCall("System", "IndexOf", new IndexOfInvocation(indexOf));
return indexOf;
} | [
"private",
"IndexOf",
"resolveIndexOf",
"(",
"FunctionRef",
"fun",
")",
"{",
"checkNumberOfOperands",
"(",
"fun",
",",
"2",
")",
";",
"final",
"IndexOf",
"indexOf",
"=",
"of",
".",
"createIndexOf",
"(",
")",
";",
"indexOf",
".",
"setSource",
"(",
"fun",
".... | List Function Support | [
"List",
"Function",
"Support"
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/SystemFunctionResolver.java#L460-L467 | train |
cqframework/clinical_quality_language | Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/SystemFunctionResolver.java | SystemFunctionResolver.resolveCombine | private Combine resolveCombine(FunctionRef fun) {
if (fun.getOperand().isEmpty() || fun.getOperand().size() > 2) {
throw new IllegalArgumentException("Could not resolve call to system operator Combine. Expected 1 or 2 arguments.");
}
final Combine combine = of.createCombine().withSource(fun.getOperand().get(0));
if (fun.getOperand().size() == 2) {
combine.setSeparator(fun.getOperand().get(1));
}
builder.resolveCall("System", "Combine", new CombineInvocation(combine));
return combine;
} | java | private Combine resolveCombine(FunctionRef fun) {
if (fun.getOperand().isEmpty() || fun.getOperand().size() > 2) {
throw new IllegalArgumentException("Could not resolve call to system operator Combine. Expected 1 or 2 arguments.");
}
final Combine combine = of.createCombine().withSource(fun.getOperand().get(0));
if (fun.getOperand().size() == 2) {
combine.setSeparator(fun.getOperand().get(1));
}
builder.resolveCall("System", "Combine", new CombineInvocation(combine));
return combine;
} | [
"private",
"Combine",
"resolveCombine",
"(",
"FunctionRef",
"fun",
")",
"{",
"if",
"(",
"fun",
".",
"getOperand",
"(",
")",
".",
"isEmpty",
"(",
")",
"||",
"fun",
".",
"getOperand",
"(",
")",
".",
"size",
"(",
")",
">",
"2",
")",
"{",
"throw",
"new... | String Function Support | [
"String",
"Function",
"Support"
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/SystemFunctionResolver.java#L519-L529 | train |
cqframework/clinical_quality_language | Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/SystemFunctionResolver.java | SystemFunctionResolver.resolveUnary | private UnaryExpression resolveUnary(FunctionRef fun) {
UnaryExpression operator = null;
try {
Class clazz = Class.forName("org.hl7.elm.r1." + fun.getName());
if (UnaryExpression.class.isAssignableFrom(clazz)) {
operator = (UnaryExpression) clazz.newInstance();
checkNumberOfOperands(fun, 1);
operator.setOperand(fun.getOperand().get(0));
builder.resolveUnaryCall("System", fun.getName(), operator);
return operator;
}
} catch (Exception e) {
// Do nothing but fall through
}
return null;
} | java | private UnaryExpression resolveUnary(FunctionRef fun) {
UnaryExpression operator = null;
try {
Class clazz = Class.forName("org.hl7.elm.r1." + fun.getName());
if (UnaryExpression.class.isAssignableFrom(clazz)) {
operator = (UnaryExpression) clazz.newInstance();
checkNumberOfOperands(fun, 1);
operator.setOperand(fun.getOperand().get(0));
builder.resolveUnaryCall("System", fun.getName(), operator);
return operator;
}
} catch (Exception e) {
// Do nothing but fall through
}
return null;
} | [
"private",
"UnaryExpression",
"resolveUnary",
"(",
"FunctionRef",
"fun",
")",
"{",
"UnaryExpression",
"operator",
"=",
"null",
";",
"try",
"{",
"Class",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"\"org.hl7.elm.r1.\"",
"+",
"fun",
".",
"getName",
"(",
")",
... | General Function Support | [
"General",
"Function",
"Support"
] | 67459d1ef453e49db8d7c5c86e87278377ed0a0b | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/SystemFunctionResolver.java#L645-L660 | train |
jgilfelt/SystemBarTint | library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java | SystemBarTintManager.setStatusBarTintEnabled | public void setStatusBarTintEnabled(boolean enabled) {
mStatusBarTintEnabled = enabled;
if (mStatusBarAvailable) {
mStatusBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE);
}
} | java | public void setStatusBarTintEnabled(boolean enabled) {
mStatusBarTintEnabled = enabled;
if (mStatusBarAvailable) {
mStatusBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE);
}
} | [
"public",
"void",
"setStatusBarTintEnabled",
"(",
"boolean",
"enabled",
")",
"{",
"mStatusBarTintEnabled",
"=",
"enabled",
";",
"if",
"(",
"mStatusBarAvailable",
")",
"{",
"mStatusBarTintView",
".",
"setVisibility",
"(",
"enabled",
"?",
"View",
".",
"VISIBLE",
":"... | Enable tinting of the system status bar.
If the platform is running Jelly Bean or earlier, or translucent system
UI modes have not been enabled in either the theme or via window flags,
then this method does nothing.
@param enabled True to enable tinting, false to disable it (default). | [
"Enable",
"tinting",
"of",
"the",
"system",
"status",
"bar",
"."
] | daa0796a488b5480ef808aa6363d300675b4af83 | https://github.com/jgilfelt/SystemBarTint/blob/daa0796a488b5480ef808aa6363d300675b4af83/library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java#L140-L145 | train |
jgilfelt/SystemBarTint | library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java | SystemBarTintManager.setNavigationBarTintEnabled | public void setNavigationBarTintEnabled(boolean enabled) {
mNavBarTintEnabled = enabled;
if (mNavBarAvailable) {
mNavBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE);
}
} | java | public void setNavigationBarTintEnabled(boolean enabled) {
mNavBarTintEnabled = enabled;
if (mNavBarAvailable) {
mNavBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE);
}
} | [
"public",
"void",
"setNavigationBarTintEnabled",
"(",
"boolean",
"enabled",
")",
"{",
"mNavBarTintEnabled",
"=",
"enabled",
";",
"if",
"(",
"mNavBarAvailable",
")",
"{",
"mNavBarTintView",
".",
"setVisibility",
"(",
"enabled",
"?",
"View",
".",
"VISIBLE",
":",
"... | Enable tinting of the system navigation bar.
If the platform does not have soft navigation keys, is running Jelly Bean
or earlier, or translucent system UI modes have not been enabled in either
the theme or via window flags, then this method does nothing.
@param enabled True to enable tinting, false to disable it (default). | [
"Enable",
"tinting",
"of",
"the",
"system",
"navigation",
"bar",
"."
] | daa0796a488b5480ef808aa6363d300675b4af83 | https://github.com/jgilfelt/SystemBarTint/blob/daa0796a488b5480ef808aa6363d300675b4af83/library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java#L156-L161 | train |
jgilfelt/SystemBarTint | library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java | SystemBarTintManager.setStatusBarAlpha | @TargetApi(11)
public void setStatusBarAlpha(float alpha) {
if (mStatusBarAvailable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mStatusBarTintView.setAlpha(alpha);
}
} | java | @TargetApi(11)
public void setStatusBarAlpha(float alpha) {
if (mStatusBarAvailable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mStatusBarTintView.setAlpha(alpha);
}
} | [
"@",
"TargetApi",
"(",
"11",
")",
"public",
"void",
"setStatusBarAlpha",
"(",
"float",
"alpha",
")",
"{",
"if",
"(",
"mStatusBarAvailable",
"&&",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"HONEYCOMB",
")",
"{",
"mSt... | Apply the specified alpha to the system status bar.
@param alpha The alpha to use | [
"Apply",
"the",
"specified",
"alpha",
"to",
"the",
"system",
"status",
"bar",
"."
] | daa0796a488b5480ef808aa6363d300675b4af83 | https://github.com/jgilfelt/SystemBarTint/blob/daa0796a488b5480ef808aa6363d300675b4af83/library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java#L242-L247 | train |
jgilfelt/SystemBarTint | library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java | SystemBarTintManager.setNavigationBarAlpha | @TargetApi(11)
public void setNavigationBarAlpha(float alpha) {
if (mNavBarAvailable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mNavBarTintView.setAlpha(alpha);
}
} | java | @TargetApi(11)
public void setNavigationBarAlpha(float alpha) {
if (mNavBarAvailable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mNavBarTintView.setAlpha(alpha);
}
} | [
"@",
"TargetApi",
"(",
"11",
")",
"public",
"void",
"setNavigationBarAlpha",
"(",
"float",
"alpha",
")",
"{",
"if",
"(",
"mNavBarAvailable",
"&&",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"HONEYCOMB",
")",
"{",
"mN... | Apply the specified alpha to the system navigation bar.
@param alpha The alpha to use | [
"Apply",
"the",
"specified",
"alpha",
"to",
"the",
"system",
"navigation",
"bar",
"."
] | daa0796a488b5480ef808aa6363d300675b4af83 | https://github.com/jgilfelt/SystemBarTint/blob/daa0796a488b5480ef808aa6363d300675b4af83/library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java#L288-L293 | train |
sockeqwe/mosby | sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/ShoppingCart.java | ShoppingCart.addProduct | public Completable addProduct(Product product) {
List<Product> updatedShoppingCart = new ArrayList<>();
updatedShoppingCart.addAll(itemsInShoppingCart.getValue());
updatedShoppingCart.add(product);
itemsInShoppingCart.onNext(updatedShoppingCart);
return Completable.complete();
} | java | public Completable addProduct(Product product) {
List<Product> updatedShoppingCart = new ArrayList<>();
updatedShoppingCart.addAll(itemsInShoppingCart.getValue());
updatedShoppingCart.add(product);
itemsInShoppingCart.onNext(updatedShoppingCart);
return Completable.complete();
} | [
"public",
"Completable",
"addProduct",
"(",
"Product",
"product",
")",
"{",
"List",
"<",
"Product",
">",
"updatedShoppingCart",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"updatedShoppingCart",
".",
"addAll",
"(",
"itemsInShoppingCart",
".",
"getValue",
"(",
... | Adds a product to the shopping cart | [
"Adds",
"a",
"product",
"to",
"the",
"shopping",
"cart"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/ShoppingCart.java#L47-L53 | train |
sockeqwe/mosby | sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/ShoppingCart.java | ShoppingCart.removeProduct | public Completable removeProduct(Product product) {
List<Product> updatedShoppingCart = new ArrayList<>();
updatedShoppingCart.addAll(itemsInShoppingCart.getValue());
updatedShoppingCart.remove(product);
itemsInShoppingCart.onNext(updatedShoppingCart);
return Completable.complete();
} | java | public Completable removeProduct(Product product) {
List<Product> updatedShoppingCart = new ArrayList<>();
updatedShoppingCart.addAll(itemsInShoppingCart.getValue());
updatedShoppingCart.remove(product);
itemsInShoppingCart.onNext(updatedShoppingCart);
return Completable.complete();
} | [
"public",
"Completable",
"removeProduct",
"(",
"Product",
"product",
")",
"{",
"List",
"<",
"Product",
">",
"updatedShoppingCart",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"updatedShoppingCart",
".",
"addAll",
"(",
"itemsInShoppingCart",
".",
"getValue",
"(... | Remove a product to the shopping cart | [
"Remove",
"a",
"product",
"to",
"the",
"shopping",
"cart"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/ShoppingCart.java#L58-L64 | train |
sockeqwe/mosby | sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/ShoppingCart.java | ShoppingCart.removeProducts | public Completable removeProducts(List<Product> products) {
List<Product> updatedShoppingCart = new ArrayList<>();
updatedShoppingCart.addAll(itemsInShoppingCart.getValue());
updatedShoppingCart.removeAll(products);
itemsInShoppingCart.onNext(updatedShoppingCart);
return Completable.complete();
} | java | public Completable removeProducts(List<Product> products) {
List<Product> updatedShoppingCart = new ArrayList<>();
updatedShoppingCart.addAll(itemsInShoppingCart.getValue());
updatedShoppingCart.removeAll(products);
itemsInShoppingCart.onNext(updatedShoppingCart);
return Completable.complete();
} | [
"public",
"Completable",
"removeProducts",
"(",
"List",
"<",
"Product",
">",
"products",
")",
"{",
"List",
"<",
"Product",
">",
"updatedShoppingCart",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"updatedShoppingCart",
".",
"addAll",
"(",
"itemsInShoppingCart",... | Remove a list of Products from the shopping cart | [
"Remove",
"a",
"list",
"of",
"Products",
"from",
"the",
"shopping",
"cart"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/ShoppingCart.java#L69-L75 | train |
sockeqwe/mosby | sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/base/presenter/BaseRxLcePresenter.java | BaseRxLcePresenter.subscribe | public void subscribe(Observable<M> observable, final boolean pullToRefresh) {
if (isViewAttached()) {
getView().showLoading(pullToRefresh);
}
unsubscribe();
subscriber = new Subscriber<M>() {
private boolean ptr = pullToRefresh;
@Override public void onCompleted() {
BaseRxLcePresenter.this.onCompleted();
}
@Override public void onError(Throwable e) {
BaseRxLcePresenter.this.onError(e, ptr);
}
@Override public void onNext(M m) {
BaseRxLcePresenter.this.onNext(m);
}
};
observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(subscriber);
} | java | public void subscribe(Observable<M> observable, final boolean pullToRefresh) {
if (isViewAttached()) {
getView().showLoading(pullToRefresh);
}
unsubscribe();
subscriber = new Subscriber<M>() {
private boolean ptr = pullToRefresh;
@Override public void onCompleted() {
BaseRxLcePresenter.this.onCompleted();
}
@Override public void onError(Throwable e) {
BaseRxLcePresenter.this.onError(e, ptr);
}
@Override public void onNext(M m) {
BaseRxLcePresenter.this.onNext(m);
}
};
observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(subscriber);
} | [
"public",
"void",
"subscribe",
"(",
"Observable",
"<",
"M",
">",
"observable",
",",
"final",
"boolean",
"pullToRefresh",
")",
"{",
"if",
"(",
"isViewAttached",
"(",
")",
")",
"{",
"getView",
"(",
")",
".",
"showLoading",
"(",
"pullToRefresh",
")",
";",
"... | Subscribes the presenter himself as subscriber on the observable
@param observable The observable to subscribe
@param pullToRefresh Pull to refresh? | [
"Subscribes",
"the",
"presenter",
"himself",
"as",
"subscriber",
"on",
"the",
"observable"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/base/presenter/BaseRxLcePresenter.java#L60-L87 | train |
sockeqwe/mosby | mvp/src/main/java/com/hannesdorfmann/mosby3/mvp/MvpActivity.java | MvpActivity.getMvpDelegate | @NonNull protected ActivityMvpDelegate<V, P> getMvpDelegate() {
if (mvpDelegate == null) {
mvpDelegate = new ActivityMvpDelegateImpl(this, this, true);
}
return mvpDelegate;
} | java | @NonNull protected ActivityMvpDelegate<V, P> getMvpDelegate() {
if (mvpDelegate == null) {
mvpDelegate = new ActivityMvpDelegateImpl(this, this, true);
}
return mvpDelegate;
} | [
"@",
"NonNull",
"protected",
"ActivityMvpDelegate",
"<",
"V",
",",
"P",
">",
"getMvpDelegate",
"(",
")",
"{",
"if",
"(",
"mvpDelegate",
"==",
"null",
")",
"{",
"mvpDelegate",
"=",
"new",
"ActivityMvpDelegateImpl",
"(",
"this",
",",
"this",
",",
"true",
")"... | Get the mvp delegate. This is internally used for creating presenter, attaching and detaching
view from presenter.
<p><b>Please note that only one instance of mvp delegate should be used per Activity
instance</b>.
</p>
<p>
Only override this method if you really know what you are doing.
</p>
@return {@link ActivityMvpDelegateImpl} | [
"Get",
"the",
"mvp",
"delegate",
".",
"This",
"is",
"internally",
"used",
"for",
"creating",
"presenter",
"attaching",
"and",
"detaching",
"view",
"from",
"presenter",
"."
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/mvp/src/main/java/com/hannesdorfmann/mosby3/mvp/MvpActivity.java#L111-L117 | train |
sockeqwe/mosby | mvi-common/src/main/java/com/hannesdorfmann/mosby3/mvi/MviBasePresenter.java | MviBasePresenter.subscribeViewStateConsumerActually | @MainThread
private void subscribeViewStateConsumerActually(@NonNull final V view) {
if (view == null) {
throw new NullPointerException("View is null");
}
if (viewStateConsumer == null) {
throw new NullPointerException(ViewStateConsumer.class.getSimpleName()
+ " is null. This is a Mosby internal bug. Please file an issue at https://github.com/sockeqwe/mosby/issues");
}
viewRelayConsumerDisposable = viewStateBehaviorSubject.subscribe(new Consumer<VS>() {
@Override
public void accept(VS vs) throws Exception {
viewStateConsumer.accept(view, vs);
}
});
} | java | @MainThread
private void subscribeViewStateConsumerActually(@NonNull final V view) {
if (view == null) {
throw new NullPointerException("View is null");
}
if (viewStateConsumer == null) {
throw new NullPointerException(ViewStateConsumer.class.getSimpleName()
+ " is null. This is a Mosby internal bug. Please file an issue at https://github.com/sockeqwe/mosby/issues");
}
viewRelayConsumerDisposable = viewStateBehaviorSubject.subscribe(new Consumer<VS>() {
@Override
public void accept(VS vs) throws Exception {
viewStateConsumer.accept(view, vs);
}
});
} | [
"@",
"MainThread",
"private",
"void",
"subscribeViewStateConsumerActually",
"(",
"@",
"NonNull",
"final",
"V",
"view",
")",
"{",
"if",
"(",
"view",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"View is null\"",
")",
";",
"}",
"if",
... | Actually subscribes the view as consumer to the internally view relay.
@param view The mvp view | [
"Actually",
"subscribes",
"the",
"view",
"as",
"consumer",
"to",
"the",
"internally",
"view",
"relay",
"."
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/mvi-common/src/main/java/com/hannesdorfmann/mosby3/mvi/MviBasePresenter.java#L375-L393 | train |
sockeqwe/mosby | sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/model/account/DefaultAccountManager.java | DefaultAccountManager.doLogin | @Override public Observable<Account> doLogin(AuthCredentials credentials) {
return Observable.just(credentials).flatMap(new Func1<AuthCredentials, Observable<Account>>() {
@Override public Observable<Account> call(AuthCredentials credentials) {
try {
// Simulate network delay
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (credentials.getUsername().equals("ted") && credentials.getPassword().equals("robin")) {
currentAccount = new Account();
return Observable.just(currentAccount);
}
return Observable.error(new LoginException());
}
});
} | java | @Override public Observable<Account> doLogin(AuthCredentials credentials) {
return Observable.just(credentials).flatMap(new Func1<AuthCredentials, Observable<Account>>() {
@Override public Observable<Account> call(AuthCredentials credentials) {
try {
// Simulate network delay
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (credentials.getUsername().equals("ted") && credentials.getPassword().equals("robin")) {
currentAccount = new Account();
return Observable.just(currentAccount);
}
return Observable.error(new LoginException());
}
});
} | [
"@",
"Override",
"public",
"Observable",
"<",
"Account",
">",
"doLogin",
"(",
"AuthCredentials",
"credentials",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"credentials",
")",
".",
"flatMap",
"(",
"new",
"Func1",
"<",
"AuthCredentials",
",",
"Observabl... | Returns the Account observable | [
"Returns",
"the",
"Account",
"observable"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/model/account/DefaultAccountManager.java#L32-L52 | train |
sockeqwe/mosby | mvp-lce/src/main/java/com/hannesdorfmann/mosby3/mvp/lce/LceAnimator.java | LceAnimator.showErrorView | public static void showErrorView(@NonNull final View loadingView, @NonNull final View contentView,
final View errorView) {
contentView.setVisibility(View.GONE);
final Resources resources = loadingView.getResources();
// Not visible yet, so animate the view in
AnimatorSet set = new AnimatorSet();
ObjectAnimator in = ObjectAnimator.ofFloat(errorView, View.ALPHA, 1f);
ObjectAnimator loadingOut = ObjectAnimator.ofFloat(loadingView, View.ALPHA, 0f);
set.playTogether(in, loadingOut);
set.setDuration(resources.getInteger(R.integer.lce_error_view_show_animation_time));
set.addListener(new AnimatorListenerAdapter() {
@Override public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
errorView.setVisibility(View.VISIBLE);
}
@Override public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
loadingView.setVisibility(View.GONE);
loadingView.setAlpha(1f); // For future showLoading calls
}
});
set.start();
} | java | public static void showErrorView(@NonNull final View loadingView, @NonNull final View contentView,
final View errorView) {
contentView.setVisibility(View.GONE);
final Resources resources = loadingView.getResources();
// Not visible yet, so animate the view in
AnimatorSet set = new AnimatorSet();
ObjectAnimator in = ObjectAnimator.ofFloat(errorView, View.ALPHA, 1f);
ObjectAnimator loadingOut = ObjectAnimator.ofFloat(loadingView, View.ALPHA, 0f);
set.playTogether(in, loadingOut);
set.setDuration(resources.getInteger(R.integer.lce_error_view_show_animation_time));
set.addListener(new AnimatorListenerAdapter() {
@Override public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
errorView.setVisibility(View.VISIBLE);
}
@Override public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
loadingView.setVisibility(View.GONE);
loadingView.setAlpha(1f); // For future showLoading calls
}
});
set.start();
} | [
"public",
"static",
"void",
"showErrorView",
"(",
"@",
"NonNull",
"final",
"View",
"loadingView",
",",
"@",
"NonNull",
"final",
"View",
"contentView",
",",
"final",
"View",
"errorView",
")",
"{",
"contentView",
".",
"setVisibility",
"(",
"View",
".",
"GONE",
... | Shows the error view instead of the loading view | [
"Shows",
"the",
"error",
"view",
"instead",
"of",
"the",
"loading",
"view"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/mvp-lce/src/main/java/com/hannesdorfmann/mosby3/mvp/lce/LceAnimator.java#L53-L82 | train |
sockeqwe/mosby | mvp-lce/src/main/java/com/hannesdorfmann/mosby3/mvp/lce/LceAnimator.java | LceAnimator.showContent | public static void showContent(@NonNull final View loadingView, @NonNull final View contentView,
@NonNull final View errorView) {
if (contentView.getVisibility() == View.VISIBLE) {
// No Changing needed, because contentView is already visible
errorView.setVisibility(View.GONE);
loadingView.setVisibility(View.GONE);
} else {
errorView.setVisibility(View.GONE);
final Resources resources = loadingView.getResources();
final int translateInPixels = resources.getDimensionPixelSize(R.dimen.lce_content_view_animation_translate_y);
// Not visible yet, so animate the view in
AnimatorSet set = new AnimatorSet();
ObjectAnimator contentFadeIn = ObjectAnimator.ofFloat(contentView, View.ALPHA, 0f, 1f);
ObjectAnimator contentTranslateIn = ObjectAnimator.ofFloat(contentView, View.TRANSLATION_Y,
translateInPixels, 0);
ObjectAnimator loadingFadeOut = ObjectAnimator.ofFloat(loadingView, View.ALPHA, 1f, 0f);
ObjectAnimator loadingTranslateOut = ObjectAnimator.ofFloat(loadingView, View.TRANSLATION_Y, 0,
-translateInPixels);
set.playTogether(contentFadeIn, contentTranslateIn, loadingFadeOut, loadingTranslateOut);
set.setDuration(resources.getInteger(R.integer.lce_content_view_show_animation_time));
set.addListener(new AnimatorListenerAdapter() {
@Override public void onAnimationStart(Animator animation) {
contentView.setTranslationY(0);
loadingView.setTranslationY(0);
contentView.setVisibility(View.VISIBLE);
}
@Override public void onAnimationEnd(Animator animation) {
loadingView.setVisibility(View.GONE);
loadingView.setAlpha(1f); // For future showLoading calls
contentView.setTranslationY(0);
loadingView.setTranslationY(0);
}
});
set.start();
}
} | java | public static void showContent(@NonNull final View loadingView, @NonNull final View contentView,
@NonNull final View errorView) {
if (contentView.getVisibility() == View.VISIBLE) {
// No Changing needed, because contentView is already visible
errorView.setVisibility(View.GONE);
loadingView.setVisibility(View.GONE);
} else {
errorView.setVisibility(View.GONE);
final Resources resources = loadingView.getResources();
final int translateInPixels = resources.getDimensionPixelSize(R.dimen.lce_content_view_animation_translate_y);
// Not visible yet, so animate the view in
AnimatorSet set = new AnimatorSet();
ObjectAnimator contentFadeIn = ObjectAnimator.ofFloat(contentView, View.ALPHA, 0f, 1f);
ObjectAnimator contentTranslateIn = ObjectAnimator.ofFloat(contentView, View.TRANSLATION_Y,
translateInPixels, 0);
ObjectAnimator loadingFadeOut = ObjectAnimator.ofFloat(loadingView, View.ALPHA, 1f, 0f);
ObjectAnimator loadingTranslateOut = ObjectAnimator.ofFloat(loadingView, View.TRANSLATION_Y, 0,
-translateInPixels);
set.playTogether(contentFadeIn, contentTranslateIn, loadingFadeOut, loadingTranslateOut);
set.setDuration(resources.getInteger(R.integer.lce_content_view_show_animation_time));
set.addListener(new AnimatorListenerAdapter() {
@Override public void onAnimationStart(Animator animation) {
contentView.setTranslationY(0);
loadingView.setTranslationY(0);
contentView.setVisibility(View.VISIBLE);
}
@Override public void onAnimationEnd(Animator animation) {
loadingView.setVisibility(View.GONE);
loadingView.setAlpha(1f); // For future showLoading calls
contentView.setTranslationY(0);
loadingView.setTranslationY(0);
}
});
set.start();
}
} | [
"public",
"static",
"void",
"showContent",
"(",
"@",
"NonNull",
"final",
"View",
"loadingView",
",",
"@",
"NonNull",
"final",
"View",
"contentView",
",",
"@",
"NonNull",
"final",
"View",
"errorView",
")",
"{",
"if",
"(",
"contentView",
".",
"getVisibility",
... | Display the content instead of the loadingView | [
"Display",
"the",
"content",
"instead",
"of",
"the",
"loadingView"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/mvp-lce/src/main/java/com/hannesdorfmann/mosby3/mvp/lce/LceAnimator.java#L87-L131 | train |
sockeqwe/mosby | mvp-nullobject-presenter/src/main/java/com/hannesdorfmann/mosby3/mvp/MvpNullObjectBasePresenter.java | MvpNullObjectBasePresenter.isSubTypeOfMvpView | private boolean isSubTypeOfMvpView(Class<?> klass) {
if (klass.equals(MvpView.class)) {
return true;
}
Class[] superInterfaces = klass.getInterfaces();
for (int i = 0; i < superInterfaces.length; i++) {
if (isSubTypeOfMvpView(superInterfaces[i])) {
return true;
}
}
return false;
} | java | private boolean isSubTypeOfMvpView(Class<?> klass) {
if (klass.equals(MvpView.class)) {
return true;
}
Class[] superInterfaces = klass.getInterfaces();
for (int i = 0; i < superInterfaces.length; i++) {
if (isSubTypeOfMvpView(superInterfaces[i])) {
return true;
}
}
return false;
} | [
"private",
"boolean",
"isSubTypeOfMvpView",
"(",
"Class",
"<",
"?",
">",
"klass",
")",
"{",
"if",
"(",
"klass",
".",
"equals",
"(",
"MvpView",
".",
"class",
")",
")",
"{",
"return",
"true",
";",
"}",
"Class",
"[",
"]",
"superInterfaces",
"=",
"klass",
... | Scans the interface inheritance hierarchy and checks if on the root is MvpView.class
@param klass The leaf interface where to begin to scan
@return true if subtype of MvpView, otherwise false | [
"Scans",
"the",
"interface",
"inheritance",
"hierarchy",
"and",
"checks",
"if",
"on",
"the",
"root",
"is",
"MvpView",
".",
"class"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/mvp-nullobject-presenter/src/main/java/com/hannesdorfmann/mosby3/mvp/MvpNullObjectBasePresenter.java#L85-L96 | train |
sockeqwe/mosby | sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/utils/DimensUtils.java | DimensUtils.dpToPx | public static int dpToPx(Context context, float dp) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
return (int) ((dp * displayMetrics.density) + 0.5);
} | java | public static int dpToPx(Context context, float dp) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
return (int) ((dp * displayMetrics.density) + 0.5);
} | [
"public",
"static",
"int",
"dpToPx",
"(",
"Context",
"context",
",",
"float",
"dp",
")",
"{",
"DisplayMetrics",
"displayMetrics",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"getDisplayMetrics",
"(",
")",
";",
"return",
"(",
"int",
")",
"(",
"(",
... | Converts a dp value to a px value
@param context The context
@param dp the dp value
@return value in pixels | [
"Converts",
"a",
"dp",
"value",
"to",
"a",
"px",
"value"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/utils/DimensUtils.java#L21-L24 | train |
sockeqwe/mosby | sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/utils/DimensUtils.java | DimensUtils.pxToDp | public static int pxToDp(Context context, int px) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
return (int) ((px / displayMetrics.density) + 0.5);
} | java | public static int pxToDp(Context context, int px) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
return (int) ((px / displayMetrics.density) + 0.5);
} | [
"public",
"static",
"int",
"pxToDp",
"(",
"Context",
"context",
",",
"int",
"px",
")",
"{",
"DisplayMetrics",
"displayMetrics",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"getDisplayMetrics",
"(",
")",
";",
"return",
"(",
"int",
")",
"(",
"(",
"... | Converts pixel in dp
@param context The context
@param px the pixel value
@return value in dp | [
"Converts",
"pixel",
"in",
"dp"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/utils/DimensUtils.java#L33-L36 | train |
sockeqwe/mosby | sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/utils/DimensUtils.java | DimensUtils.pxToSp | public static float pxToSp(Context context, Float px) {
float scaledDensity = context.getResources().getDisplayMetrics().scaledDensity;
return px / scaledDensity;
} | java | public static float pxToSp(Context context, Float px) {
float scaledDensity = context.getResources().getDisplayMetrics().scaledDensity;
return px / scaledDensity;
} | [
"public",
"static",
"float",
"pxToSp",
"(",
"Context",
"context",
",",
"Float",
"px",
")",
"{",
"float",
"scaledDensity",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"getDisplayMetrics",
"(",
")",
".",
"scaledDensity",
";",
"return",
"px",
"/",
"sc... | Convertes pixels to sp | [
"Convertes",
"pixels",
"to",
"sp"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/utils/DimensUtils.java#L41-L44 | train |
sockeqwe/mosby | viewstate/src/main/java/com/hannesdorfmann/mosby3/mvp/delegate/FragmentMvpViewStateDelegateImpl.java | FragmentMvpViewStateDelegateImpl.restorePresenterOrRecreateNewPresenterAfterProcessDeath | private P restorePresenterOrRecreateNewPresenterAfterProcessDeath() {
P presenter;
if (keepPresenterInstanceDuringScreenOrientationChanges) {
if (mosbyViewId != null
&& (presenter = PresenterManager.getPresenter(getActivity(), mosbyViewId)) != null) {
//
// Presenter restored from cache
//
if (DEBUG) {
Log.d(DEBUG_TAG,
"Reused presenter " + presenter + " for view " + delegateCallback.getMvpView());
}
return presenter;
} else {
//
// No presenter found in cache, most likely caused by process death
//
presenter = createViewIdAndPresenter();
if (DEBUG) {
Log.d(DEBUG_TAG, "No presenter found although view Id was here: "
+ mosbyViewId
+ ". Most likely this was caused by a process death. New Presenter created"
+ presenter
+ " for view "
+ delegateCallback.getMvpView());
}
return presenter;
}
} else {
//
// starting first time, so create a new presenter
//
presenter = createViewIdAndPresenter();
if (DEBUG) {
Log.d(DEBUG_TAG,
"New presenter " + presenter + " for view " + delegateCallback.getMvpView());
}
return presenter;
}
} | java | private P restorePresenterOrRecreateNewPresenterAfterProcessDeath() {
P presenter;
if (keepPresenterInstanceDuringScreenOrientationChanges) {
if (mosbyViewId != null
&& (presenter = PresenterManager.getPresenter(getActivity(), mosbyViewId)) != null) {
//
// Presenter restored from cache
//
if (DEBUG) {
Log.d(DEBUG_TAG,
"Reused presenter " + presenter + " for view " + delegateCallback.getMvpView());
}
return presenter;
} else {
//
// No presenter found in cache, most likely caused by process death
//
presenter = createViewIdAndPresenter();
if (DEBUG) {
Log.d(DEBUG_TAG, "No presenter found although view Id was here: "
+ mosbyViewId
+ ". Most likely this was caused by a process death. New Presenter created"
+ presenter
+ " for view "
+ delegateCallback.getMvpView());
}
return presenter;
}
} else {
//
// starting first time, so create a new presenter
//
presenter = createViewIdAndPresenter();
if (DEBUG) {
Log.d(DEBUG_TAG,
"New presenter " + presenter + " for view " + delegateCallback.getMvpView());
}
return presenter;
}
} | [
"private",
"P",
"restorePresenterOrRecreateNewPresenterAfterProcessDeath",
"(",
")",
"{",
"P",
"presenter",
";",
"if",
"(",
"keepPresenterInstanceDuringScreenOrientationChanges",
")",
"{",
"if",
"(",
"mosbyViewId",
"!=",
"null",
"&&",
"(",
"presenter",
"=",
"PresenterMa... | Creates the presenter instance if not able to reuse presenter from PresenterManager | [
"Creates",
"the",
"presenter",
"instance",
"if",
"not",
"able",
"to",
"reuse",
"presenter",
"from",
"PresenterManager"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/viewstate/src/main/java/com/hannesdorfmann/mosby3/mvp/delegate/FragmentMvpViewStateDelegateImpl.java#L279-L323 | train |
sockeqwe/mosby | viewstate/src/main/java/com/hannesdorfmann/mosby3/mvp/delegate/FragmentMvpViewStateDelegateImpl.java | FragmentMvpViewStateDelegateImpl.createViewState | private VS createViewState() {
VS viewState = delegateCallback.createViewState();
if (viewState == null) {
throw new NullPointerException(
"ViewState returned from createViewState() is null. Fragment is " + fragment);
}
if (keepPresenterInstanceDuringScreenOrientationChanges) {
PresenterManager.putViewState(getActivity(), mosbyViewId, viewState);
}
return viewState;
} | java | private VS createViewState() {
VS viewState = delegateCallback.createViewState();
if (viewState == null) {
throw new NullPointerException(
"ViewState returned from createViewState() is null. Fragment is " + fragment);
}
if (keepPresenterInstanceDuringScreenOrientationChanges) {
PresenterManager.putViewState(getActivity(), mosbyViewId, viewState);
}
return viewState;
} | [
"private",
"VS",
"createViewState",
"(",
")",
"{",
"VS",
"viewState",
"=",
"delegateCallback",
".",
"createViewState",
"(",
")",
";",
"if",
"(",
"viewState",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"ViewState returned from createView... | Creates a new ViewState instance
@return the newly created instance | [
"Creates",
"a",
"new",
"ViewState",
"instance"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/viewstate/src/main/java/com/hannesdorfmann/mosby3/mvp/delegate/FragmentMvpViewStateDelegateImpl.java#L363-L375 | train |
sockeqwe/mosby | sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/interactor/details/DetailsInteractor.java | DetailsInteractor.getDetails | public Observable<ProductDetailsViewState> getDetails(int productId) {
return getProductWithShoppingCartInfo(productId)
.subscribeOn(Schedulers.io())
.map(ProductDetailsViewState.DataState::new)
.cast(ProductDetailsViewState.class)
.startWith(new ProductDetailsViewState.LoadingState())
.onErrorReturn(ProductDetailsViewState.ErrorState::new);
} | java | public Observable<ProductDetailsViewState> getDetails(int productId) {
return getProductWithShoppingCartInfo(productId)
.subscribeOn(Schedulers.io())
.map(ProductDetailsViewState.DataState::new)
.cast(ProductDetailsViewState.class)
.startWith(new ProductDetailsViewState.LoadingState())
.onErrorReturn(ProductDetailsViewState.ErrorState::new);
} | [
"public",
"Observable",
"<",
"ProductDetailsViewState",
">",
"getDetails",
"(",
"int",
"productId",
")",
"{",
"return",
"getProductWithShoppingCartInfo",
"(",
"productId",
")",
".",
"subscribeOn",
"(",
"Schedulers",
".",
"io",
"(",
")",
")",
".",
"map",
"(",
"... | Get the details of a given product | [
"Get",
"the",
"details",
"of",
"a",
"given",
"product"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/interactor/details/DetailsInteractor.java#L67-L74 | train |
sockeqwe/mosby | sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/http/ProductBackendApiDecorator.java | ProductBackendApiDecorator.getAllProducts | public Observable<List<Product>> getAllProducts() {
return Observable.zip(getProducts(0), getProducts(1), getProducts(2), getProducts(3),
(products0, products1, products2, products3) -> {
List<Product> productList = new ArrayList<Product>();
productList.addAll(products0);
productList.addAll(products1);
productList.addAll(products2);
productList.addAll(products3);
return productList;
});
} | java | public Observable<List<Product>> getAllProducts() {
return Observable.zip(getProducts(0), getProducts(1), getProducts(2), getProducts(3),
(products0, products1, products2, products3) -> {
List<Product> productList = new ArrayList<Product>();
productList.addAll(products0);
productList.addAll(products1);
productList.addAll(products2);
productList.addAll(products3);
return productList;
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"Product",
">",
">",
"getAllProducts",
"(",
")",
"{",
"return",
"Observable",
".",
"zip",
"(",
"getProducts",
"(",
"0",
")",
",",
"getProducts",
"(",
"1",
")",
",",
"getProducts",
"(",
"2",
")",
",",
"getProduc... | Get a list with all products from backend | [
"Get",
"a",
"list",
"with",
"all",
"products",
"from",
"backend"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/http/ProductBackendApiDecorator.java#L52-L62 | train |
sockeqwe/mosby | sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/http/ProductBackendApiDecorator.java | ProductBackendApiDecorator.getAllProductsOfCategory | public Observable<List<Product>> getAllProductsOfCategory(String categoryName) {
return getAllProducts().flatMap(Observable::fromIterable)
.filter(product -> product.getCategory().equals(categoryName))
.toList()
.toObservable();
} | java | public Observable<List<Product>> getAllProductsOfCategory(String categoryName) {
return getAllProducts().flatMap(Observable::fromIterable)
.filter(product -> product.getCategory().equals(categoryName))
.toList()
.toObservable();
} | [
"public",
"Observable",
"<",
"List",
"<",
"Product",
">",
">",
"getAllProductsOfCategory",
"(",
"String",
"categoryName",
")",
"{",
"return",
"getAllProducts",
"(",
")",
".",
"flatMap",
"(",
"Observable",
"::",
"fromIterable",
")",
".",
"filter",
"(",
"product... | Get all products of a certain category
@param categoryName The name of the category | [
"Get",
"all",
"products",
"of",
"a",
"certain",
"category"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/http/ProductBackendApiDecorator.java#L69-L74 | train |
sockeqwe/mosby | sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/http/ProductBackendApiDecorator.java | ProductBackendApiDecorator.getAllCategories | public Observable<List<String>> getAllCategories() {
return getAllProducts().map(products -> {
Set<String> categories = new HashSet<String>();
for (Product p : products) {
categories.add(p.getCategory());
}
List<String> result = new ArrayList<String>(categories.size());
result.addAll(categories);
return result;
});
} | java | public Observable<List<String>> getAllCategories() {
return getAllProducts().map(products -> {
Set<String> categories = new HashSet<String>();
for (Product p : products) {
categories.add(p.getCategory());
}
List<String> result = new ArrayList<String>(categories.size());
result.addAll(categories);
return result;
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"String",
">",
">",
"getAllCategories",
"(",
")",
"{",
"return",
"getAllProducts",
"(",
")",
".",
"map",
"(",
"products",
"->",
"{",
"Set",
"<",
"String",
">",
"categories",
"=",
"new",
"HashSet",
"<",
"String",
... | Get a list with all categories | [
"Get",
"a",
"list",
"with",
"all",
"categories"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/http/ProductBackendApiDecorator.java#L79-L90 | train |
sockeqwe/mosby | sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/http/ProductBackendApiDecorator.java | ProductBackendApiDecorator.getProduct | public Observable<Product> getProduct(int productId) {
return getAllProducts().flatMap(products -> Observable.fromIterable(products))
.filter(product -> product.getId() == productId)
.take(1);
} | java | public Observable<Product> getProduct(int productId) {
return getAllProducts().flatMap(products -> Observable.fromIterable(products))
.filter(product -> product.getId() == productId)
.take(1);
} | [
"public",
"Observable",
"<",
"Product",
">",
"getProduct",
"(",
"int",
"productId",
")",
"{",
"return",
"getAllProducts",
"(",
")",
".",
"flatMap",
"(",
"products",
"->",
"Observable",
".",
"fromIterable",
"(",
"products",
")",
")",
".",
"filter",
"(",
"pr... | Get the product with the given id
@param productId The product id | [
"Get",
"the",
"product",
"with",
"the",
"given",
"id"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/http/ProductBackendApiDecorator.java#L97-L101 | train |
sockeqwe/mosby | sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/feed/HomeFeedLoader.java | HomeFeedLoader.loadProductsOfCategory | public Observable<List<Product>> loadProductsOfCategory(String categoryName) {
return backendApi.getAllProductsOfCategory(categoryName).delay(3, TimeUnit.SECONDS);
} | java | public Observable<List<Product>> loadProductsOfCategory(String categoryName) {
return backendApi.getAllProductsOfCategory(categoryName).delay(3, TimeUnit.SECONDS);
} | [
"public",
"Observable",
"<",
"List",
"<",
"Product",
">",
">",
"loadProductsOfCategory",
"(",
"String",
"categoryName",
")",
"{",
"return",
"backendApi",
".",
"getAllProductsOfCategory",
"(",
"categoryName",
")",
".",
"delay",
"(",
"3",
",",
"TimeUnit",
".",
"... | Loads all items of a given category
@param categoryName the category name | [
"Loads",
"all",
"items",
"of",
"a",
"given",
"category"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/feed/HomeFeedLoader.java#L68-L70 | train |
sockeqwe/mosby | mvp-queuing-presenter/src/main/java/com/hannesdorfmann/mosby3/mvp/MvpQueuingBasePresenter.java | MvpQueuingBasePresenter.runQueuedActions | private void runQueuedActions() {
V view = viewRef == null ? null : viewRef.get();
if (view != null) {
while (!viewActionQueue.isEmpty()) {
ViewAction<V> action = viewActionQueue.poll();
action.run(view);
}
}
} | java | private void runQueuedActions() {
V view = viewRef == null ? null : viewRef.get();
if (view != null) {
while (!viewActionQueue.isEmpty()) {
ViewAction<V> action = viewActionQueue.poll();
action.run(view);
}
}
} | [
"private",
"void",
"runQueuedActions",
"(",
")",
"{",
"V",
"view",
"=",
"viewRef",
"==",
"null",
"?",
"null",
":",
"viewRef",
".",
"get",
"(",
")",
";",
"if",
"(",
"view",
"!=",
"null",
")",
"{",
"while",
"(",
"!",
"viewActionQueue",
".",
"isEmpty",
... | Runs the queued actions. | [
"Runs",
"the",
"queued",
"actions",
"."
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/mvp-queuing-presenter/src/main/java/com/hannesdorfmann/mosby3/mvp/MvpQueuingBasePresenter.java#L108-L116 | train |
sockeqwe/mosby | sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/utils/KeyboardUtils.java | KeyboardUtils.hideKeyboard | public static boolean hideKeyboard(View view) {
if (view == null) {
throw new NullPointerException("View is null!");
}
try {
InputMethodManager imm =
(InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null) {
return false;
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
} catch (Exception e) {
return false;
}
return true;
} | java | public static boolean hideKeyboard(View view) {
if (view == null) {
throw new NullPointerException("View is null!");
}
try {
InputMethodManager imm =
(InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null) {
return false;
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
} catch (Exception e) {
return false;
}
return true;
} | [
"public",
"static",
"boolean",
"hideKeyboard",
"(",
"View",
"view",
")",
"{",
"if",
"(",
"view",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"View is null!\"",
")",
";",
"}",
"try",
"{",
"InputMethodManager",
"imm",
"=",
"(",
"In... | Hides the soft keyboard from screen
@param view Usually the EditText, but in dynamically layouts you should pass the layout
instead of the EditText
@return true, if keyboard has been hidden, otherwise false (i.e. the keyboard was not displayed
on the screen or no Softkeyboard because device has hardware keyboard) | [
"Hides",
"the",
"soft",
"keyboard",
"from",
"screen"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/utils/KeyboardUtils.java#L33-L53 | train |
sockeqwe/mosby | sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/interactor/search/SearchInteractor.java | SearchInteractor.search | public Observable<SearchViewState> search(String searchString) {
// Empty String, so no search
if (searchString.isEmpty()) {
return Observable.just(new SearchViewState.SearchNotStartedYet());
}
// search for product
return searchEngine.searchFor(searchString)
.map(products -> {
if (products.isEmpty()) {
return new SearchViewState.EmptyResult(searchString);
} else {
return new SearchViewState.SearchResult(searchString, products);
}
})
.startWith(new SearchViewState.Loading())
.onErrorReturn(error -> new SearchViewState.Error(searchString, error));
} | java | public Observable<SearchViewState> search(String searchString) {
// Empty String, so no search
if (searchString.isEmpty()) {
return Observable.just(new SearchViewState.SearchNotStartedYet());
}
// search for product
return searchEngine.searchFor(searchString)
.map(products -> {
if (products.isEmpty()) {
return new SearchViewState.EmptyResult(searchString);
} else {
return new SearchViewState.SearchResult(searchString, products);
}
})
.startWith(new SearchViewState.Loading())
.onErrorReturn(error -> new SearchViewState.Error(searchString, error));
} | [
"public",
"Observable",
"<",
"SearchViewState",
">",
"search",
"(",
"String",
"searchString",
")",
"{",
"// Empty String, so no search",
"if",
"(",
"searchString",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"new",
"SearchViewSt... | Search for items | [
"Search",
"for",
"items"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/interactor/search/SearchInteractor.java#L38-L55 | train |
sockeqwe/mosby | sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/model/mail/MailProvider.java | MailProvider.getLabels | public Observable<List<Label>> getLabels() {
return Observable.just(mails).flatMap(new Func1<List<Mail>, Observable<List<Label>>>() {
@Override public Observable<List<Label>> call(List<Mail> mails) {
delay();
Observable error = checkExceptions();
if (error != null) {
return error;
}
List<Label> labels = new ArrayList<>(4);
labels.add(INBOX_LABEL);
labels.add(sentLabel);
labels.add(spamLabel);
labels.add(trashLabel);
int inbox = 0;
int spam = 0;
int sent = 0;
int trash = 0;
for (Mail m : mails) {
if (m.isRead()) {
continue;
}
switch (m.getLabel()) {
case Label.INBOX:
inbox++;
break;
case Label.SENT:
sent++;
break;
case Label.SPAM:
spam++;
break;
case Label.TRASH:
trash++;
break;
}
}
INBOX_LABEL.setUnreadCount(inbox);
sentLabel.setUnreadCount(sent);
spamLabel.setUnreadCount(spam);
trashLabel.setUnreadCount(trash);
return Observable.just(labels);
}
});
} | java | public Observable<List<Label>> getLabels() {
return Observable.just(mails).flatMap(new Func1<List<Mail>, Observable<List<Label>>>() {
@Override public Observable<List<Label>> call(List<Mail> mails) {
delay();
Observable error = checkExceptions();
if (error != null) {
return error;
}
List<Label> labels = new ArrayList<>(4);
labels.add(INBOX_LABEL);
labels.add(sentLabel);
labels.add(spamLabel);
labels.add(trashLabel);
int inbox = 0;
int spam = 0;
int sent = 0;
int trash = 0;
for (Mail m : mails) {
if (m.isRead()) {
continue;
}
switch (m.getLabel()) {
case Label.INBOX:
inbox++;
break;
case Label.SENT:
sent++;
break;
case Label.SPAM:
spam++;
break;
case Label.TRASH:
trash++;
break;
}
}
INBOX_LABEL.setUnreadCount(inbox);
sentLabel.setUnreadCount(sent);
spamLabel.setUnreadCount(spam);
trashLabel.setUnreadCount(trash);
return Observable.just(labels);
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"Label",
">",
">",
"getLabels",
"(",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"mails",
")",
".",
"flatMap",
"(",
"new",
"Func1",
"<",
"List",
"<",
"Mail",
">",
",",
"Observable",
"<",
"List",
"<",
... | Get the labels with the number of unread mails. | [
"Get",
"the",
"labels",
"with",
"the",
"number",
"of",
"unread",
"mails",
"."
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/model/mail/MailProvider.java#L63-L118 | train |
sockeqwe/mosby | sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/model/mail/MailProvider.java | MailProvider.getMailsOfLabel | public Observable<List<Mail>> getMailsOfLabel(final String l) {
return getFilteredMailList(new Func1<Mail, Boolean>() {
@Override public Boolean call(Mail mail) {
return mail.getLabel().equals(l);
}
});
} | java | public Observable<List<Mail>> getMailsOfLabel(final String l) {
return getFilteredMailList(new Func1<Mail, Boolean>() {
@Override public Boolean call(Mail mail) {
return mail.getLabel().equals(l);
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"Mail",
">",
">",
"getMailsOfLabel",
"(",
"final",
"String",
"l",
")",
"{",
"return",
"getFilteredMailList",
"(",
"new",
"Func1",
"<",
"Mail",
",",
"Boolean",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Boole... | Get a list of mails with the given label | [
"Get",
"a",
"list",
"of",
"mails",
"with",
"the",
"given",
"label"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/model/mail/MailProvider.java#L140-L147 | train |
sockeqwe/mosby | sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/model/mail/MailProvider.java | MailProvider.starMail | public Observable<Mail> starMail(int mailId, final boolean star) {
return getMail(mailId).map(new Func1<Mail, Mail>() {
@Override public Mail call(Mail mail) {
mail.setStarred(star);
return mail;
}
});
} | java | public Observable<Mail> starMail(int mailId, final boolean star) {
return getMail(mailId).map(new Func1<Mail, Mail>() {
@Override public Mail call(Mail mail) {
mail.setStarred(star);
return mail;
}
});
} | [
"public",
"Observable",
"<",
"Mail",
">",
"starMail",
"(",
"int",
"mailId",
",",
"final",
"boolean",
"star",
")",
"{",
"return",
"getMail",
"(",
"mailId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"Mail",
",",
"Mail",
">",
"(",
")",
"{",
"@",
"Ove... | Star or unstar a mail
@param mailId the id of the mail
@param star true, if you want to star, false if you want to unstar | [
"Star",
"or",
"unstar",
"a",
"mail"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/model/mail/MailProvider.java#L177-L185 | train |
sockeqwe/mosby | sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/model/mail/MailProvider.java | MailProvider.addMailWithDelay | public Observable<Mail> addMailWithDelay(final Mail mail) {
return Observable.defer(new Func0<Observable<Mail>>() {
@Override public Observable<Mail> call() {
delay();
Observable o = checkExceptions();
if (o != null) {
return o;
}
return Observable.just(mail);
}
}).flatMap(new Func1<Mail, Observable<Mail>>() {
@Override public Observable<Mail> call(Mail mail) {
return addMail(mail);
}
});
} | java | public Observable<Mail> addMailWithDelay(final Mail mail) {
return Observable.defer(new Func0<Observable<Mail>>() {
@Override public Observable<Mail> call() {
delay();
Observable o = checkExceptions();
if (o != null) {
return o;
}
return Observable.just(mail);
}
}).flatMap(new Func1<Mail, Observable<Mail>>() {
@Override public Observable<Mail> call(Mail mail) {
return addMail(mail);
}
});
} | [
"public",
"Observable",
"<",
"Mail",
">",
"addMailWithDelay",
"(",
"final",
"Mail",
"mail",
")",
"{",
"return",
"Observable",
".",
"defer",
"(",
"new",
"Func0",
"<",
"Observable",
"<",
"Mail",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observab... | Creates and saves a new mail | [
"Creates",
"and",
"saves",
"a",
"new",
"mail"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/model/mail/MailProvider.java#L190-L206 | train |
sockeqwe/mosby | sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/model/mail/MailProvider.java | MailProvider.getFilteredMailList | private Observable<List<Mail>> getFilteredMailList(Func1<Mail, Boolean> filterFnc,
final boolean withDelayAndError) {
return Observable.defer(new Func0<Observable<Mail>>() {
@Override public Observable<Mail> call() {
if (withDelayAndError) {
delay();
Observable o = checkExceptions();
if (o != null) {
return o;
}
}
return Observable.from(mails);
}
}).filter(filterFnc).collect(new Func0<List<Mail>>() {
@Override public List<Mail> call() {
return new ArrayList<Mail>();
}
}, new Action2<List<Mail>, Mail>() {
@Override public void call(List<Mail> mails, Mail mail) {
mails.add(mail);
}
}).map(new Func1<List<Mail>, List<Mail>>() {
@Override public List<Mail> call(List<Mail> mails) {
Collections.sort(mails, MailComparator.INSTANCE);
return mails;
}
});
} | java | private Observable<List<Mail>> getFilteredMailList(Func1<Mail, Boolean> filterFnc,
final boolean withDelayAndError) {
return Observable.defer(new Func0<Observable<Mail>>() {
@Override public Observable<Mail> call() {
if (withDelayAndError) {
delay();
Observable o = checkExceptions();
if (o != null) {
return o;
}
}
return Observable.from(mails);
}
}).filter(filterFnc).collect(new Func0<List<Mail>>() {
@Override public List<Mail> call() {
return new ArrayList<Mail>();
}
}, new Action2<List<Mail>, Mail>() {
@Override public void call(List<Mail> mails, Mail mail) {
mails.add(mail);
}
}).map(new Func1<List<Mail>, List<Mail>>() {
@Override public List<Mail> call(List<Mail> mails) {
Collections.sort(mails, MailComparator.INSTANCE);
return mails;
}
});
} | [
"private",
"Observable",
"<",
"List",
"<",
"Mail",
">",
">",
"getFilteredMailList",
"(",
"Func1",
"<",
"Mail",
",",
"Boolean",
">",
"filterFnc",
",",
"final",
"boolean",
"withDelayAndError",
")",
"{",
"return",
"Observable",
".",
"defer",
"(",
"new",
"Func0"... | Filters the list of mails by the given criteria | [
"Filters",
"the",
"list",
"of",
"mails",
"by",
"the",
"given",
"criteria"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/model/mail/MailProvider.java#L305-L334 | train |
sockeqwe/mosby | sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/mails/MailsAdapter.java | MailsAdapter.findMail | public Mail findMail(int id) {
if (items == null) {
return null;
}
for (Mail m : items) {
if (m.getId() == id) {
return m;
}
}
return null;
} | java | public Mail findMail(int id) {
if (items == null) {
return null;
}
for (Mail m : items) {
if (m.getId() == id) {
return m;
}
}
return null;
} | [
"public",
"Mail",
"findMail",
"(",
"int",
"id",
")",
"{",
"if",
"(",
"items",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"Mail",
"m",
":",
"items",
")",
"{",
"if",
"(",
"m",
".",
"getId",
"(",
")",
"==",
"id",
")",
"{",
... | Finds a mail by his id if displayed in this adapter | [
"Finds",
"a",
"mail",
"by",
"his",
"id",
"if",
"displayed",
"in",
"this",
"adapter"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/mails/MailsAdapter.java#L120-L132 | train |
sockeqwe/mosby | sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/searchengine/SearchEngine.java | SearchEngine.isProductMatchingSearchCriteria | private boolean isProductMatchingSearchCriteria(Product product, String searchQueryText) {
String words[] = searchQueryText.split(" ");
for (String w : words) {
if (product.getName().contains(w)) return true;
if (product.getDescription().contains(w)) return true;
if (product.getCategory().contains(w)) return true;
}
return false;
} | java | private boolean isProductMatchingSearchCriteria(Product product, String searchQueryText) {
String words[] = searchQueryText.split(" ");
for (String w : words) {
if (product.getName().contains(w)) return true;
if (product.getDescription().contains(w)) return true;
if (product.getCategory().contains(w)) return true;
}
return false;
} | [
"private",
"boolean",
"isProductMatchingSearchCriteria",
"(",
"Product",
"product",
",",
"String",
"searchQueryText",
")",
"{",
"String",
"words",
"[",
"]",
"=",
"searchQueryText",
".",
"split",
"(",
"\" \"",
")",
";",
"for",
"(",
"String",
"w",
":",
"words",
... | Filters those items that contains the search query text in name, description or category | [
"Filters",
"those",
"items",
"that",
"contains",
"the",
"search",
"query",
"text",
"in",
"name",
"description",
"or",
"category"
] | 7f22118c950b5e6fbba0ec42d8e97586dfb08940 | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/businesslogic/searchengine/SearchEngine.java#L60-L68 | train |
kubernetes-client/java | util/src/main/java/io/kubernetes/client/informer/cache/SharedProcessor.java | SharedProcessor.addAndStartListener | public void addAndStartListener(final ProcessorListener<ApiType> processorListener) {
lock.writeLock().lock();
try {
addListenerLocked(processorListener);
executorService.execute(processorListener);
} finally {
lock.writeLock().unlock();
}
} | java | public void addAndStartListener(final ProcessorListener<ApiType> processorListener) {
lock.writeLock().lock();
try {
addListenerLocked(processorListener);
executorService.execute(processorListener);
} finally {
lock.writeLock().unlock();
}
} | [
"public",
"void",
"addAndStartListener",
"(",
"final",
"ProcessorListener",
"<",
"ApiType",
">",
"processorListener",
")",
"{",
"lock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"addListenerLocked",
"(",
"processorListener",
")",
";",... | addAndStartListener first adds the specific processorListener then starts the listener with
executor.
@param processorListener specific processor listener | [
"addAndStartListener",
"first",
"adds",
"the",
"specific",
"processorListener",
"then",
"starts",
"the",
"listener",
"with",
"executor",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/util/src/main/java/io/kubernetes/client/informer/cache/SharedProcessor.java#L41-L50 | train |
kubernetes-client/java | util/src/main/java/io/kubernetes/client/informer/cache/SharedProcessor.java | SharedProcessor.addListener | public void addListener(final ProcessorListener<ApiType> processorListener) {
lock.writeLock().lock();
try {
addListenerLocked(processorListener);
} finally {
lock.writeLock().unlock();
}
} | java | public void addListener(final ProcessorListener<ApiType> processorListener) {
lock.writeLock().lock();
try {
addListenerLocked(processorListener);
} finally {
lock.writeLock().unlock();
}
} | [
"public",
"void",
"addListener",
"(",
"final",
"ProcessorListener",
"<",
"ApiType",
">",
"processorListener",
")",
"{",
"lock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"addListenerLocked",
"(",
"processorListener",
")",
";",
"}",
... | addListener adds the specific processorListener, but not start it.
@param processorListener specific processor listener | [
"addListener",
"adds",
"the",
"specific",
"processorListener",
"but",
"not",
"start",
"it",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/util/src/main/java/io/kubernetes/client/informer/cache/SharedProcessor.java#L57-L64 | train |
kubernetes-client/java | util/src/main/java/io/kubernetes/client/informer/cache/SharedProcessor.java | SharedProcessor.run | public void run() {
lock.readLock().lock();
try {
if (Collections.isEmptyCollection(listeners)) {
return;
}
for (ProcessorListener listener : listeners) {
executorService.execute(listener);
}
} finally {
lock.readLock().unlock();
}
} | java | public void run() {
lock.readLock().lock();
try {
if (Collections.isEmptyCollection(listeners)) {
return;
}
for (ProcessorListener listener : listeners) {
executorService.execute(listener);
}
} finally {
lock.readLock().unlock();
}
} | [
"public",
"void",
"run",
"(",
")",
"{",
"lock",
".",
"readLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"Collections",
".",
"isEmptyCollection",
"(",
"listeners",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"ProcessorListener... | starts the processor listeners. | [
"starts",
"the",
"processor",
"listeners",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/util/src/main/java/io/kubernetes/client/informer/cache/SharedProcessor.java#L72-L84 | train |
kubernetes-client/java | util/src/main/java/io/kubernetes/client/informer/cache/SharedProcessor.java | SharedProcessor.distribute | public void distribute(ProcessorListener.Notification<ApiType> obj, boolean isSync) {
lock.readLock().lock();
try {
if (isSync) {
for (ProcessorListener<ApiType> listener : syncingListeners) {
listener.add(obj);
}
} else {
for (ProcessorListener<ApiType> listener : listeners) {
listener.add(obj);
}
}
} finally {
lock.readLock().unlock();
}
} | java | public void distribute(ProcessorListener.Notification<ApiType> obj, boolean isSync) {
lock.readLock().lock();
try {
if (isSync) {
for (ProcessorListener<ApiType> listener : syncingListeners) {
listener.add(obj);
}
} else {
for (ProcessorListener<ApiType> listener : listeners) {
listener.add(obj);
}
}
} finally {
lock.readLock().unlock();
}
} | [
"public",
"void",
"distribute",
"(",
"ProcessorListener",
".",
"Notification",
"<",
"ApiType",
">",
"obj",
",",
"boolean",
"isSync",
")",
"{",
"lock",
".",
"readLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"isSync",
")",
"{",
"... | distribute the object among listeners.
@param obj specific obj
@param isSync is sync or not | [
"distribute",
"the",
"object",
"among",
"listeners",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/util/src/main/java/io/kubernetes/client/informer/cache/SharedProcessor.java#L92-L107 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.setUsername | public void setUsername(String username) {
for (Authentication auth : authentications.values()) {
if (auth instanceof HttpBasicAuth) {
((HttpBasicAuth) auth).setUsername(username);
return;
}
}
throw new RuntimeException("No HTTP basic authentication configured!");
} | java | public void setUsername(String username) {
for (Authentication auth : authentications.values()) {
if (auth instanceof HttpBasicAuth) {
((HttpBasicAuth) auth).setUsername(username);
return;
}
}
throw new RuntimeException("No HTTP basic authentication configured!");
} | [
"public",
"void",
"setUsername",
"(",
"String",
"username",
")",
"{",
"for",
"(",
"Authentication",
"auth",
":",
"authentications",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"auth",
"instanceof",
"HttpBasicAuth",
")",
"{",
"(",
"(",
"HttpBasicAuth",
")... | Helper method to set username for the first HTTP basic authentication.
@param username Username | [
"Helper",
"method",
"to",
"set",
"username",
"for",
"the",
"first",
"HTTP",
"basic",
"authentication",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L277-L285 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.setPassword | public void setPassword(String password) {
for (Authentication auth : authentications.values()) {
if (auth instanceof HttpBasicAuth) {
((HttpBasicAuth) auth).setPassword(password);
return;
}
}
throw new RuntimeException("No HTTP basic authentication configured!");
} | java | public void setPassword(String password) {
for (Authentication auth : authentications.values()) {
if (auth instanceof HttpBasicAuth) {
((HttpBasicAuth) auth).setPassword(password);
return;
}
}
throw new RuntimeException("No HTTP basic authentication configured!");
} | [
"public",
"void",
"setPassword",
"(",
"String",
"password",
")",
"{",
"for",
"(",
"Authentication",
"auth",
":",
"authentications",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"auth",
"instanceof",
"HttpBasicAuth",
")",
"{",
"(",
"(",
"HttpBasicAuth",
")... | Helper method to set password for the first HTTP basic authentication.
@param password Password | [
"Helper",
"method",
"to",
"set",
"password",
"for",
"the",
"first",
"HTTP",
"basic",
"authentication",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L292-L300 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.setApiKey | public void setApiKey(String apiKey) {
for (Authentication auth : authentications.values()) {
if (auth instanceof ApiKeyAuth) {
((ApiKeyAuth) auth).setApiKey(apiKey);
return;
}
}
throw new RuntimeException("No API key authentication configured!");
} | java | public void setApiKey(String apiKey) {
for (Authentication auth : authentications.values()) {
if (auth instanceof ApiKeyAuth) {
((ApiKeyAuth) auth).setApiKey(apiKey);
return;
}
}
throw new RuntimeException("No API key authentication configured!");
} | [
"public",
"void",
"setApiKey",
"(",
"String",
"apiKey",
")",
"{",
"for",
"(",
"Authentication",
"auth",
":",
"authentications",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"auth",
"instanceof",
"ApiKeyAuth",
")",
"{",
"(",
"(",
"ApiKeyAuth",
")",
"auth... | Helper method to set API key value for the first API key authentication.
@param apiKey API key | [
"Helper",
"method",
"to",
"set",
"API",
"key",
"value",
"for",
"the",
"first",
"API",
"key",
"authentication",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L307-L315 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.setApiKeyPrefix | public void setApiKeyPrefix(String apiKeyPrefix) {
for (Authentication auth : authentications.values()) {
if (auth instanceof ApiKeyAuth) {
((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
return;
}
}
throw new RuntimeException("No API key authentication configured!");
} | java | public void setApiKeyPrefix(String apiKeyPrefix) {
for (Authentication auth : authentications.values()) {
if (auth instanceof ApiKeyAuth) {
((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
return;
}
}
throw new RuntimeException("No API key authentication configured!");
} | [
"public",
"void",
"setApiKeyPrefix",
"(",
"String",
"apiKeyPrefix",
")",
"{",
"for",
"(",
"Authentication",
"auth",
":",
"authentications",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"auth",
"instanceof",
"ApiKeyAuth",
")",
"{",
"(",
"(",
"ApiKeyAuth",
... | Helper method to set API key prefix for the first API key authentication.
@param apiKeyPrefix API key prefix | [
"Helper",
"method",
"to",
"set",
"API",
"key",
"prefix",
"for",
"the",
"first",
"API",
"key",
"authentication",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L322-L330 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.setAccessToken | public void setAccessToken(String accessToken) {
for (Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).setAccessToken(accessToken);
return;
}
}
throw new RuntimeException("No OAuth2 authentication configured!");
} | java | public void setAccessToken(String accessToken) {
for (Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).setAccessToken(accessToken);
return;
}
}
throw new RuntimeException("No OAuth2 authentication configured!");
} | [
"public",
"void",
"setAccessToken",
"(",
"String",
"accessToken",
")",
"{",
"for",
"(",
"Authentication",
"auth",
":",
"authentications",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"auth",
"instanceof",
"OAuth",
")",
"{",
"(",
"(",
"OAuth",
")",
"auth... | Helper method to set access token for the first OAuth2 authentication.
@param accessToken Access token | [
"Helper",
"method",
"to",
"set",
"access",
"token",
"for",
"the",
"first",
"OAuth2",
"authentication",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L337-L345 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.deserialize | @SuppressWarnings("unchecked")
public <T> T deserialize(Response response, Type returnType) throws ApiException {
if (response == null || returnType == null) {
return null;
}
if ("byte[]".equals(returnType.toString())) {
// Handle binary response (byte array).
try {
return (T) response.body().bytes();
} catch (IOException e) {
throw new ApiException(e);
}
} else if (returnType.equals(File.class)) {
// Handle file downloading.
return (T) downloadFileFromResponse(response);
}
String respBody;
try {
if (response.body() != null)
respBody = response.body().string();
else
respBody = null;
} catch (IOException e) {
throw new ApiException(e);
}
if (respBody == null || "".equals(respBody)) {
return null;
}
String contentType = response.headers().get("Content-Type");
if (contentType == null) {
// ensuring a default content type
contentType = "application/json";
}
if (isJsonMime(contentType)) {
return json.deserialize(respBody, returnType);
} else if (returnType.equals(String.class)) {
// Expecting string, return the raw response body.
return (T) respBody;
} else {
throw new ApiException(
"Content type \"" + contentType + "\" is not supported for type: " + returnType,
response.code(),
response.headers().toMultimap(),
respBody);
}
} | java | @SuppressWarnings("unchecked")
public <T> T deserialize(Response response, Type returnType) throws ApiException {
if (response == null || returnType == null) {
return null;
}
if ("byte[]".equals(returnType.toString())) {
// Handle binary response (byte array).
try {
return (T) response.body().bytes();
} catch (IOException e) {
throw new ApiException(e);
}
} else if (returnType.equals(File.class)) {
// Handle file downloading.
return (T) downloadFileFromResponse(response);
}
String respBody;
try {
if (response.body() != null)
respBody = response.body().string();
else
respBody = null;
} catch (IOException e) {
throw new ApiException(e);
}
if (respBody == null || "".equals(respBody)) {
return null;
}
String contentType = response.headers().get("Content-Type");
if (contentType == null) {
// ensuring a default content type
contentType = "application/json";
}
if (isJsonMime(contentType)) {
return json.deserialize(respBody, returnType);
} else if (returnType.equals(String.class)) {
// Expecting string, return the raw response body.
return (T) respBody;
} else {
throw new ApiException(
"Content type \"" + contentType + "\" is not supported for type: " + returnType,
response.code(),
response.headers().toMultimap(),
respBody);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"deserialize",
"(",
"Response",
"response",
",",
"Type",
"returnType",
")",
"throws",
"ApiException",
"{",
"if",
"(",
"response",
"==",
"null",
"||",
"returnType",
"==",
"null"... | Deserialize response body to Java object, according to the return type and
the Content-Type response header.
@param <T> Type
@param response HTTP response
@param returnType The type of the Java object
@return The deserialized Java object
@throws ApiException If fail to deserialize response body, i.e. cannot read response body
or the Content-Type of the response is not supported. | [
"Deserialize",
"response",
"body",
"to",
"Java",
"object",
"according",
"to",
"the",
"return",
"type",
"and",
"the",
"Content",
"-",
"Type",
"response",
"header",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L634-L683 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.serialize | public RequestBody serialize(Object obj, String contentType) throws ApiException {
if (obj instanceof byte[]) {
// Binary (byte array) body parameter support.
return RequestBody.create(MediaType.parse(contentType), (byte[]) obj);
} else if (obj instanceof File) {
// File body parameter support.
return RequestBody.create(MediaType.parse(contentType), (File) obj);
} else if (isJsonMime(contentType)) {
String content;
if (obj != null) {
content = json.serialize(obj);
} else {
content = null;
}
return RequestBody.create(MediaType.parse(contentType), content);
} else {
throw new ApiException("Content type \"" + contentType + "\" is not supported");
}
} | java | public RequestBody serialize(Object obj, String contentType) throws ApiException {
if (obj instanceof byte[]) {
// Binary (byte array) body parameter support.
return RequestBody.create(MediaType.parse(contentType), (byte[]) obj);
} else if (obj instanceof File) {
// File body parameter support.
return RequestBody.create(MediaType.parse(contentType), (File) obj);
} else if (isJsonMime(contentType)) {
String content;
if (obj != null) {
content = json.serialize(obj);
} else {
content = null;
}
return RequestBody.create(MediaType.parse(contentType), content);
} else {
throw new ApiException("Content type \"" + contentType + "\" is not supported");
}
} | [
"public",
"RequestBody",
"serialize",
"(",
"Object",
"obj",
",",
"String",
"contentType",
")",
"throws",
"ApiException",
"{",
"if",
"(",
"obj",
"instanceof",
"byte",
"[",
"]",
")",
"{",
"// Binary (byte array) body parameter support.",
"return",
"RequestBody",
".",
... | Serialize the given Java object into request body according to the object's
class and the request Content-Type.
@param obj The Java object
@param contentType The request Content-Type
@return The serialized request body
@throws ApiException If fail to serialize the given object | [
"Serialize",
"the",
"given",
"Java",
"object",
"into",
"request",
"body",
"according",
"to",
"the",
"object",
"s",
"class",
"and",
"the",
"request",
"Content",
"-",
"Type",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L694-L712 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.downloadFileFromResponse | public File downloadFileFromResponse(Response response) throws ApiException {
try {
File file = prepareDownloadFile(response);
BufferedSink sink = Okio.buffer(Okio.sink(file));
sink.writeAll(response.body().source());
sink.close();
return file;
} catch (IOException e) {
throw new ApiException(e);
}
} | java | public File downloadFileFromResponse(Response response) throws ApiException {
try {
File file = prepareDownloadFile(response);
BufferedSink sink = Okio.buffer(Okio.sink(file));
sink.writeAll(response.body().source());
sink.close();
return file;
} catch (IOException e) {
throw new ApiException(e);
}
} | [
"public",
"File",
"downloadFileFromResponse",
"(",
"Response",
"response",
")",
"throws",
"ApiException",
"{",
"try",
"{",
"File",
"file",
"=",
"prepareDownloadFile",
"(",
"response",
")",
";",
"BufferedSink",
"sink",
"=",
"Okio",
".",
"buffer",
"(",
"Okio",
"... | Download file from the given response.
@param response An instance of the Response object
@throws ApiException If fail to read file content from response and write to disk
@return Downloaded file | [
"Download",
"file",
"from",
"the",
"given",
"response",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L721-L731 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.execute | public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiException {
try {
Response response = call.execute();
T data = handleResponse(response, returnType);
return new ApiResponse<T>(response.code(), response.headers().toMultimap(), data);
} catch (IOException e) {
throw new ApiException(e);
}
} | java | public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiException {
try {
Response response = call.execute();
T data = handleResponse(response, returnType);
return new ApiResponse<T>(response.code(), response.headers().toMultimap(), data);
} catch (IOException e) {
throw new ApiException(e);
}
} | [
"public",
"<",
"T",
">",
"ApiResponse",
"<",
"T",
">",
"execute",
"(",
"Call",
"call",
",",
"Type",
"returnType",
")",
"throws",
"ApiException",
"{",
"try",
"{",
"Response",
"response",
"=",
"call",
".",
"execute",
"(",
")",
";",
"T",
"data",
"=",
"h... | Execute HTTP call and deserialize the HTTP response body into the given return type.
@param returnType The return type used to deserialize HTTP response body
@param <T> The return type corresponding to (same with) returnType
@param call Call
@return ApiResponse object containing response status, headers and
data, which is a Java object deserialized from response body and would be null
when returnType is null.
@throws ApiException If fail to execute the call | [
"Execute",
"HTTP",
"call",
"and",
"deserialize",
"the",
"HTTP",
"response",
"body",
"into",
"the",
"given",
"return",
"type",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L799-L807 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.executeAsync | @SuppressWarnings("unchecked")
public <T> void executeAsync(Call call, final Type returnType, final ApiCallback<T> callback) {
call.enqueue(new Callback() {
@Override
public void onFailure(Request request, IOException e) {
callback.onFailure(new ApiException(e), 0, null);
}
@Override
public void onResponse(Response response) throws IOException {
T result;
try {
result = (T) handleResponse(response, returnType);
} catch (ApiException e) {
callback.onFailure(e, response.code(), response.headers().toMultimap());
return;
}
callback.onSuccess(result, response.code(), response.headers().toMultimap());
}
});
} | java | @SuppressWarnings("unchecked")
public <T> void executeAsync(Call call, final Type returnType, final ApiCallback<T> callback) {
call.enqueue(new Callback() {
@Override
public void onFailure(Request request, IOException e) {
callback.onFailure(new ApiException(e), 0, null);
}
@Override
public void onResponse(Response response) throws IOException {
T result;
try {
result = (T) handleResponse(response, returnType);
} catch (ApiException e) {
callback.onFailure(e, response.code(), response.headers().toMultimap());
return;
}
callback.onSuccess(result, response.code(), response.headers().toMultimap());
}
});
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"void",
"executeAsync",
"(",
"Call",
"call",
",",
"final",
"Type",
"returnType",
",",
"final",
"ApiCallback",
"<",
"T",
">",
"callback",
")",
"{",
"call",
".",
"enqueue",
"(",
"... | Execute HTTP call asynchronously.
@see #execute(Call, Type)
@param <T> Type
@param call The callback to be executed when the API call finishes
@param returnType Return type
@param callback ApiCallback | [
"Execute",
"HTTP",
"call",
"asynchronously",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L829-L849 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.buildCall | public Call buildCall(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, progressRequestListener);
return httpClient.newCall(request);
} | java | public Call buildCall(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, progressRequestListener);
return httpClient.newCall(request);
} | [
"public",
"Call",
"buildCall",
"(",
"String",
"path",
",",
"String",
"method",
",",
"List",
"<",
"Pair",
">",
"queryParams",
",",
"List",
"<",
"Pair",
">",
"collectionQueryParams",
",",
"Object",
"body",
",",
"Map",
"<",
"String",
",",
"String",
">",
"he... | Build HTTP call with the given options.
@param path The sub-path of the HTTP URL
@param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
@param queryParams The query parameters
@param collectionQueryParams The collection query parameters
@param body The request body object
@param headerParams The header parameters
@param formParams The form parameters
@param authNames The authentications to apply
@param progressRequestListener Progress request listener
@return The HTTP call
@throws ApiException If fail to serialize the request body object | [
"Build",
"HTTP",
"call",
"with",
"the",
"given",
"options",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L905-L909 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.buildRequest | public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams);
final String url = buildUrl(path, queryParams, collectionQueryParams);
final Request.Builder reqBuilder = new Request.Builder().url(url);
processHeaderParams(headerParams, reqBuilder);
String contentType = (String) headerParams.get("Content-Type");
// ensuring a default content type
if (contentType == null) {
contentType = "application/json";
}
RequestBody reqBody;
if (!HttpMethod.permitsRequestBody(method)) {
reqBody = null;
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
reqBody = buildRequestBodyFormEncoding(formParams);
} else if ("multipart/form-data".equals(contentType)) {
reqBody = buildRequestBodyMultipart(formParams);
} else if (body == null) {
if ("DELETE".equals(method)) {
// allow calling DELETE without sending a request body
reqBody = null;
} else {
// use an empty request body (for POST, PUT and PATCH)
reqBody = RequestBody.create(MediaType.parse(contentType), "");
}
} else {
reqBody = serialize(body, contentType);
}
Request request = null;
if(progressRequestListener != null && reqBody != null) {
ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, progressRequestListener);
request = reqBuilder.method(method, progressRequestBody).build();
} else {
request = reqBuilder.method(method, reqBody).build();
}
return request;
} | java | public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams);
final String url = buildUrl(path, queryParams, collectionQueryParams);
final Request.Builder reqBuilder = new Request.Builder().url(url);
processHeaderParams(headerParams, reqBuilder);
String contentType = (String) headerParams.get("Content-Type");
// ensuring a default content type
if (contentType == null) {
contentType = "application/json";
}
RequestBody reqBody;
if (!HttpMethod.permitsRequestBody(method)) {
reqBody = null;
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
reqBody = buildRequestBodyFormEncoding(formParams);
} else if ("multipart/form-data".equals(contentType)) {
reqBody = buildRequestBodyMultipart(formParams);
} else if (body == null) {
if ("DELETE".equals(method)) {
// allow calling DELETE without sending a request body
reqBody = null;
} else {
// use an empty request body (for POST, PUT and PATCH)
reqBody = RequestBody.create(MediaType.parse(contentType), "");
}
} else {
reqBody = serialize(body, contentType);
}
Request request = null;
if(progressRequestListener != null && reqBody != null) {
ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, progressRequestListener);
request = reqBuilder.method(method, progressRequestBody).build();
} else {
request = reqBuilder.method(method, reqBody).build();
}
return request;
} | [
"public",
"Request",
"buildRequest",
"(",
"String",
"path",
",",
"String",
"method",
",",
"List",
"<",
"Pair",
">",
"queryParams",
",",
"List",
"<",
"Pair",
">",
"collectionQueryParams",
",",
"Object",
"body",
",",
"Map",
"<",
"String",
",",
"String",
">",... | Build an HTTP request with the given options.
@param path The sub-path of the HTTP URL
@param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
@param queryParams The query parameters
@param collectionQueryParams The collection query parameters
@param body The request body object
@param headerParams The header parameters
@param formParams The form parameters
@param authNames The authentications to apply
@param progressRequestListener Progress request listener
@return The HTTP request
@throws ApiException If fail to serialize the request body object | [
"Build",
"an",
"HTTP",
"request",
"with",
"the",
"given",
"options",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L926-L968 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.processHeaderParams | public void processHeaderParams(Map<String, String> headerParams, Request.Builder reqBuilder) {
for (Entry<String, String> param : headerParams.entrySet()) {
reqBuilder.header(param.getKey(), parameterToString(param.getValue()));
}
for (Entry<String, String> header : defaultHeaderMap.entrySet()) {
if (!headerParams.containsKey(header.getKey())) {
reqBuilder.header(header.getKey(), parameterToString(header.getValue()));
}
}
} | java | public void processHeaderParams(Map<String, String> headerParams, Request.Builder reqBuilder) {
for (Entry<String, String> param : headerParams.entrySet()) {
reqBuilder.header(param.getKey(), parameterToString(param.getValue()));
}
for (Entry<String, String> header : defaultHeaderMap.entrySet()) {
if (!headerParams.containsKey(header.getKey())) {
reqBuilder.header(header.getKey(), parameterToString(header.getValue()));
}
}
} | [
"public",
"void",
"processHeaderParams",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"headerParams",
",",
"Request",
".",
"Builder",
"reqBuilder",
")",
"{",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"param",
":",
"headerParams",
".",
"entr... | Set header parameters to the request builder, including default headers.
@param headerParams Header parameters in the ofrm of Map
@param reqBuilder Reqeust.Builder | [
"Set",
"header",
"parameters",
"to",
"the",
"request",
"builder",
"including",
"default",
"headers",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L1025-L1034 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.updateParamsForAuth | public void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) {
for (String authName : authNames) {
Authentication auth = authentications.get(authName);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams);
}
} | java | public void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) {
for (String authName : authNames) {
Authentication auth = authentications.get(authName);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams);
}
} | [
"public",
"void",
"updateParamsForAuth",
"(",
"String",
"[",
"]",
"authNames",
",",
"List",
"<",
"Pair",
">",
"queryParams",
",",
"Map",
"<",
"String",
",",
"String",
">",
"headerParams",
")",
"{",
"for",
"(",
"String",
"authName",
":",
"authNames",
")",
... | Update query and header parameters based on authentication settings.
@param authNames The authentications to apply
@param queryParams List of query parameters
@param headerParams Map of header parameters | [
"Update",
"query",
"and",
"header",
"parameters",
"based",
"on",
"authentication",
"settings",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L1043-L1049 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.buildRequestBodyFormEncoding | public RequestBody buildRequestBodyFormEncoding(Map<String, Object> formParams) {
FormEncodingBuilder formBuilder = new FormEncodingBuilder();
for (Entry<String, Object> param : formParams.entrySet()) {
formBuilder.add(param.getKey(), parameterToString(param.getValue()));
}
return formBuilder.build();
} | java | public RequestBody buildRequestBodyFormEncoding(Map<String, Object> formParams) {
FormEncodingBuilder formBuilder = new FormEncodingBuilder();
for (Entry<String, Object> param : formParams.entrySet()) {
formBuilder.add(param.getKey(), parameterToString(param.getValue()));
}
return formBuilder.build();
} | [
"public",
"RequestBody",
"buildRequestBodyFormEncoding",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"formParams",
")",
"{",
"FormEncodingBuilder",
"formBuilder",
"=",
"new",
"FormEncodingBuilder",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"Obje... | Build a form-encoding request body with the given form parameters.
@param formParams Form parameters in the form of Map
@return RequestBody | [
"Build",
"a",
"form",
"-",
"encoding",
"request",
"body",
"with",
"the",
"given",
"form",
"parameters",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L1057-L1063 | train |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.applySslSettings | private void applySslSettings() {
try {
TrustManager[] trustManagers = null;
HostnameVerifier hostnameVerifier = null;
if (!verifyingSsl) {
TrustManager trustAll = new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
@Override
public X509Certificate[] getAcceptedIssuers() { return null; }
};
SSLContext sslContext = SSLContext.getInstance("TLS");
trustManagers = new TrustManager[]{ trustAll };
hostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) { return true; }
};
} else if (sslCaCert != null) {
char[] password = null; // Any password will work.
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
Collection<? extends Certificate> certificates = certificateFactory.generateCertificates(sslCaCert);
if (certificates.isEmpty()) {
throw new IllegalArgumentException("expected non-empty set of trusted certificates");
}
KeyStore caKeyStore = newEmptyKeyStore(password);
int index = 0;
for (Certificate certificate : certificates) {
String certificateAlias = "ca" + Integer.toString(index++);
caKeyStore.setCertificateEntry(certificateAlias, certificate);
}
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(caKeyStore);
trustManagers = trustManagerFactory.getTrustManagers();
}
if (keyManagers != null || trustManagers != null) {
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManagers, trustManagers, new SecureRandom());
httpClient.setSslSocketFactory(sslContext.getSocketFactory());
} else {
httpClient.setSslSocketFactory(null);
}
httpClient.setHostnameVerifier(hostnameVerifier);
} catch (GeneralSecurityException e) {
throw new RuntimeException(e);
}
} | java | private void applySslSettings() {
try {
TrustManager[] trustManagers = null;
HostnameVerifier hostnameVerifier = null;
if (!verifyingSsl) {
TrustManager trustAll = new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
@Override
public X509Certificate[] getAcceptedIssuers() { return null; }
};
SSLContext sslContext = SSLContext.getInstance("TLS");
trustManagers = new TrustManager[]{ trustAll };
hostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) { return true; }
};
} else if (sslCaCert != null) {
char[] password = null; // Any password will work.
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
Collection<? extends Certificate> certificates = certificateFactory.generateCertificates(sslCaCert);
if (certificates.isEmpty()) {
throw new IllegalArgumentException("expected non-empty set of trusted certificates");
}
KeyStore caKeyStore = newEmptyKeyStore(password);
int index = 0;
for (Certificate certificate : certificates) {
String certificateAlias = "ca" + Integer.toString(index++);
caKeyStore.setCertificateEntry(certificateAlias, certificate);
}
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(caKeyStore);
trustManagers = trustManagerFactory.getTrustManagers();
}
if (keyManagers != null || trustManagers != null) {
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManagers, trustManagers, new SecureRandom());
httpClient.setSslSocketFactory(sslContext.getSocketFactory());
} else {
httpClient.setSslSocketFactory(null);
}
httpClient.setHostnameVerifier(hostnameVerifier);
} catch (GeneralSecurityException e) {
throw new RuntimeException(e);
}
} | [
"private",
"void",
"applySslSettings",
"(",
")",
"{",
"try",
"{",
"TrustManager",
"[",
"]",
"trustManagers",
"=",
"null",
";",
"HostnameVerifier",
"hostnameVerifier",
"=",
"null",
";",
"if",
"(",
"!",
"verifyingSsl",
")",
"{",
"TrustManager",
"trustAll",
"=",
... | Apply SSL related settings to httpClient according to the current values of
verifyingSsl and sslCaCert. | [
"Apply",
"SSL",
"related",
"settings",
"to",
"httpClient",
"according",
"to",
"the",
"current",
"values",
"of",
"verifyingSsl",
"and",
"sslCaCert",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L1107-L1155 | train |
kubernetes-client/java | util/src/main/java/io/kubernetes/client/informer/cache/Controller.java | Controller.stop | public void stop() {
reflector.stop();
reflectorFuture.cancel(true);
reflectExecutor.shutdown();
if (resyncFuture != null) {
resyncFuture.cancel(true);
resyncExecutor.shutdown();
}
} | java | public void stop() {
reflector.stop();
reflectorFuture.cancel(true);
reflectExecutor.shutdown();
if (resyncFuture != null) {
resyncFuture.cancel(true);
resyncExecutor.shutdown();
}
} | [
"public",
"void",
"stop",
"(",
")",
"{",
"reflector",
".",
"stop",
"(",
")",
";",
"reflectorFuture",
".",
"cancel",
"(",
"true",
")",
";",
"reflectExecutor",
".",
"shutdown",
"(",
")",
";",
"if",
"(",
"resyncFuture",
"!=",
"null",
")",
"{",
"resyncFutu... | stops the resync thread pool firstly, then stop the reflector | [
"stops",
"the",
"resync",
"thread",
"pool",
"firstly",
"then",
"stop",
"the",
"reflector"
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/util/src/main/java/io/kubernetes/client/informer/cache/Controller.java#L111-L121 | train |
kubernetes-client/java | util/src/main/java/io/kubernetes/client/informer/cache/Controller.java | Controller.processLoop | private void processLoop() {
while (true) {
try {
this.queue.pop(this.processFunc);
} catch (InterruptedException t) {
log.error("DefaultController#processLoop get interrupted {}", t.getMessage(), t);
}
}
} | java | private void processLoop() {
while (true) {
try {
this.queue.pop(this.processFunc);
} catch (InterruptedException t) {
log.error("DefaultController#processLoop get interrupted {}", t.getMessage(), t);
}
}
} | [
"private",
"void",
"processLoop",
"(",
")",
"{",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"this",
".",
"queue",
".",
"pop",
"(",
"this",
".",
"processFunc",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"t",
")",
"{",
"log",
".",
"error",
... | processLoop drains the work queue. | [
"processLoop",
"drains",
"the",
"work",
"queue",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/util/src/main/java/io/kubernetes/client/informer/cache/Controller.java#L137-L145 | train |
kubernetes-client/java | util/src/main/java/io/kubernetes/client/informer/cache/DeltaFIFO.java | DeltaFIFO.add | @Override
public void add(Object obj) {
lock.writeLock().lock();
try {
populated = true;
this.queueActionLocked(DeltaType.Added, obj);
} finally {
lock.writeLock().unlock();
}
} | java | @Override
public void add(Object obj) {
lock.writeLock().lock();
try {
populated = true;
this.queueActionLocked(DeltaType.Added, obj);
} finally {
lock.writeLock().unlock();
}
} | [
"@",
"Override",
"public",
"void",
"add",
"(",
"Object",
"obj",
")",
"{",
"lock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"populated",
"=",
"true",
";",
"this",
".",
"queueActionLocked",
"(",
"DeltaType",
".",
"Added",
","... | Add items to the delta FIFO.
@param obj the obj | [
"Add",
"items",
"to",
"the",
"delta",
"FIFO",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/util/src/main/java/io/kubernetes/client/informer/cache/DeltaFIFO.java#L67-L76 | train |
kubernetes-client/java | util/src/main/java/io/kubernetes/client/informer/cache/DeltaFIFO.java | DeltaFIFO.update | @Override
public void update(Object obj) {
lock.writeLock().lock();
try {
populated = true;
this.queueActionLocked(DeltaType.Updated, obj);
} finally {
lock.writeLock().unlock();
}
} | java | @Override
public void update(Object obj) {
lock.writeLock().lock();
try {
populated = true;
this.queueActionLocked(DeltaType.Updated, obj);
} finally {
lock.writeLock().unlock();
}
} | [
"@",
"Override",
"public",
"void",
"update",
"(",
"Object",
"obj",
")",
"{",
"lock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"populated",
"=",
"true",
";",
"this",
".",
"queueActionLocked",
"(",
"DeltaType",
".",
"Updated",
... | Update items in the delta FIFO.
@param obj the obj | [
"Update",
"items",
"in",
"the",
"delta",
"FIFO",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/util/src/main/java/io/kubernetes/client/informer/cache/DeltaFIFO.java#L83-L92 | train |
kubernetes-client/java | util/src/main/java/io/kubernetes/client/informer/cache/DeltaFIFO.java | DeltaFIFO.delete | @Override
public void delete(Object obj) {
String id = this.keyOf(obj);
lock.writeLock().lock();
try {
this.populated = true;
if (this.knownObjects == null) {
if (!this.items.containsKey(id)) {
// Presumably, this was deleted when a relist happened.
// Don't provide a second report of the same deletion.
return;
}
} else {
// We only want to skip the "deletion" action if the object doesn't
// exist in knownObjects and it doesn't have corresponding item in items.
if (this.knownObjects.getByKey(id) == null && !this.items.containsKey(id)) {
return;
}
}
this.queueActionLocked(DeltaType.Deleted, obj);
} finally {
lock.writeLock().unlock();
}
} | java | @Override
public void delete(Object obj) {
String id = this.keyOf(obj);
lock.writeLock().lock();
try {
this.populated = true;
if (this.knownObjects == null) {
if (!this.items.containsKey(id)) {
// Presumably, this was deleted when a relist happened.
// Don't provide a second report of the same deletion.
return;
}
} else {
// We only want to skip the "deletion" action if the object doesn't
// exist in knownObjects and it doesn't have corresponding item in items.
if (this.knownObjects.getByKey(id) == null && !this.items.containsKey(id)) {
return;
}
}
this.queueActionLocked(DeltaType.Deleted, obj);
} finally {
lock.writeLock().unlock();
}
} | [
"@",
"Override",
"public",
"void",
"delete",
"(",
"Object",
"obj",
")",
"{",
"String",
"id",
"=",
"this",
".",
"keyOf",
"(",
"obj",
")",
";",
"lock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"this",
".",
"populated",
"=... | Delete items from the delta FIFO.
@param obj the obj | [
"Delete",
"items",
"from",
"the",
"delta",
"FIFO",
"."
] | 7413e98bd904f09d1ad00fb60e8c6ff787f3f560 | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/util/src/main/java/io/kubernetes/client/informer/cache/DeltaFIFO.java#L99-L122 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.