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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/maven/SurefireMojoInterceptor.java | SurefireMojoInterceptor.updateParallel | private static void updateParallel(Object mojo) throws Exception {
try {
String currentParallel = getStringField(PARALLEL_FIELD, mojo);
if (currentParallel != null) {
warn(mojo, "Ekstazi does not support parallel parameter. This parameter will be set to null for this run.");
setField(PARALLEL_FIELD, mojo, null);
}
} catch (NoSuchMethodException ex) {
// "parallel" was introduced in Surefire 2.2, so methods
// may not exist, but we do not fail because default is
// sequential execution.
}
} | java | private static void updateParallel(Object mojo) throws Exception {
try {
String currentParallel = getStringField(PARALLEL_FIELD, mojo);
if (currentParallel != null) {
warn(mojo, "Ekstazi does not support parallel parameter. This parameter will be set to null for this run.");
setField(PARALLEL_FIELD, mojo, null);
}
} catch (NoSuchMethodException ex) {
// "parallel" was introduced in Surefire 2.2, so methods
// may not exist, but we do not fail because default is
// sequential execution.
}
} | [
"private",
"static",
"void",
"updateParallel",
"(",
"Object",
"mojo",
")",
"throws",
"Exception",
"{",
"try",
"{",
"String",
"currentParallel",
"=",
"getStringField",
"(",
"PARALLEL_FIELD",
",",
"mojo",
")",
";",
"if",
"(",
"currentParallel",
"!=",
"null",
")"... | Sets parallel parameter to null if the parameter is different from null
and prints a warning.
This method is written in Shanghai'14. | [
"Sets",
"parallel",
"parameter",
"to",
"null",
"if",
"the",
"parameter",
"is",
"different",
"from",
"null",
"and",
"prints",
"a",
"warning",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/maven/SurefireMojoInterceptor.java#L182-L194 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/maven/SurefireMojoInterceptor.java | SurefireMojoInterceptor.isOneVMPerClass | private static boolean isOneVMPerClass(Object mojo) throws Exception {
// We already know that we fork process (checked in
// precondition). Threfore if we see reuseForks=false, we know
// that one class will be run in one VM.
try {
return !invokeAndGetBoolean(IS_REUSE_FORKS, mojo);
} catch (NoSuchMethodException ex) {
// Nothing: earlier versions (before 2.13) of surefire did
// not have reuseForks.
return false;
}
} | java | private static boolean isOneVMPerClass(Object mojo) throws Exception {
// We already know that we fork process (checked in
// precondition). Threfore if we see reuseForks=false, we know
// that one class will be run in one VM.
try {
return !invokeAndGetBoolean(IS_REUSE_FORKS, mojo);
} catch (NoSuchMethodException ex) {
// Nothing: earlier versions (before 2.13) of surefire did
// not have reuseForks.
return false;
}
} | [
"private",
"static",
"boolean",
"isOneVMPerClass",
"(",
"Object",
"mojo",
")",
"throws",
"Exception",
"{",
"// We already know that we fork process (checked in",
"// precondition). Threfore if we see reuseForks=false, we know",
"// that one class will be run in one VM.",
"try",
"{",
... | Returns true if one test class is executed in one VM.
@param mojo
Mojo
@return True if one test class is executed in one VM, false otherwise
@throws Exception
If value of the fields cannot be retrieved | [
"Returns",
"true",
"if",
"one",
"test",
"class",
"is",
"executed",
"in",
"one",
"VM",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/maven/SurefireMojoInterceptor.java#L205-L216 | train |
gdx-libs/gdx-kiwi | src/com/github/czyzby/kiwi/util/gdx/asset/lazy/provider/ArrayObjectProvider.java | ArrayObjectProvider.getProvider | public static <Type> ArrayObjectProvider<Type> getProvider(final Class<Type> arrayType) {
return new ArrayObjectProvider<Type>(arrayType);
} | java | public static <Type> ArrayObjectProvider<Type> getProvider(final Class<Type> arrayType) {
return new ArrayObjectProvider<Type>(arrayType);
} | [
"public",
"static",
"<",
"Type",
">",
"ArrayObjectProvider",
"<",
"Type",
">",
"getProvider",
"(",
"final",
"Class",
"<",
"Type",
">",
"arrayType",
")",
"{",
"return",
"new",
"ArrayObjectProvider",
"<",
"Type",
">",
"(",
"arrayType",
")",
";",
"}"
] | Produces typed arrays. | [
"Produces",
"typed",
"arrays",
"."
] | 0172ee7534162f33b939bcdc4de089bc9579dd62 | https://github.com/gdx-libs/gdx-kiwi/blob/0172ee7534162f33b939bcdc4de089bc9579dd62/src/com/github/czyzby/kiwi/util/gdx/asset/lazy/provider/ArrayObjectProvider.java#L37-L39 | train |
phax/ph-oton | ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5Request.java | FineUploader5Request.addCustomHeaders | @Nonnull
public FineUploader5Request addCustomHeaders (@Nullable final Map <String, String> aCustomHeaders)
{
m_aRequestCustomHeaders.addAll (aCustomHeaders);
return this;
} | java | @Nonnull
public FineUploader5Request addCustomHeaders (@Nullable final Map <String, String> aCustomHeaders)
{
m_aRequestCustomHeaders.addAll (aCustomHeaders);
return this;
} | [
"@",
"Nonnull",
"public",
"FineUploader5Request",
"addCustomHeaders",
"(",
"@",
"Nullable",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"aCustomHeaders",
")",
"{",
"m_aRequestCustomHeaders",
".",
"addAll",
"(",
"aCustomHeaders",
")",
";",
"return",
"this",
... | Additional headers sent along with each upload request.
@param aCustomHeaders
Custom headers to be added.
@return this | [
"Additional",
"headers",
"sent",
"along",
"with",
"each",
"upload",
"request",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5Request.java#L92-L97 | train |
phax/ph-oton | ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5Request.java | FineUploader5Request.setEndpoint | @Nonnull
public FineUploader5Request setEndpoint (@Nonnull final ISimpleURL aRequestEndpoint)
{
ValueEnforcer.notNull (aRequestEndpoint, "RequestEndpoint");
m_aRequestEndpoint = aRequestEndpoint;
return this;
} | java | @Nonnull
public FineUploader5Request setEndpoint (@Nonnull final ISimpleURL aRequestEndpoint)
{
ValueEnforcer.notNull (aRequestEndpoint, "RequestEndpoint");
m_aRequestEndpoint = aRequestEndpoint;
return this;
} | [
"@",
"Nonnull",
"public",
"FineUploader5Request",
"setEndpoint",
"(",
"@",
"Nonnull",
"final",
"ISimpleURL",
"aRequestEndpoint",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aRequestEndpoint",
",",
"\"RequestEndpoint\"",
")",
";",
"m_aRequestEndpoint",
"=",
"aRequ... | The endpoint to send upload requests to.
@param aRequestEndpoint
The new action URL. May not be <code>null</code>.
@return this | [
"The",
"endpoint",
"to",
"send",
"upload",
"requests",
"to",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5Request.java#L131-L137 | train |
phax/ph-oton | ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5Request.java | FineUploader5Request.setFilenameParam | @Nonnull
public FineUploader5Request setFilenameParam (@Nonnull @Nonempty final String sFilenameParam)
{
ValueEnforcer.notEmpty (sFilenameParam, "FilenameParam");
m_sRequestFilenameParam = sFilenameParam;
return this;
} | java | @Nonnull
public FineUploader5Request setFilenameParam (@Nonnull @Nonempty final String sFilenameParam)
{
ValueEnforcer.notEmpty (sFilenameParam, "FilenameParam");
m_sRequestFilenameParam = sFilenameParam;
return this;
} | [
"@",
"Nonnull",
"public",
"FineUploader5Request",
"setFilenameParam",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sFilenameParam",
")",
"{",
"ValueEnforcer",
".",
"notEmpty",
"(",
"sFilenameParam",
",",
"\"FilenameParam\"",
")",
";",
"m_sRequestFilenameP... | The name of the parameter passed if the original filename has been edited
or a Blob is being sent.
@param sFilenameParam
New value. May neither be <code>null</code> nor empty.
@return this | [
"The",
"name",
"of",
"the",
"parameter",
"passed",
"if",
"the",
"original",
"filename",
"has",
"been",
"edited",
"or",
"a",
"Blob",
"is",
"being",
"sent",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5Request.java#L153-L159 | train |
phax/ph-oton | ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5Request.java | FineUploader5Request.setUUIDName | @Nonnull
public FineUploader5Request setUUIDName (@Nonnull @Nonempty final String sUUIDName)
{
ValueEnforcer.notEmpty (sUUIDName, "UUIDName");
m_sRequestUUIDName = sUUIDName;
return this;
} | java | @Nonnull
public FineUploader5Request setUUIDName (@Nonnull @Nonempty final String sUUIDName)
{
ValueEnforcer.notEmpty (sUUIDName, "UUIDName");
m_sRequestUUIDName = sUUIDName;
return this;
} | [
"@",
"Nonnull",
"public",
"FineUploader5Request",
"setUUIDName",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sUUIDName",
")",
"{",
"ValueEnforcer",
".",
"notEmpty",
"(",
"sUUIDName",
",",
"\"UUIDName\"",
")",
";",
"m_sRequestUUIDName",
"=",
"sUUIDNam... | The name of the parameter the uniquely identifies each associated item. The
value is a Level 4 UUID.
@param sUUIDName
New value. May neither be <code>null</code> nor empty.
@return this | [
"The",
"name",
"of",
"the",
"parameter",
"the",
"uniquely",
"identifies",
"each",
"associated",
"item",
".",
"The",
"value",
"is",
"a",
"Level",
"4",
"UUID",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5Request.java#L316-L322 | train |
phax/ph-oton | ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5Request.java | FineUploader5Request.setTotalFileSizeName | @Nonnull
public FineUploader5Request setTotalFileSizeName (@Nonnull @Nonempty final String sTotalFileSizeName)
{
ValueEnforcer.notEmpty (sTotalFileSizeName, "TotalFileSizeName");
m_sRequestTotalFileSizeName = sTotalFileSizeName;
return this;
} | java | @Nonnull
public FineUploader5Request setTotalFileSizeName (@Nonnull @Nonempty final String sTotalFileSizeName)
{
ValueEnforcer.notEmpty (sTotalFileSizeName, "TotalFileSizeName");
m_sRequestTotalFileSizeName = sTotalFileSizeName;
return this;
} | [
"@",
"Nonnull",
"public",
"FineUploader5Request",
"setTotalFileSizeName",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sTotalFileSizeName",
")",
"{",
"ValueEnforcer",
".",
"notEmpty",
"(",
"sTotalFileSizeName",
",",
"\"TotalFileSizeName\"",
")",
";",
"m_s... | The name of the parameter passed that specifies the total file size in
bytes.
@param sTotalFileSizeName
New value. May neither be <code>null</code> nor empty.
@return this | [
"The",
"name",
"of",
"the",
"parameter",
"passed",
"that",
"specifies",
"the",
"total",
"file",
"size",
"in",
"bytes",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5Request.java#L339-L345 | train |
phax/ph-oton | ph-oton-app/src/main/java/com/helger/photon/app/resource/WebSiteResourceWithCondition.java | WebSiteResourceWithCondition.canBeBundledWith | public boolean canBeBundledWith (@Nonnull final WebSiteResourceWithCondition aOther)
{
ValueEnforcer.notNull (aOther, "Other");
// Resource cannot be bundled at all
if (!m_bIsBundlable || !aOther.isBundlable ())
return false;
// Can only bundle resources of the same type
if (!m_aResource.getResourceType ().equals (aOther.m_aResource.getResourceType ()))
return false;
// If the conditional comment is different, items cannot be bundled!
if (!EqualsHelper.equals (m_sConditionalComment, aOther.m_sConditionalComment))
return false;
// If the CSS media list is different, items cannot be bundled!
if (!EqualsHelper.equals (m_aMediaList, aOther.m_aMediaList))
return false;
// Can be bundled!
return true;
} | java | public boolean canBeBundledWith (@Nonnull final WebSiteResourceWithCondition aOther)
{
ValueEnforcer.notNull (aOther, "Other");
// Resource cannot be bundled at all
if (!m_bIsBundlable || !aOther.isBundlable ())
return false;
// Can only bundle resources of the same type
if (!m_aResource.getResourceType ().equals (aOther.m_aResource.getResourceType ()))
return false;
// If the conditional comment is different, items cannot be bundled!
if (!EqualsHelper.equals (m_sConditionalComment, aOther.m_sConditionalComment))
return false;
// If the CSS media list is different, items cannot be bundled!
if (!EqualsHelper.equals (m_aMediaList, aOther.m_aMediaList))
return false;
// Can be bundled!
return true;
} | [
"public",
"boolean",
"canBeBundledWith",
"(",
"@",
"Nonnull",
"final",
"WebSiteResourceWithCondition",
"aOther",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aOther",
",",
"\"Other\"",
")",
";",
"// Resource cannot be bundled at all",
"if",
"(",
"!",
"m_bIsBundlab... | Check if this resource can be bundled with the passed resource.
@param aOther
The resource to check against. May not be <code>null</code>.
@return <code>true</code> if this resource can be bundled with the passed
resource, <code>false</code> if not. | [
"Check",
"if",
"this",
"resource",
"can",
"be",
"bundled",
"with",
"the",
"passed",
"resource",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-app/src/main/java/com/helger/photon/app/resource/WebSiteResourceWithCondition.java#L114-L136 | train |
phax/ph-oton | ph-oton-app/src/main/java/com/helger/photon/app/resource/WebSiteResourceWithCondition.java | WebSiteResourceWithCondition.createForJS | @Nonnull
public static WebSiteResourceWithCondition createForJS (@Nonnull final IJSPathProvider aPP, final boolean bRegular)
{
return createForJS (aPP.getJSItemPath (bRegular), aPP.getConditionalComment (), aPP.isBundlable ());
} | java | @Nonnull
public static WebSiteResourceWithCondition createForJS (@Nonnull final IJSPathProvider aPP, final boolean bRegular)
{
return createForJS (aPP.getJSItemPath (bRegular), aPP.getConditionalComment (), aPP.isBundlable ());
} | [
"@",
"Nonnull",
"public",
"static",
"WebSiteResourceWithCondition",
"createForJS",
"(",
"@",
"Nonnull",
"final",
"IJSPathProvider",
"aPP",
",",
"final",
"boolean",
"bRegular",
")",
"{",
"return",
"createForJS",
"(",
"aPP",
".",
"getJSItemPath",
"(",
"bRegular",
")... | Factory method for JavaScript resources.
@param aPP
The path provider.
@param bRegular
<code>true</code> for regular version, <code>false</code> for the
minified/optimized version.
@return New {@link WebSiteResourceWithCondition} object. Never
<code>null</code>. | [
"Factory",
"method",
"for",
"JavaScript",
"resources",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-app/src/main/java/com/helger/photon/app/resource/WebSiteResourceWithCondition.java#L243-L247 | train |
phax/ph-oton | ph-oton-app/src/main/java/com/helger/photon/app/resource/WebSiteResourceWithCondition.java | WebSiteResourceWithCondition.createForCSS | @Nonnull
public static WebSiteResourceWithCondition createForCSS (@Nonnull final ICSSPathProvider aPP, final boolean bRegular)
{
return createForCSS (aPP.getCSSItemPath (bRegular),
aPP.getConditionalComment (),
aPP.isBundlable (),
aPP.getMediaList ());
} | java | @Nonnull
public static WebSiteResourceWithCondition createForCSS (@Nonnull final ICSSPathProvider aPP, final boolean bRegular)
{
return createForCSS (aPP.getCSSItemPath (bRegular),
aPP.getConditionalComment (),
aPP.isBundlable (),
aPP.getMediaList ());
} | [
"@",
"Nonnull",
"public",
"static",
"WebSiteResourceWithCondition",
"createForCSS",
"(",
"@",
"Nonnull",
"final",
"ICSSPathProvider",
"aPP",
",",
"final",
"boolean",
"bRegular",
")",
"{",
"return",
"createForCSS",
"(",
"aPP",
".",
"getCSSItemPath",
"(",
"bRegular",
... | Factory method for CSS resources.
@param aPP
The path provider.
@param bRegular
<code>true</code> for regular version, <code>false</code> for the
minified/optimized version.
@return New {@link WebSiteResourceWithCondition} object. Never
<code>null</code>. | [
"Factory",
"method",
"for",
"CSS",
"resources",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-app/src/main/java/com/helger/photon/app/resource/WebSiteResourceWithCondition.java#L273-L280 | train |
phax/ph-oton | ph-oton-bootstrap4-pages/src/main/java/com/helger/photon/bootstrap4/pages/security/SecurityUIHelper.java | SecurityUIHelper.canBeDeleted | public static boolean canBeDeleted (@Nullable final IUser aUser)
{
return aUser != null && !aUser.isDeleted () && !aUser.isAdministrator ();
} | java | public static boolean canBeDeleted (@Nullable final IUser aUser)
{
return aUser != null && !aUser.isDeleted () && !aUser.isAdministrator ();
} | [
"public",
"static",
"boolean",
"canBeDeleted",
"(",
"@",
"Nullable",
"final",
"IUser",
"aUser",
")",
"{",
"return",
"aUser",
"!=",
"null",
"&&",
"!",
"aUser",
".",
"isDeleted",
"(",
")",
"&&",
"!",
"aUser",
".",
"isAdministrator",
"(",
")",
";",
"}"
] | Check if a user can be deleted or not. Currently all not deleted users can
be deleted except for the administrator special user.
@param aUser
The user to check. May be <code>null</code>.
@return <code>true</code> if the user can be deleted, <code>false</code> if
not. | [
"Check",
"if",
"a",
"user",
"can",
"be",
"deleted",
"or",
"not",
".",
"Currently",
"all",
"not",
"deleted",
"users",
"can",
"be",
"deleted",
"except",
"for",
"the",
"administrator",
"special",
"user",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-bootstrap4-pages/src/main/java/com/helger/photon/bootstrap4/pages/security/SecurityUIHelper.java#L59-L62 | train |
phax/ph-oton | ph-oton-datatables/src/main/java/com/helger/photon/uictrls/datatables/ajax/DataTablesServerData.java | DataTablesServerData.createConversionSettings | @Nonnull
public static IHCConversionSettings createConversionSettings ()
{
// Create HTML without namespaces
final HCConversionSettings aRealCS = HCSettings.getMutableConversionSettings ().getClone ();
aRealCS.getMutableXMLWriterSettings ().setEmitNamespaces (false);
// Remove any "HCCustomizerAutoFocusFirstCtrl" customizer for AJAX calls on
// DataTables
final IHCCustomizer aCustomizer = aRealCS.getCustomizer ();
if (aCustomizer instanceof HCCustomizerAutoFocusFirstCtrl)
aRealCS.setCustomizer (null);
else
if (aCustomizer instanceof HCCustomizerList)
((HCCustomizerList) aCustomizer).removeAllCustomizersOfClass (HCCustomizerAutoFocusFirstCtrl.class);
return aRealCS;
} | java | @Nonnull
public static IHCConversionSettings createConversionSettings ()
{
// Create HTML without namespaces
final HCConversionSettings aRealCS = HCSettings.getMutableConversionSettings ().getClone ();
aRealCS.getMutableXMLWriterSettings ().setEmitNamespaces (false);
// Remove any "HCCustomizerAutoFocusFirstCtrl" customizer for AJAX calls on
// DataTables
final IHCCustomizer aCustomizer = aRealCS.getCustomizer ();
if (aCustomizer instanceof HCCustomizerAutoFocusFirstCtrl)
aRealCS.setCustomizer (null);
else
if (aCustomizer instanceof HCCustomizerList)
((HCCustomizerList) aCustomizer).removeAllCustomizersOfClass (HCCustomizerAutoFocusFirstCtrl.class);
return aRealCS;
} | [
"@",
"Nonnull",
"public",
"static",
"IHCConversionSettings",
"createConversionSettings",
"(",
")",
"{",
"// Create HTML without namespaces",
"final",
"HCConversionSettings",
"aRealCS",
"=",
"HCSettings",
".",
"getMutableConversionSettings",
"(",
")",
".",
"getClone",
"(",
... | Create the HC conversion settings to be used for HTML serialization.
@return Never <code>null</code>. | [
"Create",
"the",
"HC",
"conversion",
"settings",
"to",
"be",
"used",
"for",
"HTML",
"serialization",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-datatables/src/main/java/com/helger/photon/uictrls/datatables/ajax/DataTablesServerData.java#L137-L154 | train |
phax/ph-oton | ph-oton-app/src/main/java/com/helger/photon/app/html/PhotonCSS.java | PhotonCSS.unregisterCSSIncludeFromThisRequest | public static void unregisterCSSIncludeFromThisRequest (@Nonnull final ICSSPathProvider aCSSPathProvider)
{
final CSSResourceSet aSet = _getPerRequestSet (false);
if (aSet != null)
aSet.removeItem (aCSSPathProvider);
} | java | public static void unregisterCSSIncludeFromThisRequest (@Nonnull final ICSSPathProvider aCSSPathProvider)
{
final CSSResourceSet aSet = _getPerRequestSet (false);
if (aSet != null)
aSet.removeItem (aCSSPathProvider);
} | [
"public",
"static",
"void",
"unregisterCSSIncludeFromThisRequest",
"(",
"@",
"Nonnull",
"final",
"ICSSPathProvider",
"aCSSPathProvider",
")",
"{",
"final",
"CSSResourceSet",
"aSet",
"=",
"_getPerRequestSet",
"(",
"false",
")",
";",
"if",
"(",
"aSet",
"!=",
"null",
... | Unregister an existing CSS item only from this request
@param aCSSPathProvider
The CSS path provider to use. May not be <code>null</code>. | [
"Unregister",
"an",
"existing",
"CSS",
"item",
"only",
"from",
"this",
"request"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-app/src/main/java/com/helger/photon/app/html/PhotonCSS.java#L231-L236 | train |
phax/ph-oton | ph-oton-html/src/main/java/com/helger/html/hc/html/grouping/HCOutput.java | HCOutput.setFor | @Nonnull
public final HCOutput setFor (@Nullable final IHCHasID <?> aFor)
{
if (aFor == null)
m_sFor = null;
else
m_sFor = aFor.ensureID ().getID ();
return this;
} | java | @Nonnull
public final HCOutput setFor (@Nullable final IHCHasID <?> aFor)
{
if (aFor == null)
m_sFor = null;
else
m_sFor = aFor.ensureID ().getID ();
return this;
} | [
"@",
"Nonnull",
"public",
"final",
"HCOutput",
"setFor",
"(",
"@",
"Nullable",
"final",
"IHCHasID",
"<",
"?",
">",
"aFor",
")",
"{",
"if",
"(",
"aFor",
"==",
"null",
")",
"m_sFor",
"=",
"null",
";",
"else",
"m_sFor",
"=",
"aFor",
".",
"ensureID",
"("... | Specifies the relationship between the result of the calculation, and the
elements used in the calculation
@param aFor
The HTML of the other object.
@return this | [
"Specifies",
"the",
"relationship",
"between",
"the",
"result",
"of",
"the",
"calculation",
"and",
"the",
"elements",
"used",
"in",
"the",
"calculation"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-html/src/main/java/com/helger/html/hc/html/grouping/HCOutput.java#L78-L86 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/instrument/CoverageMethodVisitor.java | CoverageMethodVisitor.visitLdcInsn | @Override
public void visitLdcInsn(Object cst) {
// We use this method to support accesses to .class.
if (cst instanceof Type) {
int sort = ((Type) cst).getSort();
if (sort == Type.OBJECT) {
String className = Types.descToInternalName(((Type) cst).getDescriptor());
insertTInvocation0(className, mProbeCounter.incrementAndGet());
}
}
mv.visitLdcInsn(cst);
} | java | @Override
public void visitLdcInsn(Object cst) {
// We use this method to support accesses to .class.
if (cst instanceof Type) {
int sort = ((Type) cst).getSort();
if (sort == Type.OBJECT) {
String className = Types.descToInternalName(((Type) cst).getDescriptor());
insertTInvocation0(className, mProbeCounter.incrementAndGet());
}
}
mv.visitLdcInsn(cst);
} | [
"@",
"Override",
"public",
"void",
"visitLdcInsn",
"(",
"Object",
"cst",
")",
"{",
"// We use this method to support accesses to .class.",
"if",
"(",
"cst",
"instanceof",
"Type",
")",
"{",
"int",
"sort",
"=",
"(",
"(",
"Type",
")",
"cst",
")",
".",
"getSort",
... | METHOD VISITOR INTERFACE | [
"METHOD",
"VISITOR",
"INTERFACE"
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/instrument/CoverageMethodVisitor.java#L81-L92 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/instrument/CoverageMethodVisitor.java | CoverageMethodVisitor.insertTInvocation0 | private void insertTInvocation0(String className, int probeId) {
// Check if class name has been seen since the last label.
if (!mSeenClasses.add(className)) return;
// Check if this class name should be ignored.
if (Types.isIgnorableInternalName(className)) return;
// x. (we tried). Surround invocation of monitor with
// try/finally. This approach did not work in some cases as I
// was using local variables to save exception exception that
// has to be thrown; however, the same local variable may be
// used in finally block, so I would override.
// NOTE: The following is deprecated and excluded from code
// (see monitor for new approach and accesses to fields):
// We check if class contains "$" in which case we assume (without
// consequences) that the class is inner and we invoke coverage method
// that takes string as input. The reason for this special treatment is
// access policy, as the inner class may be private and we cannot load
// its .class. (See 57f5365935d26d2e6c47ec368612c6b003a2da79 for the
// test that is throwing an exception without this.) However, note
// that this slows down the execution a lot.
// boolean isNonInnerClass = !className.contains("$");
boolean isNonInnerClass = true;
// See the class visitor; currently we override
// the version number to 49 for all classes that have lower version
// number (so else branch should not be executed for this reason any
// more). Earlier comment: Note that we have to use class name in case
// of classes that have classfiles with major version of 48 or lower
// as ldc could not load .class prior to version 49 (in theory we
// could generate a method that does it for us, as the compiler
// would do, but then we would change bytecode too much).
if (isNonInnerClass && mIsNewerThanJava4) {
insertTInvocation(className, probeId);
} else {
// DEPRECATED: This part is deprecated and should never be executed.
// Using Class.forName(className) was very slow.
mv.visitLdcInsn(className.replaceAll("/", "."));
mv.visitMethodInsn(Opcodes.INVOKESTATIC, Names.COVERAGE_MONITOR_VM,
Instr.COVERAGE_MONITOR_MNAME, Instr.STRING_V_DESC, false);
}
} | java | private void insertTInvocation0(String className, int probeId) {
// Check if class name has been seen since the last label.
if (!mSeenClasses.add(className)) return;
// Check if this class name should be ignored.
if (Types.isIgnorableInternalName(className)) return;
// x. (we tried). Surround invocation of monitor with
// try/finally. This approach did not work in some cases as I
// was using local variables to save exception exception that
// has to be thrown; however, the same local variable may be
// used in finally block, so I would override.
// NOTE: The following is deprecated and excluded from code
// (see monitor for new approach and accesses to fields):
// We check if class contains "$" in which case we assume (without
// consequences) that the class is inner and we invoke coverage method
// that takes string as input. The reason for this special treatment is
// access policy, as the inner class may be private and we cannot load
// its .class. (See 57f5365935d26d2e6c47ec368612c6b003a2da79 for the
// test that is throwing an exception without this.) However, note
// that this slows down the execution a lot.
// boolean isNonInnerClass = !className.contains("$");
boolean isNonInnerClass = true;
// See the class visitor; currently we override
// the version number to 49 for all classes that have lower version
// number (so else branch should not be executed for this reason any
// more). Earlier comment: Note that we have to use class name in case
// of classes that have classfiles with major version of 48 or lower
// as ldc could not load .class prior to version 49 (in theory we
// could generate a method that does it for us, as the compiler
// would do, but then we would change bytecode too much).
if (isNonInnerClass && mIsNewerThanJava4) {
insertTInvocation(className, probeId);
} else {
// DEPRECATED: This part is deprecated and should never be executed.
// Using Class.forName(className) was very slow.
mv.visitLdcInsn(className.replaceAll("/", "."));
mv.visitMethodInsn(Opcodes.INVOKESTATIC, Names.COVERAGE_MONITOR_VM,
Instr.COVERAGE_MONITOR_MNAME, Instr.STRING_V_DESC, false);
}
} | [
"private",
"void",
"insertTInvocation0",
"(",
"String",
"className",
",",
"int",
"probeId",
")",
"{",
"// Check if class name has been seen since the last label.",
"if",
"(",
"!",
"mSeenClasses",
".",
"add",
"(",
"className",
")",
")",
"return",
";",
"// Check if this... | Checks if the class name belongs to a set of classes that should be
ignored; if not, an invocation to coverage monitor is inserted.
@param className
Name of the class to be passed to coverage monitor. | [
"Checks",
"if",
"the",
"class",
"name",
"belongs",
"to",
"a",
"set",
"of",
"classes",
"that",
"should",
"be",
"ignored",
";",
"if",
"not",
"an",
"invocation",
"to",
"coverage",
"monitor",
"is",
"inserted",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/instrument/CoverageMethodVisitor.java#L210-L250 | train |
gliga/ekstazi | ekstazi-maven-plugin/src/main/java/org/ekstazi/maven/AbstractEkstaziMojo.java | AbstractEkstaziMojo.lookupPlugin | protected Plugin lookupPlugin(String key) {
List<Plugin> plugins = project.getBuildPlugins();
for (Iterator<Plugin> iterator = plugins.iterator(); iterator.hasNext();) {
Plugin plugin = iterator.next();
if(key.equalsIgnoreCase(plugin.getKey())) {
return plugin;
}
}
return null;
} | java | protected Plugin lookupPlugin(String key) {
List<Plugin> plugins = project.getBuildPlugins();
for (Iterator<Plugin> iterator = plugins.iterator(); iterator.hasNext();) {
Plugin plugin = iterator.next();
if(key.equalsIgnoreCase(plugin.getKey())) {
return plugin;
}
}
return null;
} | [
"protected",
"Plugin",
"lookupPlugin",
"(",
"String",
"key",
")",
"{",
"List",
"<",
"Plugin",
">",
"plugins",
"=",
"project",
".",
"getBuildPlugins",
"(",
")",
";",
"for",
"(",
"Iterator",
"<",
"Plugin",
">",
"iterator",
"=",
"plugins",
".",
"iterator",
... | Find plugin based on the plugin key. Returns null if plugin
cannot be located. | [
"Find",
"plugin",
"based",
"on",
"the",
"plugin",
"key",
".",
"Returns",
"null",
"if",
"plugin",
"cannot",
"be",
"located",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/ekstazi-maven-plugin/src/main/java/org/ekstazi/maven/AbstractEkstaziMojo.java#L128-L138 | train |
gliga/ekstazi | ekstazi-maven-plugin/src/main/java/org/ekstazi/maven/AbstractEkstaziMojo.java | AbstractEkstaziMojo.isRestoreGoalPresent | protected boolean isRestoreGoalPresent() {
Plugin ekstaziPlugin = lookupPlugin(EKSTAZI_PLUGIN_KEY);
if (ekstaziPlugin == null) {
return false;
}
for (Object execution : ekstaziPlugin.getExecutions()) {
for (Object goal : ((PluginExecution) execution).getGoals()) {
if (((String) goal).equals("restore")) {
return true;
}
}
}
return false;
} | java | protected boolean isRestoreGoalPresent() {
Plugin ekstaziPlugin = lookupPlugin(EKSTAZI_PLUGIN_KEY);
if (ekstaziPlugin == null) {
return false;
}
for (Object execution : ekstaziPlugin.getExecutions()) {
for (Object goal : ((PluginExecution) execution).getGoals()) {
if (((String) goal).equals("restore")) {
return true;
}
}
}
return false;
} | [
"protected",
"boolean",
"isRestoreGoalPresent",
"(",
")",
"{",
"Plugin",
"ekstaziPlugin",
"=",
"lookupPlugin",
"(",
"EKSTAZI_PLUGIN_KEY",
")",
";",
"if",
"(",
"ekstaziPlugin",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"Object",
"executio... | Returns true if restore goal is present, false otherwise. | [
"Returns",
"true",
"if",
"restore",
"goal",
"is",
"present",
"false",
"otherwise",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/ekstazi-maven-plugin/src/main/java/org/ekstazi/maven/AbstractEkstaziMojo.java#L143-L156 | train |
gliga/ekstazi | ekstazi-maven-plugin/src/main/java/org/ekstazi/maven/AbstractEkstaziMojo.java | AbstractEkstaziMojo.restoreExcludesFile | private void restoreExcludesFile(File excludesFileFile) throws MojoExecutionException {
if (!excludesFileFile.exists()) {
return;
}
try {
String[] lines = FileUtil.readLines(excludesFileFile);
List<String> newLines = new ArrayList<String>();
for (String line : lines) {
if (line.equals(EKSTAZI_LINE_MARKER)) break;
newLines.add(line);
}
FileUtil.writeLines(excludesFileFile, newLines);
} catch (IOException ex) {
throw new MojoExecutionException("Could not restore 'excludesFile'", ex);
}
} | java | private void restoreExcludesFile(File excludesFileFile) throws MojoExecutionException {
if (!excludesFileFile.exists()) {
return;
}
try {
String[] lines = FileUtil.readLines(excludesFileFile);
List<String> newLines = new ArrayList<String>();
for (String line : lines) {
if (line.equals(EKSTAZI_LINE_MARKER)) break;
newLines.add(line);
}
FileUtil.writeLines(excludesFileFile, newLines);
} catch (IOException ex) {
throw new MojoExecutionException("Could not restore 'excludesFile'", ex);
}
} | [
"private",
"void",
"restoreExcludesFile",
"(",
"File",
"excludesFileFile",
")",
"throws",
"MojoExecutionException",
"{",
"if",
"(",
"!",
"excludesFileFile",
".",
"exists",
"(",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"String",
"[",
"]",
"lines",
"=",
... | Removes lines from excludesFile that are added by Ekstazi. | [
"Removes",
"lines",
"from",
"excludesFile",
"that",
"are",
"added",
"by",
"Ekstazi",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/ekstazi-maven-plugin/src/main/java/org/ekstazi/maven/AbstractEkstaziMojo.java#L200-L216 | train |
spotify/crtauth-java | src/main/java/com/spotify/crtauth/utils/TraditionalKeyParser.java | TraditionalKeyParser.parsePrivateKeyASN1 | private static List<byte[]> parsePrivateKeyASN1(ByteBuffer byteBuffer) {
final List<byte[]> collection = new ArrayList<byte[]>();
while (byteBuffer.hasRemaining()) {
byte type = byteBuffer.get();
int length = UnsignedBytes.toInt(byteBuffer.get());
if ((length & 0x80) != 0) {
int numberOfOctets = length ^ 0x80;
length = 0;
for (int i = 0; i < numberOfOctets; ++i) {
int lengthChunk = UnsignedBytes.toInt(byteBuffer.get());
length += lengthChunk << (numberOfOctets - i - 1) * 8;
}
}
if (length < 0) {
throw new IllegalArgumentException();
}
if (type == 0x30) {
int position = byteBuffer.position();
byte[] data = Arrays.copyOfRange(byteBuffer.array(), position, position + length);
return parsePrivateKeyASN1(ByteBuffer.wrap(data));
}
if (type == 0x02) {
byte[] segment = new byte[length];
byteBuffer.get(segment);
collection.add(segment);
}
}
return collection;
} | java | private static List<byte[]> parsePrivateKeyASN1(ByteBuffer byteBuffer) {
final List<byte[]> collection = new ArrayList<byte[]>();
while (byteBuffer.hasRemaining()) {
byte type = byteBuffer.get();
int length = UnsignedBytes.toInt(byteBuffer.get());
if ((length & 0x80) != 0) {
int numberOfOctets = length ^ 0x80;
length = 0;
for (int i = 0; i < numberOfOctets; ++i) {
int lengthChunk = UnsignedBytes.toInt(byteBuffer.get());
length += lengthChunk << (numberOfOctets - i - 1) * 8;
}
}
if (length < 0) {
throw new IllegalArgumentException();
}
if (type == 0x30) {
int position = byteBuffer.position();
byte[] data = Arrays.copyOfRange(byteBuffer.array(), position, position + length);
return parsePrivateKeyASN1(ByteBuffer.wrap(data));
}
if (type == 0x02) {
byte[] segment = new byte[length];
byteBuffer.get(segment);
collection.add(segment);
}
}
return collection;
} | [
"private",
"static",
"List",
"<",
"byte",
"[",
"]",
">",
"parsePrivateKeyASN1",
"(",
"ByteBuffer",
"byteBuffer",
")",
"{",
"final",
"List",
"<",
"byte",
"[",
"]",
">",
"collection",
"=",
"new",
"ArrayList",
"<",
"byte",
"[",
"]",
">",
"(",
")",
";",
... | This is a simplistic ASN.1 parser that can only parse a collection of primitive types.
@param byteBuffer the raw byte representation of a Pcks1 private key.
@return A list of bytes array that represent the content of the original ASN.1 collection. | [
"This",
"is",
"a",
"simplistic",
"ASN",
".",
"1",
"parser",
"that",
"can",
"only",
"parse",
"a",
"collection",
"of",
"primitive",
"types",
"."
] | 90f3b40323848740c915b195ad1b547fbeb41700 | https://github.com/spotify/crtauth-java/blob/90f3b40323848740c915b195ad1b547fbeb41700/src/main/java/com/spotify/crtauth/utils/TraditionalKeyParser.java#L99-L127 | train |
phax/ph-oton | ph-oton-api/src/main/java/com/helger/photon/api/pathdescriptor/PathDescriptorHelper.java | PathDescriptorHelper.getCleanPathParts | @Nonnull
@ReturnsMutableCopy
public static ICommonsList <String> getCleanPathParts (@Nonnull final String sPath)
{
// Remove leading and trailing whitespaces and slashes
String sRealPath = StringHelper.trimStartAndEnd (sPath.trim (), "/", "/");
// Remove obscure path parts
sRealPath = FilenameHelper.getCleanPath (sRealPath);
// Split into pieces
final ICommonsList <String> aPathParts = StringHelper.getExploded ('/', sRealPath);
return aPathParts;
} | java | @Nonnull
@ReturnsMutableCopy
public static ICommonsList <String> getCleanPathParts (@Nonnull final String sPath)
{
// Remove leading and trailing whitespaces and slashes
String sRealPath = StringHelper.trimStartAndEnd (sPath.trim (), "/", "/");
// Remove obscure path parts
sRealPath = FilenameHelper.getCleanPath (sRealPath);
// Split into pieces
final ICommonsList <String> aPathParts = StringHelper.getExploded ('/', sRealPath);
return aPathParts;
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"ICommonsList",
"<",
"String",
">",
"getCleanPathParts",
"(",
"@",
"Nonnull",
"final",
"String",
"sPath",
")",
"{",
"// Remove leading and trailing whitespaces and slashes",
"String",
"sRealPath",
"=",
"Stri... | Clean the provided path and split it into parts, separated by slashes.
@param sPath
Source path. May not be <code>null</code>.
@return The list with all path parts. Never <code>null</code>. | [
"Clean",
"the",
"provided",
"path",
"and",
"split",
"it",
"into",
"parts",
"separated",
"by",
"slashes",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-api/src/main/java/com/helger/photon/api/pathdescriptor/PathDescriptorHelper.java#L45-L58 | train |
phax/ph-oton | ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5Paste.java | FineUploader5Paste.setDefaultName | @Nonnull
public FineUploader5Paste setDefaultName (@Nonnull @Nonempty final String sDefaultName)
{
ValueEnforcer.notEmpty (sDefaultName, "DefaultName");
m_sPasteDefaultName = sDefaultName;
return this;
} | java | @Nonnull
public FineUploader5Paste setDefaultName (@Nonnull @Nonempty final String sDefaultName)
{
ValueEnforcer.notEmpty (sDefaultName, "DefaultName");
m_sPasteDefaultName = sDefaultName;
return this;
} | [
"@",
"Nonnull",
"public",
"FineUploader5Paste",
"setDefaultName",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sDefaultName",
")",
"{",
"ValueEnforcer",
".",
"notEmpty",
"(",
"sDefaultName",
",",
"\"DefaultName\"",
")",
";",
"m_sPasteDefaultName",
"=",
... | The default name given to pasted images.
@param sDefaultName
New value. May neither be <code>null</code> nor empty.
@return this for chaining | [
"The",
"default",
"name",
"given",
"to",
"pasted",
"images",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5Paste.java#L57-L63 | train |
bayofmany/peapod | core/src/main/java/peapod/internal/Inflector.java | Inflector.ordinalize | public String ordinalize(int number) {
String numberStr = Integer.toString(number);
if (11 <= number && number <= 13) return numberStr + "th";
int remainder = number % 10;
if (remainder == 1) return numberStr + "st";
if (remainder == 2) return numberStr + "nd";
if (remainder == 3) return numberStr + "rd";
return numberStr + "th";
} | java | public String ordinalize(int number) {
String numberStr = Integer.toString(number);
if (11 <= number && number <= 13) return numberStr + "th";
int remainder = number % 10;
if (remainder == 1) return numberStr + "st";
if (remainder == 2) return numberStr + "nd";
if (remainder == 3) return numberStr + "rd";
return numberStr + "th";
} | [
"public",
"String",
"ordinalize",
"(",
"int",
"number",
")",
"{",
"String",
"numberStr",
"=",
"Integer",
".",
"toString",
"(",
"number",
")",
";",
"if",
"(",
"11",
"<=",
"number",
"&&",
"number",
"<=",
"13",
")",
"return",
"numberStr",
"+",
"\"th\"",
"... | Turns a non-negative number into an ordinal string used to denote the position in an ordered sequence, such as 1st, 2nd,
3rd, 4th.
@param number the non-negative number
@return the string with the number and ordinal suffix | [
"Turns",
"a",
"non",
"-",
"negative",
"number",
"into",
"an",
"ordinal",
"string",
"used",
"to",
"denote",
"the",
"position",
"in",
"an",
"ordered",
"sequence",
"such",
"as",
"1st",
"2nd",
"3rd",
"4th",
"."
] | 46ca0a8a19b5e57158abfb1ca9fa1c6811c6da11 | https://github.com/bayofmany/peapod/blob/46ca0a8a19b5e57158abfb1ca9fa1c6811c6da11/core/src/main/java/peapod/internal/Inflector.java#L403-L411 | train |
phax/ph-oton | ph-oton-core/src/main/java/com/helger/photon/core/login/AbstractLoginManager.java | AbstractLoginManager.isLoginInProgress | @OverrideOnDemand
protected boolean isLoginInProgress (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope)
{
return CLogin.REQUEST_ACTION_VALIDATE_LOGIN_CREDENTIALS.equals (aRequestScope.params ()
.getAsString (CLogin.REQUEST_PARAM_ACTION));
} | java | @OverrideOnDemand
protected boolean isLoginInProgress (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope)
{
return CLogin.REQUEST_ACTION_VALIDATE_LOGIN_CREDENTIALS.equals (aRequestScope.params ()
.getAsString (CLogin.REQUEST_PARAM_ACTION));
} | [
"@",
"OverrideOnDemand",
"protected",
"boolean",
"isLoginInProgress",
"(",
"@",
"Nonnull",
"final",
"IRequestWebScopeWithoutResponse",
"aRequestScope",
")",
"{",
"return",
"CLogin",
".",
"REQUEST_ACTION_VALIDATE_LOGIN_CREDENTIALS",
".",
"equals",
"(",
"aRequestScope",
".",
... | Check if the login process is in progress
@param aRequestScope
Request scope
@return <code>true</code> if it is in progress
@since 3.4.0 | [
"Check",
"if",
"the",
"login",
"process",
"is",
"in",
"progress"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-core/src/main/java/com/helger/photon/core/login/AbstractLoginManager.java#L127-L132 | train |
phax/ph-oton | ph-oton-core/src/main/java/com/helger/photon/core/login/AbstractLoginManager.java | AbstractLoginManager.getLoginName | @Nullable
@OverrideOnDemand
protected String getLoginName (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope)
{
return aRequestScope.params ().getAsString (CLogin.REQUEST_ATTR_USERID);
} | java | @Nullable
@OverrideOnDemand
protected String getLoginName (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope)
{
return aRequestScope.params ().getAsString (CLogin.REQUEST_ATTR_USERID);
} | [
"@",
"Nullable",
"@",
"OverrideOnDemand",
"protected",
"String",
"getLoginName",
"(",
"@",
"Nonnull",
"final",
"IRequestWebScopeWithoutResponse",
"aRequestScope",
")",
"{",
"return",
"aRequestScope",
".",
"params",
"(",
")",
".",
"getAsString",
"(",
"CLogin",
".",
... | Get the current login name
@param aRequestScope
Request scope
@return <code>null</code> if no login name was present
@since 3.4.0 | [
"Get",
"the",
"current",
"login",
"name"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-core/src/main/java/com/helger/photon/core/login/AbstractLoginManager.java#L142-L147 | train |
phax/ph-oton | ph-oton-core/src/main/java/com/helger/photon/core/login/AbstractLoginManager.java | AbstractLoginManager.getPassword | @Nullable
@OverrideOnDemand
protected String getPassword (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope)
{
return aRequestScope.params ().getAsString (CLogin.REQUEST_ATTR_PASSWORD);
} | java | @Nullable
@OverrideOnDemand
protected String getPassword (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope)
{
return aRequestScope.params ().getAsString (CLogin.REQUEST_ATTR_PASSWORD);
} | [
"@",
"Nullable",
"@",
"OverrideOnDemand",
"protected",
"String",
"getPassword",
"(",
"@",
"Nonnull",
"final",
"IRequestWebScopeWithoutResponse",
"aRequestScope",
")",
"{",
"return",
"aRequestScope",
".",
"params",
"(",
")",
".",
"getAsString",
"(",
"CLogin",
".",
... | Get the current password
@param aRequestScope
Request scope
@return <code>null</code> if no password was present
@since 3.4.0 | [
"Get",
"the",
"current",
"password"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-core/src/main/java/com/helger/photon/core/login/AbstractLoginManager.java#L157-L162 | train |
phax/ph-oton | ph-oton-core/src/main/java/com/helger/photon/core/login/AbstractLoginManager.java | AbstractLoginManager.checkUserAndShowLogin | @Nonnull
public final EContinue checkUserAndShowLogin (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope,
@Nonnull final UnifiedResponse aUnifiedResponse)
{
final LoggedInUserManager aLoggedInUserManager = LoggedInUserManager.getInstance ();
String sSessionUserID = aLoggedInUserManager.getCurrentUserID ();
boolean bLoggedInInThisRequest = false;
if (sSessionUserID == null)
{
// No user currently logged in -> start login
boolean bLoginError = false;
ICredentialValidationResult aLoginResult = ELoginResult.SUCCESS;
// Is the special login-check action present?
if (isLoginInProgress (aRequestScope))
{
// Login screen was already shown
// -> Check request parameters
final String sLoginName = getLoginName (aRequestScope);
final String sPassword = getPassword (aRequestScope);
// Resolve user - may be null
final IUser aUser = getUserOfLoginName (sLoginName);
// Try main login
aLoginResult = aLoggedInUserManager.loginUser (aUser, sPassword, m_aRequiredRoleIDs);
if (aLoginResult.isSuccess ())
{
// Credentials are valid - implies that the user was resolved
// correctly
sSessionUserID = aUser.getID ();
bLoggedInInThisRequest = true;
}
else
{
// Credentials are invalid
if (GlobalDebug.isDebugMode ())
LOGGER.warn ("Login of '" + sLoginName + "' failed because " + aLoginResult);
// Anyway show the error message only if at least some credential
// values are passed
bLoginError = StringHelper.hasText (sLoginName) || StringHelper.hasText (sPassword);
}
}
if (sSessionUserID == null)
{
// Show login screen as no user is in the session
final IHTMLProvider aLoginScreenProvider = createLoginScreen (bLoginError, aLoginResult);
PhotonHTMLHelper.createHTMLResponse (aRequestScope, aUnifiedResponse, aLoginScreenProvider);
}
}
// Update details
final LoginInfo aLoginInfo = aLoggedInUserManager.getLoginInfo (sSessionUserID);
if (aLoginInfo != null)
{
// Update last login info
aLoginInfo.setLastAccessDTNow ();
// Set custom attributes
modifyLoginInfo (aLoginInfo, aRequestScope, bLoggedInInThisRequest);
}
else
{
// Internal inconsistency
if (sSessionUserID != null)
LOGGER.error ("Failed to resolve LoginInfo of user ID '" + sSessionUserID + "'");
}
if (bLoggedInInThisRequest)
{
// Avoid double submit by simply redirecting to the desired destination
// URL without the login parameters
aUnifiedResponse.setRedirect (aRequestScope.getURL ());
return EContinue.BREAK;
}
// Continue only, if a valid user ID is present
return EContinue.valueOf (sSessionUserID != null);
} | java | @Nonnull
public final EContinue checkUserAndShowLogin (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope,
@Nonnull final UnifiedResponse aUnifiedResponse)
{
final LoggedInUserManager aLoggedInUserManager = LoggedInUserManager.getInstance ();
String sSessionUserID = aLoggedInUserManager.getCurrentUserID ();
boolean bLoggedInInThisRequest = false;
if (sSessionUserID == null)
{
// No user currently logged in -> start login
boolean bLoginError = false;
ICredentialValidationResult aLoginResult = ELoginResult.SUCCESS;
// Is the special login-check action present?
if (isLoginInProgress (aRequestScope))
{
// Login screen was already shown
// -> Check request parameters
final String sLoginName = getLoginName (aRequestScope);
final String sPassword = getPassword (aRequestScope);
// Resolve user - may be null
final IUser aUser = getUserOfLoginName (sLoginName);
// Try main login
aLoginResult = aLoggedInUserManager.loginUser (aUser, sPassword, m_aRequiredRoleIDs);
if (aLoginResult.isSuccess ())
{
// Credentials are valid - implies that the user was resolved
// correctly
sSessionUserID = aUser.getID ();
bLoggedInInThisRequest = true;
}
else
{
// Credentials are invalid
if (GlobalDebug.isDebugMode ())
LOGGER.warn ("Login of '" + sLoginName + "' failed because " + aLoginResult);
// Anyway show the error message only if at least some credential
// values are passed
bLoginError = StringHelper.hasText (sLoginName) || StringHelper.hasText (sPassword);
}
}
if (sSessionUserID == null)
{
// Show login screen as no user is in the session
final IHTMLProvider aLoginScreenProvider = createLoginScreen (bLoginError, aLoginResult);
PhotonHTMLHelper.createHTMLResponse (aRequestScope, aUnifiedResponse, aLoginScreenProvider);
}
}
// Update details
final LoginInfo aLoginInfo = aLoggedInUserManager.getLoginInfo (sSessionUserID);
if (aLoginInfo != null)
{
// Update last login info
aLoginInfo.setLastAccessDTNow ();
// Set custom attributes
modifyLoginInfo (aLoginInfo, aRequestScope, bLoggedInInThisRequest);
}
else
{
// Internal inconsistency
if (sSessionUserID != null)
LOGGER.error ("Failed to resolve LoginInfo of user ID '" + sSessionUserID + "'");
}
if (bLoggedInInThisRequest)
{
// Avoid double submit by simply redirecting to the desired destination
// URL without the login parameters
aUnifiedResponse.setRedirect (aRequestScope.getURL ());
return EContinue.BREAK;
}
// Continue only, if a valid user ID is present
return EContinue.valueOf (sSessionUserID != null);
} | [
"@",
"Nonnull",
"public",
"final",
"EContinue",
"checkUserAndShowLogin",
"(",
"@",
"Nonnull",
"final",
"IRequestWebScopeWithoutResponse",
"aRequestScope",
",",
"@",
"Nonnull",
"final",
"UnifiedResponse",
"aUnifiedResponse",
")",
"{",
"final",
"LoggedInUserManager",
"aLogg... | Main login routine.
@param aRequestScope
Request scope
@param aUnifiedResponse
Response
@return {@link EContinue#BREAK} to indicate that no user is logged in and
therefore the login screen should be shown,
{@link EContinue#CONTINUE} if a user is correctly logged in. | [
"Main",
"login",
"routine",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-core/src/main/java/com/helger/photon/core/login/AbstractLoginManager.java#L217-L298 | train |
phax/ph-oton | ph-oton-uicore/src/main/java/com/helger/photon/uicore/js/JSFormHelper.java | JSFormHelper.setSelectOptions | @Nonnull
public static JSInvocation setSelectOptions (@Nonnull final IJSExpression aSelector,
@Nonnull final IJSExpression aValueList)
{
return getFormHelper ().invoke ("setSelectOptions").arg (aSelector).arg (aValueList);
} | java | @Nonnull
public static JSInvocation setSelectOptions (@Nonnull final IJSExpression aSelector,
@Nonnull final IJSExpression aValueList)
{
return getFormHelper ().invoke ("setSelectOptions").arg (aSelector).arg (aValueList);
} | [
"@",
"Nonnull",
"public",
"static",
"JSInvocation",
"setSelectOptions",
"(",
"@",
"Nonnull",
"final",
"IJSExpression",
"aSelector",
",",
"@",
"Nonnull",
"final",
"IJSExpression",
"aValueList",
")",
"{",
"return",
"getFormHelper",
"(",
")",
".",
"invoke",
"(",
"\... | Set all options of a <select>
@param aSelector
jQuery object
@param aValueList
list of array[value,text] - nested array!
@return the invocation | [
"Set",
"all",
"options",
"of",
"a",
"<",
";",
"select>",
";"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uicore/src/main/java/com/helger/photon/uicore/js/JSFormHelper.java#L119-L124 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/data/TxtStorer.java | TxtStorer.isMagicCorrect | protected boolean isMagicCorrect(BufferedReader br) throws IOException {
if (mCheckMagicSequence) {
String magicLine = br.readLine();
return (magicLine != null && magicLine.equals(mMode.getMagicSequence()));
} else {
return true;
}
} | java | protected boolean isMagicCorrect(BufferedReader br) throws IOException {
if (mCheckMagicSequence) {
String magicLine = br.readLine();
return (magicLine != null && magicLine.equals(mMode.getMagicSequence()));
} else {
return true;
}
} | [
"protected",
"boolean",
"isMagicCorrect",
"(",
"BufferedReader",
"br",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mCheckMagicSequence",
")",
"{",
"String",
"magicLine",
"=",
"br",
".",
"readLine",
"(",
")",
";",
"return",
"(",
"magicLine",
"!=",
"null",
... | Check magic sequence. Note that subclasses are responsible to decide if
something should be read from buffer. This approach was taken to support
old format without magic sequence. | [
"Check",
"magic",
"sequence",
".",
"Note",
"that",
"subclasses",
"are",
"responsible",
"to",
"decide",
"if",
"something",
"should",
"be",
"read",
"from",
"buffer",
".",
"This",
"approach",
"was",
"taken",
"to",
"support",
"old",
"format",
"without",
"magic",
... | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/data/TxtStorer.java#L127-L134 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/data/TxtStorer.java | TxtStorer.parseLine | protected RegData parseLine(State state, String line) {
// Note. Initial this method was using String.split, but that method
// seems to be much more expensive than playing with indexOf and
// substring.
int sepIndex = line.indexOf(SEPARATOR);
String urlExternalForm = line.substring(0, sepIndex);
String hash = line.substring(sepIndex + SEPARATOR_LEN);
return new RegData(urlExternalForm, hash);
} | java | protected RegData parseLine(State state, String line) {
// Note. Initial this method was using String.split, but that method
// seems to be much more expensive than playing with indexOf and
// substring.
int sepIndex = line.indexOf(SEPARATOR);
String urlExternalForm = line.substring(0, sepIndex);
String hash = line.substring(sepIndex + SEPARATOR_LEN);
return new RegData(urlExternalForm, hash);
} | [
"protected",
"RegData",
"parseLine",
"(",
"State",
"state",
",",
"String",
"line",
")",
"{",
"// Note. Initial this method was using String.split, but that method",
"// seems to be much more expensive than playing with indexOf and",
"// substring.",
"int",
"sepIndex",
"=",
"line",
... | Parses a single line from the file. This method is never invoked for
magic sequence. The line includes path to file and hash. Subclasses may
include more fields.
This method returns null if the line is of no interest. This can be used
by subclasses to implement different protocols. | [
"Parses",
"a",
"single",
"line",
"from",
"the",
"file",
".",
"This",
"method",
"is",
"never",
"invoked",
"for",
"magic",
"sequence",
".",
"The",
"line",
"includes",
"path",
"to",
"file",
"and",
"hash",
".",
"Subclasses",
"may",
"include",
"more",
"fields",... | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/data/TxtStorer.java#L144-L152 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/data/TxtStorer.java | TxtStorer.printLine | protected void printLine(State state, Writer pw, String externalForm, String hash) throws IOException {
pw.write(externalForm);
pw.write(SEPARATOR);
pw.write(hash);
pw.write('\n');
} | java | protected void printLine(State state, Writer pw, String externalForm, String hash) throws IOException {
pw.write(externalForm);
pw.write(SEPARATOR);
pw.write(hash);
pw.write('\n');
} | [
"protected",
"void",
"printLine",
"(",
"State",
"state",
",",
"Writer",
"pw",
",",
"String",
"externalForm",
",",
"String",
"hash",
")",
"throws",
"IOException",
"{",
"pw",
".",
"write",
"(",
"externalForm",
")",
";",
"pw",
".",
"write",
"(",
"SEPARATOR",
... | Prints one line to the given writer; the line includes path to file and
hash. Subclasses may include more fields. | [
"Prints",
"one",
"line",
"to",
"the",
"given",
"writer",
";",
"the",
"line",
"includes",
"path",
"to",
"file",
"and",
"hash",
".",
"Subclasses",
"may",
"include",
"more",
"fields",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/data/TxtStorer.java#L185-L190 | train |
gdx-libs/gdx-kiwi | src/com/github/czyzby/kiwi/util/gdx/scene2d/range/FloatRange.java | FloatRange.update | public void update(final float delta) {
if (transitionInProgress) {
currentValue += (targetValue - initialValue) * delta / transitionLength;
if (isInitialGreater) {
if (currentValue <= targetValue) {
finalizeTransition();
}
} else {
if (currentValue >= targetValue) {
finalizeTransition();
}
}
}
} | java | public void update(final float delta) {
if (transitionInProgress) {
currentValue += (targetValue - initialValue) * delta / transitionLength;
if (isInitialGreater) {
if (currentValue <= targetValue) {
finalizeTransition();
}
} else {
if (currentValue >= targetValue) {
finalizeTransition();
}
}
}
} | [
"public",
"void",
"update",
"(",
"final",
"float",
"delta",
")",
"{",
"if",
"(",
"transitionInProgress",
")",
"{",
"currentValue",
"+=",
"(",
"targetValue",
"-",
"initialValue",
")",
"*",
"delta",
"/",
"transitionLength",
";",
"if",
"(",
"isInitialGreater",
... | Updates current value as long as it doesn't match the target value.
@param delta time passed since the last update. | [
"Updates",
"current",
"value",
"as",
"long",
"as",
"it",
"doesn",
"t",
"match",
"the",
"target",
"value",
"."
] | 0172ee7534162f33b939bcdc4de089bc9579dd62 | https://github.com/gdx-libs/gdx-kiwi/blob/0172ee7534162f33b939bcdc4de089bc9579dd62/src/com/github/czyzby/kiwi/util/gdx/scene2d/range/FloatRange.java#L59-L72 | train |
gdx-libs/gdx-kiwi | src/com/github/czyzby/kiwi/util/gdx/scene2d/range/FloatRange.java | FloatRange.setCurrentValue | public void setCurrentValue(final float currentValue) {
this.currentValue = currentValue;
initialValue = currentValue;
targetValue = currentValue;
transitionInProgress = false;
} | java | public void setCurrentValue(final float currentValue) {
this.currentValue = currentValue;
initialValue = currentValue;
targetValue = currentValue;
transitionInProgress = false;
} | [
"public",
"void",
"setCurrentValue",
"(",
"final",
"float",
"currentValue",
")",
"{",
"this",
".",
"currentValue",
"=",
"currentValue",
";",
"initialValue",
"=",
"currentValue",
";",
"targetValue",
"=",
"currentValue",
";",
"transitionInProgress",
"=",
"false",
";... | Ends transition. Immediately changes managed current value. | [
"Ends",
"transition",
".",
"Immediately",
"changes",
"managed",
"current",
"value",
"."
] | 0172ee7534162f33b939bcdc4de089bc9579dd62 | https://github.com/gdx-libs/gdx-kiwi/blob/0172ee7534162f33b939bcdc4de089bc9579dd62/src/com/github/czyzby/kiwi/util/gdx/scene2d/range/FloatRange.java#L90-L95 | train |
phax/ph-oton | ph-oton-uicore/src/main/java/com/helger/photon/uicore/UITextFormatter.java | UITextFormatter.markdown | @Nonnull
public static IHCNode markdown (@Nullable final String sMD)
{
try
{
final HCNodeList aNL = MARKDOWN_PROC.process (sMD).getNodeList ();
// Replace a single <p> element with its contents
if (aNL.getChildCount () == 1 && aNL.getChildAtIndex (0) instanceof HCP)
return ((HCP) aNL.getChildAtIndex (0)).getAllChildrenAsNodeList ();
return aNL;
}
catch (final Exception ex)
{
LOGGER.warn ("Failed to markdown '" + sMD + "': " + ex.getMessage ());
return new HCTextNode (sMD);
}
} | java | @Nonnull
public static IHCNode markdown (@Nullable final String sMD)
{
try
{
final HCNodeList aNL = MARKDOWN_PROC.process (sMD).getNodeList ();
// Replace a single <p> element with its contents
if (aNL.getChildCount () == 1 && aNL.getChildAtIndex (0) instanceof HCP)
return ((HCP) aNL.getChildAtIndex (0)).getAllChildrenAsNodeList ();
return aNL;
}
catch (final Exception ex)
{
LOGGER.warn ("Failed to markdown '" + sMD + "': " + ex.getMessage ());
return new HCTextNode (sMD);
}
} | [
"@",
"Nonnull",
"public",
"static",
"IHCNode",
"markdown",
"(",
"@",
"Nullable",
"final",
"String",
"sMD",
")",
"{",
"try",
"{",
"final",
"HCNodeList",
"aNL",
"=",
"MARKDOWN_PROC",
".",
"process",
"(",
"sMD",
")",
".",
"getNodeList",
"(",
")",
";",
"// R... | Process the provided String as Markdown and return the created IHCNode.
@param sMD
The Markdown source to be invoked. May be <code>null</code>.
@return Either the processed markdown code or in case of an internal error
a {@link HCTextNode} which contains the source text. | [
"Process",
"the",
"provided",
"String",
"as",
"Markdown",
"and",
"return",
"the",
"created",
"IHCNode",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uicore/src/main/java/com/helger/photon/uicore/UITextFormatter.java#L110-L128 | train |
phax/ph-oton | ph-oton-uicore/src/main/java/com/helger/photon/uicore/page/AbstractWebPage.java | AbstractWebPage.getContent | public final void getContent (@Nonnull final WPECTYPE aWPEC)
{
if (isValidToDisplayPage (aWPEC).isValid ())
{
// "before"-callback
beforeFillContent (aWPEC);
// Create the main page content
fillContent (aWPEC);
// "after"-callback
afterFillContent (aWPEC);
}
else
{
// Invalid to display page
onInvalidToDisplayPage (aWPEC);
}
} | java | public final void getContent (@Nonnull final WPECTYPE aWPEC)
{
if (isValidToDisplayPage (aWPEC).isValid ())
{
// "before"-callback
beforeFillContent (aWPEC);
// Create the main page content
fillContent (aWPEC);
// "after"-callback
afterFillContent (aWPEC);
}
else
{
// Invalid to display page
onInvalidToDisplayPage (aWPEC);
}
} | [
"public",
"final",
"void",
"getContent",
"(",
"@",
"Nonnull",
"final",
"WPECTYPE",
"aWPEC",
")",
"{",
"if",
"(",
"isValidToDisplayPage",
"(",
"aWPEC",
")",
".",
"isValid",
"(",
")",
")",
"{",
"// \"before\"-callback",
"beforeFillContent",
"(",
"aWPEC",
")",
... | Default implementation calling the abstract fillContent method and creating
the help node if desired. | [
"Default",
"implementation",
"calling",
"the",
"abstract",
"fillContent",
"method",
"and",
"creating",
"the",
"help",
"node",
"if",
"desired",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uicore/src/main/java/com/helger/photon/uicore/page/AbstractWebPage.java#L152-L170 | train |
phax/ph-oton | ph-oton-uicore/src/main/java/com/helger/photon/uicore/page/AbstractWebPage.java | AbstractWebPage.addAjax | @Nonnull
public static final AjaxFunctionDeclaration addAjax (@Nullable final String sPrefix,
@Nonnull final IAjaxExecutor aExecutor)
{
// null means random name
final String sFuncName = StringHelper.hasText (sPrefix) ? sPrefix + AjaxFunctionDeclaration.getUniqueFunctionID ()
: null;
final AjaxFunctionDeclaration aFunction = AjaxFunctionDeclaration.builder (sFuncName)
.withExecutor (aExecutor)
.build ();
GlobalAjaxInvoker.getInstance ().getRegistry ().registerFunction (aFunction);
return aFunction;
} | java | @Nonnull
public static final AjaxFunctionDeclaration addAjax (@Nullable final String sPrefix,
@Nonnull final IAjaxExecutor aExecutor)
{
// null means random name
final String sFuncName = StringHelper.hasText (sPrefix) ? sPrefix + AjaxFunctionDeclaration.getUniqueFunctionID ()
: null;
final AjaxFunctionDeclaration aFunction = AjaxFunctionDeclaration.builder (sFuncName)
.withExecutor (aExecutor)
.build ();
GlobalAjaxInvoker.getInstance ().getRegistry ().registerFunction (aFunction);
return aFunction;
} | [
"@",
"Nonnull",
"public",
"static",
"final",
"AjaxFunctionDeclaration",
"addAjax",
"(",
"@",
"Nullable",
"final",
"String",
"sPrefix",
",",
"@",
"Nonnull",
"final",
"IAjaxExecutor",
"aExecutor",
")",
"{",
"// null means random name",
"final",
"String",
"sFuncName",
... | Add a per-page AJAX executor, with an automatically generated name. It is
automatically generated with the global AjaxInvoker.
@param sPrefix
Function name prefix. If one is provided, this will be used as URL
name so only limited chars are allowed.
@param aExecutor
The executor to be executed. May not be <code>null</code>.
@return The create {@link AjaxFunctionDeclaration} to be invoked. | [
"Add",
"a",
"per",
"-",
"page",
"AJAX",
"executor",
"with",
"an",
"automatically",
"generated",
"name",
".",
"It",
"is",
"automatically",
"generated",
"with",
"the",
"global",
"AjaxInvoker",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uicore/src/main/java/com/helger/photon/uicore/page/AbstractWebPage.java#L189-L201 | train |
deltatree/qrsct | src/main/java/de/deltatree/tools/qrsct/QRSCT.java | QRSCT.reference | public QRSCT reference(String reference) {
if (reference != null && reference.length() <= 35) {
this.text = ""; //$NON-NLS-1$
this.reference = checkValidSigns(reference);
return this;
}
throw new IllegalArgumentException("supplied reference [" + reference //$NON-NLS-1$
+ "] not valid: has to be not null and of max length 35"); //$NON-NLS-1$
} | java | public QRSCT reference(String reference) {
if (reference != null && reference.length() <= 35) {
this.text = ""; //$NON-NLS-1$
this.reference = checkValidSigns(reference);
return this;
}
throw new IllegalArgumentException("supplied reference [" + reference //$NON-NLS-1$
+ "] not valid: has to be not null and of max length 35"); //$NON-NLS-1$
} | [
"public",
"QRSCT",
"reference",
"(",
"String",
"reference",
")",
"{",
"if",
"(",
"reference",
"!=",
"null",
"&&",
"reference",
".",
"length",
"(",
")",
"<=",
"35",
")",
"{",
"this",
".",
"text",
"=",
"\"\"",
";",
"//$NON-NLS-1$\r",
"this",
".",
"refere... | Sets the reference of this builder !!!If you set this attribute,
attribute text will be reset to an empty string!!! It's only possible to
define one of these attributes
@param reference
reference (max length: 35)
@return QRSCT builder | [
"Sets",
"the",
"reference",
"of",
"this",
"builder",
"!!!If",
"you",
"set",
"this",
"attribute",
"attribute",
"text",
"will",
"be",
"reset",
"to",
"an",
"empty",
"string!!!",
"It",
"s",
"only",
"possible",
"to",
"define",
"one",
"of",
"these",
"attributes"
] | 81a137f74d9eceb47d4225d6f1ff45569d359a19 | https://github.com/deltatree/qrsct/blob/81a137f74d9eceb47d4225d6f1ff45569d359a19/src/main/java/de/deltatree/tools/qrsct/QRSCT.java#L181-L189 | train |
deltatree/qrsct | src/main/java/de/deltatree/tools/qrsct/QRSCT.java | QRSCT.text | public QRSCT text(String text) {
if (text != null && text.length() <= 140) {
this.reference = ""; //$NON-NLS-1$
this.text = checkValidSigns(text);
return this;
}
throw new IllegalArgumentException("supplied text [" + text //$NON-NLS-1$
+ "] not valid: has to be not null and of max length 140"); //$NON-NLS-1$
} | java | public QRSCT text(String text) {
if (text != null && text.length() <= 140) {
this.reference = ""; //$NON-NLS-1$
this.text = checkValidSigns(text);
return this;
}
throw new IllegalArgumentException("supplied text [" + text //$NON-NLS-1$
+ "] not valid: has to be not null and of max length 140"); //$NON-NLS-1$
} | [
"public",
"QRSCT",
"text",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"text",
"!=",
"null",
"&&",
"text",
".",
"length",
"(",
")",
"<=",
"140",
")",
"{",
"this",
".",
"reference",
"=",
"\"\"",
";",
"//$NON-NLS-1$\r",
"this",
".",
"text",
"=",
"che... | Sets the text of this builder !!!If you set this attribute, attribute
reference will be reset to an empty string!!! It's only possible to
define one of these attributes
@param text
text (max length: 140)
@return QRSCT builder | [
"Sets",
"the",
"text",
"of",
"this",
"builder",
"!!!If",
"you",
"set",
"this",
"attribute",
"attribute",
"reference",
"will",
"be",
"reset",
"to",
"an",
"empty",
"string!!!",
"It",
"s",
"only",
"possible",
"to",
"define",
"one",
"of",
"these",
"attributes"
] | 81a137f74d9eceb47d4225d6f1ff45569d359a19 | https://github.com/deltatree/qrsct/blob/81a137f74d9eceb47d4225d6f1ff45569d359a19/src/main/java/de/deltatree/tools/qrsct/QRSCT.java#L200-L208 | train |
sosandstrom/mardao | mardao-maven-plugin/src/main/java/net/sf/mardao/plugin/ProcessDomainMojo.java | ProcessDomainMojo.processClasspath | private void processClasspath(String classpathElement) throws ResourceNotFoundException, ParseErrorException, Exception {
// getLog().info("Classpath is " + classpathElement);
if (classpathElement.endsWith(".jar")) {
// TODO: implement JAR scanning
} else {
final File dir = new File(classpathElement);
processPackage(dir, dir);
}
} | java | private void processClasspath(String classpathElement) throws ResourceNotFoundException, ParseErrorException, Exception {
// getLog().info("Classpath is " + classpathElement);
if (classpathElement.endsWith(".jar")) {
// TODO: implement JAR scanning
} else {
final File dir = new File(classpathElement);
processPackage(dir, dir);
}
} | [
"private",
"void",
"processClasspath",
"(",
"String",
"classpathElement",
")",
"throws",
"ResourceNotFoundException",
",",
"ParseErrorException",
",",
"Exception",
"{",
"// getLog().info(\"Classpath is \" + classpathElement);",
"if",
"(",
"classpathElement",
".",
"endsWi... | Process the classes for a specified package
@param classpathElement
@throws ResourceNotFoundException
@throws ParseErrorException
@throws Exception | [
"Process",
"the",
"classes",
"for",
"a",
"specified",
"package"
] | b77e3a2ac1d8932e0a3174f3645f71b211dfc055 | https://github.com/sosandstrom/mardao/blob/b77e3a2ac1d8932e0a3174f3645f71b211dfc055/mardao-maven-plugin/src/main/java/net/sf/mardao/plugin/ProcessDomainMojo.java#L272-L281 | train |
sosandstrom/mardao | mardao-maven-plugin/src/main/java/net/sf/mardao/plugin/ProcessDomainMojo.java | ProcessDomainMojo.processPackage | private void processPackage(File root, File dir) {
getLog().debug("- package: " + dir);
if (null != dir && dir.isDirectory()) {
for (File f : dir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory() || pathname.getName().endsWith(".class");
}
})) {
if (f.isDirectory()) {
processPackage(root, f);
} else if (f.getParentFile().getAbsolutePath().replace(File.separatorChar, '.').endsWith(basePackage + '.' + domainPackageName)) {
final String simpleName = f.getName().substring(0, f.getName().lastIndexOf(".class"));
final String className = String.format("%s.%s.%s", basePackage, domainPackageName, simpleName);
getLog().debug(String.format("--- class %s", className));
try {
Class clazz = loader.loadClass(className);
if (!Modifier.isAbstract(clazz.getModifiers()) && isEntity(clazz)) {
getLog().debug("@Entity " + clazz.getName());
final Entity entity = new Entity();
entity.setClazz(clazz);
final String packageName = clazz.getPackage().getName();
Group group = packages.get(packageName);
if (null == group) {
group = new Group();
group.setName(packageName);
packages.put(packageName, group);
}
group.getEntities().put(simpleName, entity);
entities.put(entity.getClassName(), entity);
}
} catch (ClassNotFoundException ex) {
Logger.getLogger(ProcessDomainMojo.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
} | java | private void processPackage(File root, File dir) {
getLog().debug("- package: " + dir);
if (null != dir && dir.isDirectory()) {
for (File f : dir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory() || pathname.getName().endsWith(".class");
}
})) {
if (f.isDirectory()) {
processPackage(root, f);
} else if (f.getParentFile().getAbsolutePath().replace(File.separatorChar, '.').endsWith(basePackage + '.' + domainPackageName)) {
final String simpleName = f.getName().substring(0, f.getName().lastIndexOf(".class"));
final String className = String.format("%s.%s.%s", basePackage, domainPackageName, simpleName);
getLog().debug(String.format("--- class %s", className));
try {
Class clazz = loader.loadClass(className);
if (!Modifier.isAbstract(clazz.getModifiers()) && isEntity(clazz)) {
getLog().debug("@Entity " + clazz.getName());
final Entity entity = new Entity();
entity.setClazz(clazz);
final String packageName = clazz.getPackage().getName();
Group group = packages.get(packageName);
if (null == group) {
group = new Group();
group.setName(packageName);
packages.put(packageName, group);
}
group.getEntities().put(simpleName, entity);
entities.put(entity.getClassName(), entity);
}
} catch (ClassNotFoundException ex) {
Logger.getLogger(ProcessDomainMojo.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
} | [
"private",
"void",
"processPackage",
"(",
"File",
"root",
",",
"File",
"dir",
")",
"{",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"- package: \"",
"+",
"dir",
")",
";",
"if",
"(",
"null",
"!=",
"dir",
"&&",
"dir",
".",
"isDirectory",
"(",
")",
")",
... | Recursive method to process a folder or file; if a folder, call
recursively for each file. If for a file, process the file using the
classVisitor.
@param root base folder
@param dir this (sub-)packages folder | [
"Recursive",
"method",
"to",
"process",
"a",
"folder",
"or",
"file",
";",
"if",
"a",
"folder",
"call",
"recursively",
"for",
"each",
"file",
".",
"If",
"for",
"a",
"file",
"process",
"the",
"file",
"using",
"the",
"classVisitor",
"."
] | b77e3a2ac1d8932e0a3174f3645f71b211dfc055 | https://github.com/sosandstrom/mardao/blob/b77e3a2ac1d8932e0a3174f3645f71b211dfc055/mardao-maven-plugin/src/main/java/net/sf/mardao/plugin/ProcessDomainMojo.java#L315-L354 | train |
phax/ph-datetime | ph-holiday/src/main/java/com/helger/holiday/mgr/XMLHolidayManager.java | XMLHolidayManager._getHolidays | @Nonnull
@ReturnsMutableCopy
private HolidayMap _getHolidays (final int nYear,
@Nonnull final Configuration aConfig,
@Nullable final String... aArgs)
{
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Adding holidays for " + aConfig.getDescription ());
final HolidayMap aHolidayMap = new HolidayMap ();
for (final IHolidayParser aParser : _getParsers (aConfig.getHolidays ()))
aParser.parse (nYear, aHolidayMap, aConfig.getHolidays ());
if (ArrayHelper.isNotEmpty (aArgs))
{
final String sHierarchy = aArgs[0];
for (final Configuration aSubConfig : aConfig.getSubConfigurations ())
{
if (sHierarchy.equalsIgnoreCase (aSubConfig.getHierarchy ()))
{
// Recursive call
final HolidayMap aSubHolidays = _getHolidays (nYear,
aSubConfig,
ArrayHelper.getCopy (aArgs, 1, aArgs.length - 1));
aHolidayMap.addAll (aSubHolidays);
break;
}
}
}
return aHolidayMap;
} | java | @Nonnull
@ReturnsMutableCopy
private HolidayMap _getHolidays (final int nYear,
@Nonnull final Configuration aConfig,
@Nullable final String... aArgs)
{
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Adding holidays for " + aConfig.getDescription ());
final HolidayMap aHolidayMap = new HolidayMap ();
for (final IHolidayParser aParser : _getParsers (aConfig.getHolidays ()))
aParser.parse (nYear, aHolidayMap, aConfig.getHolidays ());
if (ArrayHelper.isNotEmpty (aArgs))
{
final String sHierarchy = aArgs[0];
for (final Configuration aSubConfig : aConfig.getSubConfigurations ())
{
if (sHierarchy.equalsIgnoreCase (aSubConfig.getHierarchy ()))
{
// Recursive call
final HolidayMap aSubHolidays = _getHolidays (nYear,
aSubConfig,
ArrayHelper.getCopy (aArgs, 1, aArgs.length - 1));
aHolidayMap.addAll (aSubHolidays);
break;
}
}
}
return aHolidayMap;
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"private",
"HolidayMap",
"_getHolidays",
"(",
"final",
"int",
"nYear",
",",
"@",
"Nonnull",
"final",
"Configuration",
"aConfig",
",",
"@",
"Nullable",
"final",
"String",
"...",
"aArgs",
")",
"{",
"if",
"(",
"LOGGER",
... | Parses the provided configuration for the provided year and fills the list
of holidays.
@param nYear
@param aConfig
@param aArgs
@return the holidays | [
"Parses",
"the",
"provided",
"configuration",
"for",
"the",
"provided",
"year",
"and",
"fills",
"the",
"list",
"of",
"holidays",
"."
] | cfaff01cb76d9affb934800ff55734b5a7d8983e | https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/mgr/XMLHolidayManager.java#L174-L204 | train |
phax/ph-datetime | ph-holiday/src/main/java/com/helger/holiday/mgr/XMLHolidayManager.java | XMLHolidayManager._validateConfigurationHierarchy | private static void _validateConfigurationHierarchy (@Nonnull final Configuration aConfig)
{
final ICommonsSet <String> aHierarchySet = new CommonsHashSet <> ();
for (final Configuration aSubConfig : aConfig.getSubConfigurations ())
{
final String sHierarchy = aSubConfig.getHierarchy ();
if (!aHierarchySet.add (sHierarchy))
throw new IllegalArgumentException ("Configuration for " +
aConfig.getHierarchy () +
" contains multiple SubConfigurations with the same hierarchy id '" +
sHierarchy +
"'. ");
}
for (final Configuration aSubConfig : aConfig.getSubConfigurations ())
_validateConfigurationHierarchy (aSubConfig);
} | java | private static void _validateConfigurationHierarchy (@Nonnull final Configuration aConfig)
{
final ICommonsSet <String> aHierarchySet = new CommonsHashSet <> ();
for (final Configuration aSubConfig : aConfig.getSubConfigurations ())
{
final String sHierarchy = aSubConfig.getHierarchy ();
if (!aHierarchySet.add (sHierarchy))
throw new IllegalArgumentException ("Configuration for " +
aConfig.getHierarchy () +
" contains multiple SubConfigurations with the same hierarchy id '" +
sHierarchy +
"'. ");
}
for (final Configuration aSubConfig : aConfig.getSubConfigurations ())
_validateConfigurationHierarchy (aSubConfig);
} | [
"private",
"static",
"void",
"_validateConfigurationHierarchy",
"(",
"@",
"Nonnull",
"final",
"Configuration",
"aConfig",
")",
"{",
"final",
"ICommonsSet",
"<",
"String",
">",
"aHierarchySet",
"=",
"new",
"CommonsHashSet",
"<>",
"(",
")",
";",
"for",
"(",
"final... | Validates the content of the provided configuration by checking for
multiple hierarchy entries within one configuration. It traverses down the
configuration tree. | [
"Validates",
"the",
"content",
"of",
"the",
"provided",
"configuration",
"by",
"checking",
"for",
"multiple",
"hierarchy",
"entries",
"within",
"one",
"configuration",
".",
"It",
"traverses",
"down",
"the",
"configuration",
"tree",
"."
] | cfaff01cb76d9affb934800ff55734b5a7d8983e | https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/mgr/XMLHolidayManager.java#L211-L227 | train |
phax/ph-datetime | ph-holiday/src/main/java/com/helger/holiday/mgr/XMLHolidayManager.java | XMLHolidayManager._createConfigurationHierarchy | @Nonnull
private static CalendarHierarchy _createConfigurationHierarchy (@Nonnull final Configuration aConfig,
@Nullable final CalendarHierarchy aParent)
{
final ECountry eCountry = ECountry.getFromIDOrNull (aConfig.getHierarchy ());
final CalendarHierarchy aHierarchy = new CalendarHierarchy (aParent, aConfig.getHierarchy (), eCountry);
for (final Configuration aSubConfig : aConfig.getSubConfigurations ())
{
final CalendarHierarchy aSubHierarchy = _createConfigurationHierarchy (aSubConfig, aHierarchy);
aHierarchy.addChild (aSubHierarchy);
}
return aHierarchy;
} | java | @Nonnull
private static CalendarHierarchy _createConfigurationHierarchy (@Nonnull final Configuration aConfig,
@Nullable final CalendarHierarchy aParent)
{
final ECountry eCountry = ECountry.getFromIDOrNull (aConfig.getHierarchy ());
final CalendarHierarchy aHierarchy = new CalendarHierarchy (aParent, aConfig.getHierarchy (), eCountry);
for (final Configuration aSubConfig : aConfig.getSubConfigurations ())
{
final CalendarHierarchy aSubHierarchy = _createConfigurationHierarchy (aSubConfig, aHierarchy);
aHierarchy.addChild (aSubHierarchy);
}
return aHierarchy;
} | [
"@",
"Nonnull",
"private",
"static",
"CalendarHierarchy",
"_createConfigurationHierarchy",
"(",
"@",
"Nonnull",
"final",
"Configuration",
"aConfig",
",",
"@",
"Nullable",
"final",
"CalendarHierarchy",
"aParent",
")",
"{",
"final",
"ECountry",
"eCountry",
"=",
"ECountr... | Creates the configuration hierarchy for the provided configuration.
@param aConfig
@return configuration hierarchy | [
"Creates",
"the",
"configuration",
"hierarchy",
"for",
"the",
"provided",
"configuration",
"."
] | cfaff01cb76d9affb934800ff55734b5a7d8983e | https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/mgr/XMLHolidayManager.java#L248-L260 | train |
sosandstrom/mardao | mardao-jdbc/src/main/java/net/sf/mardao/dao/JdbcSupplier.java | JdbcSupplier.setDbType | public static void setDbType(JdbcDialect dialect, String key, String type) {
Properties props = getTypesProps(dialect);
props.setProperty(key, type);
} | java | public static void setDbType(JdbcDialect dialect, String key, String type) {
Properties props = getTypesProps(dialect);
props.setProperty(key, type);
} | [
"public",
"static",
"void",
"setDbType",
"(",
"JdbcDialect",
"dialect",
",",
"String",
"key",
",",
"String",
"type",
")",
"{",
"Properties",
"props",
"=",
"getTypesProps",
"(",
"dialect",
")",
";",
"props",
".",
"setProperty",
"(",
"key",
",",
"type",
")",... | Add a type for your DB's dialect | [
"Add",
"a",
"type",
"for",
"your",
"DB",
"s",
"dialect"
] | b77e3a2ac1d8932e0a3174f3645f71b211dfc055 | https://github.com/sosandstrom/mardao/blob/b77e3a2ac1d8932e0a3174f3645f71b211dfc055/mardao-jdbc/src/main/java/net/sf/mardao/dao/JdbcSupplier.java#L505-L508 | train |
phax/ph-datetime | ph-holiday/src/main/java/com/helger/holiday/parser/EthiopianOrthodoxHolidayParser.java | EthiopianOrthodoxHolidayParser._getEthiopianOrthodoxHolidaysInGregorianYear | private static ICommonsSet <LocalDate> _getEthiopianOrthodoxHolidaysInGregorianYear (final int nGregorianYear,
final int nEOMonth,
final int nEODay)
{
return CalendarHelper.getDatesFromChronologyWithinGregorianYear (nEOMonth,
nEODay,
nGregorianYear,
CopticChronology.INSTANCE);
} | java | private static ICommonsSet <LocalDate> _getEthiopianOrthodoxHolidaysInGregorianYear (final int nGregorianYear,
final int nEOMonth,
final int nEODay)
{
return CalendarHelper.getDatesFromChronologyWithinGregorianYear (nEOMonth,
nEODay,
nGregorianYear,
CopticChronology.INSTANCE);
} | [
"private",
"static",
"ICommonsSet",
"<",
"LocalDate",
">",
"_getEthiopianOrthodoxHolidaysInGregorianYear",
"(",
"final",
"int",
"nGregorianYear",
",",
"final",
"int",
"nEOMonth",
",",
"final",
"int",
"nEODay",
")",
"{",
"return",
"CalendarHelper",
".",
"getDatesFromCh... | Returns a set of gregorian dates within a gregorian year which equal the
Ethiopian orthodox month and day. Because the Ethiopian orthodox year
different from the gregorian there may be more than one occurrence of an
Ethiopian orthodox date in an gregorian year.
@param nGregorianYear
@param nEOMonth
orthodox month
@param nEODay
orthodox day
@return List of gregorian dates for the Ethiopian orthodox month/day. | [
"Returns",
"a",
"set",
"of",
"gregorian",
"dates",
"within",
"a",
"gregorian",
"year",
"which",
"equal",
"the",
"Ethiopian",
"orthodox",
"month",
"and",
"day",
".",
"Because",
"the",
"Ethiopian",
"orthodox",
"year",
"different",
"from",
"the",
"gregorian",
"th... | cfaff01cb76d9affb934800ff55734b5a7d8983e | https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/parser/EthiopianOrthodoxHolidayParser.java#L64-L72 | train |
revelytix/spark | spark-http-client/src/main/java/spark/protocol/parser/XMLResultsParser.java | XMLResultsParser.parse | @Override
public Result parse(Command cmd, InputStream input, ResultType type) {
return parseResults(cmd, input, type);
} | java | @Override
public Result parse(Command cmd, InputStream input, ResultType type) {
return parseResults(cmd, input, type);
} | [
"@",
"Override",
"public",
"Result",
"parse",
"(",
"Command",
"cmd",
",",
"InputStream",
"input",
",",
"ResultType",
"type",
")",
"{",
"return",
"parseResults",
"(",
"cmd",
",",
"input",
",",
"type",
")",
";",
"}"
] | Parses the input stream as either XML select or ask results. | [
"Parses",
"the",
"input",
"stream",
"as",
"either",
"XML",
"select",
"or",
"ask",
"results",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/parser/XMLResultsParser.java#L80-L83 | train |
revelytix/spark | spark-http-client/src/main/java/spark/protocol/parser/XMLResultsParser.java | XMLResultsParser.parseResults | public static Result parseResults(Command cmd, InputStream input, ResultType type) throws SparqlException {
try {
return createResults(cmd, input, type);
} catch (Throwable t) {
logger.debug("Error parsing results from stream, cleaning up.");
try {
input.close();
} catch (IOException e) {
logger.warn("Error closing input stream from failed protocol response", e);
}
throw SparqlException.convert("Error parsing SPARQL protocol results from stream", t);
}
} | java | public static Result parseResults(Command cmd, InputStream input, ResultType type) throws SparqlException {
try {
return createResults(cmd, input, type);
} catch (Throwable t) {
logger.debug("Error parsing results from stream, cleaning up.");
try {
input.close();
} catch (IOException e) {
logger.warn("Error closing input stream from failed protocol response", e);
}
throw SparqlException.convert("Error parsing SPARQL protocol results from stream", t);
}
} | [
"public",
"static",
"Result",
"parseResults",
"(",
"Command",
"cmd",
",",
"InputStream",
"input",
",",
"ResultType",
"type",
")",
"throws",
"SparqlException",
"{",
"try",
"{",
"return",
"createResults",
"(",
"cmd",
",",
"input",
",",
"type",
")",
";",
"}",
... | Parses an XMLResults object based on the contents of the given stream.
@param cmd The command that originated the request.
@param stream The input stream containing raw XML.
@param query The query used to generate the stream.
@return A new XMLResults object. Either variable bindings, or a boolean result.
@throws SparqlException If the data stream was not valid. | [
"Parses",
"an",
"XMLResults",
"object",
"based",
"on",
"the",
"contents",
"of",
"the",
"given",
"stream",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/parser/XMLResultsParser.java#L93-L105 | train |
revelytix/spark | spark-http-client/src/main/java/spark/protocol/parser/XMLResultsParser.java | XMLResultsParser.createResults | private static Result createResults(Command cmd, InputStream stream, ResultType type) throws SparqlException {
XMLInputFactory xmlStreamFactory = XMLInputFactory.newInstance();
// Tell the factory to combine adjacent character blocks into a single event, so we don't have to do it ourselves.
xmlStreamFactory.setProperty(XMLInputFactory.IS_COALESCING, true);
// Tell the factory to create a reader that will close the underlying stream when done.
xmlStreamFactory.setProperty(XMLInputFactory2.P_AUTO_CLOSE_INPUT, true);
XMLStreamReader rdr;
try {
rdr = xmlStreamFactory.createXMLStreamReader(stream, "UTF-8");
} catch (XMLStreamException e) {
throw new SparqlException("Unable to open XML data", e);
}
List<String> cols = new ArrayList<String>();
List<String> md = new ArrayList<String>();
try {
if (rdr.nextTag() != START_ELEMENT || !nameIs(rdr, SPARQL)) {
throw new SparqlException("Result is not a SPARQL XML result document");
}
// Initialize the base URI to the
String base = null;
if (cmd != null) {
base = ((ProtocolDataSource)cmd.getConnection().getDataSource()).getUrl().toString();
}
// read the header information
parseHeader(base, rdr, cols, md);
// move the cursor into the results, and read in the first row
if (rdr.nextTag() != START_ELEMENT) throw new SparqlException("No body to result document");
String typeName = rdr.getLocalName();
if (typeName.equalsIgnoreCase(RESULTS.toString())) {
if (type != null && type != ResultType.SELECT) {
throw new SparqlException("Unexpected result type; expected " + type + " but found SELECT.");
}
return new XMLSelectResults(cmd, rdr, cols, md);
}
if (typeName.equalsIgnoreCase(BOOLEAN.toString())) {
if (type != null && type != ResultType.ASK) {
throw new SparqlException("Unexpected result type; expected " + type + " but found ASK.");
}
if (!cols.isEmpty()) {
logger.warn("Boolean result contained column definitions in head: {}", cols);
}
return parseBooleanResult(cmd, rdr, md);
}
throw new SparqlException("Unknown element type in result document. Expected <results> or <boolean> but got <" + typeName + ">");
} catch (XMLStreamException e) {
throw new SparqlException("Error reading the XML stream", e);
}
} | java | private static Result createResults(Command cmd, InputStream stream, ResultType type) throws SparqlException {
XMLInputFactory xmlStreamFactory = XMLInputFactory.newInstance();
// Tell the factory to combine adjacent character blocks into a single event, so we don't have to do it ourselves.
xmlStreamFactory.setProperty(XMLInputFactory.IS_COALESCING, true);
// Tell the factory to create a reader that will close the underlying stream when done.
xmlStreamFactory.setProperty(XMLInputFactory2.P_AUTO_CLOSE_INPUT, true);
XMLStreamReader rdr;
try {
rdr = xmlStreamFactory.createXMLStreamReader(stream, "UTF-8");
} catch (XMLStreamException e) {
throw new SparqlException("Unable to open XML data", e);
}
List<String> cols = new ArrayList<String>();
List<String> md = new ArrayList<String>();
try {
if (rdr.nextTag() != START_ELEMENT || !nameIs(rdr, SPARQL)) {
throw new SparqlException("Result is not a SPARQL XML result document");
}
// Initialize the base URI to the
String base = null;
if (cmd != null) {
base = ((ProtocolDataSource)cmd.getConnection().getDataSource()).getUrl().toString();
}
// read the header information
parseHeader(base, rdr, cols, md);
// move the cursor into the results, and read in the first row
if (rdr.nextTag() != START_ELEMENT) throw new SparqlException("No body to result document");
String typeName = rdr.getLocalName();
if (typeName.equalsIgnoreCase(RESULTS.toString())) {
if (type != null && type != ResultType.SELECT) {
throw new SparqlException("Unexpected result type; expected " + type + " but found SELECT.");
}
return new XMLSelectResults(cmd, rdr, cols, md);
}
if (typeName.equalsIgnoreCase(BOOLEAN.toString())) {
if (type != null && type != ResultType.ASK) {
throw new SparqlException("Unexpected result type; expected " + type + " but found ASK.");
}
if (!cols.isEmpty()) {
logger.warn("Boolean result contained column definitions in head: {}", cols);
}
return parseBooleanResult(cmd, rdr, md);
}
throw new SparqlException("Unknown element type in result document. Expected <results> or <boolean> but got <" + typeName + ">");
} catch (XMLStreamException e) {
throw new SparqlException("Error reading the XML stream", e);
}
} | [
"private",
"static",
"Result",
"createResults",
"(",
"Command",
"cmd",
",",
"InputStream",
"stream",
",",
"ResultType",
"type",
")",
"throws",
"SparqlException",
"{",
"XMLInputFactory",
"xmlStreamFactory",
"=",
"XMLInputFactory",
".",
"newInstance",
"(",
")",
";",
... | Sets up an XML parser for the input, and creates the appropriate result type based on the parsed XML. | [
"Sets",
"up",
"an",
"XML",
"parser",
"for",
"the",
"input",
"and",
"creates",
"the",
"appropriate",
"result",
"type",
"based",
"on",
"the",
"parsed",
"XML",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/parser/XMLResultsParser.java#L108-L164 | train |
revelytix/spark | spark-http-client/src/main/java/spark/protocol/parser/XMLResultsParser.java | XMLResultsParser.parseHeader | static private void parseHeader(String base, XMLStreamReader rdr, List<String> cols, List<String> md) throws XMLStreamException, SparqlException {
logger.debug("xml:base is initially {}", base);
base = getBase(base, rdr);
testOpen(rdr, rdr.nextTag(), HEAD, "Missing header from XML results");
base = getBase(base, rdr);
boolean endedVars = false;
int eventType;
while ((eventType = rdr.nextTag()) != END_ELEMENT || !nameIs(rdr, HEAD)) {
if (eventType == START_ELEMENT) {
if (nameIs(rdr, VARIABLE)) {
if (endedVars) throw new SparqlException("Encountered a variable after header metadata");
String var = rdr.getAttributeValue(null, "name");
if (var != null) cols.add(var);
else logger.warn("<variable> element without 'name' attribute");
} else if (nameIs(rdr, LINK)) {
String b = getBase(base, rdr); // Copy to a new var since we're looping.
String href = rdr.getAttributeValue(null, HREF);
if (href != null) md.add(resolve(b, href));
else logger.warn("<link> element without 'href' attribute");
endedVars = true;
}
}
}
// ending on </head>. next() should be <results> or <boolean>
testClose(rdr, eventType, HEAD, "Unexpected element in header: " + rdr.getLocalName());
} | java | static private void parseHeader(String base, XMLStreamReader rdr, List<String> cols, List<String> md) throws XMLStreamException, SparqlException {
logger.debug("xml:base is initially {}", base);
base = getBase(base, rdr);
testOpen(rdr, rdr.nextTag(), HEAD, "Missing header from XML results");
base = getBase(base, rdr);
boolean endedVars = false;
int eventType;
while ((eventType = rdr.nextTag()) != END_ELEMENT || !nameIs(rdr, HEAD)) {
if (eventType == START_ELEMENT) {
if (nameIs(rdr, VARIABLE)) {
if (endedVars) throw new SparqlException("Encountered a variable after header metadata");
String var = rdr.getAttributeValue(null, "name");
if (var != null) cols.add(var);
else logger.warn("<variable> element without 'name' attribute");
} else if (nameIs(rdr, LINK)) {
String b = getBase(base, rdr); // Copy to a new var since we're looping.
String href = rdr.getAttributeValue(null, HREF);
if (href != null) md.add(resolve(b, href));
else logger.warn("<link> element without 'href' attribute");
endedVars = true;
}
}
}
// ending on </head>. next() should be <results> or <boolean>
testClose(rdr, eventType, HEAD, "Unexpected element in header: " + rdr.getLocalName());
} | [
"static",
"private",
"void",
"parseHeader",
"(",
"String",
"base",
",",
"XMLStreamReader",
"rdr",
",",
"List",
"<",
"String",
">",
"cols",
",",
"List",
"<",
"String",
">",
"md",
")",
"throws",
"XMLStreamException",
",",
"SparqlException",
"{",
"logger",
".",... | Parse the <head> element with the variables and metadata.
@param base The base URI, initialized to the endpoint URL if known.
@param rdr The XML reader to parse information from.
@param cols A list to populate with the columns that may appear in the header.
@param md A list to populate with metada that may appear in the header.
@throws XMLStreamException There was an error reading the XML stream.
@throws SparqlException The XML was not valid SPARQL results. | [
"Parse",
"the",
"<",
";",
"head>",
";",
"element",
"with",
"the",
"variables",
"and",
"metadata",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/parser/XMLResultsParser.java#L194-L219 | train |
revelytix/spark | spark-http-client/src/main/java/spark/protocol/parser/XMLResultsParser.java | XMLResultsParser.nameIs | static final boolean nameIs(XMLStreamReader rdr, Element elt) {
return rdr.getLocalName().equalsIgnoreCase(elt.name());
} | java | static final boolean nameIs(XMLStreamReader rdr, Element elt) {
return rdr.getLocalName().equalsIgnoreCase(elt.name());
} | [
"static",
"final",
"boolean",
"nameIs",
"(",
"XMLStreamReader",
"rdr",
",",
"Element",
"elt",
")",
"{",
"return",
"rdr",
".",
"getLocalName",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"elt",
".",
"name",
"(",
")",
")",
";",
"}"
] | Convenience method to test if the current local name is the same as an expected element.
@param rdr The XMLStreamReader to get the current state from.
@param elt The element to test against.
@return <code>true</code> iff the current local name is the same as the element name. | [
"Convenience",
"method",
"to",
"test",
"if",
"the",
"current",
"local",
"name",
"is",
"the",
"same",
"as",
"an",
"expected",
"element",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/parser/XMLResultsParser.java#L271-L273 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ThreadUtil.java | ThreadUtil.runOnUiThread | public static void runOnUiThread(@NonNull final Runnable runnable) {
Condition.INSTANCE.ensureNotNull(runnable, "The runnable may not be null");
new Handler(Looper.getMainLooper()).post(runnable);
} | java | public static void runOnUiThread(@NonNull final Runnable runnable) {
Condition.INSTANCE.ensureNotNull(runnable, "The runnable may not be null");
new Handler(Looper.getMainLooper()).post(runnable);
} | [
"public",
"static",
"void",
"runOnUiThread",
"(",
"@",
"NonNull",
"final",
"Runnable",
"runnable",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"runnable",
",",
"\"The runnable may not be null\"",
")",
";",
"new",
"Handler",
"(",
"Looper",
... | Executes a specific runnable on the UI thread.
@param runnable
The runnable, which should be executed, as an instance of the type {@link Runnable}.
The runnable may not be null | [
"Executes",
"a",
"specific",
"runnable",
"on",
"the",
"UI",
"thread",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ThreadUtil.java#L44-L47 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java | AbstractDataBinder.notifyOnLoad | @SafeVarargs
private final boolean notifyOnLoad(@NonNull final KeyType key,
@NonNull final ParamType... params) {
boolean result = true;
for (Listener<DataType, KeyType, ViewType, ParamType> listener : listeners) {
result &= listener.onLoadData(this, key, params);
}
return result;
} | java | @SafeVarargs
private final boolean notifyOnLoad(@NonNull final KeyType key,
@NonNull final ParamType... params) {
boolean result = true;
for (Listener<DataType, KeyType, ViewType, ParamType> listener : listeners) {
result &= listener.onLoadData(this, key, params);
}
return result;
} | [
"@",
"SafeVarargs",
"private",
"final",
"boolean",
"notifyOnLoad",
"(",
"@",
"NonNull",
"final",
"KeyType",
"key",
",",
"@",
"NonNull",
"final",
"ParamType",
"...",
"params",
")",
"{",
"boolean",
"result",
"=",
"true",
";",
"for",
"(",
"Listener",
"<",
"Da... | Notifies all listeners, that the data binder starts to load data asynchronously.
@param key
The key of the data, which should be loaded, as an instance of the generic type
KeyType. The key may not be null
@param params
An array, which contains optional parameters, as an array of the type ParamType or an
empty array, if no parameters should be used
@return True, if loading the data should be proceeded, false otherwise | [
"Notifies",
"all",
"listeners",
"that",
"the",
"data",
"binder",
"starts",
"to",
"load",
"data",
"asynchronously",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java#L261-L271 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java | AbstractDataBinder.notifyOnFinished | @SafeVarargs
private final void notifyOnFinished(@NonNull final KeyType key, @Nullable final DataType data,
@NonNull final ViewType view,
@NonNull final ParamType... params) {
for (Listener<DataType, KeyType, ViewType, ParamType> listener : listeners) {
listener.onFinished(this, key, data, view, params);
}
} | java | @SafeVarargs
private final void notifyOnFinished(@NonNull final KeyType key, @Nullable final DataType data,
@NonNull final ViewType view,
@NonNull final ParamType... params) {
for (Listener<DataType, KeyType, ViewType, ParamType> listener : listeners) {
listener.onFinished(this, key, data, view, params);
}
} | [
"@",
"SafeVarargs",
"private",
"final",
"void",
"notifyOnFinished",
"(",
"@",
"NonNull",
"final",
"KeyType",
"key",
",",
"@",
"Nullable",
"final",
"DataType",
"data",
",",
"@",
"NonNull",
"final",
"ViewType",
"view",
",",
"@",
"NonNull",
"final",
"ParamType",
... | Notifies all listeners, that the data binder is showing data, which has been loaded either
asynchronously or from cache.
@param key
The key of the data, which has be loaded, as an instance of the generic type KeyType.
The key may not be null
@param data
The data, which has been loaded, as an instance of the generic type DataType or null,
if no data has been loaded
@param view
The view, which is used to display the data, as an instance of the generic type
ViewType. The view may not be null
@param params
An array, which contains optional parameters, as an array of the type ParamType or an
empty array, if no parameters should be used | [
"Notifies",
"all",
"listeners",
"that",
"the",
"data",
"binder",
"is",
"showing",
"data",
"which",
"has",
"been",
"loaded",
"either",
"asynchronously",
"or",
"from",
"cache",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java#L290-L297 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java | AbstractDataBinder.notifyOnCanceled | private void notifyOnCanceled() {
for (Listener<DataType, KeyType, ViewType, ParamType> listener : listeners) {
listener.onCanceled(this);
}
} | java | private void notifyOnCanceled() {
for (Listener<DataType, KeyType, ViewType, ParamType> listener : listeners) {
listener.onCanceled(this);
}
} | [
"private",
"void",
"notifyOnCanceled",
"(",
")",
"{",
"for",
"(",
"Listener",
"<",
"DataType",
",",
"KeyType",
",",
"ViewType",
",",
"ParamType",
">",
"listener",
":",
"listeners",
")",
"{",
"listener",
".",
"onCanceled",
"(",
"this",
")",
";",
"}",
"}"
... | Notifies all listeners, that the data binder has been canceled. | [
"Notifies",
"all",
"listeners",
"that",
"the",
"data",
"binder",
"has",
"been",
"canceled",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java#L302-L306 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java | AbstractDataBinder.getCachedData | @Nullable
private DataType getCachedData(@NonNull final KeyType key) {
synchronized (cache) {
return cache.get(key);
}
} | java | @Nullable
private DataType getCachedData(@NonNull final KeyType key) {
synchronized (cache) {
return cache.get(key);
}
} | [
"@",
"Nullable",
"private",
"DataType",
"getCachedData",
"(",
"@",
"NonNull",
"final",
"KeyType",
"key",
")",
"{",
"synchronized",
"(",
"cache",
")",
"{",
"return",
"cache",
".",
"get",
"(",
"key",
")",
";",
"}",
"}"
] | Returns the data, which corresponds to a specific key, from the cache.
@param key
The key of the data, which should be retrieved, as an instance of the generic type
KeyType. The key may not be null
@return The data, which has been retrieved, as an instance of the generic type DataType or
null, if no data with the given key is contained by the cache | [
"Returns",
"the",
"data",
"which",
"corresponds",
"to",
"a",
"specific",
"key",
"from",
"the",
"cache",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java#L317-L322 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java | AbstractDataBinder.cacheData | private void cacheData(@NonNull final KeyType key, @NonNull final DataType data) {
synchronized (cache) {
if (useCache) {
cache.put(key, data);
}
}
} | java | private void cacheData(@NonNull final KeyType key, @NonNull final DataType data) {
synchronized (cache) {
if (useCache) {
cache.put(key, data);
}
}
} | [
"private",
"void",
"cacheData",
"(",
"@",
"NonNull",
"final",
"KeyType",
"key",
",",
"@",
"NonNull",
"final",
"DataType",
"data",
")",
"{",
"synchronized",
"(",
"cache",
")",
"{",
"if",
"(",
"useCache",
")",
"{",
"cache",
".",
"put",
"(",
"key",
",",
... | Adds the data, which corresponds to a specific key, to the cache, if caching is enabled.
@param key
The key of the data, which should be added to the cache, as an instance of the
generic type KeyType. The key may not be null
@param data
The data, which should be added to the cache, as an instance of the generic type
DataType. The data may not be null | [
"Adds",
"the",
"data",
"which",
"corresponds",
"to",
"a",
"specific",
"key",
"to",
"the",
"cache",
"if",
"caching",
"is",
"enabled",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java#L334-L340 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java | AbstractDataBinder.loadDataAsynchronously | private void loadDataAsynchronously(
@NonNull final Task<DataType, KeyType, ViewType, ParamType> task) {
threadPool.submit(new Runnable() {
@Override
public void run() {
if (!isCanceled()) {
while (!notifyOnLoad(task.key, task.params)) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
break;
}
}
task.result = loadData(task);
Message message = Message.obtain();
message.obj = task;
sendMessage(message);
}
}
});
} | java | private void loadDataAsynchronously(
@NonNull final Task<DataType, KeyType, ViewType, ParamType> task) {
threadPool.submit(new Runnable() {
@Override
public void run() {
if (!isCanceled()) {
while (!notifyOnLoad(task.key, task.params)) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
break;
}
}
task.result = loadData(task);
Message message = Message.obtain();
message.obj = task;
sendMessage(message);
}
}
});
} | [
"private",
"void",
"loadDataAsynchronously",
"(",
"@",
"NonNull",
"final",
"Task",
"<",
"DataType",
",",
"KeyType",
",",
"ViewType",
",",
"ParamType",
">",
"task",
")",
"{",
"threadPool",
".",
"submit",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override... | Asynchronously executes a specific task in order to load data and to display it afterwards.
@param task
The task, which should be executed, as an instance of the class {@link Task}. The
task may not be null | [
"Asynchronously",
"executes",
"a",
"specific",
"task",
"in",
"order",
"to",
"load",
"data",
"and",
"to",
"display",
"it",
"afterwards",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java#L349-L372 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java | AbstractDataBinder.loadData | @Nullable
private DataType loadData(@NonNull final Task<DataType, KeyType, ViewType, ParamType> task) {
try {
DataType data = doInBackground(task.key, task.params);
if (data != null) {
cacheData(task.key, data);
}
logger.logInfo(getClass(), "Loaded data with key " + task.key);
return data;
} catch (Exception e) {
logger.logError(getClass(), "An error occurred while loading data with key " + task.key,
e);
return null;
}
} | java | @Nullable
private DataType loadData(@NonNull final Task<DataType, KeyType, ViewType, ParamType> task) {
try {
DataType data = doInBackground(task.key, task.params);
if (data != null) {
cacheData(task.key, data);
}
logger.logInfo(getClass(), "Loaded data with key " + task.key);
return data;
} catch (Exception e) {
logger.logError(getClass(), "An error occurred while loading data with key " + task.key,
e);
return null;
}
} | [
"@",
"Nullable",
"private",
"DataType",
"loadData",
"(",
"@",
"NonNull",
"final",
"Task",
"<",
"DataType",
",",
"KeyType",
",",
"ViewType",
",",
"ParamType",
">",
"task",
")",
"{",
"try",
"{",
"DataType",
"data",
"=",
"doInBackground",
"(",
"task",
".",
... | Executes a specific task in order to load data.
@param task
The task, which should be executed, as an instance of the class {@link Task}. The
task may not be null
@return The data, which has been loaded, as an instance of the generic type DataType or null,
if no data has been loaded | [
"Executes",
"a",
"specific",
"task",
"in",
"order",
"to",
"load",
"data",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java#L383-L399 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java | AbstractDataBinder.addListener | public final void addListener(
@NonNull final Listener<DataType, KeyType, ViewType, ParamType> listener) {
listeners.add(listener);
} | java | public final void addListener(
@NonNull final Listener<DataType, KeyType, ViewType, ParamType> listener) {
listeners.add(listener);
} | [
"public",
"final",
"void",
"addListener",
"(",
"@",
"NonNull",
"final",
"Listener",
"<",
"DataType",
",",
"KeyType",
",",
"ViewType",
",",
"ParamType",
">",
"listener",
")",
"{",
"listeners",
".",
"add",
"(",
"listener",
")",
";",
"}"
] | Adds a new listener, which should be notified about the events of the data binder.
@param listener
The listener, which should be added, as an instance of the type {@link Listener}. The
listener may not be null | [
"Adds",
"a",
"new",
"listener",
"which",
"should",
"be",
"notified",
"about",
"the",
"events",
"of",
"the",
"data",
"binder",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java#L592-L595 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java | AbstractDataBinder.removeListener | public final void removeListener(
@NonNull final Listener<DataType, KeyType, ViewType, ParamType> listener) {
listeners.remove(listener);
} | java | public final void removeListener(
@NonNull final Listener<DataType, KeyType, ViewType, ParamType> listener) {
listeners.remove(listener);
} | [
"public",
"final",
"void",
"removeListener",
"(",
"@",
"NonNull",
"final",
"Listener",
"<",
"DataType",
",",
"KeyType",
",",
"ViewType",
",",
"ParamType",
">",
"listener",
")",
"{",
"listeners",
".",
"remove",
"(",
"listener",
")",
";",
"}"
] | Removes a specific listener, which should not be notified about the events of the data
binder, anymore.
@param listener
The listener, which should be removed, as an instance of the type {@link Listener}.
The listener may not be null | [
"Removes",
"a",
"specific",
"listener",
"which",
"should",
"not",
"be",
"notified",
"about",
"the",
"events",
"of",
"the",
"data",
"binder",
"anymore",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java#L605-L608 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java | AbstractDataBinder.load | @SafeVarargs
public final void load(@NonNull final KeyType key, @NonNull final ViewType view,
@NonNull final ParamType... params) {
load(key, view, true, params);
} | java | @SafeVarargs
public final void load(@NonNull final KeyType key, @NonNull final ViewType view,
@NonNull final ParamType... params) {
load(key, view, true, params);
} | [
"@",
"SafeVarargs",
"public",
"final",
"void",
"load",
"(",
"@",
"NonNull",
"final",
"KeyType",
"key",
",",
"@",
"NonNull",
"final",
"ViewType",
"view",
",",
"@",
"NonNull",
"final",
"ParamType",
"...",
"params",
")",
"{",
"load",
"(",
"key",
",",
"view"... | Loads the the data, which corresponds to a specific key, and displays it in a specific view.
If the data has already been loaded, it will be retrieved from the cache. By default, the
data is loaded in a background thread.
@param key
The key of the data, which should be loaded, as an instance of the generic type
KeyType. The key may not be null
@param view
The view, which should be used to display the data, as an instance of the generic
type ViewType. The view may not be null
@param params
An array, which contains optional parameters, as an array of the type ParamType or an
empty array, if no parameters should be used | [
"Loads",
"the",
"the",
"data",
"which",
"corresponds",
"to",
"a",
"specific",
"key",
"and",
"displays",
"it",
"in",
"a",
"specific",
"view",
".",
"If",
"the",
"data",
"has",
"already",
"been",
"loaded",
"it",
"will",
"be",
"retrieved",
"from",
"the",
"ca... | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java#L625-L629 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java | AbstractDataBinder.load | @SafeVarargs
public final void load(@NonNull final KeyType key, @NonNull final ViewType view,
final boolean async, @NonNull final ParamType... params) {
Condition.INSTANCE.ensureNotNull(key, "The key may not be null");
Condition.INSTANCE.ensureNotNull(view, "The view may not be null");
Condition.INSTANCE.ensureNotNull(params, "The array may not be null");
setCanceled(false);
views.put(view, key);
DataType data = getCachedData(key);
if (!isCanceled()) {
if (data != null) {
onPostExecute(view, data, 0, params);
notifyOnFinished(key, data, view, params);
logger.logInfo(getClass(), "Loaded data with key " + key + " from cache");
} else {
onPreExecute(view, params);
Task<DataType, KeyType, ViewType, ParamType> task = new Task<>(view, key, params);
if (async) {
loadDataAsynchronously(task);
} else {
data = loadData(task);
onPostExecute(view, data, 0, params);
notifyOnFinished(key, data, view, params);
}
}
}
} | java | @SafeVarargs
public final void load(@NonNull final KeyType key, @NonNull final ViewType view,
final boolean async, @NonNull final ParamType... params) {
Condition.INSTANCE.ensureNotNull(key, "The key may not be null");
Condition.INSTANCE.ensureNotNull(view, "The view may not be null");
Condition.INSTANCE.ensureNotNull(params, "The array may not be null");
setCanceled(false);
views.put(view, key);
DataType data = getCachedData(key);
if (!isCanceled()) {
if (data != null) {
onPostExecute(view, data, 0, params);
notifyOnFinished(key, data, view, params);
logger.logInfo(getClass(), "Loaded data with key " + key + " from cache");
} else {
onPreExecute(view, params);
Task<DataType, KeyType, ViewType, ParamType> task = new Task<>(view, key, params);
if (async) {
loadDataAsynchronously(task);
} else {
data = loadData(task);
onPostExecute(view, data, 0, params);
notifyOnFinished(key, data, view, params);
}
}
}
} | [
"@",
"SafeVarargs",
"public",
"final",
"void",
"load",
"(",
"@",
"NonNull",
"final",
"KeyType",
"key",
",",
"@",
"NonNull",
"final",
"ViewType",
"view",
",",
"final",
"boolean",
"async",
",",
"@",
"NonNull",
"final",
"ParamType",
"...",
"params",
")",
"{",... | Loads the the data, which corresponds to a specific key, and displays it in a specific view.
If the data has already been loaded, it will be retrieved from the cache.
@param key
The key of the data, which should be loaded, as an instance of the generic type
KeyType. The key may not be null
@param view
The view, which should be used to display the data, as an instance of the generic
type ViewType. The view may not be null
@param async
True, if the data should be loaded in a background thread, false otherwise
@param params
An array, which contains optional parameters, as an array of the type ParamType or an
empty array, if no parameters should be used | [
"Loads",
"the",
"the",
"data",
"which",
"corresponds",
"to",
"a",
"specific",
"key",
"and",
"displays",
"it",
"in",
"a",
"specific",
"view",
".",
"If",
"the",
"data",
"has",
"already",
"been",
"loaded",
"it",
"will",
"be",
"retrieved",
"from",
"the",
"ca... | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java#L647-L675 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java | AbstractDataBinder.isCached | public final boolean isCached(@NonNull final KeyType key) {
Condition.INSTANCE.ensureNotNull(key, "The key may not be null");
synchronized (cache) {
return cache.get(key) != null;
}
} | java | public final boolean isCached(@NonNull final KeyType key) {
Condition.INSTANCE.ensureNotNull(key, "The key may not be null");
synchronized (cache) {
return cache.get(key) != null;
}
} | [
"public",
"final",
"boolean",
"isCached",
"(",
"@",
"NonNull",
"final",
"KeyType",
"key",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"key",
",",
"\"The key may not be null\"",
")",
";",
"synchronized",
"(",
"cache",
")",
"{",
"return",
... | Returns, whether the data, which corresponds to a specific key, is currently cached, or not.
@param key
The key, which corresponds to the data, which should be checked, as an instance of
the generic type KeyType. The key may not be null
@return True, if the data, which corresponds to the given key, is currently cached, false
otherwise | [
"Returns",
"whether",
"the",
"data",
"which",
"corresponds",
"to",
"a",
"specific",
"key",
"is",
"currently",
"cached",
"or",
"not",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java#L706-L712 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java | AbstractDataBinder.useCache | public final void useCache(final boolean useCache) {
synchronized (cache) {
this.useCache = useCache;
logger.logDebug(getClass(), useCache ? "Enabled" : "Disabled" + " caching");
if (!useCache) {
clearCache();
}
}
} | java | public final void useCache(final boolean useCache) {
synchronized (cache) {
this.useCache = useCache;
logger.logDebug(getClass(), useCache ? "Enabled" : "Disabled" + " caching");
if (!useCache) {
clearCache();
}
}
} | [
"public",
"final",
"void",
"useCache",
"(",
"final",
"boolean",
"useCache",
")",
"{",
"synchronized",
"(",
"cache",
")",
"{",
"this",
".",
"useCache",
"=",
"useCache",
";",
"logger",
".",
"logDebug",
"(",
"getClass",
"(",
")",
",",
"useCache",
"?",
"\"En... | Sets, whether data should be cached, or not.
@param useCache
True, if data should be cached, false otherwise. | [
"Sets",
"whether",
"data",
"should",
"be",
"cached",
"or",
"not",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/multithreading/AbstractDataBinder.java#L731-L740 | train |
rahulsom/genealogy | src/main/java/com/github/rahulsom/genealogy/NameDbUsa.java | NameDbUsa.profile | private static void profile(Task task, String message, int tries) {
for (int i = 0; i < tries; i++) {
long start = System.nanoTime();
task.run();
long finish = System.nanoTime();
System.out.println(
String.format("[Try %d] %-30s: %-5.2fms", i + 1, message, (finish - start) / 1000000.0)
);
}
} | java | private static void profile(Task task, String message, int tries) {
for (int i = 0; i < tries; i++) {
long start = System.nanoTime();
task.run();
long finish = System.nanoTime();
System.out.println(
String.format("[Try %d] %-30s: %-5.2fms", i + 1, message, (finish - start) / 1000000.0)
);
}
} | [
"private",
"static",
"void",
"profile",
"(",
"Task",
"task",
",",
"String",
"message",
",",
"int",
"tries",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tries",
";",
"i",
"++",
")",
"{",
"long",
"start",
"=",
"System",
".",
"nanoTi... | Poor mans profiler
@param task task to execute
@param message message identifying the task
@param tries number of times task needs to be executed | [
"Poor",
"mans",
"profiler"
] | 2beb35ab9c6e03080328aa08b18f0a3c5d3f5c12 | https://github.com/rahulsom/genealogy/blob/2beb35ab9c6e03080328aa08b18f0a3c5d3f5c12/src/main/java/com/github/rahulsom/genealogy/NameDbUsa.java#L193-L203 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/ElevationShadowView.java | ElevationShadowView.obtainShadowElevation | private void obtainShadowElevation(@NonNull final TypedArray typedArray) {
int defaultValue = getResources().getDimensionPixelSize(
R.dimen.elevation_shadow_view_shadow_elevation_default_value);
elevation = pixelsToDp(getContext(), typedArray
.getDimensionPixelSize(R.styleable.ElevationShadowView_shadowElevation,
defaultValue));
} | java | private void obtainShadowElevation(@NonNull final TypedArray typedArray) {
int defaultValue = getResources().getDimensionPixelSize(
R.dimen.elevation_shadow_view_shadow_elevation_default_value);
elevation = pixelsToDp(getContext(), typedArray
.getDimensionPixelSize(R.styleable.ElevationShadowView_shadowElevation,
defaultValue));
} | [
"private",
"void",
"obtainShadowElevation",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"int",
"defaultValue",
"=",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"elevation_shadow_view_shadow_elevation_def... | Obtains the elevation of the shadow, which is visualized by the view, from a specific typed
array.
@param typedArray
The typed array, the elevation should be obtained from, as an instance of the class
{@link TypedArray}. The typed array may not be null | [
"Obtains",
"the",
"elevation",
"of",
"the",
"shadow",
"which",
"is",
"visualized",
"by",
"the",
"view",
"from",
"a",
"specific",
"typed",
"array",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ElevationShadowView.java#L117-L123 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/ElevationShadowView.java | ElevationShadowView.obtainShadowOrientation | private void obtainShadowOrientation(@NonNull final TypedArray typedArray) {
int defaultValue = getResources()
.getInteger(R.integer.elevation_shadow_view_shadow_orientation_default_value);
orientation = Orientation.fromValue(typedArray
.getInteger(R.styleable.ElevationShadowView_shadowOrientation, defaultValue));
} | java | private void obtainShadowOrientation(@NonNull final TypedArray typedArray) {
int defaultValue = getResources()
.getInteger(R.integer.elevation_shadow_view_shadow_orientation_default_value);
orientation = Orientation.fromValue(typedArray
.getInteger(R.styleable.ElevationShadowView_shadowOrientation, defaultValue));
} | [
"private",
"void",
"obtainShadowOrientation",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"int",
"defaultValue",
"=",
"getResources",
"(",
")",
".",
"getInteger",
"(",
"R",
".",
"integer",
".",
"elevation_shadow_view_shadow_orientation_default_... | Obtains the orientation of the shadow, which is visualized by the view, from a specific typed
array.
@param typedArray
The typed array, the elevation should be obtained from, as an instance of the class
{@link TypedArray}. The typed array may not be null | [
"Obtains",
"the",
"orientation",
"of",
"the",
"shadow",
"which",
"is",
"visualized",
"by",
"the",
"view",
"from",
"a",
"specific",
"typed",
"array",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ElevationShadowView.java#L133-L138 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/ElevationShadowView.java | ElevationShadowView.obtainEmulateParallelLight | private void obtainEmulateParallelLight(@NonNull final TypedArray typedArray) {
boolean defaultValue = getResources()
.getBoolean(R.bool.elevation_shadow_view_emulate_parallel_light_default_value);
emulateParallelLight = typedArray
.getBoolean(R.styleable.ElevationShadowView_emulateParallelLight, defaultValue);
} | java | private void obtainEmulateParallelLight(@NonNull final TypedArray typedArray) {
boolean defaultValue = getResources()
.getBoolean(R.bool.elevation_shadow_view_emulate_parallel_light_default_value);
emulateParallelLight = typedArray
.getBoolean(R.styleable.ElevationShadowView_emulateParallelLight, defaultValue);
} | [
"private",
"void",
"obtainEmulateParallelLight",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"boolean",
"defaultValue",
"=",
"getResources",
"(",
")",
".",
"getBoolean",
"(",
"R",
".",
"bool",
".",
"elevation_shadow_view_emulate_parallel_light_... | Obtains the boolean value, which specifies whether parallel light should be emulated, from a
specific typed array.
@param typedArray
The typed array, the boolean value should be obtained from, as an instance of the
class {@link TypedArray} | [
"Obtains",
"the",
"boolean",
"value",
"which",
"specifies",
"whether",
"parallel",
"light",
"should",
"be",
"emulated",
"from",
"a",
"specific",
"typed",
"array",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ElevationShadowView.java#L148-L153 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/ElevationShadowView.java | ElevationShadowView.adaptElevationShadow | private void adaptElevationShadow() {
setImageBitmap(
createElevationShadow(getContext(), elevation, orientation, emulateParallelLight));
setScaleType(orientation == Orientation.LEFT || orientation == Orientation.TOP ||
orientation == Orientation.RIGHT || orientation == Orientation.BOTTOM ?
ScaleType.FIT_XY : ScaleType.FIT_CENTER);
} | java | private void adaptElevationShadow() {
setImageBitmap(
createElevationShadow(getContext(), elevation, orientation, emulateParallelLight));
setScaleType(orientation == Orientation.LEFT || orientation == Orientation.TOP ||
orientation == Orientation.RIGHT || orientation == Orientation.BOTTOM ?
ScaleType.FIT_XY : ScaleType.FIT_CENTER);
} | [
"private",
"void",
"adaptElevationShadow",
"(",
")",
"{",
"setImageBitmap",
"(",
"createElevationShadow",
"(",
"getContext",
"(",
")",
",",
"elevation",
",",
"orientation",
",",
"emulateParallelLight",
")",
")",
";",
"setScaleType",
"(",
"orientation",
"==",
"Orie... | Adapts the shadow, which is visualized by the view, depending on its current attributes. | [
"Adapts",
"the",
"shadow",
"which",
"is",
"visualized",
"by",
"the",
"view",
"depending",
"on",
"its",
"current",
"attributes",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ElevationShadowView.java#L158-L164 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/ElevationShadowView.java | ElevationShadowView.setShadowElevation | public final void setShadowElevation(final int elevation) {
Condition.INSTANCE.ensureAtLeast(elevation, 0, "The elevation must be at least 0");
Condition.INSTANCE.ensureAtMaximum(elevation, ElevationUtil.MAX_ELEVATION,
"The elevation must be at maximum " + ElevationUtil.MAX_ELEVATION);
this.elevation = elevation;
adaptElevationShadow();
} | java | public final void setShadowElevation(final int elevation) {
Condition.INSTANCE.ensureAtLeast(elevation, 0, "The elevation must be at least 0");
Condition.INSTANCE.ensureAtMaximum(elevation, ElevationUtil.MAX_ELEVATION,
"The elevation must be at maximum " + ElevationUtil.MAX_ELEVATION);
this.elevation = elevation;
adaptElevationShadow();
} | [
"public",
"final",
"void",
"setShadowElevation",
"(",
"final",
"int",
"elevation",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureAtLeast",
"(",
"elevation",
",",
"0",
",",
"\"The elevation must be at least 0\"",
")",
";",
"Condition",
".",
"INSTANCE",
".",
... | Sets the elevation of the shadow, which should be visualized by the view.
@param elevation
The elevation of the shadow, which should be set, in dp as an {@link Integer} value.
The elevation must be at least 0 and at maximum 16 | [
"Sets",
"the",
"elevation",
"of",
"the",
"shadow",
"which",
"should",
"be",
"visualized",
"by",
"the",
"view",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ElevationShadowView.java#L234-L240 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/ElevationShadowView.java | ElevationShadowView.setShadowOrientation | public final void setShadowOrientation(@NonNull final Orientation orientation) {
Condition.INSTANCE.ensureNotNull(orientation, "The orientation may not be null");
this.orientation = orientation;
adaptElevationShadow();
} | java | public final void setShadowOrientation(@NonNull final Orientation orientation) {
Condition.INSTANCE.ensureNotNull(orientation, "The orientation may not be null");
this.orientation = orientation;
adaptElevationShadow();
} | [
"public",
"final",
"void",
"setShadowOrientation",
"(",
"@",
"NonNull",
"final",
"Orientation",
"orientation",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"orientation",
",",
"\"The orientation may not be null\"",
")",
";",
"this",
".",
"orien... | Sets the orientation of the shadow, which should be visualized by the view.
@param orientation
The orientation, which should be set, 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> | [
"Sets",
"the",
"orientation",
"of",
"the",
"shadow",
"which",
"should",
"be",
"visualized",
"by",
"the",
"view",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ElevationShadowView.java#L263-L267 | train |
avarabyeu/restendpoint | src/main/java/com/github/avarabyeu/restendpoint/http/DefaultErrorHandler.java | DefaultErrorHandler.hasError | @Override
public boolean hasError(Response<ByteSource> rs) {
StatusType statusType = StatusType.valueOf(rs.getStatus());
return (statusType == StatusType.CLIENT_ERROR || statusType == StatusType.SERVER_ERROR);
} | java | @Override
public boolean hasError(Response<ByteSource> rs) {
StatusType statusType = StatusType.valueOf(rs.getStatus());
return (statusType == StatusType.CLIENT_ERROR || statusType == StatusType.SERVER_ERROR);
} | [
"@",
"Override",
"public",
"boolean",
"hasError",
"(",
"Response",
"<",
"ByteSource",
">",
"rs",
")",
"{",
"StatusType",
"statusType",
"=",
"StatusType",
".",
"valueOf",
"(",
"rs",
".",
"getStatus",
"(",
")",
")",
";",
"return",
"(",
"statusType",
"==",
... | Returns TRUE in case status code of response starts with 4 or 5 | [
"Returns",
"TRUE",
"in",
"case",
"status",
"code",
"of",
"response",
"starts",
"with",
"4",
"or",
"5"
] | e11fc0813ea4cefbe4d8bca292cd48b40abf185d | https://github.com/avarabyeu/restendpoint/blob/e11fc0813ea4cefbe4d8bca292cd48b40abf185d/src/main/java/com/github/avarabyeu/restendpoint/http/DefaultErrorHandler.java#L36-L40 | train |
avarabyeu/restendpoint | src/main/java/com/github/avarabyeu/restendpoint/http/DefaultErrorHandler.java | DefaultErrorHandler.handleError | protected void handleError(URI requestUri, HttpMethod requestMethod, int statusCode, String statusMessage,
ByteSource errorBody) throws RestEndpointIOException {
throw new RestEndpointException(requestUri, requestMethod, statusCode, statusMessage, errorBody);
} | java | protected void handleError(URI requestUri, HttpMethod requestMethod, int statusCode, String statusMessage,
ByteSource errorBody) throws RestEndpointIOException {
throw new RestEndpointException(requestUri, requestMethod, statusCode, statusMessage, errorBody);
} | [
"protected",
"void",
"handleError",
"(",
"URI",
"requestUri",
",",
"HttpMethod",
"requestMethod",
",",
"int",
"statusCode",
",",
"String",
"statusMessage",
",",
"ByteSource",
"errorBody",
")",
"throws",
"RestEndpointIOException",
"{",
"throw",
"new",
"RestEndpointExce... | Handler methods for HTTP client errors
@param requestUri - Request URI
@param requestMethod - Request HTTP Method
@param statusCode - HTTP status code
@param statusMessage - HTTP status message
@param errorBody - HTTP response body | [
"Handler",
"methods",
"for",
"HTTP",
"client",
"errors"
] | e11fc0813ea4cefbe4d8bca292cd48b40abf185d | https://github.com/avarabyeu/restendpoint/blob/e11fc0813ea4cefbe4d8bca292cd48b40abf185d/src/main/java/com/github/avarabyeu/restendpoint/http/DefaultErrorHandler.java#L69-L72 | train |
misberner/duzzt | processor/src/main/java/com/github/misberner/duzzt/processor/Duzzt.java | Duzzt.init | public void init(APUtils utils) throws DuzztInitializationException {
URL url = GenerateEDSLProcessor.class.getResource(ST_RESOURCE_NAME);
this.sourceGenGroup = new STGroupFile(
url,
ST_ENCODING,
ST_DELIM_START_CHAR,
ST_DELIM_STOP_CHAR);
sourceGenGroup.setListener(new ReporterDiagnosticListener(utils.getReporter()));
sourceGenGroup.load();
if(!sourceGenGroup.isDefined(ST_MAIN_TEMPLATE_NAME)) {
sourceGenGroup = null;
throw new DuzztInitializationException("Could not find main template '"
+ ST_MAIN_TEMPLATE_NAME + "' in template group file " + url.toString());
}
this.isJava9OrNewer = isJava9OrNewer(utils.getProcessingEnv().getSourceVersion());
} | java | public void init(APUtils utils) throws DuzztInitializationException {
URL url = GenerateEDSLProcessor.class.getResource(ST_RESOURCE_NAME);
this.sourceGenGroup = new STGroupFile(
url,
ST_ENCODING,
ST_DELIM_START_CHAR,
ST_DELIM_STOP_CHAR);
sourceGenGroup.setListener(new ReporterDiagnosticListener(utils.getReporter()));
sourceGenGroup.load();
if(!sourceGenGroup.isDefined(ST_MAIN_TEMPLATE_NAME)) {
sourceGenGroup = null;
throw new DuzztInitializationException("Could not find main template '"
+ ST_MAIN_TEMPLATE_NAME + "' in template group file " + url.toString());
}
this.isJava9OrNewer = isJava9OrNewer(utils.getProcessingEnv().getSourceVersion());
} | [
"public",
"void",
"init",
"(",
"APUtils",
"utils",
")",
"throws",
"DuzztInitializationException",
"{",
"URL",
"url",
"=",
"GenerateEDSLProcessor",
".",
"class",
".",
"getResource",
"(",
"ST_RESOURCE_NAME",
")",
";",
"this",
".",
"sourceGenGroup",
"=",
"new",
"ST... | Initialize the Duzzt embedded DSL generator.
@param utils the APUtils instance wrapping the {@link javax.annotation.processing.ProcessingEnvironment}
@throws DuzztInitializationException if a fatal error occurs during initialization | [
"Initialize",
"the",
"Duzzt",
"embedded",
"DSL",
"generator",
"."
] | 3fb784c1a9142967141743587fe7ad3945d0ac28 | https://github.com/misberner/duzzt/blob/3fb784c1a9142967141743587fe7ad3945d0ac28/processor/src/main/java/com/github/misberner/duzzt/processor/Duzzt.java#L132-L151 | train |
misberner/duzzt | processor/src/main/java/com/github/misberner/duzzt/processor/Duzzt.java | Duzzt.process | public void process(Element elem, GenerateEmbeddedDSL annotation,
Elements elementUtils, Types typeUtils, Filer filer, Reporter reporter) throws IOException {
if(!ElementUtils.checkElementKind(elem, ElementKind.CLASS, ElementKind.INTERFACE)) {
throw new IllegalArgumentException("Annotation " + GenerateEmbeddedDSL.class.getSimpleName()
+ " can only be used on class or interface declarations!");
}
TypeElement te = (TypeElement)elem;
ReporterDiagnosticListener dl = new ReporterDiagnosticListener(reporter);
DSLSettings settings = new DSLSettings(annotation);
DSLSpecification spec = DSLSpecification.create(te, settings, elementUtils, typeUtils);
BricsCompiler compiler = new BricsCompiler(spec.getImplementation());
DuzztAutomaton automaton = compiler.compile(spec.getDSLSyntax(), spec.getSubExpressions());
// Make sure classes have same name if generated twice from the same spec
automaton.reassignStateIds(typeUtils);
render(spec, automaton, filer, dl);
} | java | public void process(Element elem, GenerateEmbeddedDSL annotation,
Elements elementUtils, Types typeUtils, Filer filer, Reporter reporter) throws IOException {
if(!ElementUtils.checkElementKind(elem, ElementKind.CLASS, ElementKind.INTERFACE)) {
throw new IllegalArgumentException("Annotation " + GenerateEmbeddedDSL.class.getSimpleName()
+ " can only be used on class or interface declarations!");
}
TypeElement te = (TypeElement)elem;
ReporterDiagnosticListener dl = new ReporterDiagnosticListener(reporter);
DSLSettings settings = new DSLSettings(annotation);
DSLSpecification spec = DSLSpecification.create(te, settings, elementUtils, typeUtils);
BricsCompiler compiler = new BricsCompiler(spec.getImplementation());
DuzztAutomaton automaton = compiler.compile(spec.getDSLSyntax(), spec.getSubExpressions());
// Make sure classes have same name if generated twice from the same spec
automaton.reassignStateIds(typeUtils);
render(spec, automaton, filer, dl);
} | [
"public",
"void",
"process",
"(",
"Element",
"elem",
",",
"GenerateEmbeddedDSL",
"annotation",
",",
"Elements",
"elementUtils",
",",
"Types",
"typeUtils",
",",
"Filer",
"filer",
",",
"Reporter",
"reporter",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"E... | Process an annotated element.
@param elem the element to process (must be class or interface)
@param annotation the annotation specifying the EDSL
@param elementUtils {@link javax.lang.model} element utilities class
@param typeUtils {@link javax.lang.model} type utilities
@param filer the {@link Filer} used to write output files
@param reporter reporter for error and warning reporting
@throws IOException if writing the generated source code fails | [
"Process",
"an",
"annotated",
"element",
"."
] | 3fb784c1a9142967141743587fe7ad3945d0ac28 | https://github.com/misberner/duzzt/blob/3fb784c1a9142967141743587fe7ad3945d0ac28/processor/src/main/java/com/github/misberner/duzzt/processor/Duzzt.java#L165-L189 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/PermissionUtil.java | PermissionUtil.isPermissionGranted | public static boolean isPermissionGranted(@NonNull final Context context,
@NonNull final String permission) {
Condition.INSTANCE.ensureNotNull(context, "The context may not be null");
Condition.INSTANCE.ensureNotNull(permission, "The permission may not be null");
Condition.INSTANCE.ensureNotEmpty(permission, "The permission may not be empty");
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M ||
ContextCompat.checkSelfPermission(context, permission) ==
PackageManager.PERMISSION_GRANTED;
} | java | public static boolean isPermissionGranted(@NonNull final Context context,
@NonNull final String permission) {
Condition.INSTANCE.ensureNotNull(context, "The context may not be null");
Condition.INSTANCE.ensureNotNull(permission, "The permission may not be null");
Condition.INSTANCE.ensureNotEmpty(permission, "The permission may not be empty");
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M ||
ContextCompat.checkSelfPermission(context, permission) ==
PackageManager.PERMISSION_GRANTED;
} | [
"public",
"static",
"boolean",
"isPermissionGranted",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"NonNull",
"final",
"String",
"permission",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"context",
",",
"\"The context may no... | Returns, whether a specific permission is granted, or not.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param permission
The permission, which should be checked, as a {@link String}, e.g.
<code>android.Manifest.permission.CALL_PHONE</code>. The permission may neither be
null, nor empty
@return True, if the given permission is granted, false otherwise | [
"Returns",
"whether",
"a",
"specific",
"permission",
"is",
"granted",
"or",
"not",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/PermissionUtil.java#L57-L65 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/PermissionUtil.java | PermissionUtil.areAllPermissionsGranted | public static boolean areAllPermissionsGranted(@NonNull final Context context,
@NonNull final String... permissions) {
Condition.INSTANCE.ensureNotNull(context, "The context may not be null");
Condition.INSTANCE.ensureNotNull(permissions, "The array may not be null");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
for (String permission : permissions) {
if (!isPermissionGranted(context, permission)) {
return false;
}
}
}
return true;
} | java | public static boolean areAllPermissionsGranted(@NonNull final Context context,
@NonNull final String... permissions) {
Condition.INSTANCE.ensureNotNull(context, "The context may not be null");
Condition.INSTANCE.ensureNotNull(permissions, "The array may not be null");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
for (String permission : permissions) {
if (!isPermissionGranted(context, permission)) {
return false;
}
}
}
return true;
} | [
"public",
"static",
"boolean",
"areAllPermissionsGranted",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"NonNull",
"final",
"String",
"...",
"permissions",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"context",
",",
"\"The... | Returns, whether all permissions, which are contained by a specific array, are granted, or
not.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param permissions
An array, which contains the permissions, e.g. <code>android.Manifest.permission.CALL_PHONE</code>,
which should be checked, as a {@link String} array. The array may not be null
@return True, if all given permissions are granted, false otherwise | [
"Returns",
"whether",
"all",
"permissions",
"which",
"are",
"contained",
"by",
"a",
"specific",
"array",
"are",
"granted",
"or",
"not",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/PermissionUtil.java#L79-L93 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/PermissionUtil.java | PermissionUtil.getNotGrantedPermissions | @NonNull
public static String[] getNotGrantedPermissions(@NonNull final Context context,
@NonNull final String... permissions) {
Condition.INSTANCE.ensureNotNull(permissions, "The array may not be null");
Collection<String> notGrantedPermissions = new LinkedList<>();
for (String permission : permissions) {
if (!isPermissionGranted(context, permission)) {
notGrantedPermissions.add(permission);
}
}
String[] result = new String[notGrantedPermissions.size()];
notGrantedPermissions.toArray(result);
return result;
} | java | @NonNull
public static String[] getNotGrantedPermissions(@NonNull final Context context,
@NonNull final String... permissions) {
Condition.INSTANCE.ensureNotNull(permissions, "The array may not be null");
Collection<String> notGrantedPermissions = new LinkedList<>();
for (String permission : permissions) {
if (!isPermissionGranted(context, permission)) {
notGrantedPermissions.add(permission);
}
}
String[] result = new String[notGrantedPermissions.size()];
notGrantedPermissions.toArray(result);
return result;
} | [
"@",
"NonNull",
"public",
"static",
"String",
"[",
"]",
"getNotGrantedPermissions",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"NonNull",
"final",
"String",
"...",
"permissions",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
... | Returns the subset of specific permissions, which are not granted.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param permissions
An array, which contains the permissions, e.g. <code>android.Manifest.CALL_PHONE</code>,
which should be checked, as a {@link String} array. The array may not be null
@return An array, which contains the permissions, which are not granted, as a {@link String}
array or an empty array, if all permissions are granted | [
"Returns",
"the",
"subset",
"of",
"specific",
"permissions",
"which",
"are",
"not",
"granted",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/PermissionUtil.java#L107-L122 | train |
MKLab-ITI/simmo | src/main/java/gr/iti/mklab/simmo/core/morphia/ObjectDAO.java | ObjectDAO.findByDate | private List<O> findByDate(String dateField, Date start, Date end, int numObjects, boolean asc) {
if (start == null)
start = new Date(0);
if (end == null)
end = new Date();
return getDatastore().find(clazz).filter(dateField + " >", start).filter(dateField + " <", end).order(asc ? dateField : '-' + dateField).limit(numObjects).asList();
} | java | private List<O> findByDate(String dateField, Date start, Date end, int numObjects, boolean asc) {
if (start == null)
start = new Date(0);
if (end == null)
end = new Date();
return getDatastore().find(clazz).filter(dateField + " >", start).filter(dateField + " <", end).order(asc ? dateField : '-' + dateField).limit(numObjects).asList();
} | [
"private",
"List",
"<",
"O",
">",
"findByDate",
"(",
"String",
"dateField",
",",
"Date",
"start",
",",
"Date",
"end",
",",
"int",
"numObjects",
",",
"boolean",
"asc",
")",
"{",
"if",
"(",
"start",
"==",
"null",
")",
"start",
"=",
"new",
"Date",
"(",
... | A private helper method that can be applied to "creationDate", "crawledDate", "lastModifiedDate".
For usage sample see the methods below
@param dateField
@param start
@param end
@param numObjects
@param asc
@return | [
"A",
"private",
"helper",
"method",
"that",
"can",
"be",
"applied",
"to",
"creationDate",
"crawledDate",
"lastModifiedDate",
".",
"For",
"usage",
"sample",
"see",
"the",
"methods",
"below"
] | a78436e982e160fb0260746c563c7e4d24736486 | https://github.com/MKLab-ITI/simmo/blob/a78436e982e160fb0260746c563c7e4d24736486/src/main/java/gr/iti/mklab/simmo/core/morphia/ObjectDAO.java#L55-L61 | train |
MKLab-ITI/simmo | src/main/java/gr/iti/mklab/simmo/core/morphia/ObjectDAO.java | ObjectDAO.createdInPeriod | public List<O> createdInPeriod(Date start, Date end, int numObjects) {
return findByDate("creationDate", start, end, numObjects, true);
} | java | public List<O> createdInPeriod(Date start, Date end, int numObjects) {
return findByDate("creationDate", start, end, numObjects, true);
} | [
"public",
"List",
"<",
"O",
">",
"createdInPeriod",
"(",
"Date",
"start",
",",
"Date",
"end",
",",
"int",
"numObjects",
")",
"{",
"return",
"findByDate",
"(",
"\"creationDate\"",
",",
"start",
",",
"end",
",",
"numObjects",
",",
"true",
")",
";",
"}"
] | Returns a list of images created in the time period specified by start and end
@param start
@param end
@param numObjects
@return | [
"Returns",
"a",
"list",
"of",
"images",
"created",
"in",
"the",
"time",
"period",
"specified",
"by",
"start",
"and",
"end"
] | a78436e982e160fb0260746c563c7e4d24736486 | https://github.com/MKLab-ITI/simmo/blob/a78436e982e160fb0260746c563c7e4d24736486/src/main/java/gr/iti/mklab/simmo/core/morphia/ObjectDAO.java#L93-L95 | train |
MKLab-ITI/simmo | src/main/java/gr/iti/mklab/simmo/core/morphia/ObjectDAO.java | ObjectDAO.similar | public List<Similarity> similar(Image object, double threshold) {
//return getDatastore().find(Similarity.class).field("firstObject").equal(object).order("similarityScore").asList();
Query<Similarity> q = getDatastore().createQuery(Similarity.class);
q.or(
q.criteria("firstObject").equal(object),
q.criteria("secondObject").equal(object)
);
return q.order("-similarityScore").filter("similarityScore >", threshold).asList();
} | java | public List<Similarity> similar(Image object, double threshold) {
//return getDatastore().find(Similarity.class).field("firstObject").equal(object).order("similarityScore").asList();
Query<Similarity> q = getDatastore().createQuery(Similarity.class);
q.or(
q.criteria("firstObject").equal(object),
q.criteria("secondObject").equal(object)
);
return q.order("-similarityScore").filter("similarityScore >", threshold).asList();
} | [
"public",
"List",
"<",
"Similarity",
">",
"similar",
"(",
"Image",
"object",
",",
"double",
"threshold",
")",
"{",
"//return getDatastore().find(Similarity.class).field(\"firstObject\").equal(object).order(\"similarityScore\").asList();",
"Query",
"<",
"Similarity",
">",
"q",
... | Returns a list of objects that are similar to the specified object
@param object
@param threshold
@return | [
"Returns",
"a",
"list",
"of",
"objects",
"that",
"are",
"similar",
"to",
"the",
"specified",
"object"
] | a78436e982e160fb0260746c563c7e4d24736486 | https://github.com/MKLab-ITI/simmo/blob/a78436e982e160fb0260746c563c7e4d24736486/src/main/java/gr/iti/mklab/simmo/core/morphia/ObjectDAO.java#L104-L112 | train |
edwardcapriolo/teknek-core | src/main/java/io/teknek/datalayer/WorkerDao.java | WorkerDao.createZookeeperBase | public void createZookeeperBase() throws WorkerDaoException {
createPersistentEmptyNodeIfNotExist(BASE_ZK);
createPersistentEmptyNodeIfNotExist(WORKERS_ZK);
createPersistentEmptyNodeIfNotExist(PLANS_ZK);
createPersistentEmptyNodeIfNotExist(SAVED_ZK);
createPersistentEmptyNodeIfNotExist(LOCKS_ZK);
createPersistentEmptyNodeIfNotExist(PLAN_WORKERS_ZK);
} | java | public void createZookeeperBase() throws WorkerDaoException {
createPersistentEmptyNodeIfNotExist(BASE_ZK);
createPersistentEmptyNodeIfNotExist(WORKERS_ZK);
createPersistentEmptyNodeIfNotExist(PLANS_ZK);
createPersistentEmptyNodeIfNotExist(SAVED_ZK);
createPersistentEmptyNodeIfNotExist(LOCKS_ZK);
createPersistentEmptyNodeIfNotExist(PLAN_WORKERS_ZK);
} | [
"public",
"void",
"createZookeeperBase",
"(",
")",
"throws",
"WorkerDaoException",
"{",
"createPersistentEmptyNodeIfNotExist",
"(",
"BASE_ZK",
")",
";",
"createPersistentEmptyNodeIfNotExist",
"(",
"WORKERS_ZK",
")",
";",
"createPersistentEmptyNodeIfNotExist",
"(",
"PLANS_ZK",... | Creates all the required base directories in ZK for the application to run | [
"Creates",
"all",
"the",
"required",
"base",
"directories",
"in",
"ZK",
"for",
"the",
"application",
"to",
"run"
] | 4fa972d11044dee2954c0cc5e1b53b18fba319b9 | https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/datalayer/WorkerDao.java#L121-L128 | train |
edwardcapriolo/teknek-core | src/main/java/io/teknek/datalayer/WorkerDao.java | WorkerDao.findWorkersWorkingOnPlan | public List<String> findWorkersWorkingOnPlan(Plan plan) throws WorkerDaoException{
try {
Stat exists = framework.getCuratorFramework().checkExists().forPath(PLAN_WORKERS_ZK + "/" + plan.getName());
if (exists == null ){
return new ArrayList<String>();
}
return framework.getCuratorFramework().getChildren().forPath(PLAN_WORKERS_ZK + "/" + plan.getName());
} catch (Exception e) {
throw new WorkerDaoException(e);
}
} | java | public List<String> findWorkersWorkingOnPlan(Plan plan) throws WorkerDaoException{
try {
Stat exists = framework.getCuratorFramework().checkExists().forPath(PLAN_WORKERS_ZK + "/" + plan.getName());
if (exists == null ){
return new ArrayList<String>();
}
return framework.getCuratorFramework().getChildren().forPath(PLAN_WORKERS_ZK + "/" + plan.getName());
} catch (Exception e) {
throw new WorkerDaoException(e);
}
} | [
"public",
"List",
"<",
"String",
">",
"findWorkersWorkingOnPlan",
"(",
"Plan",
"plan",
")",
"throws",
"WorkerDaoException",
"{",
"try",
"{",
"Stat",
"exists",
"=",
"framework",
".",
"getCuratorFramework",
"(",
")",
".",
"checkExists",
"(",
")",
".",
"forPath",... | Returns the node name of all the ephemeral nodes under a plan. This is effectively who is
working on the plan.
@param plan
@return
@throws WorkerDaoException If there are zookeeper problems | [
"Returns",
"the",
"node",
"name",
"of",
"all",
"the",
"ephemeral",
"nodes",
"under",
"a",
"plan",
".",
"This",
"is",
"effectively",
"who",
"is",
"working",
"on",
"the",
"plan",
"."
] | 4fa972d11044dee2954c0cc5e1b53b18fba319b9 | https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/datalayer/WorkerDao.java#L137-L147 | train |
edwardcapriolo/teknek-core | src/main/java/io/teknek/datalayer/WorkerDao.java | WorkerDao.findPlanByName | public Plan findPlanByName(String name) throws WorkerDaoException {
Stat planStat;
byte[] planBytes;
try {
planStat = framework.getCuratorFramework().checkExists().forPath(PLANS_ZK + "/" + name);
if (planStat == null) {
return null;
}
planBytes = framework.getCuratorFramework().getData().forPath(PLANS_ZK + "/" + name);
} catch (Exception e) {
LOGGER.warn(e);
throw new WorkerDaoException(e);
}
Plan p = null;
try {
p = deserializePlan(planBytes);
} catch (JsonParseException | JsonMappingException e) {
LOGGER.warn("while parsing plan " + name, e);
} catch (IOException e) {
LOGGER.warn("while parsing plan " + name, e);
}
return p;
} | java | public Plan findPlanByName(String name) throws WorkerDaoException {
Stat planStat;
byte[] planBytes;
try {
planStat = framework.getCuratorFramework().checkExists().forPath(PLANS_ZK + "/" + name);
if (planStat == null) {
return null;
}
planBytes = framework.getCuratorFramework().getData().forPath(PLANS_ZK + "/" + name);
} catch (Exception e) {
LOGGER.warn(e);
throw new WorkerDaoException(e);
}
Plan p = null;
try {
p = deserializePlan(planBytes);
} catch (JsonParseException | JsonMappingException e) {
LOGGER.warn("while parsing plan " + name, e);
} catch (IOException e) {
LOGGER.warn("while parsing plan " + name, e);
}
return p;
} | [
"public",
"Plan",
"findPlanByName",
"(",
"String",
"name",
")",
"throws",
"WorkerDaoException",
"{",
"Stat",
"planStat",
";",
"byte",
"[",
"]",
"planBytes",
";",
"try",
"{",
"planStat",
"=",
"framework",
".",
"getCuratorFramework",
"(",
")",
".",
"checkExists"... | Search zookeeper for a plan with given name.
@param name
@return null if plan not found, null if plan is corrupt data
@throws WorkerDaoException
for zookeeper problems | [
"Search",
"zookeeper",
"for",
"a",
"plan",
"with",
"given",
"name",
"."
] | 4fa972d11044dee2954c0cc5e1b53b18fba319b9 | https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/datalayer/WorkerDao.java#L173-L195 | train |
edwardcapriolo/teknek-core | src/main/java/io/teknek/datalayer/WorkerDao.java | WorkerDao.createOrUpdatePlan | public void createOrUpdatePlan(Plan plan) throws WorkerDaoException {
try {
createZookeeperBase();
Stat s = this.framework.getCuratorFramework().checkExists().forPath(PLANS_ZK + "/" + plan.getName());
if (s != null) {
framework.getCuratorFramework().setData().withVersion(s.getVersion())
.forPath(PLANS_ZK + "/" + plan.getName(), serializePlan(plan));
} else {
framework.getCuratorFramework().create().withMode(CreateMode.PERSISTENT)
.withACL(Ids.OPEN_ACL_UNSAFE)
.forPath(PLANS_ZK + "/" + plan.getName(), serializePlan(plan));
}
} catch (Exception e) {
LOGGER.warn(e);
throw new WorkerDaoException(e);
}
} | java | public void createOrUpdatePlan(Plan plan) throws WorkerDaoException {
try {
createZookeeperBase();
Stat s = this.framework.getCuratorFramework().checkExists().forPath(PLANS_ZK + "/" + plan.getName());
if (s != null) {
framework.getCuratorFramework().setData().withVersion(s.getVersion())
.forPath(PLANS_ZK + "/" + plan.getName(), serializePlan(plan));
} else {
framework.getCuratorFramework().create().withMode(CreateMode.PERSISTENT)
.withACL(Ids.OPEN_ACL_UNSAFE)
.forPath(PLANS_ZK + "/" + plan.getName(), serializePlan(plan));
}
} catch (Exception e) {
LOGGER.warn(e);
throw new WorkerDaoException(e);
}
} | [
"public",
"void",
"createOrUpdatePlan",
"(",
"Plan",
"plan",
")",
"throws",
"WorkerDaoException",
"{",
"try",
"{",
"createZookeeperBase",
"(",
")",
";",
"Stat",
"s",
"=",
"this",
".",
"framework",
".",
"getCuratorFramework",
"(",
")",
".",
"checkExists",
"(",
... | Creates or updates a plan in zookeeper.
@param plan
@throws WorkerDaoException if malformed plan or communication error with zookeeper | [
"Creates",
"or",
"updates",
"a",
"plan",
"in",
"zookeeper",
"."
] | 4fa972d11044dee2954c0cc5e1b53b18fba319b9 | https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/datalayer/WorkerDao.java#L217-L233 | train |
edwardcapriolo/teknek-core | src/main/java/io/teknek/datalayer/WorkerDao.java | WorkerDao.createEphemeralNodeForDaemon | public void createEphemeralNodeForDaemon(TeknekDaemon d) throws WorkerDaoException {
try {
byte [] hostbytes = d.getHostname().getBytes(ENCODING);
framework.getCuratorFramework().create()
.withMode(CreateMode.EPHEMERAL).withACL(Ids.OPEN_ACL_UNSAFE).forPath(WORKERS_ZK + "/" + d.getMyId(),
hostbytes);
} catch (Exception e) {
LOGGER.warn(e);
throw new WorkerDaoException(e);
}
} | java | public void createEphemeralNodeForDaemon(TeknekDaemon d) throws WorkerDaoException {
try {
byte [] hostbytes = d.getHostname().getBytes(ENCODING);
framework.getCuratorFramework().create()
.withMode(CreateMode.EPHEMERAL).withACL(Ids.OPEN_ACL_UNSAFE).forPath(WORKERS_ZK + "/" + d.getMyId(),
hostbytes);
} catch (Exception e) {
LOGGER.warn(e);
throw new WorkerDaoException(e);
}
} | [
"public",
"void",
"createEphemeralNodeForDaemon",
"(",
"TeknekDaemon",
"d",
")",
"throws",
"WorkerDaoException",
"{",
"try",
"{",
"byte",
"[",
"]",
"hostbytes",
"=",
"d",
".",
"getHostname",
"(",
")",
".",
"getBytes",
"(",
"ENCODING",
")",
";",
"framework",
... | Creates an ephemeral node so that we can determine how many current live nodes there are
@param zk
@param d
@throws WorkerDaoException | [
"Creates",
"an",
"ephemeral",
"node",
"so",
"that",
"we",
"can",
"determine",
"how",
"many",
"current",
"live",
"nodes",
"there",
"are"
] | 4fa972d11044dee2954c0cc5e1b53b18fba319b9 | https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/datalayer/WorkerDao.java#L241-L251 | train |
edwardcapriolo/teknek-core | src/main/java/io/teknek/datalayer/WorkerDao.java | WorkerDao.findAllWorkerStatusForPlan | public List<WorkerStatus> findAllWorkerStatusForPlan(Plan plan, List<String> otherWorkers) throws WorkerDaoException{
List<WorkerStatus> results = new ArrayList<WorkerStatus>();
try {
Stat preCheck = framework.getCuratorFramework().checkExists().forPath(PLAN_WORKERS_ZK + "/" + plan.getName());
if (preCheck == null){
return results;
}
} catch (Exception e1) {
LOGGER.warn(e1);
throw new WorkerDaoException(e1);
}
for (String worker : otherWorkers) {
String lookAtPath = PLAN_WORKERS_ZK + "/" + plan.getName() + "/" + worker;
try {
Stat stat = framework.getCuratorFramework().checkExists().forPath(lookAtPath);
byte[] data = framework.getCuratorFramework().getData().storingStatIn(stat).forPath(lookAtPath);
results.add(MAPPER.readValue(data, WorkerStatus.class));
} catch (Exception e) {
LOGGER.warn(e);
throw new WorkerDaoException(e);
}
}
return results;
} | java | public List<WorkerStatus> findAllWorkerStatusForPlan(Plan plan, List<String> otherWorkers) throws WorkerDaoException{
List<WorkerStatus> results = new ArrayList<WorkerStatus>();
try {
Stat preCheck = framework.getCuratorFramework().checkExists().forPath(PLAN_WORKERS_ZK + "/" + plan.getName());
if (preCheck == null){
return results;
}
} catch (Exception e1) {
LOGGER.warn(e1);
throw new WorkerDaoException(e1);
}
for (String worker : otherWorkers) {
String lookAtPath = PLAN_WORKERS_ZK + "/" + plan.getName() + "/" + worker;
try {
Stat stat = framework.getCuratorFramework().checkExists().forPath(lookAtPath);
byte[] data = framework.getCuratorFramework().getData().storingStatIn(stat).forPath(lookAtPath);
results.add(MAPPER.readValue(data, WorkerStatus.class));
} catch (Exception e) {
LOGGER.warn(e);
throw new WorkerDaoException(e);
}
}
return results;
} | [
"public",
"List",
"<",
"WorkerStatus",
">",
"findAllWorkerStatusForPlan",
"(",
"Plan",
"plan",
",",
"List",
"<",
"String",
">",
"otherWorkers",
")",
"throws",
"WorkerDaoException",
"{",
"List",
"<",
"WorkerStatus",
">",
"results",
"=",
"new",
"ArrayList",
"<",
... | Gets the status of each worker. The status contains the partitionId being consumed. This information
helps the next worker bind to an unconsumed partition
@param plan
@param otherWorkers
@return
@throws WorkerDaoException | [
"Gets",
"the",
"status",
"of",
"each",
"worker",
".",
"The",
"status",
"contains",
"the",
"partitionId",
"being",
"consumed",
".",
"This",
"information",
"helps",
"the",
"next",
"worker",
"bind",
"to",
"an",
"unconsumed",
"partition"
] | 4fa972d11044dee2954c0cc5e1b53b18fba319b9 | https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/datalayer/WorkerDao.java#L275-L298 | train |
edwardcapriolo/teknek-core | src/main/java/io/teknek/datalayer/WorkerDao.java | WorkerDao.registerWorkerStatus | public void registerWorkerStatus(ZooKeeper zk, Plan plan, WorkerStatus s) throws WorkerDaoException{
String writeToPath = PLAN_WORKERS_ZK + "/" + plan.getName() + "/" + s.getWorkerUuid();
try {
Stat planBase = zk.exists(PLAN_WORKERS_ZK + "/" + plan.getName(), false);
if (planBase == null){
try {
zk.create(PLAN_WORKERS_ZK + "/" + plan.getName(), new byte [0] , Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
} catch (Exception ignore){}
}
zk.create(writeToPath, MAPPER.writeValueAsBytes(s), Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
LOGGER.debug("Registered as ephemeral " + writeToPath);
zk.exists(PLANS_ZK + "/" + plan.getName(), true); //watch job for events
} catch (KeeperException | InterruptedException | IOException e) {
LOGGER.warn(e);
throw new WorkerDaoException(e);
}
} | java | public void registerWorkerStatus(ZooKeeper zk, Plan plan, WorkerStatus s) throws WorkerDaoException{
String writeToPath = PLAN_WORKERS_ZK + "/" + plan.getName() + "/" + s.getWorkerUuid();
try {
Stat planBase = zk.exists(PLAN_WORKERS_ZK + "/" + plan.getName(), false);
if (planBase == null){
try {
zk.create(PLAN_WORKERS_ZK + "/" + plan.getName(), new byte [0] , Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
} catch (Exception ignore){}
}
zk.create(writeToPath, MAPPER.writeValueAsBytes(s), Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
LOGGER.debug("Registered as ephemeral " + writeToPath);
zk.exists(PLANS_ZK + "/" + plan.getName(), true); //watch job for events
} catch (KeeperException | InterruptedException | IOException e) {
LOGGER.warn(e);
throw new WorkerDaoException(e);
}
} | [
"public",
"void",
"registerWorkerStatus",
"(",
"ZooKeeper",
"zk",
",",
"Plan",
"plan",
",",
"WorkerStatus",
"s",
")",
"throws",
"WorkerDaoException",
"{",
"String",
"writeToPath",
"=",
"PLAN_WORKERS_ZK",
"+",
"\"/\"",
"+",
"plan",
".",
"getName",
"(",
")",
"+"... | Registers an ephemeral node representing ownership of a feed partition.
Note we do not use curator here because we want a standard watch not from the main thread!
@param zk
@param plan
@param s
@throws WorkerDaoException | [
"Registers",
"an",
"ephemeral",
"node",
"representing",
"ownership",
"of",
"a",
"feed",
"partition",
".",
"Note",
"we",
"do",
"not",
"use",
"curator",
"here",
"because",
"we",
"want",
"a",
"standard",
"watch",
"not",
"from",
"the",
"main",
"thread!"
] | 4fa972d11044dee2954c0cc5e1b53b18fba319b9 | https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/datalayer/WorkerDao.java#L308-L324 | train |
edwardcapriolo/teknek-core | src/main/java/io/teknek/datalayer/WorkerDao.java | WorkerDao.deletePlan | public void deletePlan(Plan p) throws WorkerDaoException {
String planNode = PLANS_ZK + "/" + p.getName();
try {
Stat s = framework.getCuratorFramework().checkExists().forPath(planNode);
framework.getCuratorFramework().delete().withVersion(s.getVersion()).forPath(planNode);
} catch (Exception e) {
throw new WorkerDaoException(e);
}
} | java | public void deletePlan(Plan p) throws WorkerDaoException {
String planNode = PLANS_ZK + "/" + p.getName();
try {
Stat s = framework.getCuratorFramework().checkExists().forPath(planNode);
framework.getCuratorFramework().delete().withVersion(s.getVersion()).forPath(planNode);
} catch (Exception e) {
throw new WorkerDaoException(e);
}
} | [
"public",
"void",
"deletePlan",
"(",
"Plan",
"p",
")",
"throws",
"WorkerDaoException",
"{",
"String",
"planNode",
"=",
"PLANS_ZK",
"+",
"\"/\"",
"+",
"p",
".",
"getName",
"(",
")",
";",
"try",
"{",
"Stat",
"s",
"=",
"framework",
".",
"getCuratorFramework",... | Note you should call stop the plan if it is running before deleting
@param p
@throws WorkerDaoException | [
"Note",
"you",
"should",
"call",
"stop",
"the",
"plan",
"if",
"it",
"is",
"running",
"before",
"deleting"
] | 4fa972d11044dee2954c0cc5e1b53b18fba319b9 | https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/datalayer/WorkerDao.java#L444-L452 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ArrayUtil.java | ArrayUtil.indexOf | public static int indexOf(@NonNull final boolean[] array, final boolean value) {
Condition.INSTANCE.ensureNotNull(array, "The array may not be null");
for (int i = 0; i < array.length; i++) {
if (array[i] == value) {
return i;
}
}
return -1;
} | java | public static int indexOf(@NonNull final boolean[] array, final boolean value) {
Condition.INSTANCE.ensureNotNull(array, "The array may not be null");
for (int i = 0; i < array.length; i++) {
if (array[i] == value) {
return i;
}
}
return -1;
} | [
"public",
"static",
"int",
"indexOf",
"(",
"@",
"NonNull",
"final",
"boolean",
"[",
"]",
"array",
",",
"final",
"boolean",
"value",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"array",
",",
"\"The array may not be null\"",
")",
";",
"f... | Returns the index of the first item of an array, which equals a specific boolean value.
@param array
The array, which should be checked, as a {@link Boolean} array. The array may not be
null
@param value
The value, which should be checked, as a {@link Boolean} value
@return The index of the first item, which equals the given boolean value, as an {@link
Integer} value or -1, if no item of the array equals the value | [
"Returns",
"the",
"index",
"of",
"the",
"first",
"item",
"of",
"an",
"array",
"which",
"equals",
"a",
"specific",
"boolean",
"value",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ArrayUtil.java#L45-L54 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/AbstractViewRecycler.java | AbstractViewRecycler.addUnusedView | protected final void addUnusedView(@NonNull final View view, final int viewType) {
if (useCache) {
if (unusedViews == null) {
unusedViews = new SparseArray<>(adapter.getViewTypeCount());
}
Queue<View> queue = unusedViews.get(viewType);
if (queue == null) {
queue = new LinkedList<>();
unusedViews.put(viewType, queue);
}
queue.add(view);
}
} | java | protected final void addUnusedView(@NonNull final View view, final int viewType) {
if (useCache) {
if (unusedViews == null) {
unusedViews = new SparseArray<>(adapter.getViewTypeCount());
}
Queue<View> queue = unusedViews.get(viewType);
if (queue == null) {
queue = new LinkedList<>();
unusedViews.put(viewType, queue);
}
queue.add(view);
}
} | [
"protected",
"final",
"void",
"addUnusedView",
"(",
"@",
"NonNull",
"final",
"View",
"view",
",",
"final",
"int",
"viewType",
")",
"{",
"if",
"(",
"useCache",
")",
"{",
"if",
"(",
"unusedViews",
"==",
"null",
")",
"{",
"unusedViews",
"=",
"new",
"SparseA... | Adds an unused view to the cache.
@param view
The unused view, which should be added to the cache, as an instance of the class
{@link View}. The view may not be null
@param viewType
The view type, the unused view corresponds to, as an {@link Integer} value | [
"Adds",
"an",
"unused",
"view",
"to",
"the",
"cache",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/AbstractViewRecycler.java#L212-L227 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/AbstractViewRecycler.java | AbstractViewRecycler.pollUnusedView | @Nullable
protected final View pollUnusedView(final int viewType) {
if (useCache && unusedViews != null) {
Queue<View> queue = unusedViews.get(viewType);
if (queue != null) {
return queue.poll();
}
}
return null;
} | java | @Nullable
protected final View pollUnusedView(final int viewType) {
if (useCache && unusedViews != null) {
Queue<View> queue = unusedViews.get(viewType);
if (queue != null) {
return queue.poll();
}
}
return null;
} | [
"@",
"Nullable",
"protected",
"final",
"View",
"pollUnusedView",
"(",
"final",
"int",
"viewType",
")",
"{",
"if",
"(",
"useCache",
"&&",
"unusedViews",
"!=",
"null",
")",
"{",
"Queue",
"<",
"View",
">",
"queue",
"=",
"unusedViews",
".",
"get",
"(",
"view... | Retrieves an unused view, which corresponds to a specific view type, from the cache, if any
is available.
@param viewType
The view type of the unused view, which should be retrieved, as an {@link Integer}
value
@return An unused view, which corresponds to the given view type, as an instance of the class
{@link View} or null, if no such view is available in the cache | [
"Retrieves",
"an",
"unused",
"view",
"which",
"corresponds",
"to",
"a",
"specific",
"view",
"type",
"from",
"the",
"cache",
"if",
"any",
"is",
"available",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/AbstractViewRecycler.java#L239-L250 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/AbstractViewRecycler.java | AbstractViewRecycler.getView | @Nullable
public final View getView(@NonNull final ItemType item) {
Condition.INSTANCE.ensureNotNull(item, "The item may not be null");
return activeViews.get(item);
} | java | @Nullable
public final View getView(@NonNull final ItemType item) {
Condition.INSTANCE.ensureNotNull(item, "The item may not be null");
return activeViews.get(item);
} | [
"@",
"Nullable",
"public",
"final",
"View",
"getView",
"(",
"@",
"NonNull",
"final",
"ItemType",
"item",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"item",
",",
"\"The item may not be null\"",
")",
";",
"return",
"activeViews",
".",
"ge... | Returns the view, which is currently used to visualize a specific item.
@param item
The item, whose view should be returned, as an instance of the generic type ItemType.
The item may not be null
@return The view, which is currently used to visualize the given item, as an instance of the
type ItemType or null, if no such view is currently inflated | [
"Returns",
"the",
"view",
"which",
"is",
"currently",
"used",
"to",
"visualize",
"a",
"specific",
"item",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/AbstractViewRecycler.java#L429-L433 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/AbstractViewRecycler.java | AbstractViewRecycler.clearCache | public final void clearCache() {
if (unusedViews != null) {
unusedViews.clear();
unusedViews = null;
}
logger.logDebug(getClass(), "Removed all unused views from cache");
} | java | public final void clearCache() {
if (unusedViews != null) {
unusedViews.clear();
unusedViews = null;
}
logger.logDebug(getClass(), "Removed all unused views from cache");
} | [
"public",
"final",
"void",
"clearCache",
"(",
")",
"{",
"if",
"(",
"unusedViews",
"!=",
"null",
")",
"{",
"unusedViews",
".",
"clear",
"(",
")",
";",
"unusedViews",
"=",
"null",
";",
"}",
"logger",
".",
"logDebug",
"(",
"getClass",
"(",
")",
",",
"\"... | Removes all unused views from the cache. | [
"Removes",
"all",
"unused",
"views",
"from",
"the",
"cache",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/AbstractViewRecycler.java#L477-L484 | train |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/AbstractViewRecycler.java | AbstractViewRecycler.clearCache | public final void clearCache(final int viewType) {
if (unusedViews != null) {
unusedViews.remove(viewType);
}
logger.logDebug(getClass(),
"Removed all unused views of view type " + viewType + " from cache");
} | java | public final void clearCache(final int viewType) {
if (unusedViews != null) {
unusedViews.remove(viewType);
}
logger.logDebug(getClass(),
"Removed all unused views of view type " + viewType + " from cache");
} | [
"public",
"final",
"void",
"clearCache",
"(",
"final",
"int",
"viewType",
")",
"{",
"if",
"(",
"unusedViews",
"!=",
"null",
")",
"{",
"unusedViews",
".",
"remove",
"(",
"viewType",
")",
";",
"}",
"logger",
".",
"logDebug",
"(",
"getClass",
"(",
")",
",... | Removes all unused views, which correspond to a specific view type, from the cache.
@param viewType
The view type of the unused views, which should be removed from the cache, as an
{@link Integer} value | [
"Removes",
"all",
"unused",
"views",
"which",
"correspond",
"to",
"a",
"specific",
"view",
"type",
"from",
"the",
"cache",
"."
] | 67ec0e5732344eeb4d946dd1f96d782939e449f4 | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/AbstractViewRecycler.java#L493-L500 | train |
edwardcapriolo/teknek-core | src/main/java/io/teknek/daemon/Worker.java | Worker.init | public void init(){
try {
zk = new ZooKeeper(parent.getProperties().get(TeknekDaemon.ZK_SERVER_LIST).toString(), 30000, this);
} catch (IOException e1) {
throw new RuntimeException(e1);
}
Feed feed = DriverFactory.buildFeed(plan.getFeedDesc());
List<WorkerStatus> workerStatus;
try {
workerStatus = parent.getWorkerDao().findAllWorkerStatusForPlan(plan, otherWorkers);
} catch (WorkerDaoException e1) {
throw new RuntimeException(e1);
}
if (workerStatus.size() >= feed.getFeedPartitions().size()){
throw new RuntimeException("Number of running workers " + workerStatus.size()+" >= feed partitions " + feed.getFeedPartitions().size() +" plan should be fixed " +plan.getName());
}
FeedPartition toProcess = findPartitionToProcess(workerStatus, feed.getFeedPartitions());
if (toProcess != null){
driver = DriverFactory.createDriver(toProcess, plan, parent.getMetricRegistry());
driver.initialize();
WorkerStatus iGotThis = new WorkerStatus(myId.toString(), toProcess.getPartitionId() , parent.getMyId());
try {
parent.getWorkerDao().registerWorkerStatus(zk, plan, iGotThis);
} catch (WorkerDaoException e) {
throw new RuntimeException(e);
}
} else {
throw new RuntimeException("Could not start plan "+plan.getName());
}
} | java | public void init(){
try {
zk = new ZooKeeper(parent.getProperties().get(TeknekDaemon.ZK_SERVER_LIST).toString(), 30000, this);
} catch (IOException e1) {
throw new RuntimeException(e1);
}
Feed feed = DriverFactory.buildFeed(plan.getFeedDesc());
List<WorkerStatus> workerStatus;
try {
workerStatus = parent.getWorkerDao().findAllWorkerStatusForPlan(plan, otherWorkers);
} catch (WorkerDaoException e1) {
throw new RuntimeException(e1);
}
if (workerStatus.size() >= feed.getFeedPartitions().size()){
throw new RuntimeException("Number of running workers " + workerStatus.size()+" >= feed partitions " + feed.getFeedPartitions().size() +" plan should be fixed " +plan.getName());
}
FeedPartition toProcess = findPartitionToProcess(workerStatus, feed.getFeedPartitions());
if (toProcess != null){
driver = DriverFactory.createDriver(toProcess, plan, parent.getMetricRegistry());
driver.initialize();
WorkerStatus iGotThis = new WorkerStatus(myId.toString(), toProcess.getPartitionId() , parent.getMyId());
try {
parent.getWorkerDao().registerWorkerStatus(zk, plan, iGotThis);
} catch (WorkerDaoException e) {
throw new RuntimeException(e);
}
} else {
throw new RuntimeException("Could not start plan "+plan.getName());
}
} | [
"public",
"void",
"init",
"(",
")",
"{",
"try",
"{",
"zk",
"=",
"new",
"ZooKeeper",
"(",
"parent",
".",
"getProperties",
"(",
")",
".",
"get",
"(",
"TeknekDaemon",
".",
"ZK_SERVER_LIST",
")",
".",
"toString",
"(",
")",
",",
"30000",
",",
"this",
")",... | Deterine what partitions of the feed are already attached to other workers. | [
"Deterine",
"what",
"partitions",
"of",
"the",
"feed",
"are",
"already",
"attached",
"to",
"other",
"workers",
"."
] | 4fa972d11044dee2954c0cc5e1b53b18fba319b9 | https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/daemon/Worker.java#L61-L90 | train |
edwardcapriolo/teknek-core | src/main/java/io/teknek/daemon/Worker.java | Worker.shutdown | private void shutdown(){
parent.workerThreads.get(plan).remove(this);
if (zk != null) {
try {
logger.debug("closing " + zk.getSessionId());
zk.close();
zk = null;
} catch (InterruptedException e1) {
logger.debug(e1);
}
logger.debug("shutdown complete");
}
} | java | private void shutdown(){
parent.workerThreads.get(plan).remove(this);
if (zk != null) {
try {
logger.debug("closing " + zk.getSessionId());
zk.close();
zk = null;
} catch (InterruptedException e1) {
logger.debug(e1);
}
logger.debug("shutdown complete");
}
} | [
"private",
"void",
"shutdown",
"(",
")",
"{",
"parent",
".",
"workerThreads",
".",
"get",
"(",
"plan",
")",
".",
"remove",
"(",
"this",
")",
";",
"if",
"(",
"zk",
"!=",
"null",
")",
"{",
"try",
"{",
"logger",
".",
"debug",
"(",
"\"closing \"",
"+",... | Remove ourselves from parents worker threads and close our zk connection | [
"Remove",
"ourselves",
"from",
"parents",
"worker",
"threads",
"and",
"close",
"our",
"zk",
"connection"
] | 4fa972d11044dee2954c0cc5e1b53b18fba319b9 | https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/daemon/Worker.java#L106-L118 | train |
phax/ph-datetime | ph-holiday/src/main/java/com/helger/holiday/mgr/CalendarHierarchy.java | CalendarHierarchy.getDescription | @Nonnull
public String getDescription (final Locale aContentLocale)
{
final String ret = m_eCountry == null ? null : m_eCountry.getDisplayText (aContentLocale);
return ret != null ? ret : "undefined";
} | java | @Nonnull
public String getDescription (final Locale aContentLocale)
{
final String ret = m_eCountry == null ? null : m_eCountry.getDisplayText (aContentLocale);
return ret != null ? ret : "undefined";
} | [
"@",
"Nonnull",
"public",
"String",
"getDescription",
"(",
"final",
"Locale",
"aContentLocale",
")",
"{",
"final",
"String",
"ret",
"=",
"m_eCountry",
"==",
"null",
"?",
"null",
":",
"m_eCountry",
".",
"getDisplayText",
"(",
"aContentLocale",
")",
";",
"return... | Returns the hierarchies description text from the resource bundle.
@param aContentLocale
Locale to return the description text for.
@return Description text | [
"Returns",
"the",
"hierarchies",
"description",
"text",
"from",
"the",
"resource",
"bundle",
"."
] | cfaff01cb76d9affb934800ff55734b5a7d8983e | https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/mgr/CalendarHierarchy.java#L78-L83 | train |
revelytix/spark | sherpa-java/src/main/java/sherpa/client/SHPSolutions.java | SHPSolutions.toNode | private static RDFNode toNode(Object value) {
if (value == null) {
return null;
} else if (value instanceof RDFNode) {
return (RDFNode) value;
} else if (value instanceof IRI) {
return new NamedNodeImpl(URI.create(((IRI)value).iri.toString()));
} else if (value instanceof PlainLiteral) {
PlainLiteral pl = (PlainLiteral)value;
String lang = pl.language != null ? pl.language.toString() : null;
return new PlainLiteralImpl(pl.lexical.toString(), lang);
} else if (value instanceof TypedLiteral) {
TypedLiteral tl = (TypedLiteral)value;
return new TypedLiteralImpl(tl.lexical.toString(), URI.create(tl.datatype.toString()));
} else if (value instanceof BNode) {
return new BlankNodeImpl(((BNode)value).label.toString());
} else {
// Sherpa passes strings as something other than java.lang.String, so convert.
if (value instanceof CharSequence) {
value = value.toString();
}
// What's left is a primitive Java type, convert it to an XSD-typed literal.
// Falls back to xsd:anySimpleType for unrecognized classes
return Conversions.toLiteral(value);
}
} | java | private static RDFNode toNode(Object value) {
if (value == null) {
return null;
} else if (value instanceof RDFNode) {
return (RDFNode) value;
} else if (value instanceof IRI) {
return new NamedNodeImpl(URI.create(((IRI)value).iri.toString()));
} else if (value instanceof PlainLiteral) {
PlainLiteral pl = (PlainLiteral)value;
String lang = pl.language != null ? pl.language.toString() : null;
return new PlainLiteralImpl(pl.lexical.toString(), lang);
} else if (value instanceof TypedLiteral) {
TypedLiteral tl = (TypedLiteral)value;
return new TypedLiteralImpl(tl.lexical.toString(), URI.create(tl.datatype.toString()));
} else if (value instanceof BNode) {
return new BlankNodeImpl(((BNode)value).label.toString());
} else {
// Sherpa passes strings as something other than java.lang.String, so convert.
if (value instanceof CharSequence) {
value = value.toString();
}
// What's left is a primitive Java type, convert it to an XSD-typed literal.
// Falls back to xsd:anySimpleType for unrecognized classes
return Conversions.toLiteral(value);
}
} | [
"private",
"static",
"RDFNode",
"toNode",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"RDFNode",
")",
"{",
"return",
"(",
"RDFNode",
")",
"value",
... | Convert a protocol data object to an RDFNode. | [
"Convert",
"a",
"protocol",
"data",
"object",
"to",
"an",
"RDFNode",
"."
] | d777d40c962bc66fdc04b7c3a66d20b777ff6fb4 | https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/sherpa-java/src/main/java/sherpa/client/SHPSolutions.java#L71-L96 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.