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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/FileUtil.java | FileUtil.mkdir | private static void mkdir(@NonNull final File directory, final boolean createParents)
throws IOException {
Condition.INSTANCE.ensureNotNull(directory, "The directory may not be null");
boolean result = createParents ? directory.mkdirs() : directory.mkdir();
if (!result && !directory.exists()) {
throw new IOException("Failed to create directory \"" + directory + "\"");
}
} | java | private static void mkdir(@NonNull final File directory, final boolean createParents)
throws IOException {
Condition.INSTANCE.ensureNotNull(directory, "The directory may not be null");
boolean result = createParents ? directory.mkdirs() : directory.mkdir();
if (!result && !directory.exists()) {
throw new IOException("Failed to create directory \"" + directory + "\"");
}
} | [
"private",
"static",
"void",
"mkdir",
"(",
"@",
"NonNull",
"final",
"File",
"directory",
",",
"final",
"boolean",
"createParents",
")",
"throws",
"IOException",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"directory",
",",
"\"The directory may no... | Creates a specific directory, if it does not already exist.
@param directory
The directory, which should be created, as an instance of the class {@link File}. The
directory may not be null
@param createParents
True, if the parent directories should also be created, if necessary, false
otherwise
@throws IOException
The exception, which is thrown, if an error occurred while creating the directory | [
"Creates",
"a",
"specific",
"directory",
"if",
"it",
"does",
"not",
"already",
"exist",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/FileUtil.java#L42-L50 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/FileUtil.java | FileUtil.deleteRecursively | public static void deleteRecursively(@NonNull final File file) throws IOException {
Condition.INSTANCE.ensureNotNull(file, "The file or directory may not be null");
if (file.isDirectory()) {
for (File child : file.listFiles()) {
deleteRecursively(child);
}
}
delete(file);
} | java | public static void deleteRecursively(@NonNull final File file) throws IOException {
Condition.INSTANCE.ensureNotNull(file, "The file or directory may not be null");
if (file.isDirectory()) {
for (File child : file.listFiles()) {
deleteRecursively(child);
}
}
delete(file);
} | [
"public",
"static",
"void",
"deleteRecursively",
"(",
"@",
"NonNull",
"final",
"File",
"file",
")",
"throws",
"IOException",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"file",
",",
"\"The file or directory may not be null\"",
")",
";",
"if",
"("... | Deletes a specific file or directory. If the file is a directory, all contained files and
subdirectories are deleted recursively.
@param file
The file or directory, which should be deleted, as an instance of the class {@link
File}. The file or directory may not be null
@throws IOException
The exception, which is thrown, if an error occurs while deleting the file or
directory | [
"Deletes",
"a",
"specific",
"file",
"or",
"directory",
".",
"If",
"the",
"file",
"is",
"a",
"directory",
"all",
"contained",
"files",
"and",
"subdirectories",
"are",
"deleted",
"recursively",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/FileUtil.java#L124-L134 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/FileUtil.java | FileUtil.createNewFile | public static void createNewFile(@NonNull final File file, final boolean overwrite)
throws IOException {
Condition.INSTANCE.ensureNotNull(file, "The file may not be null");
boolean result = file.createNewFile();
if (!result) {
if (overwrite) {
try {
delete(file);
createNewFile(file, false);
} catch (IOException e) {
throw new IOException("Failed to overwrite file \"" + file + "\"");
}
} else if (file.exists()) {
throw new IOException("File \"" + file + "\" does already exist");
} else {
throw new IllegalArgumentException("The file must not be a directory");
}
}
} | java | public static void createNewFile(@NonNull final File file, final boolean overwrite)
throws IOException {
Condition.INSTANCE.ensureNotNull(file, "The file may not be null");
boolean result = file.createNewFile();
if (!result) {
if (overwrite) {
try {
delete(file);
createNewFile(file, false);
} catch (IOException e) {
throw new IOException("Failed to overwrite file \"" + file + "\"");
}
} else if (file.exists()) {
throw new IOException("File \"" + file + "\" does already exist");
} else {
throw new IllegalArgumentException("The file must not be a directory");
}
}
} | [
"public",
"static",
"void",
"createNewFile",
"(",
"@",
"NonNull",
"final",
"File",
"file",
",",
"final",
"boolean",
"overwrite",
")",
"throws",
"IOException",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"file",
",",
"\"The file may not be null\""... | Creates a new, empty file.
@param file
The file, which should be created, as an instance of the class {@link File}. The file
may not be null. If the file is a directory, an {@link IllegalArgumentException} will
be thrown
@param overwrite
True, if the file should be overwritten, if it does already exist, false otherwise
@throws IOException
The exception, which is thrown, if an error occurs while creating the file | [
"Creates",
"a",
"new",
"empty",
"file",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/FileUtil.java#L162-L181 | train |
edwardcapriolo/teknek-core | src/main/java/io/teknek/driver/Driver.java | Driver.maybeDoOffset | public void maybeDoOffset(){
long seen = tuplesSeen;
if (offsetCommitInterval > 0 && seen % offsetCommitInterval == 0 && offsetStorage != null && fp.supportsOffsetManagement()){
doOffsetInternal();
}
} | java | public void maybeDoOffset(){
long seen = tuplesSeen;
if (offsetCommitInterval > 0 && seen % offsetCommitInterval == 0 && offsetStorage != null && fp.supportsOffsetManagement()){
doOffsetInternal();
}
} | [
"public",
"void",
"maybeDoOffset",
"(",
")",
"{",
"long",
"seen",
"=",
"tuplesSeen",
";",
"if",
"(",
"offsetCommitInterval",
">",
"0",
"&&",
"seen",
"%",
"offsetCommitInterval",
"==",
"0",
"&&",
"offsetStorage",
"!=",
"null",
"&&",
"fp",
".",
"supportsOffset... | To do offset storage we let the topology drain itself out. Then we commit. | [
"To",
"do",
"offset",
"storage",
"we",
"let",
"the",
"topology",
"drain",
"itself",
"out",
".",
"Then",
"we",
"commit",
"."
] | 4fa972d11044dee2954c0cc5e1b53b18fba319b9 | https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/driver/Driver.java#L144-L149 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ThemeUtil.java | ThemeUtil.obtainStyledAttributes | private static TypedArray obtainStyledAttributes(@NonNull final Context context,
@StyleRes final int themeResourceId,
@AttrRes final int resourceId) {
Condition.INSTANCE.ensureNotNull(context, "The context may not be null");
Theme theme = context.getTheme();
int[] attrs = new int[]{resourceId};
if (themeResourceId != -1) {
return theme.obtainStyledAttributes(themeResourceId, attrs);
} else {
return theme.obtainStyledAttributes(attrs);
}
} | java | private static TypedArray obtainStyledAttributes(@NonNull final Context context,
@StyleRes final int themeResourceId,
@AttrRes final int resourceId) {
Condition.INSTANCE.ensureNotNull(context, "The context may not be null");
Theme theme = context.getTheme();
int[] attrs = new int[]{resourceId};
if (themeResourceId != -1) {
return theme.obtainStyledAttributes(themeResourceId, attrs);
} else {
return theme.obtainStyledAttributes(attrs);
}
} | [
"private",
"static",
"TypedArray",
"obtainStyledAttributes",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"StyleRes",
"final",
"int",
"themeResourceId",
",",
"@",
"AttrRes",
"final",
"int",
"resourceId",
")",
"{",
"Condition",
".",
"INSTANCE",
"... | Obtains the attribute, which corresponds to a specific resource id, from a theme.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param themeResourceId
The resource id of the theme, the attribute should be obtained from, as an {@link
Integer} value or -1, if the attribute should be obtained from the given context's
theme
@param resourceId
The resource id of the attribute, which should be obtained, as an {@link Integer}
value. The resource id must corresponds to a valid theme attribute
@return A type array, which holds the attribute, which has been obtained, as an instance of
the class {@link TypedArray} | [
"Obtains",
"the",
"attribute",
"which",
"corresponds",
"to",
"a",
"specific",
"resource",
"id",
"from",
"a",
"theme",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ThemeUtil.java#L54-L66 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ThemeUtil.java | ThemeUtil.getBoolean | public static boolean getBoolean(@NonNull final Context context,
@StyleRes final int themeResourceId,
@AttrRes final int resourceId) {
TypedArray typedArray = null;
try {
typedArray = obtainStyledAttributes(context, themeResourceId, resourceId);
return typedArray.getBoolean(0, false);
} finally {
if (typedArray != null) {
typedArray.recycle();
}
}
} | java | public static boolean getBoolean(@NonNull final Context context,
@StyleRes final int themeResourceId,
@AttrRes final int resourceId) {
TypedArray typedArray = null;
try {
typedArray = obtainStyledAttributes(context, themeResourceId, resourceId);
return typedArray.getBoolean(0, false);
} finally {
if (typedArray != null) {
typedArray.recycle();
}
}
} | [
"public",
"static",
"boolean",
"getBoolean",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"StyleRes",
"final",
"int",
"themeResourceId",
",",
"@",
"AttrRes",
"final",
"int",
"resourceId",
")",
"{",
"TypedArray",
"typedArray",
"=",
"null",
";",... | Obtains the boolean value, which corresponds to a specific resource id, from a specific
theme.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param themeResourceId
The resource id of the theme, the attribute should be obtained from, as an {@link
Integer} value or -1, if the attribute should be obtained from the given context's
theme
@param resourceId
The resource id of the attribute, which should be obtained, as an {@link Integer}
value. The resource id must corresponds to a valid theme attribute
@return The boolean value, which has been obtained, as a {@link Boolean} value or false, if
the given resource id is invalid | [
"Obtains",
"the",
"boolean",
"value",
"which",
"corresponds",
"to",
"a",
"specific",
"resource",
"id",
"from",
"a",
"specific",
"theme",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ThemeUtil.java#L670-L683 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ThemeUtil.java | ThemeUtil.getBoolean | public static boolean getBoolean(@NonNull final Context context, @AttrRes final int resourceId,
final boolean defaultValue) {
return getBoolean(context, -1, resourceId, defaultValue);
} | java | public static boolean getBoolean(@NonNull final Context context, @AttrRes final int resourceId,
final boolean defaultValue) {
return getBoolean(context, -1, resourceId, defaultValue);
} | [
"public",
"static",
"boolean",
"getBoolean",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"AttrRes",
"final",
"int",
"resourceId",
",",
"final",
"boolean",
"defaultValue",
")",
"{",
"return",
"getBoolean",
"(",
"context",
",",
"-",
"1",
",",... | Obtains the boolean value, which corresponds to a specific resource id, from a context's
theme.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param resourceId
The resource id of the attribute, which should be obtained, as an {@link Integer}
value. The resource id must corresponds to a valid theme attribute
@param defaultValue
The default value, which should be returned, if the given resource id is invalid, as
a {@link Boolean} value
@return The boolean value, which has been obtained, as an {@link Boolean} value or false, if
the given resource id is invalid | [
"Obtains",
"the",
"boolean",
"value",
"which",
"corresponds",
"to",
"a",
"specific",
"resource",
"id",
"from",
"a",
"context",
"s",
"theme",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ThemeUtil.java#L701-L704 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ThemeUtil.java | ThemeUtil.getInt | public static int getInt(@NonNull final Context context, @AttrRes final int resourceId,
final int defaultValue) {
return getInt(context, -1, resourceId, defaultValue);
} | java | public static int getInt(@NonNull final Context context, @AttrRes final int resourceId,
final int defaultValue) {
return getInt(context, -1, resourceId, defaultValue);
} | [
"public",
"static",
"int",
"getInt",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"AttrRes",
"final",
"int",
"resourceId",
",",
"final",
"int",
"defaultValue",
")",
"{",
"return",
"getInt",
"(",
"context",
",",
"-",
"1",
",",
"resourceId",... | Obtains the integer value, which corresponds to a specific resource id, from a context's
theme.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param resourceId
The resource id of the attribute, which should be obtained, as an {@link Integer}
value. The resource id must corresponds to a valid theme attribute
@param defaultValue
The default value, which should be returned, if the given resource id is invalid, as
an {@link Integer} value
@return The integer value, which has been obtained, as an {@link Integer} value or 0, if the
given resource id is invalid | [
"Obtains",
"the",
"integer",
"value",
"which",
"corresponds",
"to",
"a",
"specific",
"resource",
"id",
"from",
"a",
"context",
"s",
"theme",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ThemeUtil.java#L757-L760 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ThemeUtil.java | ThemeUtil.getFloat | public static float getFloat(@NonNull final Context context, @AttrRes final int resourceId,
final float defaultValue) {
return getFloat(context, -1, resourceId, defaultValue);
} | java | public static float getFloat(@NonNull final Context context, @AttrRes final int resourceId,
final float defaultValue) {
return getFloat(context, -1, resourceId, defaultValue);
} | [
"public",
"static",
"float",
"getFloat",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"AttrRes",
"final",
"int",
"resourceId",
",",
"final",
"float",
"defaultValue",
")",
"{",
"return",
"getFloat",
"(",
"context",
",",
"-",
"1",
",",
"reso... | Obtains the float value, which corresponds to a specific resource id, from a context's
theme.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param resourceId
The resource id of the attribute, which should be obtained, as an {@link Integer}
value. The resource id must corresponds to a valid theme attribute
@param defaultValue
The default value, which should be returned, if the given resource id is invalid, as
a {@link Float} value
@return The float value, which has been obtained, as a {@link Float} value or 0, if the given
resource id is invalid | [
"Obtains",
"the",
"float",
"value",
"which",
"corresponds",
"to",
"a",
"specific",
"resource",
"id",
"from",
"a",
"context",
"s",
"theme",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ThemeUtil.java#L812-L815 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ThemeUtil.java | ThemeUtil.getResId | public static int getResId(@NonNull final Context context, @AttrRes final int resourceId,
final int defaultValue) {
return getResId(context, -1, resourceId, defaultValue);
} | java | public static int getResId(@NonNull final Context context, @AttrRes final int resourceId,
final int defaultValue) {
return getResId(context, -1, resourceId, defaultValue);
} | [
"public",
"static",
"int",
"getResId",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"AttrRes",
"final",
"int",
"resourceId",
",",
"final",
"int",
"defaultValue",
")",
"{",
"return",
"getResId",
"(",
"context",
",",
"-",
"1",
",",
"resource... | Obtains the resource id, which corresponds to a specific resource id, from a context's
theme.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param resourceId
The resource id of the attribute, which should be obtained, as an {@link Integer}
value. The resource id must corresponds to a valid theme attribute
@param defaultValue
The default value, which should be returned, if the given resource id is invalid, as
an {@link Integer} value
@return The resource id, which has been obtained, as an {@link Integer} value or 0, if the
given resource id is invalid | [
"Obtains",
"the",
"resource",
"id",
"which",
"corresponds",
"to",
"a",
"specific",
"resource",
"id",
"from",
"a",
"context",
"s",
"theme",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ThemeUtil.java#L867-L870 | train |
revelytix/spark | spark-http-client/src/main/java/spark/protocol/ProtocolCommand.java | ProtocolCommand.setRequest | void setRequest(HttpUriRequest request) {
requestLock.lock();
try {
if (this.request != null) {
throw new SparqlException("Command is already executing a request.");
}
this.request = request;
} finally {
requestLock.unlock();
}
} | java | void setRequest(HttpUriRequest request) {
requestLock.lock();
try {
if (this.request != null) {
throw new SparqlException("Command is already executing a request.");
}
this.request = request;
} finally {
requestLock.unlock();
}
} | [
"void",
"setRequest",
"(",
"HttpUriRequest",
"request",
")",
"{",
"requestLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"this",
".",
"request",
"!=",
"null",
")",
"{",
"throw",
"new",
"SparqlException",
"(",
"\"Command is already executing a reques... | Sets the currently executing request. | [
"Sets",
"the",
"currently",
"executing",
"request",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/ProtocolCommand.java#L131-L141 | train |
revelytix/spark | spark-http-client/src/main/java/spark/protocol/ProtocolCommand.java | ProtocolCommand.execute | private Result execute(ResultType cmdType) throws SparqlException {
String mimeType = contentType;
// Validate the user-supplied MIME type.
if (mimeType != null && !ResultFactory.supports(mimeType, cmdType)) {
logger.warn("Requested MIME content type '{}' does not support expected response type: {}", mimeType, cmdType);
mimeType = null;
}
// Get the default MIME type to request
if (mimeType == null) {
mimeType = ResultFactory.getDefaultMediaType(cmdType);
}
if (logger.isDebugEnabled()) {
logRequest(cmdType, mimeType);
}
try {
HttpResponse response = SparqlCall.executeRequest(this, mimeType);
return ResultFactory.getResult(this, response, cmdType);
} catch (Throwable t) {
release();
throw SparqlException.convert("Error creating SPARQL result from server response", t);
}
} | java | private Result execute(ResultType cmdType) throws SparqlException {
String mimeType = contentType;
// Validate the user-supplied MIME type.
if (mimeType != null && !ResultFactory.supports(mimeType, cmdType)) {
logger.warn("Requested MIME content type '{}' does not support expected response type: {}", mimeType, cmdType);
mimeType = null;
}
// Get the default MIME type to request
if (mimeType == null) {
mimeType = ResultFactory.getDefaultMediaType(cmdType);
}
if (logger.isDebugEnabled()) {
logRequest(cmdType, mimeType);
}
try {
HttpResponse response = SparqlCall.executeRequest(this, mimeType);
return ResultFactory.getResult(this, response, cmdType);
} catch (Throwable t) {
release();
throw SparqlException.convert("Error creating SPARQL result from server response", t);
}
} | [
"private",
"Result",
"execute",
"(",
"ResultType",
"cmdType",
")",
"throws",
"SparqlException",
"{",
"String",
"mimeType",
"=",
"contentType",
";",
"// Validate the user-supplied MIME type.",
"if",
"(",
"mimeType",
"!=",
"null",
"&&",
"!",
"ResultFactory",
".",
"sup... | Executes the request, and parses the response. | [
"Executes",
"the",
"request",
"and",
"parses",
"the",
"response",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/ProtocolCommand.java#L144-L169 | train |
revelytix/spark | spark-http-client/src/main/java/spark/protocol/ProtocolCommand.java | ProtocolCommand.logRequest | private void logRequest(ResultType cmdType, String mimeType) {
StringBuilder sb = new StringBuilder("Executing SPARQL protocol request ");
sb.append("to endpoint <").append(((ProtocolDataSource)getConnection().getDataSource()).getUrl()).append("> ");
if (mimeType != null) {
sb.append("for content type '").append(mimeType).append("' ");
} else {
sb.append("for unknown content type ");
}
if (cmdType != null) {
sb.append("with expected results of type ").append(cmdType).append(".");
} else {
sb.append("with unknown expected result type.");
}
logger.debug(sb.toString());
} | java | private void logRequest(ResultType cmdType, String mimeType) {
StringBuilder sb = new StringBuilder("Executing SPARQL protocol request ");
sb.append("to endpoint <").append(((ProtocolDataSource)getConnection().getDataSource()).getUrl()).append("> ");
if (mimeType != null) {
sb.append("for content type '").append(mimeType).append("' ");
} else {
sb.append("for unknown content type ");
}
if (cmdType != null) {
sb.append("with expected results of type ").append(cmdType).append(".");
} else {
sb.append("with unknown expected result type.");
}
logger.debug(sb.toString());
} | [
"private",
"void",
"logRequest",
"(",
"ResultType",
"cmdType",
",",
"String",
"mimeType",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"\"Executing SPARQL protocol request \"",
")",
";",
"sb",
".",
"append",
"(",
"\"to endpoint <\"",
")",
"."... | Log the enpoint URL and request parameters. | [
"Log",
"the",
"enpoint",
"URL",
"and",
"request",
"parameters",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/ProtocolCommand.java#L172-L186 | train |
edwardcapriolo/teknek-core | src/main/java/io/teknek/driver/DriverNode.java | DriverNode.initialize | public void initialize(){
thread = new Thread(collectorProcessor);
thread.start();
for (DriverNode dn : this.children){
dn.initialize();
}
} | java | public void initialize(){
thread = new Thread(collectorProcessor);
thread.start();
for (DriverNode dn : this.children){
dn.initialize();
}
} | [
"public",
"void",
"initialize",
"(",
")",
"{",
"thread",
"=",
"new",
"Thread",
"(",
"collectorProcessor",
")",
";",
"thread",
".",
"start",
"(",
")",
";",
"for",
"(",
"DriverNode",
"dn",
":",
"this",
".",
"children",
")",
"{",
"dn",
".",
"initialize",
... | initialize driver node and all children of the node | [
"initialize",
"driver",
"node",
"and",
"all",
"children",
"of",
"the",
"node"
] | 4fa972d11044dee2954c0cc5e1b53b18fba319b9 | https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/driver/DriverNode.java#L45-L51 | train |
edwardcapriolo/teknek-core | src/main/java/io/teknek/driver/DriverNode.java | DriverNode.addChild | public void addChild(DriverNode dn){
collectorProcessor.getChildren().add(dn.operator);
children.add(dn);
} | java | public void addChild(DriverNode dn){
collectorProcessor.getChildren().add(dn.operator);
children.add(dn);
} | [
"public",
"void",
"addChild",
"(",
"DriverNode",
"dn",
")",
"{",
"collectorProcessor",
".",
"getChildren",
"(",
")",
".",
"add",
"(",
"dn",
".",
"operator",
")",
";",
"children",
".",
"add",
"(",
"dn",
")",
";",
"}"
] | Method adds a child data node and binds the collect processor
of this node to the operator of the next node
@param dn a child driver node | [
"Method",
"adds",
"a",
"child",
"data",
"node",
"and",
"binds",
"the",
"collect",
"processor",
"of",
"this",
"node",
"to",
"the",
"operator",
"of",
"the",
"next",
"node"
] | 4fa972d11044dee2954c0cc5e1b53b18fba319b9 | https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/driver/DriverNode.java#L58-L61 | train |
galan/verjson | src/main/java/de/galan/verjson/util/MetaWrapper.java | MetaWrapper.getNamespace | public static String getNamespace(JsonNode node) {
JsonNode nodeNs = obj(node).get(ID_NAMESPACE);
return (nodeNs != null) ? nodeNs.asText() : null;
} | java | public static String getNamespace(JsonNode node) {
JsonNode nodeNs = obj(node).get(ID_NAMESPACE);
return (nodeNs != null) ? nodeNs.asText() : null;
} | [
"public",
"static",
"String",
"getNamespace",
"(",
"JsonNode",
"node",
")",
"{",
"JsonNode",
"nodeNs",
"=",
"obj",
"(",
"node",
")",
".",
"get",
"(",
"ID_NAMESPACE",
")",
";",
"return",
"(",
"nodeNs",
"!=",
"null",
")",
"?",
"nodeNs",
".",
"asText",
"(... | Returns the namespace from a wrapped JsonNode | [
"Returns",
"the",
"namespace",
"from",
"a",
"wrapped",
"JsonNode"
] | 4db610fb5198fde913114ed628234f957e1c19d5 | https://github.com/galan/verjson/blob/4db610fb5198fde913114ed628234f957e1c19d5/src/main/java/de/galan/verjson/util/MetaWrapper.java#L58-L61 | train |
galan/verjson | src/main/java/de/galan/verjson/util/MetaWrapper.java | MetaWrapper.setVersion | public static void setVersion(JsonNode node, Long version) {
obj(node).put(ID_VERSION, version);
} | java | public static void setVersion(JsonNode node, Long version) {
obj(node).put(ID_VERSION, version);
} | [
"public",
"static",
"void",
"setVersion",
"(",
"JsonNode",
"node",
",",
"Long",
"version",
")",
"{",
"obj",
"(",
"node",
")",
".",
"put",
"(",
"ID_VERSION",
",",
"version",
")",
";",
"}"
] | Sets the version on a wrapped JsonNode | [
"Sets",
"the",
"version",
"on",
"a",
"wrapped",
"JsonNode"
] | 4db610fb5198fde913114ed628234f957e1c19d5 | https://github.com/galan/verjson/blob/4db610fb5198fde913114ed628234f957e1c19d5/src/main/java/de/galan/verjson/util/MetaWrapper.java#L71-L73 | train |
galan/verjson | src/main/java/de/galan/verjson/util/MetaWrapper.java | MetaWrapper.getTimestamp | public static Date getTimestamp(JsonNode node) {
String text = obj(node).get(ID_TIMESTAMP).asText();
return isNotBlank(text) ? from(instantUtc(text)).toDate() : null;
} | java | public static Date getTimestamp(JsonNode node) {
String text = obj(node).get(ID_TIMESTAMP).asText();
return isNotBlank(text) ? from(instantUtc(text)).toDate() : null;
} | [
"public",
"static",
"Date",
"getTimestamp",
"(",
"JsonNode",
"node",
")",
"{",
"String",
"text",
"=",
"obj",
"(",
"node",
")",
".",
"get",
"(",
"ID_TIMESTAMP",
")",
".",
"asText",
"(",
")",
";",
"return",
"isNotBlank",
"(",
"text",
")",
"?",
"from",
... | Returns the timestamp from a wrapped JsonNode | [
"Returns",
"the",
"timestamp",
"from",
"a",
"wrapped",
"JsonNode"
] | 4db610fb5198fde913114ed628234f957e1c19d5 | https://github.com/galan/verjson/blob/4db610fb5198fde913114ed628234f957e1c19d5/src/main/java/de/galan/verjson/util/MetaWrapper.java#L77-L80 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/gesture/DragHelper.java | DragHelper.update | public final void update(final float position) {
if (reset) {
reset = false;
distance = 0;
thresholdReachedPosition = -1;
dragStartTime = -1;
dragStartPosition = position;
reachedThreshold = false;
minDragDistance = 0;
maxDragDistance = 0;
}
if (!reachedThreshold) {
if (reachedThreshold(position - dragStartPosition)) {
dragStartTime = System.currentTimeMillis();
reachedThreshold = true;
thresholdReachedPosition = position;
}
} else {
float newDistance = position - thresholdReachedPosition;
if (minDragDistance != 0 && minDragDistance > newDistance) {
newDistance = minDragDistance;
thresholdReachedPosition = position - minDragDistance;
}
if (maxDragDistance != 0 && maxDragDistance < newDistance) {
newDistance = maxDragDistance;
thresholdReachedPosition = position - maxDragDistance;
}
distance = newDistance;
}
} | java | public final void update(final float position) {
if (reset) {
reset = false;
distance = 0;
thresholdReachedPosition = -1;
dragStartTime = -1;
dragStartPosition = position;
reachedThreshold = false;
minDragDistance = 0;
maxDragDistance = 0;
}
if (!reachedThreshold) {
if (reachedThreshold(position - dragStartPosition)) {
dragStartTime = System.currentTimeMillis();
reachedThreshold = true;
thresholdReachedPosition = position;
}
} else {
float newDistance = position - thresholdReachedPosition;
if (minDragDistance != 0 && minDragDistance > newDistance) {
newDistance = minDragDistance;
thresholdReachedPosition = position - minDragDistance;
}
if (maxDragDistance != 0 && maxDragDistance < newDistance) {
newDistance = maxDragDistance;
thresholdReachedPosition = position - maxDragDistance;
}
distance = newDistance;
}
} | [
"public",
"final",
"void",
"update",
"(",
"final",
"float",
"position",
")",
"{",
"if",
"(",
"reset",
")",
"{",
"reset",
"=",
"false",
";",
"distance",
"=",
"0",
";",
"thresholdReachedPosition",
"=",
"-",
"1",
";",
"dragStartTime",
"=",
"-",
"1",
";",
... | Updates the instance by adding a new position. This will cause all properties to be
re-calculated, depending on the new position.
@param position
The position, which should be added, as a {@link Float} value | [
"Updates",
"the",
"instance",
"by",
"adding",
"a",
"new",
"position",
".",
"This",
"will",
"cause",
"all",
"properties",
"to",
"be",
"re",
"-",
"calculated",
"depending",
"on",
"the",
"new",
"position",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/gesture/DragHelper.java#L163-L196 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/gesture/DragHelper.java | DragHelper.setMaxDragDistance | public final void setMaxDragDistance(final float maxDragDistance) {
if (maxDragDistance != 0) {
Condition.INSTANCE.ensureGreater(maxDragDistance, threshold,
"The maximum drag distance must be greater than " + threshold);
}
this.maxDragDistance = maxDragDistance;
} | java | public final void setMaxDragDistance(final float maxDragDistance) {
if (maxDragDistance != 0) {
Condition.INSTANCE.ensureGreater(maxDragDistance, threshold,
"The maximum drag distance must be greater than " + threshold);
}
this.maxDragDistance = maxDragDistance;
} | [
"public",
"final",
"void",
"setMaxDragDistance",
"(",
"final",
"float",
"maxDragDistance",
")",
"{",
"if",
"(",
"maxDragDistance",
"!=",
"0",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureGreater",
"(",
"maxDragDistance",
",",
"threshold",
",",
"\"The maxi... | Sets the maximum drag distance.
@param maxDragDistance
The maximum drag distance, which should be set, in pixels as a {@link Float} value or
0, if no maximum drag distance should be set | [
"Sets",
"the",
"maximum",
"drag",
"distance",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/gesture/DragHelper.java#L215-L222 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/gesture/DragHelper.java | DragHelper.setMinDragDistance | public final void setMinDragDistance(final float minDragDistance) {
if (minDragDistance != 0) {
Condition.INSTANCE.ensureSmaller(minDragDistance, -threshold,
"The minimum drag distance must be smaller than " + -threshold);
}
this.minDragDistance = minDragDistance;
} | java | public final void setMinDragDistance(final float minDragDistance) {
if (minDragDistance != 0) {
Condition.INSTANCE.ensureSmaller(minDragDistance, -threshold,
"The minimum drag distance must be smaller than " + -threshold);
}
this.minDragDistance = minDragDistance;
} | [
"public",
"final",
"void",
"setMinDragDistance",
"(",
"final",
"float",
"minDragDistance",
")",
"{",
"if",
"(",
"minDragDistance",
"!=",
"0",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureSmaller",
"(",
"minDragDistance",
",",
"-",
"threshold",
",",
"\"T... | Sets the minimum drag distance.
@param minDragDistance
The minimum drag distance, which should be set, in pixels as a {@link Float} value or
0, if no minimum drag distance should be set | [
"Sets",
"the",
"minimum",
"drag",
"distance",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/gesture/DragHelper.java#L241-L248 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/gesture/DragHelper.java | DragHelper.getDragSpeed | public final float getDragSpeed() {
if (hasThresholdBeenReached()) {
long interval = System.currentTimeMillis() - dragStartTime;
return Math.abs(getDragDistance()) / (float) interval;
} else {
return -1;
}
} | java | public final float getDragSpeed() {
if (hasThresholdBeenReached()) {
long interval = System.currentTimeMillis() - dragStartTime;
return Math.abs(getDragDistance()) / (float) interval;
} else {
return -1;
}
} | [
"public",
"final",
"float",
"getDragSpeed",
"(",
")",
"{",
"if",
"(",
"hasThresholdBeenReached",
"(",
")",
")",
"{",
"long",
"interval",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"dragStartTime",
";",
"return",
"Math",
".",
"abs",
"(",
"getDr... | Returns the speed of the drag gesture in pixels per millisecond.
@return The speed of the drag gesture as a {@link Float} value or -1, if the threshold has
not been reached yet | [
"Returns",
"the",
"speed",
"of",
"the",
"drag",
"gesture",
"in",
"pixels",
"per",
"millisecond",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/gesture/DragHelper.java#L285-L292 | train |
michael-rapp/AndroidUtil | example/src/main/java/de/mrapp/android/util/example/MainActivity.java | MainActivity.createSeekBarListener | private OnSeekBarChangeListener createSeekBarListener() {
return new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(final SeekBar seekBar, final int progress,
final boolean fromUser) {
adaptElevation(progress, parallelLightCheckBox.isChecked());
}
@Override
public void onStartTrackingTouch(final SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(final SeekBar seekBar) {
}
};
} | java | private OnSeekBarChangeListener createSeekBarListener() {
return new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(final SeekBar seekBar, final int progress,
final boolean fromUser) {
adaptElevation(progress, parallelLightCheckBox.isChecked());
}
@Override
public void onStartTrackingTouch(final SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(final SeekBar seekBar) {
}
};
} | [
"private",
"OnSeekBarChangeListener",
"createSeekBarListener",
"(",
")",
"{",
"return",
"new",
"OnSeekBarChangeListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onProgressChanged",
"(",
"final",
"SeekBar",
"seekBar",
",",
"final",
"int",
"progress",
",",... | Creates and returns a listener, which allows to adjust the elevation, when the value of a
seek bar has been changed.
@return The listener, which has been created, as an instance of the type {@link
OnSeekBarChangeListener} | [
"Creates",
"and",
"returns",
"a",
"listener",
"which",
"allows",
"to",
"adjust",
"the",
"elevation",
"when",
"the",
"value",
"of",
"a",
"seek",
"bar",
"has",
"been",
"changed",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/example/src/main/java/de/mrapp/android/util/example/MainActivity.java#L122-L142 | train |
michael-rapp/AndroidUtil | example/src/main/java/de/mrapp/android/util/example/MainActivity.java | MainActivity.adaptElevation | private void adaptElevation(final int elevation, final boolean parallelLight) {
elevationTextView.setText(String.format(getString(R.string.elevation), elevation));
elevationLeft.setShadowElevation(elevation);
elevationLeft.emulateParallelLight(parallelLight);
elevationTopLeft.setShadowElevation(elevation);
elevationTopLeft.emulateParallelLight(parallelLight);
elevationTop.setShadowElevation(elevation);
elevationTop.emulateParallelLight(parallelLight);
elevationTopRight.setShadowElevation(elevation);
elevationTopRight.emulateParallelLight(parallelLight);
elevationRight.setShadowElevation(elevation);
elevationRight.emulateParallelLight(parallelLight);
elevationBottomRight.setShadowElevation(elevation);
elevationBottomRight.emulateParallelLight(parallelLight);
elevationBottom.setShadowElevation(elevation);
elevationBottom.emulateParallelLight(parallelLight);
elevationBottomLeft.setShadowElevation(elevation);
elevationBottomLeft.emulateParallelLight(parallelLight);
} | java | private void adaptElevation(final int elevation, final boolean parallelLight) {
elevationTextView.setText(String.format(getString(R.string.elevation), elevation));
elevationLeft.setShadowElevation(elevation);
elevationLeft.emulateParallelLight(parallelLight);
elevationTopLeft.setShadowElevation(elevation);
elevationTopLeft.emulateParallelLight(parallelLight);
elevationTop.setShadowElevation(elevation);
elevationTop.emulateParallelLight(parallelLight);
elevationTopRight.setShadowElevation(elevation);
elevationTopRight.emulateParallelLight(parallelLight);
elevationRight.setShadowElevation(elevation);
elevationRight.emulateParallelLight(parallelLight);
elevationBottomRight.setShadowElevation(elevation);
elevationBottomRight.emulateParallelLight(parallelLight);
elevationBottom.setShadowElevation(elevation);
elevationBottom.emulateParallelLight(parallelLight);
elevationBottomLeft.setShadowElevation(elevation);
elevationBottomLeft.emulateParallelLight(parallelLight);
} | [
"private",
"void",
"adaptElevation",
"(",
"final",
"int",
"elevation",
",",
"final",
"boolean",
"parallelLight",
")",
"{",
"elevationTextView",
".",
"setText",
"(",
"String",
".",
"format",
"(",
"getString",
"(",
"R",
".",
"string",
".",
"elevation",
")",
",... | Adapts the elevation.
@param elevation
The elevation, which should be set, in dp as an {@link Integer} value
@param parallelLight
True, if parallel light should be emulated, false otherwise | [
"Adapts",
"the",
"elevation",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/example/src/main/java/de/mrapp/android/util/example/MainActivity.java#L163-L181 | train |
MKLab-ITI/simmo | src/main/java/gr/iti/mklab/simmo/core/segments/SegmentFactory.java | SegmentFactory.getSegment | public Segment getSegment(SEGMENT_TYPE segmentType){
if(segmentType == null){
return null;
}
if(segmentType == SEGMENT_TYPE.LINEAR){
return new LinearSegment();
}
else if(segmentType == SEGMENT_TYPE.SPATIAL){
return new SpatialSegment();
}
else if(segmentType == SEGMENT_TYPE.TEMPORAL){
return new TemporalSegment();
}
else if(segmentType == SEGMENT_TYPE.SPATIOTEMPORAL){
return new SpatioTemporalSegment();
}
return null;
} | java | public Segment getSegment(SEGMENT_TYPE segmentType){
if(segmentType == null){
return null;
}
if(segmentType == SEGMENT_TYPE.LINEAR){
return new LinearSegment();
}
else if(segmentType == SEGMENT_TYPE.SPATIAL){
return new SpatialSegment();
}
else if(segmentType == SEGMENT_TYPE.TEMPORAL){
return new TemporalSegment();
}
else if(segmentType == SEGMENT_TYPE.SPATIOTEMPORAL){
return new SpatioTemporalSegment();
}
return null;
} | [
"public",
"Segment",
"getSegment",
"(",
"SEGMENT_TYPE",
"segmentType",
")",
"{",
"if",
"(",
"segmentType",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"segmentType",
"==",
"SEGMENT_TYPE",
".",
"LINEAR",
")",
"{",
"return",
"new",
"Linear... | use getShape method to get object of type shape | [
"use",
"getShape",
"method",
"to",
"get",
"object",
"of",
"type",
"shape"
] | a78436e982e160fb0260746c563c7e4d24736486 | https://github.com/MKLab-ITI/simmo/blob/a78436e982e160fb0260746c563c7e4d24736486/src/main/java/gr/iti/mklab/simmo/core/segments/SegmentFactory.java#L10-L30 | train |
galan/verjson | src/main/java/de/galan/verjson/core/Verjson.java | Verjson.write | public String write(T obj) throws JsonProcessingException {
Date ts = includeTimestamp ? Date.from(now()) : null;
MetaWrapper wrapper = new MetaWrapper(getHighestSourceVersion(), getNamespace(), obj, ts);
return mapper.writeValueAsString(wrapper);
} | java | public String write(T obj) throws JsonProcessingException {
Date ts = includeTimestamp ? Date.from(now()) : null;
MetaWrapper wrapper = new MetaWrapper(getHighestSourceVersion(), getNamespace(), obj, ts);
return mapper.writeValueAsString(wrapper);
} | [
"public",
"String",
"write",
"(",
"T",
"obj",
")",
"throws",
"JsonProcessingException",
"{",
"Date",
"ts",
"=",
"includeTimestamp",
"?",
"Date",
".",
"from",
"(",
"now",
"(",
")",
")",
":",
"null",
";",
"MetaWrapper",
"wrapper",
"=",
"new",
"MetaWrapper",
... | Serializes the given object to a String | [
"Serializes",
"the",
"given",
"object",
"to",
"a",
"String"
] | 4db610fb5198fde913114ed628234f957e1c19d5 | https://github.com/galan/verjson/blob/4db610fb5198fde913114ed628234f957e1c19d5/src/main/java/de/galan/verjson/core/Verjson.java#L100-L104 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/ScrimInsetsLayout.java | ScrimInsetsLayout.obtainInsetForeground | private void obtainInsetForeground(@NonNull final TypedArray typedArray) {
int color = typedArray.getColor(R.styleable.ScrimInsetsLayout_insetDrawable, -1);
if (color == -1) {
Drawable drawable = typedArray.getDrawable(R.styleable.ScrimInsetsLayout_insetDrawable);
if (drawable != null) {
setInsetDrawable(drawable);
} else {
setInsetColor(ContextCompat.getColor(getContext(),
R.color.scrim_insets_layout_insets_drawable_default_value));
}
} else {
setInsetColor(color);
}
} | java | private void obtainInsetForeground(@NonNull final TypedArray typedArray) {
int color = typedArray.getColor(R.styleable.ScrimInsetsLayout_insetDrawable, -1);
if (color == -1) {
Drawable drawable = typedArray.getDrawable(R.styleable.ScrimInsetsLayout_insetDrawable);
if (drawable != null) {
setInsetDrawable(drawable);
} else {
setInsetColor(ContextCompat.getColor(getContext(),
R.color.scrim_insets_layout_insets_drawable_default_value));
}
} else {
setInsetColor(color);
}
} | [
"private",
"void",
"obtainInsetForeground",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"int",
"color",
"=",
"typedArray",
".",
"getColor",
"(",
"R",
".",
"styleable",
".",
"ScrimInsetsLayout_insetDrawable",
",",
"-",
"1",
")",
";",
"if... | Obtains the drawable, which should be shown in the layout's insets, from a specific typed
array.
@param typedArray
The typed array, the drawable should be obtained from, as an instance of the class
{@link TypedArray}. The typed array may not be null | [
"Obtains",
"the",
"drawable",
"which",
"should",
"be",
"shown",
"in",
"the",
"layout",
"s",
"insets",
"from",
"a",
"specific",
"typed",
"array",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ScrimInsetsLayout.java#L141-L156 | train |
phax/ph-datetime | ph-holiday/src/main/java/com/helger/holiday/parser/RelativeToEasterSundayParser.java | RelativeToEasterSundayParser.parse | public void parse (final int nYear, final HolidayMap aHolidayMap, final Holidays aConfig)
{
for (final RelativeToEasterSunday aDay : aConfig.getRelativeToEasterSunday ())
{
if (!isValid (aDay, nYear))
continue;
final ChronoLocalDate aEasterSunday = getEasterSunday (nYear, aDay.getChronology ());
aEasterSunday.plus (aDay.getDays (), ChronoUnit.DAYS);
final String sPropertiesKey = "christian." + aDay.getDescriptionPropertiesKey ();
addChrstianHoliday (aEasterSunday,
sPropertiesKey,
XMLHolidayHelper.getType (aDay.getLocalizedType ()),
aHolidayMap);
}
} | java | public void parse (final int nYear, final HolidayMap aHolidayMap, final Holidays aConfig)
{
for (final RelativeToEasterSunday aDay : aConfig.getRelativeToEasterSunday ())
{
if (!isValid (aDay, nYear))
continue;
final ChronoLocalDate aEasterSunday = getEasterSunday (nYear, aDay.getChronology ());
aEasterSunday.plus (aDay.getDays (), ChronoUnit.DAYS);
final String sPropertiesKey = "christian." + aDay.getDescriptionPropertiesKey ();
addChrstianHoliday (aEasterSunday,
sPropertiesKey,
XMLHolidayHelper.getType (aDay.getLocalizedType ()),
aHolidayMap);
}
} | [
"public",
"void",
"parse",
"(",
"final",
"int",
"nYear",
",",
"final",
"HolidayMap",
"aHolidayMap",
",",
"final",
"Holidays",
"aConfig",
")",
"{",
"for",
"(",
"final",
"RelativeToEasterSunday",
"aDay",
":",
"aConfig",
".",
"getRelativeToEasterSunday",
"(",
")",
... | Parses relative to Easter Sunday holidays. | [
"Parses",
"relative",
"to",
"Easter",
"Sunday",
"holidays",
"."
] | cfaff01cb76d9affb934800ff55734b5a7d8983e | https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/parser/RelativeToEasterSundayParser.java#L47-L61 | train |
phax/ph-datetime | ph-holiday/src/main/java/com/helger/holiday/parser/RelativeToEasterSundayParser.java | RelativeToEasterSundayParser.addChrstianHoliday | protected final void addChrstianHoliday (final ChronoLocalDate aDate,
final String sPropertiesKey,
final IHolidayType aHolidayType,
final HolidayMap holidays)
{
final LocalDate convertedDate = LocalDate.from (aDate);
holidays.add (convertedDate, new ResourceBundleHoliday (aHolidayType, sPropertiesKey));
} | java | protected final void addChrstianHoliday (final ChronoLocalDate aDate,
final String sPropertiesKey,
final IHolidayType aHolidayType,
final HolidayMap holidays)
{
final LocalDate convertedDate = LocalDate.from (aDate);
holidays.add (convertedDate, new ResourceBundleHoliday (aHolidayType, sPropertiesKey));
} | [
"protected",
"final",
"void",
"addChrstianHoliday",
"(",
"final",
"ChronoLocalDate",
"aDate",
",",
"final",
"String",
"sPropertiesKey",
",",
"final",
"IHolidayType",
"aHolidayType",
",",
"final",
"HolidayMap",
"holidays",
")",
"{",
"final",
"LocalDate",
"convertedDate... | Adds the given day to the list of holidays.
@param aDate
The day
@param sPropertiesKey
a {@link java.lang.String} object.
@param aHolidayType
a {@link HolidayType} object.
@param holidays
a {@link java.util.Set} object. | [
"Adds",
"the",
"given",
"day",
"to",
"the",
"list",
"of",
"holidays",
"."
] | cfaff01cb76d9affb934800ff55734b5a7d8983e | https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/parser/RelativeToEasterSundayParser.java#L75-L82 | train |
phax/ph-datetime | ph-holiday/src/main/java/com/helger/holiday/parser/RelativeToEasterSundayParser.java | RelativeToEasterSundayParser.getEasterSunday | public static ChronoLocalDate getEasterSunday (final int nYear)
{
return nYear <= CPDT.LAST_JULIAN_YEAR ? getJulianEasterSunday (nYear) : getGregorianEasterSunday (nYear);
} | java | public static ChronoLocalDate getEasterSunday (final int nYear)
{
return nYear <= CPDT.LAST_JULIAN_YEAR ? getJulianEasterSunday (nYear) : getGregorianEasterSunday (nYear);
} | [
"public",
"static",
"ChronoLocalDate",
"getEasterSunday",
"(",
"final",
"int",
"nYear",
")",
"{",
"return",
"nYear",
"<=",
"CPDT",
".",
"LAST_JULIAN_YEAR",
"?",
"getJulianEasterSunday",
"(",
"nYear",
")",
":",
"getGregorianEasterSunday",
"(",
"nYear",
")",
";",
... | Returns the easter Sunday for a given year.
@param nYear
The year to retrieve Easter Sunday date
@return Easter Sunday. | [
"Returns",
"the",
"easter",
"Sunday",
"for",
"a",
"given",
"year",
"."
] | cfaff01cb76d9affb934800ff55734b5a7d8983e | https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/parser/RelativeToEasterSundayParser.java#L91-L94 | train |
phax/ph-datetime | ph-holiday/src/main/java/com/helger/holiday/parser/RelativeToEasterSundayParser.java | RelativeToEasterSundayParser.getJulianEasterSunday | public static JulianDate getJulianEasterSunday (final int nYear)
{
final int a = nYear % 4;
final int b = nYear % 7;
final int c = nYear % 19;
final int d = (19 * c + 15) % 30;
final int e = (2 * a + 4 * b - d + 34) % 7;
final int x = d + e + 114;
final int nMonth = x / 31;
final int nDay = (x % 31) + 1;
return JulianDate.of (nYear, (nMonth == 3 ? Month.MARCH : Month.APRIL).getValue (), nDay);
} | java | public static JulianDate getJulianEasterSunday (final int nYear)
{
final int a = nYear % 4;
final int b = nYear % 7;
final int c = nYear % 19;
final int d = (19 * c + 15) % 30;
final int e = (2 * a + 4 * b - d + 34) % 7;
final int x = d + e + 114;
final int nMonth = x / 31;
final int nDay = (x % 31) + 1;
return JulianDate.of (nYear, (nMonth == 3 ? Month.MARCH : Month.APRIL).getValue (), nDay);
} | [
"public",
"static",
"JulianDate",
"getJulianEasterSunday",
"(",
"final",
"int",
"nYear",
")",
"{",
"final",
"int",
"a",
"=",
"nYear",
"%",
"4",
";",
"final",
"int",
"b",
"=",
"nYear",
"%",
"7",
";",
"final",
"int",
"c",
"=",
"nYear",
"%",
"19",
";",
... | Returns the easter Sunday within the julian chronology.
@param nYear
The year to retrieve Julian Easter Sunday date
@return julian easter Sunday | [
"Returns",
"the",
"easter",
"Sunday",
"within",
"the",
"julian",
"chronology",
"."
] | cfaff01cb76d9affb934800ff55734b5a7d8983e | https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/parser/RelativeToEasterSundayParser.java#L108-L119 | train |
phax/ph-datetime | ph-holiday/src/main/java/com/helger/holiday/parser/RelativeToEasterSundayParser.java | RelativeToEasterSundayParser.getGregorianEasterSunday | public static LocalDate getGregorianEasterSunday (final int nYear)
{
final int a = nYear % 19;
final int b = nYear / 100;
final int c = nYear % 100;
final int d = b / 4;
final int e = b % 4;
final int f = (b + 8) / 25;
final int g = (b - f + 1) / 3;
final int h = (19 * a + b - d - g + 15) % 30;
final int i = c / 4;
final int j = c % 4;
final int k = (32 + 2 * e + 2 * i - h - j) % 7;
final int l = (a + 11 * h + 22 * k) / 451;
final int x = h + k - 7 * l + 114;
final int nMonth = x / 31;
final int nDay = (x % 31) + 1;
return LocalDate.of (nYear, (nMonth == 3 ? Month.MARCH : Month.APRIL), nDay);
} | java | public static LocalDate getGregorianEasterSunday (final int nYear)
{
final int a = nYear % 19;
final int b = nYear / 100;
final int c = nYear % 100;
final int d = b / 4;
final int e = b % 4;
final int f = (b + 8) / 25;
final int g = (b - f + 1) / 3;
final int h = (19 * a + b - d - g + 15) % 30;
final int i = c / 4;
final int j = c % 4;
final int k = (32 + 2 * e + 2 * i - h - j) % 7;
final int l = (a + 11 * h + 22 * k) / 451;
final int x = h + k - 7 * l + 114;
final int nMonth = x / 31;
final int nDay = (x % 31) + 1;
return LocalDate.of (nYear, (nMonth == 3 ? Month.MARCH : Month.APRIL), nDay);
} | [
"public",
"static",
"LocalDate",
"getGregorianEasterSunday",
"(",
"final",
"int",
"nYear",
")",
"{",
"final",
"int",
"a",
"=",
"nYear",
"%",
"19",
";",
"final",
"int",
"b",
"=",
"nYear",
"/",
"100",
";",
"final",
"int",
"c",
"=",
"nYear",
"%",
"100",
... | Returns the easter Sunday within the gregorian chronology.
@param nYear
The year to retrieve Gregorian Easter Sunday date
@return gregorian easter Sunday. | [
"Returns",
"the",
"easter",
"Sunday",
"within",
"the",
"gregorian",
"chronology",
"."
] | cfaff01cb76d9affb934800ff55734b5a7d8983e | https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/parser/RelativeToEasterSundayParser.java#L128-L146 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ElevationUtil.java | ElevationUtil.createEdgeShadow | private static Bitmap createEdgeShadow(@NonNull final Context context, final int elevation,
@NonNull final Orientation orientation,
final boolean parallelLight) {
if (elevation == 0) {
return null;
} else {
float shadowWidth = getShadowWidth(context, elevation, orientation, parallelLight);
int shadowColor = getShadowColor(elevation, orientation, parallelLight);
int bitmapWidth = (int) Math
.round((orientation == Orientation.LEFT || orientation == Orientation.RIGHT) ?
Math.ceil(shadowWidth) : 1);
int bitmapHeight = (int) Math
.round((orientation == Orientation.TOP || orientation == Orientation.BOTTOM) ?
Math.ceil(shadowWidth) : 1);
Bitmap bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Shader linearGradient =
createLinearGradient(orientation, bitmapWidth, bitmapHeight, shadowWidth,
shadowColor);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setDither(true);
paint.setShader(linearGradient);
canvas.drawRect(0, 0, bitmapWidth, bitmapHeight, paint);
return bitmap;
}
} | java | private static Bitmap createEdgeShadow(@NonNull final Context context, final int elevation,
@NonNull final Orientation orientation,
final boolean parallelLight) {
if (elevation == 0) {
return null;
} else {
float shadowWidth = getShadowWidth(context, elevation, orientation, parallelLight);
int shadowColor = getShadowColor(elevation, orientation, parallelLight);
int bitmapWidth = (int) Math
.round((orientation == Orientation.LEFT || orientation == Orientation.RIGHT) ?
Math.ceil(shadowWidth) : 1);
int bitmapHeight = (int) Math
.round((orientation == Orientation.TOP || orientation == Orientation.BOTTOM) ?
Math.ceil(shadowWidth) : 1);
Bitmap bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Shader linearGradient =
createLinearGradient(orientation, bitmapWidth, bitmapHeight, shadowWidth,
shadowColor);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setDither(true);
paint.setShader(linearGradient);
canvas.drawRect(0, 0, bitmapWidth, bitmapHeight, paint);
return bitmap;
}
} | [
"private",
"static",
"Bitmap",
"createEdgeShadow",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"final",
"int",
"elevation",
",",
"@",
"NonNull",
"final",
"Orientation",
"orientation",
",",
"final",
"boolean",
"parallelLight",
")",
"{",
"if",
"(",
... | Creates and returns a bitmap, which can be used to emulate a shadow, which is located at a
corner of an elevated view on pre-Lollipop devices.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param elevation
The elevation, which should be emulated, in dp as an {@link Integer} value. The
elevation must be at least 0 and at maximum the value of the constant
<code>MAX_ELEVATION</code>
@param orientation
The orientation of the shadow in relation to the elevated view as a value of the enum
{@link Orientation}. The orientation may either be <code>TOP_LEFT</code>,
<code>TOP_RIGHT</code>, <code>BOTTOM_LEFT</code> or <code>BOTTOM_RIGHT</code>
@param parallelLight
True, if parallel light should be emulated, false otherwise
@return The bitmap, which has been created, as an instance of the class {@link Bitmap} or
null, if the given elevation is 0 | [
"Creates",
"and",
"returns",
"a",
"bitmap",
"which",
"can",
"be",
"used",
"to",
"emulate",
"a",
"shadow",
"which",
"is",
"located",
"at",
"a",
"corner",
"of",
"an",
"elevated",
"view",
"on",
"pre",
"-",
"Lollipop",
"devices",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ElevationUtil.java#L253-L279 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ElevationUtil.java | ElevationUtil.createCornerShadow | private static Bitmap createCornerShadow(@NonNull final Context context, final int elevation,
@NonNull final Orientation orientation,
final boolean parallelLight) {
if (elevation == 0) {
return null;
} else {
float horizontalShadowWidth =
getHorizontalShadowWidth(context, elevation, orientation, parallelLight);
float verticalShadowWidth =
getVerticalShadowWidth(context, elevation, orientation, parallelLight);
int horizontalShadowColor =
getHorizontalShadowColor(elevation, orientation, parallelLight);
int verticalShadowColor = getVerticalShadowColor(elevation, orientation, parallelLight);
int bitmapWidth = (int) Math.round(Math.ceil(verticalShadowWidth));
int bitmapHeight = (int) Math.round(Math.ceil(horizontalShadowWidth));
int bitmapSize = Math.max(bitmapWidth, bitmapHeight);
Bitmap bitmap = Bitmap.createBitmap(bitmapSize, bitmapSize, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setDither(true);
RectF arcBounds = getCornerBounds(orientation, bitmapSize);
float startAngle = getCornerAngle(orientation);
int[] sweepColors =
getCornerColors(orientation, horizontalShadowColor, verticalShadowColor);
SweepGradient sweepGradient = new SweepGradient(arcBounds.left + arcBounds.width() / 2f,
arcBounds.top + arcBounds.height() / 2f, sweepColors,
new float[]{startAngle / FULL_ARC_DEGRESS, startAngle / FULL_ARC_DEGRESS +
QUARTER_ARC_DEGRESS / FULL_ARC_DEGRESS});
paint.setShader(sweepGradient);
canvas.drawArc(arcBounds, startAngle, QUARTER_ARC_DEGRESS, true, paint);
Shader radialGradient = createRadialGradient(orientation, bitmapSize,
Math.max(horizontalShadowWidth, verticalShadowWidth));
paint.setShader(radialGradient);
paint.setColor(Color.BLACK);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
canvas.drawRect(0, 0, bitmapSize, bitmapSize, paint);
return BitmapUtil.resize(bitmap, bitmapWidth, bitmapHeight);
}
} | java | private static Bitmap createCornerShadow(@NonNull final Context context, final int elevation,
@NonNull final Orientation orientation,
final boolean parallelLight) {
if (elevation == 0) {
return null;
} else {
float horizontalShadowWidth =
getHorizontalShadowWidth(context, elevation, orientation, parallelLight);
float verticalShadowWidth =
getVerticalShadowWidth(context, elevation, orientation, parallelLight);
int horizontalShadowColor =
getHorizontalShadowColor(elevation, orientation, parallelLight);
int verticalShadowColor = getVerticalShadowColor(elevation, orientation, parallelLight);
int bitmapWidth = (int) Math.round(Math.ceil(verticalShadowWidth));
int bitmapHeight = (int) Math.round(Math.ceil(horizontalShadowWidth));
int bitmapSize = Math.max(bitmapWidth, bitmapHeight);
Bitmap bitmap = Bitmap.createBitmap(bitmapSize, bitmapSize, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setDither(true);
RectF arcBounds = getCornerBounds(orientation, bitmapSize);
float startAngle = getCornerAngle(orientation);
int[] sweepColors =
getCornerColors(orientation, horizontalShadowColor, verticalShadowColor);
SweepGradient sweepGradient = new SweepGradient(arcBounds.left + arcBounds.width() / 2f,
arcBounds.top + arcBounds.height() / 2f, sweepColors,
new float[]{startAngle / FULL_ARC_DEGRESS, startAngle / FULL_ARC_DEGRESS +
QUARTER_ARC_DEGRESS / FULL_ARC_DEGRESS});
paint.setShader(sweepGradient);
canvas.drawArc(arcBounds, startAngle, QUARTER_ARC_DEGRESS, true, paint);
Shader radialGradient = createRadialGradient(orientation, bitmapSize,
Math.max(horizontalShadowWidth, verticalShadowWidth));
paint.setShader(radialGradient);
paint.setColor(Color.BLACK);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
canvas.drawRect(0, 0, bitmapSize, bitmapSize, paint);
return BitmapUtil.resize(bitmap, bitmapWidth, bitmapHeight);
}
} | [
"private",
"static",
"Bitmap",
"createCornerShadow",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"final",
"int",
"elevation",
",",
"@",
"NonNull",
"final",
"Orientation",
"orientation",
",",
"final",
"boolean",
"parallelLight",
")",
"{",
"if",
"(",
... | Creates and returns a bitmap, which can be used to emulate a shadow, which is located besides
an edge of an elevated view on pre-Lollipop devices.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param elevation
The elevation, which should be emulated, in dp as an {@link Integer} value. The
elevation must be at least 0 and at maximum the value of the constant
<code>MAX_ELEVATION</code>
@param orientation
The orientation of the shadow in relation to the elevated view as a value of the enum
{@link Orientation}. The orientation may either be <code>LEFT</code>,
<code>TOP</code>, <code>RIGHT</code> or <code>BOTTOM</code>
@param parallelLight
True, if parallel light should be emulated, false otherwise
@return The bitmap, which has been created, as an instance of the class {@link Bitmap} or
null, if the given elevation is 0 | [
"Creates",
"and",
"returns",
"a",
"bitmap",
"which",
"can",
"be",
"used",
"to",
"emulate",
"a",
"shadow",
"which",
"is",
"located",
"besides",
"an",
"edge",
"of",
"an",
"elevated",
"view",
"on",
"pre",
"-",
"Lollipop",
"devices",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ElevationUtil.java#L301-L340 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ElevationUtil.java | ElevationUtil.getCornerBounds | private static RectF getCornerBounds(@NonNull final Orientation orientation, final int size) {
switch (orientation) {
case TOP_LEFT:
return new RectF(0, 0, 2 * size, 2 * size);
case TOP_RIGHT:
return new RectF(-size, 0, size, 2 * size);
case BOTTOM_LEFT:
return new RectF(0, -size, 2 * size, size);
case BOTTOM_RIGHT:
return new RectF(-size, -size, size, size);
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
} | java | private static RectF getCornerBounds(@NonNull final Orientation orientation, final int size) {
switch (orientation) {
case TOP_LEFT:
return new RectF(0, 0, 2 * size, 2 * size);
case TOP_RIGHT:
return new RectF(-size, 0, size, 2 * size);
case BOTTOM_LEFT:
return new RectF(0, -size, 2 * size, size);
case BOTTOM_RIGHT:
return new RectF(-size, -size, size, size);
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
} | [
"private",
"static",
"RectF",
"getCornerBounds",
"(",
"@",
"NonNull",
"final",
"Orientation",
"orientation",
",",
"final",
"int",
"size",
")",
"{",
"switch",
"(",
"orientation",
")",
"{",
"case",
"TOP_LEFT",
":",
"return",
"new",
"RectF",
"(",
"0",
",",
"0... | Returns the bounds, which should be used to draw a shadow, which is located at a corner of an
elevated view.
@param orientation
The orientation of the shadow in relation to the elevated view as a value of the enum
{@link Orientation}. The orientation may either be <code>TOP_LEFT</code>,
<code>TOP_RIGHT</code>, <code>BOTTOM_LEFT</code> or <code>BOTTOM_RIGHT</code>
@param size
The size of the bitmap, which is used to draw the shadow, in pixels as an {@link
Integer} value
@return The bounds, which should be used to draw the shadow, as an instance of the class
{@link RectF} | [
"Returns",
"the",
"bounds",
"which",
"should",
"be",
"used",
"to",
"draw",
"a",
"shadow",
"which",
"is",
"located",
"at",
"a",
"corner",
"of",
"an",
"elevated",
"view",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ElevationUtil.java#L387-L400 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ElevationUtil.java | ElevationUtil.getHorizontalShadowWidth | private static float getHorizontalShadowWidth(@NonNull final Context context,
final int elevation,
@NonNull final Orientation orientation,
final boolean parallelLight) {
switch (orientation) {
case TOP_LEFT:
case TOP_RIGHT:
return getShadowWidth(context, elevation, Orientation.TOP, parallelLight);
case BOTTOM_LEFT:
case BOTTOM_RIGHT:
return getShadowWidth(context, elevation, Orientation.BOTTOM, parallelLight);
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
} | java | private static float getHorizontalShadowWidth(@NonNull final Context context,
final int elevation,
@NonNull final Orientation orientation,
final boolean parallelLight) {
switch (orientation) {
case TOP_LEFT:
case TOP_RIGHT:
return getShadowWidth(context, elevation, Orientation.TOP, parallelLight);
case BOTTOM_LEFT:
case BOTTOM_RIGHT:
return getShadowWidth(context, elevation, Orientation.BOTTOM, parallelLight);
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
} | [
"private",
"static",
"float",
"getHorizontalShadowWidth",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"final",
"int",
"elevation",
",",
"@",
"NonNull",
"final",
"Orientation",
"orientation",
",",
"final",
"boolean",
"parallelLight",
")",
"{",
"switch"... | Returns the width of a shadow, which is located next to a corner of an elevated view in
horizontal direction.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param elevation
The elevation, which should be emulated, in dp as an {@link Integer} value. The
elevation must be at least 0 and at maximum the value of the constant
<code>MAX_ELEVATION</code>
@param orientation
The orientation of the shadow in relation to the elevated view as a value of the enum
{@link Orientation}. The orientation may either be <code>TOP_LEFT</code>,
<code>TOP_RIGHT</code>, <code>BOTTOM_LEFT</code> or <code>BOTTOM_RIGHT</code>
@param parallelLight
True, if the parallel light should be emulated, false otherwise
@return The width of the shadow in pixels as a {@link Float} value | [
"Returns",
"the",
"width",
"of",
"a",
"shadow",
"which",
"is",
"located",
"next",
"to",
"a",
"corner",
"of",
"an",
"elevated",
"view",
"in",
"horizontal",
"direction",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ElevationUtil.java#L421-L435 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ElevationUtil.java | ElevationUtil.getShadowWidth | private static float getShadowWidth(@NonNull final Context context, final int elevation,
@NonNull final Orientation orientation,
final boolean parallelLight) {
float referenceElevationWidth =
(float) elevation / (float) REFERENCE_ELEVATION * REFERENCE_SHADOW_WIDTH;
float shadowWidth;
if (parallelLight) {
shadowWidth = referenceElevationWidth * BOTTOM_SCALE_FACTOR;
} else {
switch (orientation) {
case LEFT:
shadowWidth = referenceElevationWidth * LEFT_SCALE_FACTOR;
break;
case TOP:
shadowWidth = referenceElevationWidth * TOP_SCALE_FACTOR;
break;
case RIGHT:
shadowWidth = referenceElevationWidth * RIGHT_SCALE_FACTOR;
break;
case BOTTOM:
shadowWidth = referenceElevationWidth * BOTTOM_SCALE_FACTOR;
break;
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
}
return dpToPixels(context, shadowWidth);
} | java | private static float getShadowWidth(@NonNull final Context context, final int elevation,
@NonNull final Orientation orientation,
final boolean parallelLight) {
float referenceElevationWidth =
(float) elevation / (float) REFERENCE_ELEVATION * REFERENCE_SHADOW_WIDTH;
float shadowWidth;
if (parallelLight) {
shadowWidth = referenceElevationWidth * BOTTOM_SCALE_FACTOR;
} else {
switch (orientation) {
case LEFT:
shadowWidth = referenceElevationWidth * LEFT_SCALE_FACTOR;
break;
case TOP:
shadowWidth = referenceElevationWidth * TOP_SCALE_FACTOR;
break;
case RIGHT:
shadowWidth = referenceElevationWidth * RIGHT_SCALE_FACTOR;
break;
case BOTTOM:
shadowWidth = referenceElevationWidth * BOTTOM_SCALE_FACTOR;
break;
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
}
return dpToPixels(context, shadowWidth);
} | [
"private",
"static",
"float",
"getShadowWidth",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"final",
"int",
"elevation",
",",
"@",
"NonNull",
"final",
"Orientation",
"orientation",
",",
"final",
"boolean",
"parallelLight",
")",
"{",
"float",
"refere... | Returns the width of a shadow, which is located besides an edge of an elevated view.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param elevation
The elevation, which should be emulated, in dp as an {@link Integer} value. The
elevation must be at least 0 and at maximum the value of the constant
<code>MAX_ELEVATION</code>
@param orientation
The orientation of the shadow in relation to the elevated view as a value of the enum
{@link Orientation}. The orientation may either be <code>LEFT</code>,
<code>TOP</code>, <code>RIGHT</code> or <code>BOTTOM</code>
@param parallelLight
True, if parallel light should be emulated, false otherwise
@return The width of the shadow in pixels as a {@link Float} value | [
"Returns",
"the",
"width",
"of",
"a",
"shadow",
"which",
"is",
"located",
"besides",
"an",
"edge",
"of",
"an",
"elevated",
"view",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ElevationUtil.java#L489-L518 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ElevationUtil.java | ElevationUtil.getHorizontalShadowColor | private static int getHorizontalShadowColor(final int elevation,
@NonNull final Orientation orientation,
final boolean parallelLight) {
switch (orientation) {
case TOP_LEFT:
case TOP_RIGHT:
return getShadowColor(elevation, Orientation.TOP, parallelLight);
case BOTTOM_LEFT:
case BOTTOM_RIGHT:
return getShadowColor(elevation, Orientation.BOTTOM, parallelLight);
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
} | java | private static int getHorizontalShadowColor(final int elevation,
@NonNull final Orientation orientation,
final boolean parallelLight) {
switch (orientation) {
case TOP_LEFT:
case TOP_RIGHT:
return getShadowColor(elevation, Orientation.TOP, parallelLight);
case BOTTOM_LEFT:
case BOTTOM_RIGHT:
return getShadowColor(elevation, Orientation.BOTTOM, parallelLight);
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
} | [
"private",
"static",
"int",
"getHorizontalShadowColor",
"(",
"final",
"int",
"elevation",
",",
"@",
"NonNull",
"final",
"Orientation",
"orientation",
",",
"final",
"boolean",
"parallelLight",
")",
"{",
"switch",
"(",
"orientation",
")",
"{",
"case",
"TOP_LEFT",
... | Returns the color of a shadow, which is located next to a corner of an elevated view in
horizontal direction.
@param elevation
The elevation, which should be emulated, in dp as an {@link Integer} value. The
elevation must be at least 0 and at maximum the value of the constant
<code>MAX_ELEVATION</code>
@param orientation
The orientation of the shadow in relation to the elevated view as a value of the enum
{@link Orientation}. The orientation may either be <code>TOP_LEFT</code>,
<code>TOP_RIGHT</code>, <code>BOTTOM_LEFT</code> or <code>BOTTOM_RIGHT</code>
@param parallelLight
True, if parallel light should be emulated, false otherwise
@return The color of the shadow as an {@link Integer} value | [
"Returns",
"the",
"color",
"of",
"a",
"shadow",
"which",
"is",
"located",
"next",
"to",
"a",
"corner",
"of",
"an",
"elevated",
"view",
"in",
"horizontal",
"direction",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ElevationUtil.java#L536-L549 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ElevationUtil.java | ElevationUtil.getVerticalShadowColor | private static int getVerticalShadowColor(final int elevation,
@NonNull final Orientation orientation,
final boolean parallelLight) {
switch (orientation) {
case TOP_LEFT:
case BOTTOM_LEFT:
return getShadowColor(elevation, Orientation.LEFT, parallelLight);
case TOP_RIGHT:
case BOTTOM_RIGHT:
return getShadowColor(elevation, Orientation.RIGHT, parallelLight);
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
} | java | private static int getVerticalShadowColor(final int elevation,
@NonNull final Orientation orientation,
final boolean parallelLight) {
switch (orientation) {
case TOP_LEFT:
case BOTTOM_LEFT:
return getShadowColor(elevation, Orientation.LEFT, parallelLight);
case TOP_RIGHT:
case BOTTOM_RIGHT:
return getShadowColor(elevation, Orientation.RIGHT, parallelLight);
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
} | [
"private",
"static",
"int",
"getVerticalShadowColor",
"(",
"final",
"int",
"elevation",
",",
"@",
"NonNull",
"final",
"Orientation",
"orientation",
",",
"final",
"boolean",
"parallelLight",
")",
"{",
"switch",
"(",
"orientation",
")",
"{",
"case",
"TOP_LEFT",
":... | Returns the color of a shadow, which is located next to a corner of an elevated view in
vertical direction.
@param elevation
The elevation, which should be emulated, in dp as an {@link Integer} value. The
elevation must be at least 0 and at maximum the value of the constant
<code>MAX_ELEVATION</code>
@param orientation
The orientation of the shadow in relation to the elevated view as a value of the enum
{@link Orientation}. The orientation may either be <code>TOP_LEFT</code>,
<code>TOP_RIGHT</code>, <code>BOTTOM_LEFT</code> or <code>BOTTOM_RIGHT</code>
@param parallelLight
True, if parallel light should be emulated, false otherwise
@return The color of the shadow as an {@link Integer} value | [
"Returns",
"the",
"color",
"of",
"a",
"shadow",
"which",
"is",
"located",
"next",
"to",
"a",
"corner",
"of",
"an",
"elevated",
"view",
"in",
"vertical",
"direction",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ElevationUtil.java#L567-L580 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ElevationUtil.java | ElevationUtil.getShadowColor | private static int getShadowColor(final int elevation, @NonNull final Orientation orientation,
final boolean parallelLight) {
int alpha;
if (parallelLight) {
alpha = getShadowAlpha(elevation, MIN_BOTTOM_ALPHA, MAX_BOTTOM_ALPHA);
} else {
switch (orientation) {
case LEFT:
alpha = getShadowAlpha(elevation, MIN_LEFT_ALPHA, MAX_LEFT_ALPHA);
break;
case TOP:
alpha = getShadowAlpha(elevation, MIN_TOP_ALPHA, MAX_TOP_ALPHA);
break;
case RIGHT:
alpha = getShadowAlpha(elevation, MIN_RIGHT_ALPHA, MAX_RIGHT_ALPHA);
break;
case BOTTOM:
alpha = getShadowAlpha(elevation, MIN_BOTTOM_ALPHA, MAX_BOTTOM_ALPHA);
break;
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
}
return Color.argb(alpha, 0, 0, 0);
} | java | private static int getShadowColor(final int elevation, @NonNull final Orientation orientation,
final boolean parallelLight) {
int alpha;
if (parallelLight) {
alpha = getShadowAlpha(elevation, MIN_BOTTOM_ALPHA, MAX_BOTTOM_ALPHA);
} else {
switch (orientation) {
case LEFT:
alpha = getShadowAlpha(elevation, MIN_LEFT_ALPHA, MAX_LEFT_ALPHA);
break;
case TOP:
alpha = getShadowAlpha(elevation, MIN_TOP_ALPHA, MAX_TOP_ALPHA);
break;
case RIGHT:
alpha = getShadowAlpha(elevation, MIN_RIGHT_ALPHA, MAX_RIGHT_ALPHA);
break;
case BOTTOM:
alpha = getShadowAlpha(elevation, MIN_BOTTOM_ALPHA, MAX_BOTTOM_ALPHA);
break;
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
}
return Color.argb(alpha, 0, 0, 0);
} | [
"private",
"static",
"int",
"getShadowColor",
"(",
"final",
"int",
"elevation",
",",
"@",
"NonNull",
"final",
"Orientation",
"orientation",
",",
"final",
"boolean",
"parallelLight",
")",
"{",
"int",
"alpha",
";",
"if",
"(",
"parallelLight",
")",
"{",
"alpha",
... | Returns the color of a shadow, which is located besides an edge of an elevated view.
@param elevation
The elevation, which should be emulated, in dp as an {@link Integer} value. The
elevation must be at least 0 and at maximum the value of the constant
<code>MAX_ELEVATION</code>
@param orientation
The orientation of the shadow in relation to the elevated view as a value of the enum
{@link Orientation}. The orientation may either be <code>LEFT</code>,
<code>TOP</code>, <code>RIGHT</code> or <code>BOTTOM</code>
@param parallelLight
True, if parallel light should be emulated, false otherwise
@return The color of the shadow as an {@link Integer} value | [
"Returns",
"the",
"color",
"of",
"a",
"shadow",
"which",
"is",
"located",
"besides",
"an",
"edge",
"of",
"an",
"elevated",
"view",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ElevationUtil.java#L597-L623 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ElevationUtil.java | ElevationUtil.getShadowAlpha | private static int getShadowAlpha(final int elevation, final int minTransparency,
final int maxTransparency) {
float ratio = (float) elevation / (float) MAX_ELEVATION;
int range = maxTransparency - minTransparency;
return Math.round(minTransparency + ratio * range);
} | java | private static int getShadowAlpha(final int elevation, final int minTransparency,
final int maxTransparency) {
float ratio = (float) elevation / (float) MAX_ELEVATION;
int range = maxTransparency - minTransparency;
return Math.round(minTransparency + ratio * range);
} | [
"private",
"static",
"int",
"getShadowAlpha",
"(",
"final",
"int",
"elevation",
",",
"final",
"int",
"minTransparency",
",",
"final",
"int",
"maxTransparency",
")",
"{",
"float",
"ratio",
"=",
"(",
"float",
")",
"elevation",
"/",
"(",
"float",
")",
"MAX_ELEV... | Returns the alpha value of a shadow by interpolating between a minimum and maximum alpha
value, depending on a specific elevation.
@param elevation
The elevation, which should be emulated, in dp as an {@link Integer} value. The
elevation must be at least 0 and at maximum the value of the constant
<code>MAX_ELEVATION</code>
@param minTransparency
The minimum alpha value, which should be used, if the given elevation is 0, as an
{@link Integer} value between 0 and 255
@param maxTransparency
The maximum alpha value, which should be used, if the given elevation is
<code>MAX_ELEVATION</code>, as an {@link Integer} value between 0 and 255
@return The alpha value of the shadow as an {@link Integer} value between 0 and 255 | [
"Returns",
"the",
"alpha",
"value",
"of",
"a",
"shadow",
"by",
"interpolating",
"between",
"a",
"minimum",
"and",
"maximum",
"alpha",
"value",
"depending",
"on",
"a",
"specific",
"elevation",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ElevationUtil.java#L641-L646 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ElevationUtil.java | ElevationUtil.createLinearGradient | private static Shader createLinearGradient(@NonNull final Orientation orientation,
final int bitmapWidth, final int bitmapHeight,
final float shadowWidth,
@ColorInt final int shadowColor) {
RectF bounds = new RectF();
switch (orientation) {
case LEFT:
bounds.left = bitmapWidth;
bounds.right = bitmapWidth - shadowWidth;
break;
case TOP:
bounds.top = bitmapHeight;
bounds.bottom = bitmapHeight - shadowWidth;
break;
case RIGHT:
bounds.right = shadowWidth;
break;
case BOTTOM:
bounds.bottom = shadowWidth;
break;
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
return new LinearGradient(bounds.left, bounds.top, bounds.right, bounds.bottom, shadowColor,
Color.TRANSPARENT, Shader.TileMode.CLAMP);
} | java | private static Shader createLinearGradient(@NonNull final Orientation orientation,
final int bitmapWidth, final int bitmapHeight,
final float shadowWidth,
@ColorInt final int shadowColor) {
RectF bounds = new RectF();
switch (orientation) {
case LEFT:
bounds.left = bitmapWidth;
bounds.right = bitmapWidth - shadowWidth;
break;
case TOP:
bounds.top = bitmapHeight;
bounds.bottom = bitmapHeight - shadowWidth;
break;
case RIGHT:
bounds.right = shadowWidth;
break;
case BOTTOM:
bounds.bottom = shadowWidth;
break;
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
return new LinearGradient(bounds.left, bounds.top, bounds.right, bounds.bottom, shadowColor,
Color.TRANSPARENT, Shader.TileMode.CLAMP);
} | [
"private",
"static",
"Shader",
"createLinearGradient",
"(",
"@",
"NonNull",
"final",
"Orientation",
"orientation",
",",
"final",
"int",
"bitmapWidth",
",",
"final",
"int",
"bitmapHeight",
",",
"final",
"float",
"shadowWidth",
",",
"@",
"ColorInt",
"final",
"int",
... | Creates and returns a shader, which can be used to draw a shadow, which located besides an
edge of an elevated view.
@param orientation
The orientation of the shadow in relation to the elevated view as a value of the enum
{@link Orientation}. The orientation may either be <code>LEFT</code>,
<code>TOP</code>, <code>RIGHT</code> or <code>BOTTOM</code>
@param bitmapWidth
The width of the bitmap, which is used to draw the shadow, in pixels as an {@link
Integer} value
@param bitmapHeight
The height of the bitmap, which is used to draw the shadow, in pixels as an {@link
Integer} value
@param shadowWidth
The width of the shadow in pixels as a {@link Float} value
@param shadowColor
The color of the shadow as an {@link Integer} value
@return The shader, which has been created as an instance of the class {@link Shader} | [
"Creates",
"and",
"returns",
"a",
"shader",
"which",
"can",
"be",
"used",
"to",
"draw",
"a",
"shadow",
"which",
"located",
"besides",
"an",
"edge",
"of",
"an",
"elevated",
"view",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ElevationUtil.java#L668-L695 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ElevationUtil.java | ElevationUtil.createRadialGradient | private static Shader createRadialGradient(@NonNull final Orientation orientation,
final int bitmapSize, final float radius) {
PointF center = new PointF();
switch (orientation) {
case TOP_LEFT:
center.x = bitmapSize;
center.y = bitmapSize;
break;
case TOP_RIGHT:
center.y = bitmapSize;
break;
case BOTTOM_LEFT:
center.x = bitmapSize;
break;
case BOTTOM_RIGHT:
break;
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
return new RadialGradient(center.x, center.y, radius, Color.TRANSPARENT, Color.BLACK,
Shader.TileMode.CLAMP);
} | java | private static Shader createRadialGradient(@NonNull final Orientation orientation,
final int bitmapSize, final float radius) {
PointF center = new PointF();
switch (orientation) {
case TOP_LEFT:
center.x = bitmapSize;
center.y = bitmapSize;
break;
case TOP_RIGHT:
center.y = bitmapSize;
break;
case BOTTOM_LEFT:
center.x = bitmapSize;
break;
case BOTTOM_RIGHT:
break;
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
return new RadialGradient(center.x, center.y, radius, Color.TRANSPARENT, Color.BLACK,
Shader.TileMode.CLAMP);
} | [
"private",
"static",
"Shader",
"createRadialGradient",
"(",
"@",
"NonNull",
"final",
"Orientation",
"orientation",
",",
"final",
"int",
"bitmapSize",
",",
"final",
"float",
"radius",
")",
"{",
"PointF",
"center",
"=",
"new",
"PointF",
"(",
")",
";",
"switch",
... | Creates and returns a shader, which can be used to draw a shadow, which located at a corner
of an elevated view.
@param orientation
The orientation of the shadow in relation to the elevated view as a value of the enum
{@link Orientation}. The orientation may either be <code>TOP_LEFT</code>,
<code>TOP_RIGHT</code>, <code>BOTTOM_LEFT</code> or <code>BOTTOM_RIGHT</code>
@param bitmapSize
The size of the bitmap, which is used to draw the shadow, in pixels as an {@link
Integer} value
@param radius
The radius, which should be used to draw the shadow, in pixels as a {@link Float}
value
@return The shader, which has been created as an instance of the class {@link Shader} | [
"Creates",
"and",
"returns",
"a",
"shader",
"which",
"can",
"be",
"used",
"to",
"draw",
"a",
"shadow",
"which",
"located",
"at",
"a",
"corner",
"of",
"an",
"elevated",
"view",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ElevationUtil.java#L713-L736 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ElevationUtil.java | ElevationUtil.getCornerAngle | private static float getCornerAngle(@NonNull final Orientation orientation) {
switch (orientation) {
case TOP_LEFT:
return QUARTER_ARC_DEGRESS * 2;
case TOP_RIGHT:
return QUARTER_ARC_DEGRESS * 3;
case BOTTOM_LEFT:
return QUARTER_ARC_DEGRESS;
case BOTTOM_RIGHT:
return 0;
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
} | java | private static float getCornerAngle(@NonNull final Orientation orientation) {
switch (orientation) {
case TOP_LEFT:
return QUARTER_ARC_DEGRESS * 2;
case TOP_RIGHT:
return QUARTER_ARC_DEGRESS * 3;
case BOTTOM_LEFT:
return QUARTER_ARC_DEGRESS;
case BOTTOM_RIGHT:
return 0;
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
} | [
"private",
"static",
"float",
"getCornerAngle",
"(",
"@",
"NonNull",
"final",
"Orientation",
"orientation",
")",
"{",
"switch",
"(",
"orientation",
")",
"{",
"case",
"TOP_LEFT",
":",
"return",
"QUARTER_ARC_DEGRESS",
"*",
"2",
";",
"case",
"TOP_RIGHT",
":",
"re... | Returns the angle, which should be used to draw a shadow, which is located at a corner of an
elevated view.
@param orientation
The orientation of the shadow in relation to the elevated view as a value of the enum
{@link Orientation}. The orientation may either be <code>TOP_LEFT</code>,
<code>TOP_RIGHT</code>, <code>BOTTOM_LEFT</code> or <code>BOTTOM_RIGHT</code>
@return The angle, which should be used to draw the shadow, as a {@link Float} value | [
"Returns",
"the",
"angle",
"which",
"should",
"be",
"used",
"to",
"draw",
"a",
"shadow",
"which",
"is",
"located",
"at",
"a",
"corner",
"of",
"an",
"elevated",
"view",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ElevationUtil.java#L748-L761 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ElevationUtil.java | ElevationUtil.createElevationShadow | public static Bitmap createElevationShadow(@NonNull final Context context, final int elevation,
@NonNull final Orientation orientation) {
return createElevationShadow(context, elevation, orientation, false);
} | java | public static Bitmap createElevationShadow(@NonNull final Context context, final int elevation,
@NonNull final Orientation orientation) {
return createElevationShadow(context, elevation, orientation, false);
} | [
"public",
"static",
"Bitmap",
"createElevationShadow",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"final",
"int",
"elevation",
",",
"@",
"NonNull",
"final",
"Orientation",
"orientation",
")",
"{",
"return",
"createElevationShadow",
"(",
"context",
",... | Creates and returns a bitmap, which can be used to emulate a shadow of an elevated view on
pre-Lollipop devices. By default a non-parallel illumination of the view is emulated, which
causes the shadow at its bottom to appear a bit more intense than the shadows to its left and
right and a lot more intense than the shadow at its top.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param elevation
The elevation, which should be emulated, in dp as an {@link Integer} value. The
elevation must be at least 0 and at maximum the value of the constant
<code>MAX_ELEVATION</code>
@param orientation
The orientation of the shadow in relation to the elevated view as a value of the enum
{@link Orientation}. The orientation may either be <code>LEFT</code>,
<code>RIGHT</code>, <code>TOP</code>, <code>BOTTOM</code>, <code>TOP_LEFT</code>,
<code>TOP_RIGHT</code>, <code>BOTTOM_LEFT</code> or <code>BOTTOM_RIGHT</code>
@return The bitmap, which has been created, as an instance of the class {@link Bitmap} or
null, if the given elevation is 0 | [
"Creates",
"and",
"returns",
"a",
"bitmap",
"which",
"can",
"be",
"used",
"to",
"emulate",
"a",
"shadow",
"of",
"an",
"elevated",
"view",
"on",
"pre",
"-",
"Lollipop",
"devices",
".",
"By",
"default",
"a",
"non",
"-",
"parallel",
"illumination",
"of",
"t... | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ElevationUtil.java#L792-L795 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ElevationUtil.java | ElevationUtil.createElevationShadow | public static Bitmap createElevationShadow(@NonNull final Context context, final int elevation,
@NonNull final Orientation orientation,
final boolean parallelLight) {
Condition.INSTANCE.ensureNotNull(context, "The context may not be null");
Condition.INSTANCE.ensureAtLeast(elevation, 0, "The elevation must be at least 0");
Condition.INSTANCE.ensureAtMaximum(elevation, MAX_ELEVATION,
"The elevation must be at maximum " + MAX_ELEVATION);
Condition.INSTANCE.ensureNotNull(orientation, "The orientation may not be null");
switch (orientation) {
case LEFT:
case TOP:
case RIGHT:
case BOTTOM:
return createEdgeShadow(context, elevation, orientation, parallelLight);
case TOP_LEFT:
case TOP_RIGHT:
case BOTTOM_LEFT:
case BOTTOM_RIGHT:
return createCornerShadow(context, elevation, orientation, parallelLight);
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
} | java | public static Bitmap createElevationShadow(@NonNull final Context context, final int elevation,
@NonNull final Orientation orientation,
final boolean parallelLight) {
Condition.INSTANCE.ensureNotNull(context, "The context may not be null");
Condition.INSTANCE.ensureAtLeast(elevation, 0, "The elevation must be at least 0");
Condition.INSTANCE.ensureAtMaximum(elevation, MAX_ELEVATION,
"The elevation must be at maximum " + MAX_ELEVATION);
Condition.INSTANCE.ensureNotNull(orientation, "The orientation may not be null");
switch (orientation) {
case LEFT:
case TOP:
case RIGHT:
case BOTTOM:
return createEdgeShadow(context, elevation, orientation, parallelLight);
case TOP_LEFT:
case TOP_RIGHT:
case BOTTOM_LEFT:
case BOTTOM_RIGHT:
return createCornerShadow(context, elevation, orientation, parallelLight);
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
} | [
"public",
"static",
"Bitmap",
"createElevationShadow",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"final",
"int",
"elevation",
",",
"@",
"NonNull",
"final",
"Orientation",
"orientation",
",",
"final",
"boolean",
"parallelLight",
")",
"{",
"Condition"... | Creates and returns a bitmap, which can be used to emulate a shadow of an elevated view on
pre-Lollipop devices. This method furthermore allows to specify, whether parallel
illumination of the view should be emulated, which causes the shadows at all of its sides to
appear identically.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param elevation
The elevation, which should be emulated, in dp as an {@link Integer} value. The
elevation must be at least 0 and at maximum the value of the constant
<code>MAX_ELEVATION</code>
@param orientation
The orientation of the shadow in relation to the elevated view as a value of the enum
{@link Orientation}. The orientation may either be <code>LEFT</code>,
<code>RIGHT</code>, <code>TOP</code>, <code>BOTTOM</code>, <code>TOP_LEFT</code>,
<code>TOP_RIGHT</code>, <code>BOTTOM_LEFT</code> or <code>BOTTOM_RIGHT</code>
@param parallelLight
True, if parallel light should be emulated, false otherwise
@return The bitmap, which has been created, as an instance of the class {@link Bitmap} or
null, if the given elevation is 0 | [
"Creates",
"and",
"returns",
"a",
"bitmap",
"which",
"can",
"be",
"used",
"to",
"emulate",
"a",
"shadow",
"of",
"an",
"elevated",
"view",
"on",
"pre",
"-",
"Lollipop",
"devices",
".",
"This",
"method",
"furthermore",
"allows",
"to",
"specify",
"whether",
"... | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ElevationUtil.java#L820-L843 | train |
sosandstrom/mardao | mardao-maven-plugin/src/main/java/net/sf/mardao/plugin/AbstractMardaoMojo.java | AbstractMardaoMojo.mergeTemplate | private void mergeTemplate(String templateFilename, File folder,
String javaFilename, boolean overwrite) {
final File javaFile = new File(folder, javaFilename);
// create destination folder?
File destinationFolder = javaFile.getParentFile();
if (false == destinationFolder.exists()) {
destinationFolder.mkdirs();
}
// up-to-date?
if (false == javaFile.exists() || overwrite) {
getLog().info("Merging " + templateFilename + " for " + javaFilename);
try {
final PrintWriter writer = new PrintWriter(javaFile);
Template template = Velocity.getTemplate(templateFilename);
template.merge(vc, writer);
writer.close();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (ResourceNotFoundException e) {
e.printStackTrace();
}
catch (ParseErrorException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
}
else {
getLog().info("Skipping " + templateFilename + " for " + javaFilename);
}
} | java | private void mergeTemplate(String templateFilename, File folder,
String javaFilename, boolean overwrite) {
final File javaFile = new File(folder, javaFilename);
// create destination folder?
File destinationFolder = javaFile.getParentFile();
if (false == destinationFolder.exists()) {
destinationFolder.mkdirs();
}
// up-to-date?
if (false == javaFile.exists() || overwrite) {
getLog().info("Merging " + templateFilename + " for " + javaFilename);
try {
final PrintWriter writer = new PrintWriter(javaFile);
Template template = Velocity.getTemplate(templateFilename);
template.merge(vc, writer);
writer.close();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (ResourceNotFoundException e) {
e.printStackTrace();
}
catch (ParseErrorException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
}
else {
getLog().info("Skipping " + templateFilename + " for " + javaFilename);
}
} | [
"private",
"void",
"mergeTemplate",
"(",
"String",
"templateFilename",
",",
"File",
"folder",
",",
"String",
"javaFilename",
",",
"boolean",
"overwrite",
")",
"{",
"final",
"File",
"javaFile",
"=",
"new",
"File",
"(",
"folder",
",",
"javaFilename",
")",
";",
... | Merges a Velocity template for a specified file, unless it already exists.
@param templateFilename
@param folder
@param javaFilename | [
"Merges",
"a",
"Velocity",
"template",
"for",
"a",
"specified",
"file",
"unless",
"it",
"already",
"exists",
"."
] | b77e3a2ac1d8932e0a3174f3645f71b211dfc055 | https://github.com/sosandstrom/mardao/blob/b77e3a2ac1d8932e0a3174f3645f71b211dfc055/mardao-maven-plugin/src/main/java/net/sf/mardao/plugin/AbstractMardaoMojo.java#L402-L437 | train |
rahulsom/genealogy | src/main/java/com/github/rahulsom/genealogy/DataUtil.java | DataUtil.processResource | private static void processResource(String resourceName, AbstractProcessor processor) {
InputStream lastNameStream = NameDbUsa.class.getClassLoader().getResourceAsStream(resourceName);
BufferedReader lastNameReader = new BufferedReader(new InputStreamReader(lastNameStream));
try {
int index = 0;
while (lastNameReader.ready()) {
String line = lastNameReader.readLine();
processor.processLine(line, index++);
}
} catch (IOException e) {
e.printStackTrace();
}
} | java | private static void processResource(String resourceName, AbstractProcessor processor) {
InputStream lastNameStream = NameDbUsa.class.getClassLoader().getResourceAsStream(resourceName);
BufferedReader lastNameReader = new BufferedReader(new InputStreamReader(lastNameStream));
try {
int index = 0;
while (lastNameReader.ready()) {
String line = lastNameReader.readLine();
processor.processLine(line, index++);
}
} catch (IOException e) {
e.printStackTrace();
}
} | [
"private",
"static",
"void",
"processResource",
"(",
"String",
"resourceName",
",",
"AbstractProcessor",
"processor",
")",
"{",
"InputStream",
"lastNameStream",
"=",
"NameDbUsa",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"resour... | Processes a given resource using provided closure
@param resourceName resource to fetch from classpath
@param processor how to process the resource | [
"Processes",
"a",
"given",
"resource",
"using",
"provided",
"closure"
] | 2beb35ab9c6e03080328aa08b18f0a3c5d3f5c12 | https://github.com/rahulsom/genealogy/blob/2beb35ab9c6e03080328aa08b18f0a3c5d3f5c12/src/main/java/com/github/rahulsom/genealogy/DataUtil.java#L97-L109 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/AttachedViewRecycler.java | AttachedViewRecycler.binarySearch | private int binarySearch(@NonNull final List<ItemType> list, @NonNull final ItemType item,
@NonNull final Comparator<ItemType> comparator) {
int index = Collections.binarySearch(list, item, comparator);
if (index < 0) {
index = ~index;
}
return index;
} | java | private int binarySearch(@NonNull final List<ItemType> list, @NonNull final ItemType item,
@NonNull final Comparator<ItemType> comparator) {
int index = Collections.binarySearch(list, item, comparator);
if (index < 0) {
index = ~index;
}
return index;
} | [
"private",
"int",
"binarySearch",
"(",
"@",
"NonNull",
"final",
"List",
"<",
"ItemType",
">",
"list",
",",
"@",
"NonNull",
"final",
"ItemType",
"item",
",",
"@",
"NonNull",
"final",
"Comparator",
"<",
"ItemType",
">",
"comparator",
")",
"{",
"int",
"index"... | Returns the index, an item should be added at, according to a specific comparator.
@param list
The list, which should be searched, as an instance of the type {@link List}. The list
may not be null
@param item
The item, whose position should be returned, as an instance of the generic type
ItemType. The item may not be null
@param comparator
The comparator, which should be used to compare items, as an instance of the type
{@link Comparator}. The comparator may not be null
@return The index, the given item should be added at, as an {@link Integer} value | [
"Returns",
"the",
"index",
"an",
"item",
"should",
"be",
"added",
"at",
"according",
"to",
"a",
"specific",
"comparator",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/AttachedViewRecycler.java#L80-L89 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/AttachedViewRecycler.java | AttachedViewRecycler.setComparator | public final void setComparator(@Nullable final Comparator<ItemType> comparator) {
this.comparator = comparator;
if (comparator != null) {
if (items.size() > 0) {
List<ItemType> newItems = new ArrayList<>();
List<View> views = new ArrayList<>();
for (int i = items.size() - 1; i >= 0; i--) {
ItemType item = items.get(i);
int index = binarySearch(newItems, item, comparator);
newItems.add(index, item);
View view = parent.getChildAt(i);
parent.removeViewAt(i);
views.add(index, view);
}
parent.removeAllViews();
for (View view : views) {
parent.addView(view);
}
this.items = newItems;
getLogger().logDebug(getClass(), "Comparator changed. Views have been reordered");
} else {
getLogger().logDebug(getClass(), "Comparator changed");
}
} else {
getLogger().logDebug(getClass(), "Comparator set to null");
}
} | java | public final void setComparator(@Nullable final Comparator<ItemType> comparator) {
this.comparator = comparator;
if (comparator != null) {
if (items.size() > 0) {
List<ItemType> newItems = new ArrayList<>();
List<View> views = new ArrayList<>();
for (int i = items.size() - 1; i >= 0; i--) {
ItemType item = items.get(i);
int index = binarySearch(newItems, item, comparator);
newItems.add(index, item);
View view = parent.getChildAt(i);
parent.removeViewAt(i);
views.add(index, view);
}
parent.removeAllViews();
for (View view : views) {
parent.addView(view);
}
this.items = newItems;
getLogger().logDebug(getClass(), "Comparator changed. Views have been reordered");
} else {
getLogger().logDebug(getClass(), "Comparator changed");
}
} else {
getLogger().logDebug(getClass(), "Comparator set to null");
}
} | [
"public",
"final",
"void",
"setComparator",
"(",
"@",
"Nullable",
"final",
"Comparator",
"<",
"ItemType",
">",
"comparator",
")",
"{",
"this",
".",
"comparator",
"=",
"comparator",
";",
"if",
"(",
"comparator",
"!=",
"null",
")",
"{",
"if",
"(",
"items",
... | Sets the comparator, which allows to determine the order, which should be used to add views
to the parent. When setting a comparator, which is different from the current one, the
currently attached views are reordered.
@param comparator
The comparator, which allows to determine the order, which should be used to add
views to the parent, as an instance of the type {@link Comparator} or null, if the
views should be added in the order of their inflation | [
"Sets",
"the",
"comparator",
"which",
"allows",
"to",
"determine",
"the",
"order",
"which",
"should",
"be",
"used",
"to",
"add",
"views",
"to",
"the",
"parent",
".",
"When",
"setting",
"a",
"comparator",
"which",
"is",
"different",
"from",
"the",
"current",
... | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/AttachedViewRecycler.java#L213-L244 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.httpRequest | public <T> T httpRequest(HttpMethod method, Class<T> cls,
Map<String, Object> params, Object data, String... segments) {
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setAccept(Collections
.singletonList(MediaType.APPLICATION_JSON));
if (accessToken != null) {
String auth = "Bearer " + accessToken;
requestHeaders.set("Authorization", auth);
log.info("Authorization: " + auth);
}
String url = path(apiUrl, segments);
MediaType contentType = MediaType.APPLICATION_JSON;
if (method.equals(HttpMethod.POST) && isEmpty(data) && !isEmpty(params)) {
data = encodeParams(params);
contentType = MediaType.APPLICATION_FORM_URLENCODED;
} else {
url = addQueryParams(url, params);
}
requestHeaders.setContentType(contentType);
HttpEntity<?> requestEntity = null;
if (method.equals(HttpMethod.POST) || method.equals(HttpMethod.PUT)) {
if (isEmpty(data)) {
data = JsonNodeFactory.instance.objectNode();
}
requestEntity = new HttpEntity<Object>(data, requestHeaders);
} else {
requestEntity = new HttpEntity<Object>(requestHeaders);
}
log.info("Client.httpRequest(): url: " + url);
ResponseEntity<T> responseEntity = restTemplate.exchange(url, method,
requestEntity, cls);
log.info("Client.httpRequest(): reponse body: "
+ responseEntity.getBody().toString());
return responseEntity.getBody();
} | java | public <T> T httpRequest(HttpMethod method, Class<T> cls,
Map<String, Object> params, Object data, String... segments) {
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setAccept(Collections
.singletonList(MediaType.APPLICATION_JSON));
if (accessToken != null) {
String auth = "Bearer " + accessToken;
requestHeaders.set("Authorization", auth);
log.info("Authorization: " + auth);
}
String url = path(apiUrl, segments);
MediaType contentType = MediaType.APPLICATION_JSON;
if (method.equals(HttpMethod.POST) && isEmpty(data) && !isEmpty(params)) {
data = encodeParams(params);
contentType = MediaType.APPLICATION_FORM_URLENCODED;
} else {
url = addQueryParams(url, params);
}
requestHeaders.setContentType(contentType);
HttpEntity<?> requestEntity = null;
if (method.equals(HttpMethod.POST) || method.equals(HttpMethod.PUT)) {
if (isEmpty(data)) {
data = JsonNodeFactory.instance.objectNode();
}
requestEntity = new HttpEntity<Object>(data, requestHeaders);
} else {
requestEntity = new HttpEntity<Object>(requestHeaders);
}
log.info("Client.httpRequest(): url: " + url);
ResponseEntity<T> responseEntity = restTemplate.exchange(url, method,
requestEntity, cls);
log.info("Client.httpRequest(): reponse body: "
+ responseEntity.getBody().toString());
return responseEntity.getBody();
} | [
"public",
"<",
"T",
">",
"T",
"httpRequest",
"(",
"HttpMethod",
"method",
",",
"Class",
"<",
"T",
">",
"cls",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"params",
",",
"Object",
"data",
",",
"String",
"...",
"segments",
")",
"{",
"HttpHeaders",
"... | Low-level HTTP request method. Synchronous, blocks till response or
timeout.
@param method
HttpMethod method
@param cls
class for the return type
@param params
parameters to encode as querystring or body parameters
@param data
JSON data to put in body
@param segments
REST url path segments (i.e. /segment1/segment2/segment3)
@return results marshalled into class specified in cls parameter | [
"Low",
"-",
"level",
"HTTP",
"request",
"method",
".",
"Synchronous",
"blocks",
"till",
"response",
"or",
"timeout",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L291-L327 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.apiRequest | public ApiResponse apiRequest(HttpMethod method,
Map<String, Object> params, Object data, String... segments) {
ApiResponse response = null;
try {
response = httpRequest(method, ApiResponse.class, params, data,
segments);
log.info("Client.apiRequest(): Response: " + response);
} catch (HttpClientErrorException e) {
log.error("Client.apiRequest(): HTTP error: "
+ e.getLocalizedMessage());
response = parse(e.getResponseBodyAsString(), ApiResponse.class);
if ((response != null) && !isEmpty(response.getError())) {
log.error("Client.apiRequest(): Response error: "
+ response.getError());
if (!isEmpty(response.getException())) {
log.error("Client.apiRequest(): Response exception: "
+ response.getException());
}
}
}
return response;
} | java | public ApiResponse apiRequest(HttpMethod method,
Map<String, Object> params, Object data, String... segments) {
ApiResponse response = null;
try {
response = httpRequest(method, ApiResponse.class, params, data,
segments);
log.info("Client.apiRequest(): Response: " + response);
} catch (HttpClientErrorException e) {
log.error("Client.apiRequest(): HTTP error: "
+ e.getLocalizedMessage());
response = parse(e.getResponseBodyAsString(), ApiResponse.class);
if ((response != null) && !isEmpty(response.getError())) {
log.error("Client.apiRequest(): Response error: "
+ response.getError());
if (!isEmpty(response.getException())) {
log.error("Client.apiRequest(): Response exception: "
+ response.getException());
}
}
}
return response;
} | [
"public",
"ApiResponse",
"apiRequest",
"(",
"HttpMethod",
"method",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"params",
",",
"Object",
"data",
",",
"String",
"...",
"segments",
")",
"{",
"ApiResponse",
"response",
"=",
"null",
";",
"try",
"{",
"respon... | High-level Usergrid API request.
@param method
@param params
@param data
@param segments
@return | [
"High",
"-",
"level",
"Usergrid",
"API",
"request",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L338-L359 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.authorizeAppUser | public ApiResponse authorizeAppUser(String email, String password) {
validateNonEmptyParam(email, "email");
validateNonEmptyParam(password,"password");
assertValidApplicationId();
loggedInUser = null;
accessToken = null;
currentOrganization = null;
Map<String, Object> formData = new HashMap<String, Object>();
formData.put("grant_type", "password");
formData.put("username", email);
formData.put("password", password);
ApiResponse response = apiRequest(HttpMethod.POST, formData, null,
organizationId, applicationId, "token");
if (response == null) {
return response;
}
if (!isEmpty(response.getAccessToken()) && (response.getUser() != null)) {
loggedInUser = response.getUser();
accessToken = response.getAccessToken();
currentOrganization = null;
log.info("Client.authorizeAppUser(): Access token: " + accessToken);
} else {
log.info("Client.authorizeAppUser(): Response: " + response);
}
return response;
} | java | public ApiResponse authorizeAppUser(String email, String password) {
validateNonEmptyParam(email, "email");
validateNonEmptyParam(password,"password");
assertValidApplicationId();
loggedInUser = null;
accessToken = null;
currentOrganization = null;
Map<String, Object> formData = new HashMap<String, Object>();
formData.put("grant_type", "password");
formData.put("username", email);
formData.put("password", password);
ApiResponse response = apiRequest(HttpMethod.POST, formData, null,
organizationId, applicationId, "token");
if (response == null) {
return response;
}
if (!isEmpty(response.getAccessToken()) && (response.getUser() != null)) {
loggedInUser = response.getUser();
accessToken = response.getAccessToken();
currentOrganization = null;
log.info("Client.authorizeAppUser(): Access token: " + accessToken);
} else {
log.info("Client.authorizeAppUser(): Response: " + response);
}
return response;
} | [
"public",
"ApiResponse",
"authorizeAppUser",
"(",
"String",
"email",
",",
"String",
"password",
")",
"{",
"validateNonEmptyParam",
"(",
"email",
",",
"\"email\"",
")",
";",
"validateNonEmptyParam",
"(",
"password",
",",
"\"password\"",
")",
";",
"assertValidApplicat... | Log the user in and get a valid access token.
@param email
@param password
@return non-null ApiResponse if request succeeds, check getError() for
"invalid_grant" to see if access is denied. | [
"Log",
"the",
"user",
"in",
"and",
"get",
"a",
"valid",
"access",
"token",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L375-L400 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.changePassword | public ApiResponse changePassword(String username, String oldPassword,
String newPassword) {
Map<String, Object> data = new HashMap<String, Object>();
data.put("newpassword", newPassword);
data.put("oldpassword", oldPassword);
return apiRequest(HttpMethod.POST, null, data, organizationId, applicationId, "users",
username, "password");
} | java | public ApiResponse changePassword(String username, String oldPassword,
String newPassword) {
Map<String, Object> data = new HashMap<String, Object>();
data.put("newpassword", newPassword);
data.put("oldpassword", oldPassword);
return apiRequest(HttpMethod.POST, null, data, organizationId, applicationId, "users",
username, "password");
} | [
"public",
"ApiResponse",
"changePassword",
"(",
"String",
"username",
",",
"String",
"oldPassword",
",",
"String",
"newPassword",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"data",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")"... | Change the password for the currently logged in user. You must supply the
old password and the new password.
@param username
@param oldPassword
@param newPassword
@return | [
"Change",
"the",
"password",
"for",
"the",
"currently",
"logged",
"in",
"user",
".",
"You",
"must",
"supply",
"the",
"old",
"password",
"and",
"the",
"new",
"password",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L411-L421 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.authorizeAppClient | public ApiResponse authorizeAppClient(String clientId, String clientSecret) {
validateNonEmptyParam(clientId, "client identifier");
validateNonEmptyParam(clientSecret, "client secret");
assertValidApplicationId();
loggedInUser = null;
accessToken = null;
currentOrganization = null;
Map<String, Object> formData = new HashMap<String, Object>();
formData.put("grant_type", "client_credentials");
formData.put("client_id", clientId);
formData.put("client_secret", clientSecret);
ApiResponse response = apiRequest(HttpMethod.POST, formData, null,
organizationId, applicationId, "token");
if (response == null) {
return response;
}
if (!isEmpty(response.getAccessToken())) {
loggedInUser = null;
accessToken = response.getAccessToken();
currentOrganization = null;
log.info("Client.authorizeAppClient(): Access token: "
+ accessToken);
} else {
log.info("Client.authorizeAppClient(): Response: " + response);
}
return response;
} | java | public ApiResponse authorizeAppClient(String clientId, String clientSecret) {
validateNonEmptyParam(clientId, "client identifier");
validateNonEmptyParam(clientSecret, "client secret");
assertValidApplicationId();
loggedInUser = null;
accessToken = null;
currentOrganization = null;
Map<String, Object> formData = new HashMap<String, Object>();
formData.put("grant_type", "client_credentials");
formData.put("client_id", clientId);
formData.put("client_secret", clientSecret);
ApiResponse response = apiRequest(HttpMethod.POST, formData, null,
organizationId, applicationId, "token");
if (response == null) {
return response;
}
if (!isEmpty(response.getAccessToken())) {
loggedInUser = null;
accessToken = response.getAccessToken();
currentOrganization = null;
log.info("Client.authorizeAppClient(): Access token: "
+ accessToken);
} else {
log.info("Client.authorizeAppClient(): Response: " + response);
}
return response;
} | [
"public",
"ApiResponse",
"authorizeAppClient",
"(",
"String",
"clientId",
",",
"String",
"clientSecret",
")",
"{",
"validateNonEmptyParam",
"(",
"clientId",
",",
"\"client identifier\"",
")",
";",
"validateNonEmptyParam",
"(",
"clientSecret",
",",
"\"client secret\"",
"... | Log the app in with it's client id and client secret key. Not recommended
for production apps.
@param email
@param pin
@return non-null ApiResponse if request succeeds, check getError() for
"invalid_grant" to see if access is denied. | [
"Log",
"the",
"app",
"in",
"with",
"it",
"s",
"client",
"id",
"and",
"client",
"secret",
"key",
".",
"Not",
"recommended",
"for",
"production",
"apps",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L502-L528 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.createEntity | public ApiResponse createEntity(Entity entity) {
assertValidApplicationId();
if (isEmpty(entity.getType())) {
throw new IllegalArgumentException("Missing entity type");
}
ApiResponse response = apiRequest(HttpMethod.POST, null, entity,
organizationId, applicationId, entity.getType());
return response;
} | java | public ApiResponse createEntity(Entity entity) {
assertValidApplicationId();
if (isEmpty(entity.getType())) {
throw new IllegalArgumentException("Missing entity type");
}
ApiResponse response = apiRequest(HttpMethod.POST, null, entity,
organizationId, applicationId, entity.getType());
return response;
} | [
"public",
"ApiResponse",
"createEntity",
"(",
"Entity",
"entity",
")",
"{",
"assertValidApplicationId",
"(",
")",
";",
"if",
"(",
"isEmpty",
"(",
"entity",
".",
"getType",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Missing ent... | Create a new entity on the server.
@param entity
@return an ApiResponse with the new entity in it. | [
"Create",
"a",
"new",
"entity",
"on",
"the",
"server",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L579-L587 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.createEntity | public ApiResponse createEntity(Map<String, Object> properties) {
assertValidApplicationId();
if (isEmpty(properties.get("type"))) {
throw new IllegalArgumentException("Missing entity type");
}
ApiResponse response = apiRequest(HttpMethod.POST, null, properties,
organizationId, applicationId, properties.get("type").toString());
return response;
} | java | public ApiResponse createEntity(Map<String, Object> properties) {
assertValidApplicationId();
if (isEmpty(properties.get("type"))) {
throw new IllegalArgumentException("Missing entity type");
}
ApiResponse response = apiRequest(HttpMethod.POST, null, properties,
organizationId, applicationId, properties.get("type").toString());
return response;
} | [
"public",
"ApiResponse",
"createEntity",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
")",
"{",
"assertValidApplicationId",
"(",
")",
";",
"if",
"(",
"isEmpty",
"(",
"properties",
".",
"get",
"(",
"\"type\"",
")",
")",
")",
"{",
"throw",
... | Create a new entity on the server from a set of properties. Properties
must include a "type" property.
@param properties
@return an ApiResponse with the new entity in it. | [
"Create",
"a",
"new",
"entity",
"on",
"the",
"server",
"from",
"a",
"set",
"of",
"properties",
".",
"Properties",
"must",
"include",
"a",
"type",
"property",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L596-L604 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.getGroupsForUser | public Map<String, Group> getGroupsForUser(String userId) {
ApiResponse response = apiRequest(HttpMethod.GET, null, null,
organizationId, applicationId, "users", userId, "groups");
Map<String, Group> groupMap = new HashMap<String, Group>();
if (response != null) {
List<Group> groups = response.getEntities(Group.class);
for (Group group : groups) {
groupMap.put(group.getPath(), group);
}
}
return groupMap;
} | java | public Map<String, Group> getGroupsForUser(String userId) {
ApiResponse response = apiRequest(HttpMethod.GET, null, null,
organizationId, applicationId, "users", userId, "groups");
Map<String, Group> groupMap = new HashMap<String, Group>();
if (response != null) {
List<Group> groups = response.getEntities(Group.class);
for (Group group : groups) {
groupMap.put(group.getPath(), group);
}
}
return groupMap;
} | [
"public",
"Map",
"<",
"String",
",",
"Group",
">",
"getGroupsForUser",
"(",
"String",
"userId",
")",
"{",
"ApiResponse",
"response",
"=",
"apiRequest",
"(",
"HttpMethod",
".",
"GET",
",",
"null",
",",
"null",
",",
"organizationId",
",",
"applicationId",
",",... | Get the groups for the user.
@param userId
@return a map with the group path as the key and the Group entity as the
value | [
"Get",
"the",
"groups",
"for",
"the",
"user",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L642-L653 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.queryActivityFeedForUser | public Query queryActivityFeedForUser(String userId) {
Query q = queryEntitiesRequest(HttpMethod.GET, null, null,
organizationId, applicationId, "users", userId, "feed");
return q;
} | java | public Query queryActivityFeedForUser(String userId) {
Query q = queryEntitiesRequest(HttpMethod.GET, null, null,
organizationId, applicationId, "users", userId, "feed");
return q;
} | [
"public",
"Query",
"queryActivityFeedForUser",
"(",
"String",
"userId",
")",
"{",
"Query",
"q",
"=",
"queryEntitiesRequest",
"(",
"HttpMethod",
".",
"GET",
",",
"null",
",",
"null",
",",
"organizationId",
",",
"applicationId",
",",
"\"users\"",
",",
"userId",
... | Get a user's activity feed. Returned as a query to ease paging.
@param userId
@return | [
"Get",
"a",
"user",
"s",
"activity",
"feed",
".",
"Returned",
"as",
"a",
"query",
"to",
"ease",
"paging",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L661-L665 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.postUserActivity | public ApiResponse postUserActivity(String userId, Activity activity) {
return apiRequest(HttpMethod.POST, null, activity, organizationId, applicationId, "users",
userId, "activities");
} | java | public ApiResponse postUserActivity(String userId, Activity activity) {
return apiRequest(HttpMethod.POST, null, activity, organizationId, applicationId, "users",
userId, "activities");
} | [
"public",
"ApiResponse",
"postUserActivity",
"(",
"String",
"userId",
",",
"Activity",
"activity",
")",
"{",
"return",
"apiRequest",
"(",
"HttpMethod",
".",
"POST",
",",
"null",
",",
"activity",
",",
"organizationId",
",",
"applicationId",
",",
"\"users\"",
",",... | Posts an activity to a user. Activity must already be created.
@param userId
@param activity
@return | [
"Posts",
"an",
"activity",
"to",
"a",
"user",
".",
"Activity",
"must",
"already",
"be",
"created",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L674-L677 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.postUserActivity | public ApiResponse postUserActivity(String verb, String title,
String content, String category, User user, Entity object,
String objectType, String objectName, String objectContent) {
Activity activity = Activity.newActivity(verb, title, content,
category, user, object, objectType, objectName, objectContent);
return postUserActivity(user.getUuid().toString(), activity);
} | java | public ApiResponse postUserActivity(String verb, String title,
String content, String category, User user, Entity object,
String objectType, String objectName, String objectContent) {
Activity activity = Activity.newActivity(verb, title, content,
category, user, object, objectType, objectName, objectContent);
return postUserActivity(user.getUuid().toString(), activity);
} | [
"public",
"ApiResponse",
"postUserActivity",
"(",
"String",
"verb",
",",
"String",
"title",
",",
"String",
"content",
",",
"String",
"category",
",",
"User",
"user",
",",
"Entity",
"object",
",",
"String",
"objectType",
",",
"String",
"objectName",
",",
"Strin... | Creates and posts an activity to a user.
@param verb
@param title
@param content
@param category
@param user
@param object
@param objectType
@param objectName
@param objectContent
@return | [
"Creates",
"and",
"posts",
"an",
"activity",
"to",
"a",
"user",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L693-L699 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.postGroupActivity | public ApiResponse postGroupActivity(String groupId, Activity activity) {
return apiRequest(HttpMethod.POST, null, activity, organizationId, applicationId, "groups",
groupId, "activities");
} | java | public ApiResponse postGroupActivity(String groupId, Activity activity) {
return apiRequest(HttpMethod.POST, null, activity, organizationId, applicationId, "groups",
groupId, "activities");
} | [
"public",
"ApiResponse",
"postGroupActivity",
"(",
"String",
"groupId",
",",
"Activity",
"activity",
")",
"{",
"return",
"apiRequest",
"(",
"HttpMethod",
".",
"POST",
",",
"null",
",",
"activity",
",",
"organizationId",
",",
"applicationId",
",",
"\"groups\"",
"... | Posts an activity to a group. Activity must already be created.
@param userId
@param activity
@return | [
"Posts",
"an",
"activity",
"to",
"a",
"group",
".",
"Activity",
"must",
"already",
"be",
"created",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L708-L711 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.postGroupActivity | public ApiResponse postGroupActivity(String groupId, String verb, String title,
String content, String category, User user, Entity object,
String objectType, String objectName, String objectContent) {
Activity activity = Activity.newActivity(verb, title, content,
category, user, object, objectType, objectName, objectContent);
return postGroupActivity(groupId, activity);
} | java | public ApiResponse postGroupActivity(String groupId, String verb, String title,
String content, String category, User user, Entity object,
String objectType, String objectName, String objectContent) {
Activity activity = Activity.newActivity(verb, title, content,
category, user, object, objectType, objectName, objectContent);
return postGroupActivity(groupId, activity);
} | [
"public",
"ApiResponse",
"postGroupActivity",
"(",
"String",
"groupId",
",",
"String",
"verb",
",",
"String",
"title",
",",
"String",
"content",
",",
"String",
"category",
",",
"User",
"user",
",",
"Entity",
"object",
",",
"String",
"objectType",
",",
"String"... | Creates and posts an activity to a group.
@param groupId
@param verb
@param title
@param content
@param category
@param user
@param object
@param objectType
@param objectName
@param objectContent
@return | [
"Creates",
"and",
"posts",
"an",
"activity",
"to",
"a",
"group",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L728-L734 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.queryActivity | public Query queryActivity() {
Query q = queryEntitiesRequest(HttpMethod.GET, null, null,
organizationId, applicationId, "activities");
return q;
} | java | public Query queryActivity() {
Query q = queryEntitiesRequest(HttpMethod.GET, null, null,
organizationId, applicationId, "activities");
return q;
} | [
"public",
"Query",
"queryActivity",
"(",
")",
"{",
"Query",
"q",
"=",
"queryEntitiesRequest",
"(",
"HttpMethod",
".",
"GET",
",",
"null",
",",
"null",
",",
"organizationId",
",",
"applicationId",
",",
"\"activities\"",
")",
";",
"return",
"q",
";",
"}"
] | Get a group's activity feed. Returned as a query to ease paging.
@param userId
@return | [
"Get",
"a",
"group",
"s",
"activity",
"feed",
".",
"Returned",
"as",
"a",
"query",
"to",
"ease",
"paging",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L774-L778 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.queryEntitiesRequest | public Query queryEntitiesRequest(HttpMethod method,
Map<String, Object> params, Object data, String... segments) {
ApiResponse response = apiRequest(method, params, data, segments);
return new EntityQuery(response, method, params, data, segments);
} | java | public Query queryEntitiesRequest(HttpMethod method,
Map<String, Object> params, Object data, String... segments) {
ApiResponse response = apiRequest(method, params, data, segments);
return new EntityQuery(response, method, params, data, segments);
} | [
"public",
"Query",
"queryEntitiesRequest",
"(",
"HttpMethod",
"method",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"params",
",",
"Object",
"data",
",",
"String",
"...",
"segments",
")",
"{",
"ApiResponse",
"response",
"=",
"apiRequest",
"(",
"method",
"... | Perform a query request and return a query object. The Query object
provides a simple way of dealing with result sets that need to be
iterated or paged through.
@param method
@param params
@param data
@param segments
@return | [
"Perform",
"a",
"query",
"request",
"and",
"return",
"a",
"query",
"object",
".",
"The",
"Query",
"object",
"provides",
"a",
"simple",
"way",
"of",
"dealing",
"with",
"result",
"sets",
"that",
"need",
"to",
"be",
"iterated",
"or",
"paged",
"through",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L805-L809 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.queryUsersForGroup | public Query queryUsersForGroup(String groupId) {
Query q = queryEntitiesRequest(HttpMethod.GET, null, null, organizationId,
applicationId, "groups", groupId, "users");
return q;
} | java | public Query queryUsersForGroup(String groupId) {
Query q = queryEntitiesRequest(HttpMethod.GET, null, null, organizationId,
applicationId, "groups", groupId, "users");
return q;
} | [
"public",
"Query",
"queryUsersForGroup",
"(",
"String",
"groupId",
")",
"{",
"Query",
"q",
"=",
"queryEntitiesRequest",
"(",
"HttpMethod",
".",
"GET",
",",
"null",
",",
"null",
",",
"organizationId",
",",
"applicationId",
",",
"\"groups\"",
",",
"groupId",
","... | Queries the users for the specified group.
@param groupId
@return | [
"Queries",
"the",
"users",
"for",
"the",
"specified",
"group",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L863-L867 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.addUserToGroup | public ApiResponse addUserToGroup(String userId, String groupId) {
return apiRequest(HttpMethod.POST, null, null, organizationId, applicationId, "groups",
groupId, "users", userId);
} | java | public ApiResponse addUserToGroup(String userId, String groupId) {
return apiRequest(HttpMethod.POST, null, null, organizationId, applicationId, "groups",
groupId, "users", userId);
} | [
"public",
"ApiResponse",
"addUserToGroup",
"(",
"String",
"userId",
",",
"String",
"groupId",
")",
"{",
"return",
"apiRequest",
"(",
"HttpMethod",
".",
"POST",
",",
"null",
",",
"null",
",",
"organizationId",
",",
"applicationId",
",",
"\"groups\"",
",",
"grou... | Adds a user to the specified groups.
@param userId
@param groupId
@return | [
"Adds",
"a",
"user",
"to",
"the",
"specified",
"groups",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L876-L879 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.createGroup | public ApiResponse createGroup(String groupPath, String groupTitle, String groupName){
Map<String, Object> data = new HashMap<String, Object>();
data.put("type", "group");
data.put("path", groupPath);
if (groupTitle != null) {
data.put("title", groupTitle);
}
if(groupName != null){
data.put("name", groupName);
}
return apiRequest(HttpMethod.POST, null, data, organizationId, applicationId, "groups");
} | java | public ApiResponse createGroup(String groupPath, String groupTitle, String groupName){
Map<String, Object> data = new HashMap<String, Object>();
data.put("type", "group");
data.put("path", groupPath);
if (groupTitle != null) {
data.put("title", groupTitle);
}
if(groupName != null){
data.put("name", groupName);
}
return apiRequest(HttpMethod.POST, null, data, organizationId, applicationId, "groups");
} | [
"public",
"ApiResponse",
"createGroup",
"(",
"String",
"groupPath",
",",
"String",
"groupTitle",
",",
"String",
"groupName",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"data",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
"... | Create a group with a path, title and name
@param groupPath
@param groupTitle
@param groupName
@return | [
"Create",
"a",
"group",
"with",
"a",
"path",
"title",
"and",
"name"
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L912-L926 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.connectEntities | public ApiResponse connectEntities(String connectingEntityType,
String connectingEntityId, String connectionType,
String connectedEntityId) {
return apiRequest(HttpMethod.POST, null, null, organizationId, applicationId,
connectingEntityType, connectingEntityId, connectionType,
connectedEntityId);
} | java | public ApiResponse connectEntities(String connectingEntityType,
String connectingEntityId, String connectionType,
String connectedEntityId) {
return apiRequest(HttpMethod.POST, null, null, organizationId, applicationId,
connectingEntityType, connectingEntityId, connectionType,
connectedEntityId);
} | [
"public",
"ApiResponse",
"connectEntities",
"(",
"String",
"connectingEntityType",
",",
"String",
"connectingEntityId",
",",
"String",
"connectionType",
",",
"String",
"connectedEntityId",
")",
"{",
"return",
"apiRequest",
"(",
"HttpMethod",
".",
"POST",
",",
"null",
... | Connect two entities together.
@param connectingEntityType
@param connectingEntityId
@param connectionType
@param connectedEntityId
@return | [
"Connect",
"two",
"entities",
"together",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L954-L960 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.disconnectEntities | public ApiResponse disconnectEntities(String connectingEntityType,
String connectingEntityId, String connectionType,
String connectedEntityId) {
return apiRequest(HttpMethod.DELETE, null, null, organizationId, applicationId,
connectingEntityType, connectingEntityId, connectionType,
connectedEntityId);
} | java | public ApiResponse disconnectEntities(String connectingEntityType,
String connectingEntityId, String connectionType,
String connectedEntityId) {
return apiRequest(HttpMethod.DELETE, null, null, organizationId, applicationId,
connectingEntityType, connectingEntityId, connectionType,
connectedEntityId);
} | [
"public",
"ApiResponse",
"disconnectEntities",
"(",
"String",
"connectingEntityType",
",",
"String",
"connectingEntityId",
",",
"String",
"connectionType",
",",
"String",
"connectedEntityId",
")",
"{",
"return",
"apiRequest",
"(",
"HttpMethod",
".",
"DELETE",
",",
"nu... | Disconnect two entities.
@param connectingEntityType
@param connectingEntityId
@param connectionType
@param connectedEntityId
@return | [
"Disconnect",
"two",
"entities",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L971-L977 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.queryEntityConnections | public Query queryEntityConnections(String connectingEntityType,
String connectingEntityId, String connectionType, String ql) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("ql", ql);
Query q = queryEntitiesRequest(HttpMethod.GET, params, null,
organizationId, applicationId, connectingEntityType, connectingEntityId,
connectionType);
return q;
} | java | public Query queryEntityConnections(String connectingEntityType,
String connectingEntityId, String connectionType, String ql) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("ql", ql);
Query q = queryEntitiesRequest(HttpMethod.GET, params, null,
organizationId, applicationId, connectingEntityType, connectingEntityId,
connectionType);
return q;
} | [
"public",
"Query",
"queryEntityConnections",
"(",
"String",
"connectingEntityType",
",",
"String",
"connectingEntityId",
",",
"String",
"connectionType",
",",
"String",
"ql",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"params",
"=",
"new",
"HashMap",
"<... | Query the connected entities.
@param connectingEntityType
@param connectingEntityId
@param connectionType
@param ql
@return | [
"Query",
"the",
"connected",
"entities",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L988-L996 | train |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.queryEntityConnectionsWithinLocation | public Query queryEntityConnectionsWithinLocation(
String connectingEntityType, String connectingEntityId,
String connectionType, float distance, float lattitude,
float longitude, String ql) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("ql", makeLocationQL(distance, lattitude, longitude, ql));
Query q = queryEntitiesRequest(HttpMethod.GET, params, null, organizationId,
applicationId, connectingEntityType, connectingEntityId,
connectionType);
return q;
} | java | public Query queryEntityConnectionsWithinLocation(
String connectingEntityType, String connectingEntityId,
String connectionType, float distance, float lattitude,
float longitude, String ql) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("ql", makeLocationQL(distance, lattitude, longitude, ql));
Query q = queryEntitiesRequest(HttpMethod.GET, params, null, organizationId,
applicationId, connectingEntityType, connectingEntityId,
connectionType);
return q;
} | [
"public",
"Query",
"queryEntityConnectionsWithinLocation",
"(",
"String",
"connectingEntityType",
",",
"String",
"connectingEntityId",
",",
"String",
"connectionType",
",",
"float",
"distance",
",",
"float",
"lattitude",
",",
"float",
"longitude",
",",
"String",
"ql",
... | Query the connected entities within distance of a specific point.
@param connectingEntityType
@param connectingEntityId
@param connectionType
@param distance
@param latitude
@param longitude
@return | [
"Query",
"the",
"connected",
"entities",
"within",
"distance",
"of",
"a",
"specific",
"point",
"."
] | 6202745f184754defff13962dfc3d830bc7d8c63 | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L1017-L1027 | train |
revelytix/spark | spark-spi/src/main/java/spark/spi/Conversions.java | Conversions.toData | public static Object toData(Literal lit) {
if (lit == null) throw new IllegalArgumentException("Can't convert null literal");
if (lit instanceof TypedLiteral) return toData((TypedLiteral)lit);
// Untyped literals are xsd:string
// Note this isn't strictly correct; language tags will be lost here.
return lit.getLexical();
} | java | public static Object toData(Literal lit) {
if (lit == null) throw new IllegalArgumentException("Can't convert null literal");
if (lit instanceof TypedLiteral) return toData((TypedLiteral)lit);
// Untyped literals are xsd:string
// Note this isn't strictly correct; language tags will be lost here.
return lit.getLexical();
} | [
"public",
"static",
"Object",
"toData",
"(",
"Literal",
"lit",
")",
"{",
"if",
"(",
"lit",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can't convert null literal\"",
")",
";",
"if",
"(",
"lit",
"instanceof",
"TypedLiteral",
")",
"ret... | Convert from RDF literal to native Java object.
@param lit RDF literal.
@return Java object converted from the literal. | [
"Convert",
"from",
"RDF",
"literal",
"to",
"native",
"Java",
"object",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-spi/src/main/java/spark/spi/Conversions.java#L270-L276 | train |
revelytix/spark | spark-spi/src/main/java/spark/spi/Conversions.java | Conversions.toData | public static Object toData(TypedLiteral lit) {
if (lit == null) throw new IllegalArgumentException("Can't convert null literal");
Conversion<?> c = uriConversions.get(lit.getDataType());
if (c == null) throw new IllegalArgumentException("Don't know how to convert literal of type " + lit.getDataType());
return c.data(lit.getLexical());
} | java | public static Object toData(TypedLiteral lit) {
if (lit == null) throw new IllegalArgumentException("Can't convert null literal");
Conversion<?> c = uriConversions.get(lit.getDataType());
if (c == null) throw new IllegalArgumentException("Don't know how to convert literal of type " + lit.getDataType());
return c.data(lit.getLexical());
} | [
"public",
"static",
"Object",
"toData",
"(",
"TypedLiteral",
"lit",
")",
"{",
"if",
"(",
"lit",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can't convert null literal\"",
")",
";",
"Conversion",
"<",
"?",
">",
"c",
"=",
"uriConversio... | Convert from RDF typed literal to native Java object.
@param lit RDF typed literal
@return Java object converted from the lexical value based on the mappings specified by the literal datatype URI. | [
"Convert",
"from",
"RDF",
"typed",
"literal",
"to",
"native",
"Java",
"object",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-spi/src/main/java/spark/spi/Conversions.java#L283-L288 | train |
revelytix/spark | spark-spi/src/main/java/spark/spi/Conversions.java | Conversions.toLiteral | public static TypedLiteral toLiteral(Object value) {
if (value == null) throw new IllegalArgumentException("Can't convert null value");
Conversion<?> c = classConversions.get(value.getClass());
if (c != null) return c.literal(value);
// The object has an unrecognized type that doesn't translate directly to XSD.
// Omitting the datatype would imply a type of xsd:string, so use xsd:anySimpleType instead.
// The use of xsd:anySimpleType prevents round-tripping; in the future we could possibly
// serialize this as a byte array and use xsd:hexBinary or xsd:base64Binary.
return new TypedLiteralImpl(value.toString(), XsdTypes.ANY_SIMPLE_TYPE);
} | java | public static TypedLiteral toLiteral(Object value) {
if (value == null) throw new IllegalArgumentException("Can't convert null value");
Conversion<?> c = classConversions.get(value.getClass());
if (c != null) return c.literal(value);
// The object has an unrecognized type that doesn't translate directly to XSD.
// Omitting the datatype would imply a type of xsd:string, so use xsd:anySimpleType instead.
// The use of xsd:anySimpleType prevents round-tripping; in the future we could possibly
// serialize this as a byte array and use xsd:hexBinary or xsd:base64Binary.
return new TypedLiteralImpl(value.toString(), XsdTypes.ANY_SIMPLE_TYPE);
} | [
"public",
"static",
"TypedLiteral",
"toLiteral",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can't convert null value\"",
")",
";",
"Conversion",
"<",
"?",
">",
"c",
"=",
"classCo... | Convert from an arbitrary Java object to an RDF typed literal, using an XSD datatype if possible.
@param value Object value
@return Converted literal | [
"Convert",
"from",
"an",
"arbitrary",
"Java",
"object",
"to",
"an",
"RDF",
"typed",
"literal",
"using",
"an",
"XSD",
"datatype",
"if",
"possible",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-spi/src/main/java/spark/spi/Conversions.java#L358-L367 | train |
revelytix/spark | spark-http-client/src/main/java/spark/protocol/parser/XMLSelectResults.java | XMLSelectResults.readNext | protected Map<String,RDFNode> readNext() throws SparqlException {
try {
// read <result> or </results>
int eventType = reader.nextTag();
// if a closing element, then it should be </results>
if (eventType == END_ELEMENT) {
// already read the final result, so clean up and return nothing
if (nameIs(RESULTS)) {
cleanup();
return null;
}
else throw new SparqlException("Bad element closure with: " + reader.getLocalName());
}
// we only expect a <result> here
testOpen(eventType, RESULT, "Expected a new result. Got :" +
((eventType == END_ELEMENT) ? "/" : "") + reader.getLocalName());
Map<String,RDFNode> result = new HashMap<String,RDFNode>();
// read <binding> list
while ((eventType = reader.nextTag()) == START_ELEMENT && nameIs(BINDING)) {
// get the name of the binding
String name = reader.getAttributeValue(null, VAR_NAME);
result.put(name, parseValue());
testClose(reader.nextTag(), BINDING, "Single Binding not closed correctly");
}
// a non- <binding> was read, so it should have been a </result>
testClose(eventType, RESULT, "Single Result not closed correctly");
return result;
} catch (XMLStreamException e) {
throw new SparqlException("Error reading from XML stream", e);
}
} | java | protected Map<String,RDFNode> readNext() throws SparqlException {
try {
// read <result> or </results>
int eventType = reader.nextTag();
// if a closing element, then it should be </results>
if (eventType == END_ELEMENT) {
// already read the final result, so clean up and return nothing
if (nameIs(RESULTS)) {
cleanup();
return null;
}
else throw new SparqlException("Bad element closure with: " + reader.getLocalName());
}
// we only expect a <result> here
testOpen(eventType, RESULT, "Expected a new result. Got :" +
((eventType == END_ELEMENT) ? "/" : "") + reader.getLocalName());
Map<String,RDFNode> result = new HashMap<String,RDFNode>();
// read <binding> list
while ((eventType = reader.nextTag()) == START_ELEMENT && nameIs(BINDING)) {
// get the name of the binding
String name = reader.getAttributeValue(null, VAR_NAME);
result.put(name, parseValue());
testClose(reader.nextTag(), BINDING, "Single Binding not closed correctly");
}
// a non- <binding> was read, so it should have been a </result>
testClose(eventType, RESULT, "Single Result not closed correctly");
return result;
} catch (XMLStreamException e) {
throw new SparqlException("Error reading from XML stream", e);
}
} | [
"protected",
"Map",
"<",
"String",
",",
"RDFNode",
">",
"readNext",
"(",
")",
"throws",
"SparqlException",
"{",
"try",
"{",
"// read <result> or </results>",
"int",
"eventType",
"=",
"reader",
".",
"nextTag",
"(",
")",
";",
"// if a closing element, then it should b... | Parse the input stream to look for a result.
@return A new Row based on a single result from the results section.
@throws XMLStreamException There was an error reading the XML stream.
@throws SparqlException The XML was not valid SPARQL results. | [
"Parse",
"the",
"input",
"stream",
"to",
"look",
"for",
"a",
"result",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/parser/XMLSelectResults.java#L133-L165 | train |
revelytix/spark | spark-spi/src/main/java/spark/spi/util/DateTime.java | DateTime.append | private static void append(StringBuilder sb, int val, int width) {
String s = Integer.toString(val);
for (int i = s.length(); i < width; i++) sb.append('0');
sb.append(s);
} | java | private static void append(StringBuilder sb, int val, int width) {
String s = Integer.toString(val);
for (int i = s.length(); i < width; i++) sb.append('0');
sb.append(s);
} | [
"private",
"static",
"void",
"append",
"(",
"StringBuilder",
"sb",
",",
"int",
"val",
",",
"int",
"width",
")",
"{",
"String",
"s",
"=",
"Integer",
".",
"toString",
"(",
"val",
")",
";",
"for",
"(",
"int",
"i",
"=",
"s",
".",
"length",
"(",
")",
... | Append the given value to the string builder, with leading zeros to result in the given minimum width. | [
"Append",
"the",
"given",
"value",
"to",
"the",
"string",
"builder",
"with",
"leading",
"zeros",
"to",
"result",
"in",
"the",
"given",
"minimum",
"width",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-spi/src/main/java/spark/spi/util/DateTime.java#L231-L235 | train |
revelytix/spark | spark-spi/src/main/java/spark/spi/util/DateTime.java | DateTime.elapsedDays | private static long elapsedDays(int year) {
int y = year - 1;
return DAYS_IN_YEAR * (long)y + div(y, 400) - div(y, 100) + div(y, 4);
} | java | private static long elapsedDays(int year) {
int y = year - 1;
return DAYS_IN_YEAR * (long)y + div(y, 400) - div(y, 100) + div(y, 4);
} | [
"private",
"static",
"long",
"elapsedDays",
"(",
"int",
"year",
")",
"{",
"int",
"y",
"=",
"year",
"-",
"1",
";",
"return",
"DAYS_IN_YEAR",
"*",
"(",
"long",
")",
"y",
"+",
"div",
"(",
"y",
",",
"400",
")",
"-",
"div",
"(",
"y",
",",
"100",
")"... | Find the number of elapsed days from the epoch to the beginning of the given year. | [
"Find",
"the",
"number",
"of",
"elapsed",
"days",
"from",
"the",
"epoch",
"to",
"the",
"beginning",
"of",
"the",
"given",
"year",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-spi/src/main/java/spark/spi/util/DateTime.java#L324-L327 | train |
revelytix/spark | spark-spi/src/main/java/spark/spi/util/DateTime.java | DateTime.daysInMonth | private static int daysInMonth(int year, int month) {
assert month >= FIRST_MONTH && month <= LAST_MONTH;
int d = DAYS_IN_MONTH[month - 1];
if (month == FEBRUARY && isLeapYear(year)) d++;
return d;
} | java | private static int daysInMonth(int year, int month) {
assert month >= FIRST_MONTH && month <= LAST_MONTH;
int d = DAYS_IN_MONTH[month - 1];
if (month == FEBRUARY && isLeapYear(year)) d++;
return d;
} | [
"private",
"static",
"int",
"daysInMonth",
"(",
"int",
"year",
",",
"int",
"month",
")",
"{",
"assert",
"month",
">=",
"FIRST_MONTH",
"&&",
"month",
"<=",
"LAST_MONTH",
";",
"int",
"d",
"=",
"DAYS_IN_MONTH",
"[",
"month",
"-",
"1",
"]",
";",
"if",
"(",... | Find the number of days in the given month, given the year. | [
"Find",
"the",
"number",
"of",
"days",
"in",
"the",
"given",
"month",
"given",
"the",
"year",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-spi/src/main/java/spark/spi/util/DateTime.java#L341-L346 | train |
revelytix/spark | spark-spi/src/main/java/spark/spi/util/DateTime.java | DateTime.parseMillis | private static int parseMillis(Input s) {
if (s.index < s.len && s.getChar() == '.') {
int startIndex = ++s.index;
int ms = parseInt(s);
int len = s.index - startIndex;
for (; len < 3; len++) ms *= 10;
for (; len > 3; len--) ms /= 10; // truncate because it's easier than rounding.
return ms;
}
return 0;
} | java | private static int parseMillis(Input s) {
if (s.index < s.len && s.getChar() == '.') {
int startIndex = ++s.index;
int ms = parseInt(s);
int len = s.index - startIndex;
for (; len < 3; len++) ms *= 10;
for (; len > 3; len--) ms /= 10; // truncate because it's easier than rounding.
return ms;
}
return 0;
} | [
"private",
"static",
"int",
"parseMillis",
"(",
"Input",
"s",
")",
"{",
"if",
"(",
"s",
".",
"index",
"<",
"s",
".",
"len",
"&&",
"s",
".",
"getChar",
"(",
")",
"==",
"'",
"'",
")",
"{",
"int",
"startIndex",
"=",
"++",
"s",
".",
"index",
";",
... | Parse the fractional seconds field from the input, returning the number of milliseconds and truncating extra places. | [
"Parse",
"the",
"fractional",
"seconds",
"field",
"from",
"the",
"input",
"returning",
"the",
"number",
"of",
"milliseconds",
"and",
"truncating",
"extra",
"places",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-spi/src/main/java/spark/spi/util/DateTime.java#L359-L369 | train |
revelytix/spark | spark-spi/src/main/java/spark/spi/util/DateTime.java | DateTime.parseTzOffsetMs | private static Integer parseTzOffsetMs(Input s, boolean strict) {
if (s.index < s.len) {
char c = s.getChar();
s.index++;
int sign;
if (c == 'Z') {
return 0;
} else if (c == '+') {
sign = 1;
} else if (c == '-') {
sign = -1;
} else {
throw new DateFormatException("unexpected character, expected one of [Z+-]", s.str, s.index - 1);
}
int tzHours = parseField("timezone hours", s, TIME_SEP, 2, 2, strict);
if (strict && tzHours > 14) throw new DateFormatException("timezone offset hours out of range [0..14]", s.str, s.index - 2);
int tzMin = parseField("timezone minutes", s, null, 2, 2, strict);
if (strict && tzMin > 59) throw new DateFormatException("timezone offset hours out of range [0..59]", s.str, s.index - 1);
if (strict && tzHours == 14 && tzMin > 0) throw new DateFormatException("timezone offset may not be greater than 14 hours", s.str, s.index - 1);
return sign * (tzHours * MINS_IN_HOUR + tzMin) * MS_IN_MIN;
}
// Reached the end of input with no timezone specified.
return null;
} | java | private static Integer parseTzOffsetMs(Input s, boolean strict) {
if (s.index < s.len) {
char c = s.getChar();
s.index++;
int sign;
if (c == 'Z') {
return 0;
} else if (c == '+') {
sign = 1;
} else if (c == '-') {
sign = -1;
} else {
throw new DateFormatException("unexpected character, expected one of [Z+-]", s.str, s.index - 1);
}
int tzHours = parseField("timezone hours", s, TIME_SEP, 2, 2, strict);
if (strict && tzHours > 14) throw new DateFormatException("timezone offset hours out of range [0..14]", s.str, s.index - 2);
int tzMin = parseField("timezone minutes", s, null, 2, 2, strict);
if (strict && tzMin > 59) throw new DateFormatException("timezone offset hours out of range [0..59]", s.str, s.index - 1);
if (strict && tzHours == 14 && tzMin > 0) throw new DateFormatException("timezone offset may not be greater than 14 hours", s.str, s.index - 1);
return sign * (tzHours * MINS_IN_HOUR + tzMin) * MS_IN_MIN;
}
// Reached the end of input with no timezone specified.
return null;
} | [
"private",
"static",
"Integer",
"parseTzOffsetMs",
"(",
"Input",
"s",
",",
"boolean",
"strict",
")",
"{",
"if",
"(",
"s",
".",
"index",
"<",
"s",
".",
"len",
")",
"{",
"char",
"c",
"=",
"s",
".",
"getChar",
"(",
")",
";",
"s",
".",
"index",
"++",... | Parse the timezone offset from the input, returning its millisecond value. | [
"Parse",
"the",
"timezone",
"offset",
"from",
"the",
"input",
"returning",
"its",
"millisecond",
"value",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-spi/src/main/java/spark/spi/util/DateTime.java#L372-L397 | train |
revelytix/spark | spark-spi/src/main/java/spark/spi/util/DateTime.java | DateTime.parseField | private static int parseField(String field, Input s, Character delim, int minLen, int maxLen, boolean strict) {
int startIndex = s.index;
int result = parseInt(s);
if (startIndex == s.index) throw new DateFormatException("missing value for field '" + field + "'", s.str, startIndex);
if (strict) {
int len = s.index - startIndex;
if (len < minLen) throw new DateFormatException("field '" + field + "' must be at least " + minLen + " digits wide", s.str, startIndex);
if (maxLen > 0 && len > maxLen) throw new DateFormatException("field '" + field + "' must be no more than " + minLen + " digits wide", s.str, startIndex);
}
if (delim != null) {
if (s.index >= s.len) throw new DateFormatException("unexpected end of input", s.str, s.index);
if (strict && s.getChar() != delim.charValue()) throw new DateFormatException("unexpected character, expected '" + delim + "'", s.str, s.index);
s.index++;
}
return result;
} | java | private static int parseField(String field, Input s, Character delim, int minLen, int maxLen, boolean strict) {
int startIndex = s.index;
int result = parseInt(s);
if (startIndex == s.index) throw new DateFormatException("missing value for field '" + field + "'", s.str, startIndex);
if (strict) {
int len = s.index - startIndex;
if (len < minLen) throw new DateFormatException("field '" + field + "' must be at least " + minLen + " digits wide", s.str, startIndex);
if (maxLen > 0 && len > maxLen) throw new DateFormatException("field '" + field + "' must be no more than " + minLen + " digits wide", s.str, startIndex);
}
if (delim != null) {
if (s.index >= s.len) throw new DateFormatException("unexpected end of input", s.str, s.index);
if (strict && s.getChar() != delim.charValue()) throw new DateFormatException("unexpected character, expected '" + delim + "'", s.str, s.index);
s.index++;
}
return result;
} | [
"private",
"static",
"int",
"parseField",
"(",
"String",
"field",
",",
"Input",
"s",
",",
"Character",
"delim",
",",
"int",
"minLen",
",",
"int",
"maxLen",
",",
"boolean",
"strict",
")",
"{",
"int",
"startIndex",
"=",
"s",
".",
"index",
";",
"int",
"re... | Parse a field from input, validating its delimiter and length if requested. | [
"Parse",
"a",
"field",
"from",
"input",
"validating",
"its",
"delimiter",
"and",
"length",
"if",
"requested",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-spi/src/main/java/spark/spi/util/DateTime.java#L400-L415 | train |
revelytix/spark | spark-spi/src/main/java/spark/spi/util/DateTime.java | DateTime.parseInt | private static int parseInt(Input s) {
if (s.index >= s.len) throw new DateFormatException("unexpected end of input", s.str, s.index);
int result = 0;
while (s.index < s.len) {
char c = s.getChar();
if (c >= '0' && c <= '9') {
if (result >= Integer.MAX_VALUE / 10) throw new ArithmeticException("Field too large.");
result = result * 10 + ((int)c - (int)'0');
s.index++;
} else {
break;
}
}
return result;
} | java | private static int parseInt(Input s) {
if (s.index >= s.len) throw new DateFormatException("unexpected end of input", s.str, s.index);
int result = 0;
while (s.index < s.len) {
char c = s.getChar();
if (c >= '0' && c <= '9') {
if (result >= Integer.MAX_VALUE / 10) throw new ArithmeticException("Field too large.");
result = result * 10 + ((int)c - (int)'0');
s.index++;
} else {
break;
}
}
return result;
} | [
"private",
"static",
"int",
"parseInt",
"(",
"Input",
"s",
")",
"{",
"if",
"(",
"s",
".",
"index",
">=",
"s",
".",
"len",
")",
"throw",
"new",
"DateFormatException",
"(",
"\"unexpected end of input\"",
",",
"s",
".",
"str",
",",
"s",
".",
"index",
")",... | Parse an integer from the input, reading up to the first non-numeric character. | [
"Parse",
"an",
"integer",
"from",
"the",
"input",
"reading",
"up",
"to",
"the",
"first",
"non",
"-",
"numeric",
"character",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-spi/src/main/java/spark/spi/util/DateTime.java#L418-L432 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/AppUtil.java | AppUtil.showAppInfo | public static void showAppInfo(@NonNull final Context context,
@NonNull final String packageName) {
Condition.INSTANCE.ensureNotNull(context, "The context may not be null");
Condition.INSTANCE.ensureNotNull(packageName, "The package name may not be null");
Condition.INSTANCE.ensureNotEmpty(packageName, "The package name may not be empty");
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", packageName, null);
intent.setData(uri);
if (intent.resolveActivity(context.getPackageManager()) == null) {
throw new ActivityNotFoundException(
"App info for package " + packageName + " not available");
}
context.startActivity(intent);
} | java | public static void showAppInfo(@NonNull final Context context,
@NonNull final String packageName) {
Condition.INSTANCE.ensureNotNull(context, "The context may not be null");
Condition.INSTANCE.ensureNotNull(packageName, "The package name may not be null");
Condition.INSTANCE.ensureNotEmpty(packageName, "The package name may not be empty");
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", packageName, null);
intent.setData(uri);
if (intent.resolveActivity(context.getPackageManager()) == null) {
throw new ActivityNotFoundException(
"App info for package " + packageName + " not available");
}
context.startActivity(intent);
} | [
"public",
"static",
"void",
"showAppInfo",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"NonNull",
"final",
"String",
"packageName",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"context",
",",
"\"The context may not be null\... | Starts the settings app in order to show the information about a specific app.
@param context
The context, the settings app should be started from, as an instance of the class
{@link Context}. The context may not be null
@param packageName
The fully qualified package name of the app, whose information should be shown, as a
{@link String}. The package name may neither be null, nor empty | [
"Starts",
"the",
"settings",
"app",
"in",
"order",
"to",
"show",
"the",
"information",
"about",
"a",
"specific",
"app",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/AppUtil.java#L451-L467 | train |
GenesysPureEngage/provisioning-client-java | src/main/java/com/genesys/internal/provisioning/api/ObjectsApi.java | ObjectsApi.postPermissionsWithHttpInfo | public ApiResponse<Void> postPermissionsWithHttpInfo(String objectType, PostPermissionsData body) throws ApiException {
com.squareup.okhttp.Call call = postPermissionsValidateBeforeCall(objectType, body, null, null);
return apiClient.execute(call);
} | java | public ApiResponse<Void> postPermissionsWithHttpInfo(String objectType, PostPermissionsData body) throws ApiException {
com.squareup.okhttp.Call call = postPermissionsValidateBeforeCall(objectType, body, null, null);
return apiClient.execute(call);
} | [
"public",
"ApiResponse",
"<",
"Void",
">",
"postPermissionsWithHttpInfo",
"(",
"String",
"objectType",
",",
"PostPermissionsData",
"body",
")",
"throws",
"ApiException",
"{",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"call",
"=",
"postPermissionsValidateBe... | Post permissions for a list of objects.
Post permissions from Configuration Server for objects identified by their type and DBIDs.
@param objectType (required)
@param body (optional)
@return ApiResponse<Void>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Post",
"permissions",
"for",
"a",
"list",
"of",
"objects",
".",
"Post",
"permissions",
"from",
"Configuration",
"Server",
"for",
"objects",
"identified",
"by",
"their",
"type",
"and",
"DBIDs",
"."
] | 1ad594c3767cec83052168e350994f922a26f75e | https://github.com/GenesysPureEngage/provisioning-client-java/blob/1ad594c3767cec83052168e350994f922a26f75e/src/main/java/com/genesys/internal/provisioning/api/ObjectsApi.java#L491-L494 | train |
greenjoe/sergeants | src/main/java/pl/joegreen/sergeants/simulator/GameMap.java | GameMap.move | Optional<PlayerKilled> move(Player player) {
Move move = player.getMoves().poll();
if (move != null) {
Tile from = tiles[move.getFrom()];
boolean armyBigEnough = from.getArmySize() > 1;
boolean tileAndPlayerMatching = from.isOwnedBy(player.getPlayerIndex());
boolean oneStepAway = Stream.of(getTileAbove(from), getTileBelow(from), getTileLeftOf(from), getTileRightOf(from))
.filter(Optional::isPresent).map(Optional::get)
.map(Tile::getTileIndex)
.anyMatch(neighbourIndex -> neighbourIndex == move.getTo());
if (armyBigEnough && tileAndPlayerMatching && oneStepAway) {
int armySize = from.moveFrom(move.half());
return tiles[move.getTo()]
.moveTo(armySize, from.getOwnerPlayerIndex().get(), tiles)
.map(this::transfer);
} else {
return move(player);
}
}
return Optional.empty();
} | java | Optional<PlayerKilled> move(Player player) {
Move move = player.getMoves().poll();
if (move != null) {
Tile from = tiles[move.getFrom()];
boolean armyBigEnough = from.getArmySize() > 1;
boolean tileAndPlayerMatching = from.isOwnedBy(player.getPlayerIndex());
boolean oneStepAway = Stream.of(getTileAbove(from), getTileBelow(from), getTileLeftOf(from), getTileRightOf(from))
.filter(Optional::isPresent).map(Optional::get)
.map(Tile::getTileIndex)
.anyMatch(neighbourIndex -> neighbourIndex == move.getTo());
if (armyBigEnough && tileAndPlayerMatching && oneStepAway) {
int armySize = from.moveFrom(move.half());
return tiles[move.getTo()]
.moveTo(armySize, from.getOwnerPlayerIndex().get(), tiles)
.map(this::transfer);
} else {
return move(player);
}
}
return Optional.empty();
} | [
"Optional",
"<",
"PlayerKilled",
">",
"move",
"(",
"Player",
"player",
")",
"{",
"Move",
"move",
"=",
"player",
".",
"getMoves",
"(",
")",
".",
"poll",
"(",
")",
";",
"if",
"(",
"move",
"!=",
"null",
")",
"{",
"Tile",
"from",
"=",
"tiles",
"[",
"... | Polls move recursively until it finds a valid move. | [
"Polls",
"move",
"recursively",
"until",
"it",
"finds",
"a",
"valid",
"move",
"."
] | db624bcea8597843210f138b82bc4a26b3ec92ca | https://github.com/greenjoe/sergeants/blob/db624bcea8597843210f138b82bc4a26b3ec92ca/src/main/java/pl/joegreen/sergeants/simulator/GameMap.java#L46-L66 | train |
greenjoe/sergeants | src/main/java/pl/joegreen/sergeants/framework/model/GameResult.java | GameResult.getPlayerNames | public List<String> getPlayerNames() {
return lastGameState.getPlayers().stream().map(Player::getUsername).collect(Collectors.toList());
} | java | public List<String> getPlayerNames() {
return lastGameState.getPlayers().stream().map(Player::getUsername).collect(Collectors.toList());
} | [
"public",
"List",
"<",
"String",
">",
"getPlayerNames",
"(",
")",
"{",
"return",
"lastGameState",
".",
"getPlayers",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"Player",
"::",
"getUsername",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",... | Names of all players that played in the game. | [
"Names",
"of",
"all",
"players",
"that",
"played",
"in",
"the",
"game",
"."
] | db624bcea8597843210f138b82bc4a26b3ec92ca | https://github.com/greenjoe/sergeants/blob/db624bcea8597843210f138b82bc4a26b3ec92ca/src/main/java/pl/joegreen/sergeants/framework/model/GameResult.java#L30-L32 | train |
Zappos/zappos-json | src/main/java/com/zappos/json/util/Reflections.java | Reflections.getField | public static Field getField(Class<?> clazz, String fieldName)
throws NoSuchFieldException {
if (clazz == Object.class) {
return null;
}
try {
Field field = clazz.getDeclaredField(fieldName);
return field;
} catch (NoSuchFieldException e) {
return getField(clazz.getSuperclass(), fieldName);
}
} | java | public static Field getField(Class<?> clazz, String fieldName)
throws NoSuchFieldException {
if (clazz == Object.class) {
return null;
}
try {
Field field = clazz.getDeclaredField(fieldName);
return field;
} catch (NoSuchFieldException e) {
return getField(clazz.getSuperclass(), fieldName);
}
} | [
"public",
"static",
"Field",
"getField",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"fieldName",
")",
"throws",
"NoSuchFieldException",
"{",
"if",
"(",
"clazz",
"==",
"Object",
".",
"class",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"... | Recursively find the field by name up to the top of class hierarchy.
@param clazz the class object
@param fieldName declared field name of specified class
@return the field object | [
"Recursively",
"find",
"the",
"field",
"by",
"name",
"up",
"to",
"the",
"top",
"of",
"class",
"hierarchy",
"."
] | 340633f5db75c2e09ce49bfc3e5f67e8823f5a37 | https://github.com/Zappos/zappos-json/blob/340633f5db75c2e09ce49bfc3e5f67e8823f5a37/src/main/java/com/zappos/json/util/Reflections.java#L51-L62 | train |
GenesysPureEngage/provisioning-client-java | src/main/java/com/genesys/internal/provisioning/api/NotificationsApi.java | NotificationsApi.connectCall | public com.squareup.okhttp.Call connectCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/notifications/connect";
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
"application/json"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}
String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
} | java | public com.squareup.okhttp.Call connectCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/notifications/connect";
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
"application/json"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}
String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
} | [
"public",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"connectCall",
"(",
"final",
"ProgressResponseBody",
".",
"ProgressListener",
"progressListener",
",",
"final",
"ProgressRequestBody",
".",
"ProgressRequestListener",
"progressRequestListener",
")",
"throws",
... | Build call for connect
@param progressListener Progress listener
@param progressRequestListener Progress request listener
@return Call to execute
@throws ApiException If fail to serialize the request body object | [
"Build",
"call",
"for",
"connect"
] | 1ad594c3767cec83052168e350994f922a26f75e | https://github.com/GenesysPureEngage/provisioning-client-java/blob/1ad594c3767cec83052168e350994f922a26f75e/src/main/java/com/genesys/internal/provisioning/api/NotificationsApi.java#L63-L102 | train |
Jasig/spring-portlet-contrib | spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/filter/DelegatingPortletFilterProxy.java | DelegatingPortletFilterProxy.invokeDelegate | protected void invokeDelegate(
ActionFilter delegate, ActionRequest request, ActionResponse response, FilterChain filterChain)
throws PortletException, IOException {
delegate.doFilter(request, response, filterChain);
} | java | protected void invokeDelegate(
ActionFilter delegate, ActionRequest request, ActionResponse response, FilterChain filterChain)
throws PortletException, IOException {
delegate.doFilter(request, response, filterChain);
} | [
"protected",
"void",
"invokeDelegate",
"(",
"ActionFilter",
"delegate",
",",
"ActionRequest",
"request",
",",
"ActionResponse",
"response",
",",
"FilterChain",
"filterChain",
")",
"throws",
"PortletException",
",",
"IOException",
"{",
"delegate",
".",
"doFilter",
"(",... | Actually invoke the delegate ActionFilter with the given request and response.
@param delegate the delegate ActionFilter
@param request the current action request
@param response the current action response
@param filterChain the current FilterChain
@throws javax.portlet.PortletException if thrown by the PortletFilter
@throws java.io.IOException if thrown by the PortletFilter | [
"Actually",
"invoke",
"the",
"delegate",
"ActionFilter",
"with",
"the",
"given",
"request",
"and",
"response",
"."
] | 719240fa268ddc69900ce9775d9cad3b9c543c6b | https://github.com/Jasig/spring-portlet-contrib/blob/719240fa268ddc69900ce9775d9cad3b9c543c6b/spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/filter/DelegatingPortletFilterProxy.java#L435-L440 | train |
Jasig/spring-portlet-contrib | spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/filter/DelegatingPortletFilterProxy.java | DelegatingPortletFilterProxy.invokeDelegate | protected void invokeDelegate(
EventFilter delegate, EventRequest request, EventResponse response, FilterChain filterChain)
throws PortletException, IOException {
delegate.doFilter(request, response, filterChain);
} | java | protected void invokeDelegate(
EventFilter delegate, EventRequest request, EventResponse response, FilterChain filterChain)
throws PortletException, IOException {
delegate.doFilter(request, response, filterChain);
} | [
"protected",
"void",
"invokeDelegate",
"(",
"EventFilter",
"delegate",
",",
"EventRequest",
"request",
",",
"EventResponse",
"response",
",",
"FilterChain",
"filterChain",
")",
"throws",
"PortletException",
",",
"IOException",
"{",
"delegate",
".",
"doFilter",
"(",
... | Actually invoke the delegate EventFilter with the given request and response.
@param delegate the delegate EventFilter
@param request the current Event request
@param response the current Event response
@param filterChain the current FilterChain
@throws javax.portlet.PortletException if thrown by the PortletFilter
@throws java.io.IOException if thrown by the PortletFilter | [
"Actually",
"invoke",
"the",
"delegate",
"EventFilter",
"with",
"the",
"given",
"request",
"and",
"response",
"."
] | 719240fa268ddc69900ce9775d9cad3b9c543c6b | https://github.com/Jasig/spring-portlet-contrib/blob/719240fa268ddc69900ce9775d9cad3b9c543c6b/spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/filter/DelegatingPortletFilterProxy.java#L452-L457 | train |
Jasig/spring-portlet-contrib | spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/filter/DelegatingPortletFilterProxy.java | DelegatingPortletFilterProxy.invokeDelegate | protected void invokeDelegate(
RenderFilter delegate, RenderRequest request, RenderResponse response, FilterChain filterChain)
throws PortletException, IOException {
delegate.doFilter(request, response, filterChain);
} | java | protected void invokeDelegate(
RenderFilter delegate, RenderRequest request, RenderResponse response, FilterChain filterChain)
throws PortletException, IOException {
delegate.doFilter(request, response, filterChain);
} | [
"protected",
"void",
"invokeDelegate",
"(",
"RenderFilter",
"delegate",
",",
"RenderRequest",
"request",
",",
"RenderResponse",
"response",
",",
"FilterChain",
"filterChain",
")",
"throws",
"PortletException",
",",
"IOException",
"{",
"delegate",
".",
"doFilter",
"(",... | Actually invoke the delegate RenderFilter with the given request and response.
@param delegate the delegate RenderFilter
@param request the current Render request
@param response the current Render response
@param filterChain the current FilterChain
@throws javax.portlet.PortletException if thrown by the PortletFilter
@throws java.io.IOException if thrown by the PortletFilter | [
"Actually",
"invoke",
"the",
"delegate",
"RenderFilter",
"with",
"the",
"given",
"request",
"and",
"response",
"."
] | 719240fa268ddc69900ce9775d9cad3b9c543c6b | https://github.com/Jasig/spring-portlet-contrib/blob/719240fa268ddc69900ce9775d9cad3b9c543c6b/spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/filter/DelegatingPortletFilterProxy.java#L469-L474 | train |
Jasig/spring-portlet-contrib | spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/filter/DelegatingPortletFilterProxy.java | DelegatingPortletFilterProxy.invokeDelegate | protected void invokeDelegate(
ResourceFilter delegate, ResourceRequest request, ResourceResponse response, FilterChain filterChain)
throws PortletException, IOException {
delegate.doFilter(request, response, filterChain);
} | java | protected void invokeDelegate(
ResourceFilter delegate, ResourceRequest request, ResourceResponse response, FilterChain filterChain)
throws PortletException, IOException {
delegate.doFilter(request, response, filterChain);
} | [
"protected",
"void",
"invokeDelegate",
"(",
"ResourceFilter",
"delegate",
",",
"ResourceRequest",
"request",
",",
"ResourceResponse",
"response",
",",
"FilterChain",
"filterChain",
")",
"throws",
"PortletException",
",",
"IOException",
"{",
"delegate",
".",
"doFilter",
... | Actually invoke the delegate ResourceFilter with the given request and response.
@param delegate the delegate ResourceFilter
@param request the current Resource request
@param response the current Resource response
@param filterChain the current FilterChain
@throws javax.portlet.PortletException if thrown by the PortletFilter
@throws java.io.IOException if thrown by the PortletFilter | [
"Actually",
"invoke",
"the",
"delegate",
"ResourceFilter",
"with",
"the",
"given",
"request",
"and",
"response",
"."
] | 719240fa268ddc69900ce9775d9cad3b9c543c6b | https://github.com/Jasig/spring-portlet-contrib/blob/719240fa268ddc69900ce9775d9cad3b9c543c6b/spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/filter/DelegatingPortletFilterProxy.java#L486-L491 | train |
Jasig/spring-portlet-contrib | spring-security-portlet-contrib/src/main/java/org/jasig/springframework/security/portlet/authentication/PortletPreAuthenticatedAuthenticationDetailsSource.java | PortletPreAuthenticatedAuthenticationDetailsSource.buildDetails | public PreAuthenticatedGrantedAuthoritiesPortletAuthenticationDetails buildDetails(PortletRequest context) {
Collection<? extends GrantedAuthority> userGas = buildGrantedAuthorities(context);
PreAuthenticatedGrantedAuthoritiesPortletAuthenticationDetails result =
new PreAuthenticatedGrantedAuthoritiesPortletAuthenticationDetails(context, userGas);
return result;
} | java | public PreAuthenticatedGrantedAuthoritiesPortletAuthenticationDetails buildDetails(PortletRequest context) {
Collection<? extends GrantedAuthority> userGas = buildGrantedAuthorities(context);
PreAuthenticatedGrantedAuthoritiesPortletAuthenticationDetails result =
new PreAuthenticatedGrantedAuthoritiesPortletAuthenticationDetails(context, userGas);
return result;
} | [
"public",
"PreAuthenticatedGrantedAuthoritiesPortletAuthenticationDetails",
"buildDetails",
"(",
"PortletRequest",
"context",
")",
"{",
"Collection",
"<",
"?",
"extends",
"GrantedAuthority",
">",
"userGas",
"=",
"buildGrantedAuthorities",
"(",
"context",
")",
";",
"PreAuthe... | Builds the authentication details object.
@see org.springframework.security.authentication.AuthenticationDetailsSource#buildDetails(Object)
@param context a {@link javax.portlet.PortletRequest} object.
@return a {@link org.jasig.springframework.security.portlet.authentication.PreAuthenticatedGrantedAuthoritiesPortletAuthenticationDetails} object. | [
"Builds",
"the",
"authentication",
"details",
"object",
"."
] | 719240fa268ddc69900ce9775d9cad3b9c543c6b | https://github.com/Jasig/spring-portlet-contrib/blob/719240fa268ddc69900ce9775d9cad3b9c543c6b/spring-security-portlet-contrib/src/main/java/org/jasig/springframework/security/portlet/authentication/PortletPreAuthenticatedAuthenticationDetailsSource.java#L93-L101 | train |
venkatramanm/swf-all | swf-db/src/main/java/com/venky/swf/db/table/Table.java | Table._runDML | private boolean _runDML(DataManupulationStatement q, boolean isDDL){
boolean readOnly = ConnectionManager.instance().isPoolReadOnly(getPool());
Transaction txn = Database.getInstance().getCurrentTransaction();
if (!readOnly) {
q.executeUpdate();
if (Database.getJdbcTypeHelper(getPool()).isAutoCommitOnDDL()) {
txn.registerCommit();
}else {
txn.commit();
}
}else {
cat.fine("Pool " + getPool() +" Skipped running" + q.getRealSQL());
}
return !readOnly;
} | java | private boolean _runDML(DataManupulationStatement q, boolean isDDL){
boolean readOnly = ConnectionManager.instance().isPoolReadOnly(getPool());
Transaction txn = Database.getInstance().getCurrentTransaction();
if (!readOnly) {
q.executeUpdate();
if (Database.getJdbcTypeHelper(getPool()).isAutoCommitOnDDL()) {
txn.registerCommit();
}else {
txn.commit();
}
}else {
cat.fine("Pool " + getPool() +" Skipped running" + q.getRealSQL());
}
return !readOnly;
} | [
"private",
"boolean",
"_runDML",
"(",
"DataManupulationStatement",
"q",
",",
"boolean",
"isDDL",
")",
"{",
"boolean",
"readOnly",
"=",
"ConnectionManager",
".",
"instance",
"(",
")",
".",
"isPoolReadOnly",
"(",
"getPool",
"(",
")",
")",
";",
"Transaction",
"tx... | RReturn true if modification was done..
@param q
@param isDDL
@return | [
"RReturn",
"true",
"if",
"modification",
"was",
"done",
".."
] | e6ca342df0645bf1122d81e302575014ad565b69 | https://github.com/venkatramanm/swf-all/blob/e6ca342df0645bf1122d81e302575014ad565b69/swf-db/src/main/java/com/venky/swf/db/table/Table.java#L197-L212 | train |
Jasig/spring-portlet-contrib | spring-security-portlet-contrib/src/main/java/org/jasig/springframework/security/portlet/PortletFilterChainProxy.java | PortletFilterChainProxy.getFilters | private List<PortletFilter> getFilters(PortletRequest request) {
for (PortletSecurityFilterChain chain : filterChains) {
if (chain.matches(request)) {
return chain.getFilters();
}
}
return null;
} | java | private List<PortletFilter> getFilters(PortletRequest request) {
for (PortletSecurityFilterChain chain : filterChains) {
if (chain.matches(request)) {
return chain.getFilters();
}
}
return null;
} | [
"private",
"List",
"<",
"PortletFilter",
">",
"getFilters",
"(",
"PortletRequest",
"request",
")",
"{",
"for",
"(",
"PortletSecurityFilterChain",
"chain",
":",
"filterChains",
")",
"{",
"if",
"(",
"chain",
".",
"matches",
"(",
"request",
")",
")",
"{",
"retu... | Returns the first filter chain matching the supplied URL.
@param request the request to match
@return an ordered array of Filters defining the filter chain | [
"Returns",
"the",
"first",
"filter",
"chain",
"matching",
"the",
"supplied",
"URL",
"."
] | 719240fa268ddc69900ce9775d9cad3b9c543c6b | https://github.com/Jasig/spring-portlet-contrib/blob/719240fa268ddc69900ce9775d9cad3b9c543c6b/spring-security-portlet-contrib/src/main/java/org/jasig/springframework/security/portlet/PortletFilterChainProxy.java#L184-L192 | train |
Jasig/spring-portlet-contrib | spring-security-portlet-contrib/src/main/java/org/jasig/springframework/security/portlet/PortletFilterChainProxy.java | PortletFilterChainProxy.setFilterChainMap | @Deprecated
public void setFilterChainMap(Map<RequestMatcher, List<PortletFilter>> filterChainMap) {
filterChains = new ArrayList<PortletSecurityFilterChain>(filterChainMap.size());
for (Map.Entry<RequestMatcher,List<PortletFilter>> entry : filterChainMap.entrySet()) {
filterChains.add(new DefaultPortletSecurityFilterChain(entry.getKey(), entry.getValue()));
}
} | java | @Deprecated
public void setFilterChainMap(Map<RequestMatcher, List<PortletFilter>> filterChainMap) {
filterChains = new ArrayList<PortletSecurityFilterChain>(filterChainMap.size());
for (Map.Entry<RequestMatcher,List<PortletFilter>> entry : filterChainMap.entrySet()) {
filterChains.add(new DefaultPortletSecurityFilterChain(entry.getKey(), entry.getValue()));
}
} | [
"@",
"Deprecated",
"public",
"void",
"setFilterChainMap",
"(",
"Map",
"<",
"RequestMatcher",
",",
"List",
"<",
"PortletFilter",
">",
">",
"filterChainMap",
")",
"{",
"filterChains",
"=",
"new",
"ArrayList",
"<",
"PortletSecurityFilterChain",
">",
"(",
"filterChain... | Sets the mapping of URL patterns to filter chains.
The map keys should be the paths and the values should be arrays of {@code PortletFilter} objects.
It's VERY important that the type of map used preserves ordering - the order in which the iterator
returns the entries must be the same as the order they were added to the map, otherwise you have no way
of guaranteeing that the most specific patterns are returned before the more general ones. So make sure
the Map used is an instance of {@code LinkedHashMap} or an equivalent, rather than a plain {@code HashMap}, for
example.
@param filterChainMap the map of path Strings to {@code List<PortletFilter>}s.
@deprecated Use the constructor which takes a {@code List<PortletSecurityFilterChain>} instead. | [
"Sets",
"the",
"mapping",
"of",
"URL",
"patterns",
"to",
"filter",
"chains",
"."
] | 719240fa268ddc69900ce9775d9cad3b9c543c6b | https://github.com/Jasig/spring-portlet-contrib/blob/719240fa268ddc69900ce9775d9cad3b9c543c6b/spring-security-portlet-contrib/src/main/java/org/jasig/springframework/security/portlet/PortletFilterChainProxy.java#L207-L214 | train |
Jasig/spring-portlet-contrib | spring-security-portlet-contrib/src/main/java/org/jasig/springframework/security/portlet/PortletFilterChainProxy.java | PortletFilterChainProxy.getFilterChainMap | @Deprecated
public Map<RequestMatcher, List<PortletFilter>> getFilterChainMap() {
LinkedHashMap<RequestMatcher, List<PortletFilter>> map = new LinkedHashMap<RequestMatcher, List<PortletFilter>>();
for (PortletSecurityFilterChain chain : filterChains) {
map.put(((DefaultPortletSecurityFilterChain)chain).getRequestMatcher(), chain.getFilters());
}
return map;
} | java | @Deprecated
public Map<RequestMatcher, List<PortletFilter>> getFilterChainMap() {
LinkedHashMap<RequestMatcher, List<PortletFilter>> map = new LinkedHashMap<RequestMatcher, List<PortletFilter>>();
for (PortletSecurityFilterChain chain : filterChains) {
map.put(((DefaultPortletSecurityFilterChain)chain).getRequestMatcher(), chain.getFilters());
}
return map;
} | [
"@",
"Deprecated",
"public",
"Map",
"<",
"RequestMatcher",
",",
"List",
"<",
"PortletFilter",
">",
">",
"getFilterChainMap",
"(",
")",
"{",
"LinkedHashMap",
"<",
"RequestMatcher",
",",
"List",
"<",
"PortletFilter",
">",
">",
"map",
"=",
"new",
"LinkedHashMap",... | Returns a copy of the underlying filter chain map. Modifications to the map contents
will not affect the PortletFilterChainProxy state.
@return the map of path pattern Strings to filter chain lists (with ordering guaranteed).
@deprecated use the list of {@link org.jasig.springframework.security.portlet.PortletSecurityFilterChain}s instead | [
"Returns",
"a",
"copy",
"of",
"the",
"underlying",
"filter",
"chain",
"map",
".",
"Modifications",
"to",
"the",
"map",
"contents",
"will",
"not",
"affect",
"the",
"PortletFilterChainProxy",
"state",
"."
] | 719240fa268ddc69900ce9775d9cad3b9c543c6b | https://github.com/Jasig/spring-portlet-contrib/blob/719240fa268ddc69900ce9775d9cad3b9c543c6b/spring-security-portlet-contrib/src/main/java/org/jasig/springframework/security/portlet/PortletFilterChainProxy.java#L223-L232 | train |
aeshell/aesh-extensions | readline/src/main/java/org/aesh/extensions/manual/page/FileDisplayer.java | FileDisplayer.displaySearchLine | private void displaySearchLine(String line, String searchWord) throws IOException {
int start = line.indexOf(searchWord);
connection.write(line.substring(0,start));
connection.write(ANSI.INVERT_BACKGROUND);
connection.write(searchWord);
connection.write(ANSI.RESET);
connection.write(line.substring(start + searchWord.length(), line.length()));
} | java | private void displaySearchLine(String line, String searchWord) throws IOException {
int start = line.indexOf(searchWord);
connection.write(line.substring(0,start));
connection.write(ANSI.INVERT_BACKGROUND);
connection.write(searchWord);
connection.write(ANSI.RESET);
connection.write(line.substring(start + searchWord.length(), line.length()));
} | [
"private",
"void",
"displaySearchLine",
"(",
"String",
"line",
",",
"String",
"searchWord",
")",
"throws",
"IOException",
"{",
"int",
"start",
"=",
"line",
".",
"indexOf",
"(",
"searchWord",
")",
";",
"connection",
".",
"write",
"(",
"line",
".",
"substring"... | highlight the specific word thats found in the search | [
"highlight",
"the",
"specific",
"word",
"thats",
"found",
"in",
"the",
"search"
] | 3838ce46ed3771eb2ee6934303500f01a558e9ca | https://github.com/aeshell/aesh-extensions/blob/3838ce46ed3771eb2ee6934303500f01a558e9ca/readline/src/main/java/org/aesh/extensions/manual/page/FileDisplayer.java#L365-L372 | train |
Jasig/spring-portlet-contrib | spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/context/PortletApplicationContextUtils2.java | PortletApplicationContextUtils2.getPortletApplicationContext | public static PortletApplicationContext getPortletApplicationContext(PortletContext pc, String attrName) {
Assert.notNull(pc, "PortletContext must not be null");
Object attr = pc.getAttribute(attrName);
if (attr == null) {
return null;
}
if (attr instanceof RuntimeException) {
throw (RuntimeException) attr;
}
if (attr instanceof Error) {
throw (Error) attr;
}
if (attr instanceof Exception) {
throw new IllegalStateException((Exception) attr);
}
if (!(attr instanceof PortletApplicationContext)) {
throw new IllegalStateException("Context attribute is not of type PortletApplicationContext: " + attr.getClass() + " - " + attr);
}
return (PortletApplicationContext) attr;
} | java | public static PortletApplicationContext getPortletApplicationContext(PortletContext pc, String attrName) {
Assert.notNull(pc, "PortletContext must not be null");
Object attr = pc.getAttribute(attrName);
if (attr == null) {
return null;
}
if (attr instanceof RuntimeException) {
throw (RuntimeException) attr;
}
if (attr instanceof Error) {
throw (Error) attr;
}
if (attr instanceof Exception) {
throw new IllegalStateException((Exception) attr);
}
if (!(attr instanceof PortletApplicationContext)) {
throw new IllegalStateException("Context attribute is not of type PortletApplicationContext: " + attr.getClass() + " - " + attr);
}
return (PortletApplicationContext) attr;
} | [
"public",
"static",
"PortletApplicationContext",
"getPortletApplicationContext",
"(",
"PortletContext",
"pc",
",",
"String",
"attrName",
")",
"{",
"Assert",
".",
"notNull",
"(",
"pc",
",",
"\"PortletContext must not be null\"",
")",
";",
"Object",
"attr",
"=",
"pc",
... | Find a custom PortletApplicationContext for this web application.
@param pc PortletContext to find the web application context for
@param attrName the name of the PortletContext attribute to look for
@return the desired PortletApplicationContext for this web app, or <code>null</code> if none | [
"Find",
"a",
"custom",
"PortletApplicationContext",
"for",
"this",
"web",
"application",
"."
] | 719240fa268ddc69900ce9775d9cad3b9c543c6b | https://github.com/Jasig/spring-portlet-contrib/blob/719240fa268ddc69900ce9775d9cad3b9c543c6b/spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/context/PortletApplicationContextUtils2.java#L118-L137 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.