id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
11,400
|
phax/ph-ebinterface
|
src/main/java/com/helger/ebinterface/builder/EbInterfaceWriter.java
|
EbInterfaceWriter.ebInterface302
|
@Nonnull
public static EbInterfaceWriter <Ebi302InvoiceType> ebInterface302 ()
{
final EbInterfaceWriter <Ebi302InvoiceType> ret = EbInterfaceWriter.create (Ebi302InvoiceType.class);
ret.setNamespaceContext (EbInterface302NamespaceContext.getInstance ());
return ret;
}
|
java
|
@Nonnull
public static EbInterfaceWriter <Ebi302InvoiceType> ebInterface302 ()
{
final EbInterfaceWriter <Ebi302InvoiceType> ret = EbInterfaceWriter.create (Ebi302InvoiceType.class);
ret.setNamespaceContext (EbInterface302NamespaceContext.getInstance ());
return ret;
}
|
[
"@",
"Nonnull",
"public",
"static",
"EbInterfaceWriter",
"<",
"Ebi302InvoiceType",
">",
"ebInterface302",
"(",
")",
"{",
"final",
"EbInterfaceWriter",
"<",
"Ebi302InvoiceType",
">",
"ret",
"=",
"EbInterfaceWriter",
".",
"create",
"(",
"Ebi302InvoiceType",
".",
"class",
")",
";",
"ret",
".",
"setNamespaceContext",
"(",
"EbInterface302NamespaceContext",
".",
"getInstance",
"(",
")",
")",
";",
"return",
"ret",
";",
"}"
] |
Create a writer builder for Ebi302InvoiceType.
@return The builder and never <code>null</code>
|
[
"Create",
"a",
"writer",
"builder",
"for",
"Ebi302InvoiceType",
"."
] |
e3d2381f25c2fdfcc98acff2509bf5f33752d087
|
https://github.com/phax/ph-ebinterface/blob/e3d2381f25c2fdfcc98acff2509bf5f33752d087/src/main/java/com/helger/ebinterface/builder/EbInterfaceWriter.java#L97-L103
|
11,401
|
phax/ph-ebinterface
|
src/main/java/com/helger/ebinterface/builder/EbInterfaceWriter.java
|
EbInterfaceWriter.ebInterface40
|
@Nonnull
public static EbInterfaceWriter <Ebi40InvoiceType> ebInterface40 ()
{
final EbInterfaceWriter <Ebi40InvoiceType> ret = EbInterfaceWriter.create (Ebi40InvoiceType.class);
ret.setNamespaceContext (EbInterface40NamespaceContext.getInstance ());
return ret;
}
|
java
|
@Nonnull
public static EbInterfaceWriter <Ebi40InvoiceType> ebInterface40 ()
{
final EbInterfaceWriter <Ebi40InvoiceType> ret = EbInterfaceWriter.create (Ebi40InvoiceType.class);
ret.setNamespaceContext (EbInterface40NamespaceContext.getInstance ());
return ret;
}
|
[
"@",
"Nonnull",
"public",
"static",
"EbInterfaceWriter",
"<",
"Ebi40InvoiceType",
">",
"ebInterface40",
"(",
")",
"{",
"final",
"EbInterfaceWriter",
"<",
"Ebi40InvoiceType",
">",
"ret",
"=",
"EbInterfaceWriter",
".",
"create",
"(",
"Ebi40InvoiceType",
".",
"class",
")",
";",
"ret",
".",
"setNamespaceContext",
"(",
"EbInterface40NamespaceContext",
".",
"getInstance",
"(",
")",
")",
";",
"return",
"ret",
";",
"}"
] |
Create a writer builder for Ebi40InvoiceType.
@return The builder and never <code>null</code>
|
[
"Create",
"a",
"writer",
"builder",
"for",
"Ebi40InvoiceType",
"."
] |
e3d2381f25c2fdfcc98acff2509bf5f33752d087
|
https://github.com/phax/ph-ebinterface/blob/e3d2381f25c2fdfcc98acff2509bf5f33752d087/src/main/java/com/helger/ebinterface/builder/EbInterfaceWriter.java#L110-L116
|
11,402
|
phax/ph-ebinterface
|
src/main/java/com/helger/ebinterface/builder/EbInterfaceWriter.java
|
EbInterfaceWriter.ebInterface41
|
@Nonnull
public static EbInterfaceWriter <Ebi41InvoiceType> ebInterface41 ()
{
final EbInterfaceWriter <Ebi41InvoiceType> ret = EbInterfaceWriter.create (Ebi41InvoiceType.class);
ret.setNamespaceContext (EbInterface41NamespaceContext.getInstance ());
return ret;
}
|
java
|
@Nonnull
public static EbInterfaceWriter <Ebi41InvoiceType> ebInterface41 ()
{
final EbInterfaceWriter <Ebi41InvoiceType> ret = EbInterfaceWriter.create (Ebi41InvoiceType.class);
ret.setNamespaceContext (EbInterface41NamespaceContext.getInstance ());
return ret;
}
|
[
"@",
"Nonnull",
"public",
"static",
"EbInterfaceWriter",
"<",
"Ebi41InvoiceType",
">",
"ebInterface41",
"(",
")",
"{",
"final",
"EbInterfaceWriter",
"<",
"Ebi41InvoiceType",
">",
"ret",
"=",
"EbInterfaceWriter",
".",
"create",
"(",
"Ebi41InvoiceType",
".",
"class",
")",
";",
"ret",
".",
"setNamespaceContext",
"(",
"EbInterface41NamespaceContext",
".",
"getInstance",
"(",
")",
")",
";",
"return",
"ret",
";",
"}"
] |
Create a writer builder for Ebi41InvoiceType.
@return The builder and never <code>null</code>
|
[
"Create",
"a",
"writer",
"builder",
"for",
"Ebi41InvoiceType",
"."
] |
e3d2381f25c2fdfcc98acff2509bf5f33752d087
|
https://github.com/phax/ph-ebinterface/blob/e3d2381f25c2fdfcc98acff2509bf5f33752d087/src/main/java/com/helger/ebinterface/builder/EbInterfaceWriter.java#L123-L129
|
11,403
|
phax/ph-ebinterface
|
src/main/java/com/helger/ebinterface/builder/EbInterfaceWriter.java
|
EbInterfaceWriter.ebInterface42
|
@Nonnull
public static EbInterfaceWriter <Ebi42InvoiceType> ebInterface42 ()
{
final EbInterfaceWriter <Ebi42InvoiceType> ret = EbInterfaceWriter.create (Ebi42InvoiceType.class);
ret.setNamespaceContext (EbInterface42NamespaceContext.getInstance ());
return ret;
}
|
java
|
@Nonnull
public static EbInterfaceWriter <Ebi42InvoiceType> ebInterface42 ()
{
final EbInterfaceWriter <Ebi42InvoiceType> ret = EbInterfaceWriter.create (Ebi42InvoiceType.class);
ret.setNamespaceContext (EbInterface42NamespaceContext.getInstance ());
return ret;
}
|
[
"@",
"Nonnull",
"public",
"static",
"EbInterfaceWriter",
"<",
"Ebi42InvoiceType",
">",
"ebInterface42",
"(",
")",
"{",
"final",
"EbInterfaceWriter",
"<",
"Ebi42InvoiceType",
">",
"ret",
"=",
"EbInterfaceWriter",
".",
"create",
"(",
"Ebi42InvoiceType",
".",
"class",
")",
";",
"ret",
".",
"setNamespaceContext",
"(",
"EbInterface42NamespaceContext",
".",
"getInstance",
"(",
")",
")",
";",
"return",
"ret",
";",
"}"
] |
Create a writer builder for Ebi42InvoiceType.
@return The builder and never <code>null</code>
|
[
"Create",
"a",
"writer",
"builder",
"for",
"Ebi42InvoiceType",
"."
] |
e3d2381f25c2fdfcc98acff2509bf5f33752d087
|
https://github.com/phax/ph-ebinterface/blob/e3d2381f25c2fdfcc98acff2509bf5f33752d087/src/main/java/com/helger/ebinterface/builder/EbInterfaceWriter.java#L136-L142
|
11,404
|
phax/ph-ebinterface
|
src/main/java/com/helger/ebinterface/builder/EbInterfaceWriter.java
|
EbInterfaceWriter.ebInterface43
|
@Nonnull
public static EbInterfaceWriter <Ebi43InvoiceType> ebInterface43 ()
{
final EbInterfaceWriter <Ebi43InvoiceType> ret = EbInterfaceWriter.create (Ebi43InvoiceType.class);
ret.setNamespaceContext (EbInterface43NamespaceContext.getInstance ());
return ret;
}
|
java
|
@Nonnull
public static EbInterfaceWriter <Ebi43InvoiceType> ebInterface43 ()
{
final EbInterfaceWriter <Ebi43InvoiceType> ret = EbInterfaceWriter.create (Ebi43InvoiceType.class);
ret.setNamespaceContext (EbInterface43NamespaceContext.getInstance ());
return ret;
}
|
[
"@",
"Nonnull",
"public",
"static",
"EbInterfaceWriter",
"<",
"Ebi43InvoiceType",
">",
"ebInterface43",
"(",
")",
"{",
"final",
"EbInterfaceWriter",
"<",
"Ebi43InvoiceType",
">",
"ret",
"=",
"EbInterfaceWriter",
".",
"create",
"(",
"Ebi43InvoiceType",
".",
"class",
")",
";",
"ret",
".",
"setNamespaceContext",
"(",
"EbInterface43NamespaceContext",
".",
"getInstance",
"(",
")",
")",
";",
"return",
"ret",
";",
"}"
] |
Create a writer builder for Ebi43InvoiceType.
@return The builder and never <code>null</code>
|
[
"Create",
"a",
"writer",
"builder",
"for",
"Ebi43InvoiceType",
"."
] |
e3d2381f25c2fdfcc98acff2509bf5f33752d087
|
https://github.com/phax/ph-ebinterface/blob/e3d2381f25c2fdfcc98acff2509bf5f33752d087/src/main/java/com/helger/ebinterface/builder/EbInterfaceWriter.java#L149-L155
|
11,405
|
phax/ph-ebinterface
|
src/main/java/com/helger/ebinterface/builder/EbInterfaceWriter.java
|
EbInterfaceWriter.ebInterface50
|
@Nonnull
public static EbInterfaceWriter <Ebi50InvoiceType> ebInterface50 ()
{
final EbInterfaceWriter <Ebi50InvoiceType> ret = EbInterfaceWriter.create (Ebi50InvoiceType.class);
ret.setNamespaceContext (EbInterface50NamespaceContext.getInstance ());
return ret;
}
|
java
|
@Nonnull
public static EbInterfaceWriter <Ebi50InvoiceType> ebInterface50 ()
{
final EbInterfaceWriter <Ebi50InvoiceType> ret = EbInterfaceWriter.create (Ebi50InvoiceType.class);
ret.setNamespaceContext (EbInterface50NamespaceContext.getInstance ());
return ret;
}
|
[
"@",
"Nonnull",
"public",
"static",
"EbInterfaceWriter",
"<",
"Ebi50InvoiceType",
">",
"ebInterface50",
"(",
")",
"{",
"final",
"EbInterfaceWriter",
"<",
"Ebi50InvoiceType",
">",
"ret",
"=",
"EbInterfaceWriter",
".",
"create",
"(",
"Ebi50InvoiceType",
".",
"class",
")",
";",
"ret",
".",
"setNamespaceContext",
"(",
"EbInterface50NamespaceContext",
".",
"getInstance",
"(",
")",
")",
";",
"return",
"ret",
";",
"}"
] |
Create a writer builder for Ebi50InvoiceType.
@return The builder and never <code>null</code>
|
[
"Create",
"a",
"writer",
"builder",
"for",
"Ebi50InvoiceType",
"."
] |
e3d2381f25c2fdfcc98acff2509bf5f33752d087
|
https://github.com/phax/ph-ebinterface/blob/e3d2381f25c2fdfcc98acff2509bf5f33752d087/src/main/java/com/helger/ebinterface/builder/EbInterfaceWriter.java#L162-L168
|
11,406
|
telly/groundy
|
library/src/main/java/com/telly/groundy/CallbacksManager.java
|
CallbacksManager.init
|
public static CallbacksManager init(Bundle bundle, Object... callbackHandlers) {
if (bundle == null) {
return new CallbacksManager();
}
CallbacksManager callbacksManager = new CallbacksManager();
ArrayList<TaskHandler> taskProxies = bundle.getParcelableArrayList(TASK_PROXY_LIST);
if (taskProxies != null) {
callbacksManager.proxyTasks.addAll(taskProxies);
}
if (callbackHandlers != null) {
for (TaskHandler proxyTask : new ArrayList<TaskHandler>(callbacksManager.proxyTasks)) {
proxyTask.clearCallbacks();
proxyTask.appendCallbacks(callbackHandlers);
}
}
return callbacksManager;
}
|
java
|
public static CallbacksManager init(Bundle bundle, Object... callbackHandlers) {
if (bundle == null) {
return new CallbacksManager();
}
CallbacksManager callbacksManager = new CallbacksManager();
ArrayList<TaskHandler> taskProxies = bundle.getParcelableArrayList(TASK_PROXY_LIST);
if (taskProxies != null) {
callbacksManager.proxyTasks.addAll(taskProxies);
}
if (callbackHandlers != null) {
for (TaskHandler proxyTask : new ArrayList<TaskHandler>(callbacksManager.proxyTasks)) {
proxyTask.clearCallbacks();
proxyTask.appendCallbacks(callbackHandlers);
}
}
return callbacksManager;
}
|
[
"public",
"static",
"CallbacksManager",
"init",
"(",
"Bundle",
"bundle",
",",
"Object",
"...",
"callbackHandlers",
")",
"{",
"if",
"(",
"bundle",
"==",
"null",
")",
"{",
"return",
"new",
"CallbacksManager",
"(",
")",
";",
"}",
"CallbacksManager",
"callbacksManager",
"=",
"new",
"CallbacksManager",
"(",
")",
";",
"ArrayList",
"<",
"TaskHandler",
">",
"taskProxies",
"=",
"bundle",
".",
"getParcelableArrayList",
"(",
"TASK_PROXY_LIST",
")",
";",
"if",
"(",
"taskProxies",
"!=",
"null",
")",
"{",
"callbacksManager",
".",
"proxyTasks",
".",
"addAll",
"(",
"taskProxies",
")",
";",
"}",
"if",
"(",
"callbackHandlers",
"!=",
"null",
")",
"{",
"for",
"(",
"TaskHandler",
"proxyTask",
":",
"new",
"ArrayList",
"<",
"TaskHandler",
">",
"(",
"callbacksManager",
".",
"proxyTasks",
")",
")",
"{",
"proxyTask",
".",
"clearCallbacks",
"(",
")",
";",
"proxyTask",
".",
"appendCallbacks",
"(",
"callbackHandlers",
")",
";",
"}",
"}",
"return",
"callbacksManager",
";",
"}"
] |
Call from within your activity or fragment onCreate method.
@param bundle the onSaveInstance bundle
@param callbackHandlers an array of callback handlers to mange
@return an instance of {@link CallbacksManager}
|
[
"Call",
"from",
"within",
"your",
"activity",
"or",
"fragment",
"onCreate",
"method",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/CallbacksManager.java#L63-L81
|
11,407
|
telly/groundy
|
library/src/main/java/com/telly/groundy/CallbacksManager.java
|
CallbacksManager.linkCallbacks
|
public void linkCallbacks(Object... callbackHandlers) {
if (callbackHandlers != null) {
for (TaskHandler proxyTask : new ArrayList<TaskHandler>(proxyTasks)) {
proxyTask.clearCallbacks();
proxyTask.appendCallbacks(callbackHandlers);
}
}
}
|
java
|
public void linkCallbacks(Object... callbackHandlers) {
if (callbackHandlers != null) {
for (TaskHandler proxyTask : new ArrayList<TaskHandler>(proxyTasks)) {
proxyTask.clearCallbacks();
proxyTask.appendCallbacks(callbackHandlers);
}
}
}
|
[
"public",
"void",
"linkCallbacks",
"(",
"Object",
"...",
"callbackHandlers",
")",
"{",
"if",
"(",
"callbackHandlers",
"!=",
"null",
")",
"{",
"for",
"(",
"TaskHandler",
"proxyTask",
":",
"new",
"ArrayList",
"<",
"TaskHandler",
">",
"(",
"proxyTasks",
")",
")",
"{",
"proxyTask",
".",
"clearCallbacks",
"(",
")",
";",
"proxyTask",
".",
"appendCallbacks",
"(",
"callbackHandlers",
")",
";",
"}",
"}",
"}"
] |
Links the specified callback handlers to their respective tasks.
@param callbackHandlers an array of callback handlers
|
[
"Links",
"the",
"specified",
"callback",
"handlers",
"to",
"their",
"respective",
"tasks",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/CallbacksManager.java#L88-L95
|
11,408
|
telly/groundy
|
library/src/main/java/com/telly/groundy/CallbacksManager.java
|
CallbacksManager.onSaveInstanceState
|
public void onSaveInstanceState(Bundle bundle) {
bundle.putParcelableArrayList(TASK_PROXY_LIST, proxyTasks);
for (TaskHandler proxyTask : proxyTasks) {
bundle.putParcelable(GROUNDY_PROXY_KEY_PREFIX + proxyTask.getTaskId(), proxyTask);
}
}
|
java
|
public void onSaveInstanceState(Bundle bundle) {
bundle.putParcelableArrayList(TASK_PROXY_LIST, proxyTasks);
for (TaskHandler proxyTask : proxyTasks) {
bundle.putParcelable(GROUNDY_PROXY_KEY_PREFIX + proxyTask.getTaskId(), proxyTask);
}
}
|
[
"public",
"void",
"onSaveInstanceState",
"(",
"Bundle",
"bundle",
")",
"{",
"bundle",
".",
"putParcelableArrayList",
"(",
"TASK_PROXY_LIST",
",",
"proxyTasks",
")",
";",
"for",
"(",
"TaskHandler",
"proxyTask",
":",
"proxyTasks",
")",
"{",
"bundle",
".",
"putParcelable",
"(",
"GROUNDY_PROXY_KEY_PREFIX",
"+",
"proxyTask",
".",
"getTaskId",
"(",
")",
",",
"proxyTask",
")",
";",
"}",
"}"
] |
Saves the current callback handlers information in order to restore them after the
configuration change.
@param bundle the same bundle you receive from within your activity or fragment
onSaveInstanceState method
|
[
"Saves",
"the",
"current",
"callback",
"handlers",
"information",
"in",
"order",
"to",
"restore",
"them",
"after",
"the",
"configuration",
"change",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/CallbacksManager.java#L104-L109
|
11,409
|
ralscha/extclassgenerator
|
src/main/java/ch/rasc/extclassgenerator/ModelBean.java
|
ModelBean.addFields
|
public void addFields(List<ModelFieldBean> modelFields) {
Assert.notNull(modelFields, "modelFields must not be null");
for (ModelFieldBean bean : modelFields) {
this.fields.put(bean.getName(), bean);
}
}
|
java
|
public void addFields(List<ModelFieldBean> modelFields) {
Assert.notNull(modelFields, "modelFields must not be null");
for (ModelFieldBean bean : modelFields) {
this.fields.put(bean.getName(), bean);
}
}
|
[
"public",
"void",
"addFields",
"(",
"List",
"<",
"ModelFieldBean",
">",
"modelFields",
")",
"{",
"Assert",
".",
"notNull",
"(",
"modelFields",
",",
"\"modelFields must not be null\"",
")",
";",
"for",
"(",
"ModelFieldBean",
"bean",
":",
"modelFields",
")",
"{",
"this",
".",
"fields",
".",
"put",
"(",
"bean",
".",
"getName",
"(",
")",
",",
"bean",
")",
";",
"}",
"}"
] |
Add all provided fields to the collection of fields
@param modelFields collection of {@link ModelFieldBean}
|
[
"Add",
"all",
"provided",
"fields",
"to",
"the",
"collection",
"of",
"fields"
] |
6f106cf5ca83ef004225a3512e2291dfd028cf07
|
https://github.com/ralscha/extclassgenerator/blob/6f106cf5ca83ef004225a3512e2291dfd028cf07/src/main/java/ch/rasc/extclassgenerator/ModelBean.java#L194-L200
|
11,410
|
telly/groundy
|
library/src/main/java/com/telly/groundy/L.java
|
L.d
|
public static void d(String tag, String msg) {
if (logEnabled) {
Log.d(tag, msg);
}
}
|
java
|
public static void d(String tag, String msg) {
if (logEnabled) {
Log.d(tag, msg);
}
}
|
[
"public",
"static",
"void",
"d",
"(",
"String",
"tag",
",",
"String",
"msg",
")",
"{",
"if",
"(",
"logEnabled",
")",
"{",
"Log",
".",
"d",
"(",
"tag",
",",
"msg",
")",
";",
"}",
"}"
] |
Sends a debug message to the log.
@param tag Tag to use
@param msg Message to send
|
[
"Sends",
"a",
"debug",
"message",
"to",
"the",
"log",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/L.java#L47-L51
|
11,411
|
telly/groundy
|
library/src/main/java/com/telly/groundy/Groundy.java
|
Groundy.service
|
public Groundy service(Class<? extends GroundyService> groundyClass) {
if (groundyClass == GroundyService.class) {
throw new IllegalStateException(
"This method is meant to set a different GroundyService implementation. "
+ "You cannot use GroundyService.class, http://i.imgur.com/IR23PAe.png");
}
checkAlreadyProcessed();
mGroundyClass = groundyClass;
return this;
}
|
java
|
public Groundy service(Class<? extends GroundyService> groundyClass) {
if (groundyClass == GroundyService.class) {
throw new IllegalStateException(
"This method is meant to set a different GroundyService implementation. "
+ "You cannot use GroundyService.class, http://i.imgur.com/IR23PAe.png");
}
checkAlreadyProcessed();
mGroundyClass = groundyClass;
return this;
}
|
[
"public",
"Groundy",
"service",
"(",
"Class",
"<",
"?",
"extends",
"GroundyService",
">",
"groundyClass",
")",
"{",
"if",
"(",
"groundyClass",
"==",
"GroundyService",
".",
"class",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"This method is meant to set a different GroundyService implementation. \"",
"+",
"\"You cannot use GroundyService.class, http://i.imgur.com/IR23PAe.png\"",
")",
";",
"}",
"checkAlreadyProcessed",
"(",
")",
";",
"mGroundyClass",
"=",
"groundyClass",
";",
"return",
"this",
";",
"}"
] |
This allows you to use a different GroundyService implementation.
@param groundyClass a different Groundy service implementation
@return itself
|
[
"This",
"allows",
"you",
"to",
"use",
"a",
"different",
"GroundyService",
"implementation",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/Groundy.java#L203-L212
|
11,412
|
telly/groundy
|
library/src/main/java/com/telly/groundy/GroundyTaskFactory.java
|
GroundyTaskFactory.get
|
static GroundyTask get(Class<? extends GroundyTask> taskClass, Context context) {
if (CACHE.containsKey(taskClass)) {
return CACHE.get(taskClass);
}
GroundyTask groundyTask = null;
try {
L.d(TAG, "Instantiating " + taskClass);
Constructor ctc = taskClass.getConstructor();
groundyTask = (GroundyTask) ctc.newInstance();
if (groundyTask.canBeCached()) {
CACHE.put(taskClass, groundyTask);
} else if (CACHE.containsKey(taskClass)) {
CACHE.remove(taskClass);
}
groundyTask.setContext(context);
groundyTask.onCreate();
return groundyTask;
} catch (Exception e) {
L.e(TAG, "Unable to create value for call " + taskClass, e);
}
return groundyTask;
}
|
java
|
static GroundyTask get(Class<? extends GroundyTask> taskClass, Context context) {
if (CACHE.containsKey(taskClass)) {
return CACHE.get(taskClass);
}
GroundyTask groundyTask = null;
try {
L.d(TAG, "Instantiating " + taskClass);
Constructor ctc = taskClass.getConstructor();
groundyTask = (GroundyTask) ctc.newInstance();
if (groundyTask.canBeCached()) {
CACHE.put(taskClass, groundyTask);
} else if (CACHE.containsKey(taskClass)) {
CACHE.remove(taskClass);
}
groundyTask.setContext(context);
groundyTask.onCreate();
return groundyTask;
} catch (Exception e) {
L.e(TAG, "Unable to create value for call " + taskClass, e);
}
return groundyTask;
}
|
[
"static",
"GroundyTask",
"get",
"(",
"Class",
"<",
"?",
"extends",
"GroundyTask",
">",
"taskClass",
",",
"Context",
"context",
")",
"{",
"if",
"(",
"CACHE",
".",
"containsKey",
"(",
"taskClass",
")",
")",
"{",
"return",
"CACHE",
".",
"get",
"(",
"taskClass",
")",
";",
"}",
"GroundyTask",
"groundyTask",
"=",
"null",
";",
"try",
"{",
"L",
".",
"d",
"(",
"TAG",
",",
"\"Instantiating \"",
"+",
"taskClass",
")",
";",
"Constructor",
"ctc",
"=",
"taskClass",
".",
"getConstructor",
"(",
")",
";",
"groundyTask",
"=",
"(",
"GroundyTask",
")",
"ctc",
".",
"newInstance",
"(",
")",
";",
"if",
"(",
"groundyTask",
".",
"canBeCached",
"(",
")",
")",
"{",
"CACHE",
".",
"put",
"(",
"taskClass",
",",
"groundyTask",
")",
";",
"}",
"else",
"if",
"(",
"CACHE",
".",
"containsKey",
"(",
"taskClass",
")",
")",
"{",
"CACHE",
".",
"remove",
"(",
"taskClass",
")",
";",
"}",
"groundyTask",
".",
"setContext",
"(",
"context",
")",
";",
"groundyTask",
".",
"onCreate",
"(",
")",
";",
"return",
"groundyTask",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"L",
".",
"e",
"(",
"TAG",
",",
"\"Unable to create value for call \"",
"+",
"taskClass",
",",
"e",
")",
";",
"}",
"return",
"groundyTask",
";",
"}"
] |
Builds a GroundyTask based on call.
@param taskClass groundy value implementation class
@param context used to instantiate the value
@return An instance of a GroundyTask if a given call is valid null otherwise
|
[
"Builds",
"a",
"GroundyTask",
"based",
"on",
"call",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/GroundyTaskFactory.java#L47-L68
|
11,413
|
ralscha/extclassgenerator
|
src/main/java/ch/rasc/extclassgenerator/ModelFieldBean.java
|
ModelFieldBean.hasOnlyName
|
public boolean hasOnlyName(OutputConfig outputConfig) {
if (StringUtils.hasText(this.name) && !StringUtils.hasText(this.type)
&& this.defaultValue == null && !StringUtils.hasText(this.dateFormat)
&& !StringUtils.hasText(this.mapping) && this.persist == null
&& !StringUtils.hasText(this.convert)) {
if (outputConfig.getOutputFormat() == OutputFormat.EXTJS4) {
return this.useNull == null;
}
else if (outputConfig.getOutputFormat() == OutputFormat.TOUCH2) {
return this.allowNull == null;
}
else if (outputConfig.getOutputFormat() == OutputFormat.EXTJS5) {
return this.allowNull == null && this.critical == null
&& !StringUtils.hasText(this.calculate)
&& (this.validators == null || this.validators.isEmpty())
&& (this.depends == null || this.depends.isEmpty())
&& this.reference == null && this.allowBlank == null
&& this.unique == null;
}
}
return false;
}
|
java
|
public boolean hasOnlyName(OutputConfig outputConfig) {
if (StringUtils.hasText(this.name) && !StringUtils.hasText(this.type)
&& this.defaultValue == null && !StringUtils.hasText(this.dateFormat)
&& !StringUtils.hasText(this.mapping) && this.persist == null
&& !StringUtils.hasText(this.convert)) {
if (outputConfig.getOutputFormat() == OutputFormat.EXTJS4) {
return this.useNull == null;
}
else if (outputConfig.getOutputFormat() == OutputFormat.TOUCH2) {
return this.allowNull == null;
}
else if (outputConfig.getOutputFormat() == OutputFormat.EXTJS5) {
return this.allowNull == null && this.critical == null
&& !StringUtils.hasText(this.calculate)
&& (this.validators == null || this.validators.isEmpty())
&& (this.depends == null || this.depends.isEmpty())
&& this.reference == null && this.allowBlank == null
&& this.unique == null;
}
}
return false;
}
|
[
"public",
"boolean",
"hasOnlyName",
"(",
"OutputConfig",
"outputConfig",
")",
"{",
"if",
"(",
"StringUtils",
".",
"hasText",
"(",
"this",
".",
"name",
")",
"&&",
"!",
"StringUtils",
".",
"hasText",
"(",
"this",
".",
"type",
")",
"&&",
"this",
".",
"defaultValue",
"==",
"null",
"&&",
"!",
"StringUtils",
".",
"hasText",
"(",
"this",
".",
"dateFormat",
")",
"&&",
"!",
"StringUtils",
".",
"hasText",
"(",
"this",
".",
"mapping",
")",
"&&",
"this",
".",
"persist",
"==",
"null",
"&&",
"!",
"StringUtils",
".",
"hasText",
"(",
"this",
".",
"convert",
")",
")",
"{",
"if",
"(",
"outputConfig",
".",
"getOutputFormat",
"(",
")",
"==",
"OutputFormat",
".",
"EXTJS4",
")",
"{",
"return",
"this",
".",
"useNull",
"==",
"null",
";",
"}",
"else",
"if",
"(",
"outputConfig",
".",
"getOutputFormat",
"(",
")",
"==",
"OutputFormat",
".",
"TOUCH2",
")",
"{",
"return",
"this",
".",
"allowNull",
"==",
"null",
";",
"}",
"else",
"if",
"(",
"outputConfig",
".",
"getOutputFormat",
"(",
")",
"==",
"OutputFormat",
".",
"EXTJS5",
")",
"{",
"return",
"this",
".",
"allowNull",
"==",
"null",
"&&",
"this",
".",
"critical",
"==",
"null",
"&&",
"!",
"StringUtils",
".",
"hasText",
"(",
"this",
".",
"calculate",
")",
"&&",
"(",
"this",
".",
"validators",
"==",
"null",
"||",
"this",
".",
"validators",
".",
"isEmpty",
"(",
")",
")",
"&&",
"(",
"this",
".",
"depends",
"==",
"null",
"||",
"this",
".",
"depends",
".",
"isEmpty",
"(",
")",
")",
"&&",
"this",
".",
"reference",
"==",
"null",
"&&",
"this",
".",
"allowBlank",
"==",
"null",
"&&",
"this",
".",
"unique",
"==",
"null",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns true if only the name property is set
|
[
"Returns",
"true",
"if",
"only",
"the",
"name",
"property",
"is",
"set"
] |
6f106cf5ca83ef004225a3512e2291dfd028cf07
|
https://github.com/ralscha/extclassgenerator/blob/6f106cf5ca83ef004225a3512e2291dfd028cf07/src/main/java/ch/rasc/extclassgenerator/ModelFieldBean.java#L90-L112
|
11,414
|
Terracotta-OSS/statistics
|
src/main/java/org/terracotta/statistics/derived/histogram/ExponentialHistogram.java
|
ExponentialHistogram.merge
|
public void merge(ExponentialHistogram b) {
if (b.mergeThreshold != mergeThreshold) {
throw new IllegalArgumentException();
}
merge(b.boxes, b.total);
}
|
java
|
public void merge(ExponentialHistogram b) {
if (b.mergeThreshold != mergeThreshold) {
throw new IllegalArgumentException();
}
merge(b.boxes, b.total);
}
|
[
"public",
"void",
"merge",
"(",
"ExponentialHistogram",
"b",
")",
"{",
"if",
"(",
"b",
".",
"mergeThreshold",
"!=",
"mergeThreshold",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"merge",
"(",
"b",
".",
"boxes",
",",
"b",
".",
"total",
")",
";",
"}"
] |
Merge the supplied ExponentialHistogram in to this one.
@param b histogram to merge
@throws IllegalArgumentException if the two merge-thresholds are not equals
|
[
"Merge",
"the",
"supplied",
"ExponentialHistogram",
"in",
"to",
"this",
"one",
"."
] |
d24e4989b8c8dbe4f5210e49c7945d51b6585881
|
https://github.com/Terracotta-OSS/statistics/blob/d24e4989b8c8dbe4f5210e49c7945d51b6585881/src/main/java/org/terracotta/statistics/derived/histogram/ExponentialHistogram.java#L77-L82
|
11,415
|
Terracotta-OSS/statistics
|
src/main/java/org/terracotta/statistics/derived/histogram/ExponentialHistogram.java
|
ExponentialHistogram.expire
|
public long expire(long time) {
for (int logSize = (Long.SIZE - 1) - numberOfLeadingZeros(last); logSize >= 0; logSize--) {
boolean live = false;
for (int i = min_l(logSize); i < max_l(logSize); i++) {
long end = boxes[i];
if (end != MIN_VALUE) {
if ((time - end) >= window) {
total -= 1L << logSize;
boxes[i] = MIN_VALUE;
} else {
live = true;
}
}
}
if (live) {
last = 1L << logSize;
return count();
}
}
last = 0;
return 0;
}
|
java
|
public long expire(long time) {
for (int logSize = (Long.SIZE - 1) - numberOfLeadingZeros(last); logSize >= 0; logSize--) {
boolean live = false;
for (int i = min_l(logSize); i < max_l(logSize); i++) {
long end = boxes[i];
if (end != MIN_VALUE) {
if ((time - end) >= window) {
total -= 1L << logSize;
boxes[i] = MIN_VALUE;
} else {
live = true;
}
}
}
if (live) {
last = 1L << logSize;
return count();
}
}
last = 0;
return 0;
}
|
[
"public",
"long",
"expire",
"(",
"long",
"time",
")",
"{",
"for",
"(",
"int",
"logSize",
"=",
"(",
"Long",
".",
"SIZE",
"-",
"1",
")",
"-",
"numberOfLeadingZeros",
"(",
"last",
")",
";",
"logSize",
">=",
"0",
";",
"logSize",
"--",
")",
"{",
"boolean",
"live",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"min_l",
"(",
"logSize",
")",
";",
"i",
"<",
"max_l",
"(",
"logSize",
")",
";",
"i",
"++",
")",
"{",
"long",
"end",
"=",
"boxes",
"[",
"i",
"]",
";",
"if",
"(",
"end",
"!=",
"MIN_VALUE",
")",
"{",
"if",
"(",
"(",
"time",
"-",
"end",
")",
">=",
"window",
")",
"{",
"total",
"-=",
"1L",
"<<",
"logSize",
";",
"boxes",
"[",
"i",
"]",
"=",
"MIN_VALUE",
";",
"}",
"else",
"{",
"live",
"=",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"live",
")",
"{",
"last",
"=",
"1L",
"<<",
"logSize",
";",
"return",
"count",
"(",
")",
";",
"}",
"}",
"last",
"=",
"0",
";",
"return",
"0",
";",
"}"
] |
Expire old events.
@param time current timestamp
@return the count following expiry
|
[
"Expire",
"old",
"events",
"."
] |
d24e4989b8c8dbe4f5210e49c7945d51b6585881
|
https://github.com/Terracotta-OSS/statistics/blob/d24e4989b8c8dbe4f5210e49c7945d51b6585881/src/main/java/org/terracotta/statistics/derived/histogram/ExponentialHistogram.java#L248-L269
|
11,416
|
airomem/airomem
|
airomem-chatsample/airomem-chatsample-web/src/main/java/pl/setblack/chatsample/web/ChatService.java
|
ChatService.putJson
|
@PUT
@Consumes("application/json")
public void putJson(IncomingMessage msg) {
chatBean.addMessage(msg.nick, msg.content);
}
|
java
|
@PUT
@Consumes("application/json")
public void putJson(IncomingMessage msg) {
chatBean.addMessage(msg.nick, msg.content);
}
|
[
"@",
"PUT",
"@",
"Consumes",
"(",
"\"application/json\"",
")",
"public",
"void",
"putJson",
"(",
"IncomingMessage",
"msg",
")",
"{",
"chatBean",
".",
"addMessage",
"(",
"msg",
".",
"nick",
",",
"msg",
".",
"content",
")",
";",
"}"
] |
PUT method for updating or creating an instance of ChatService
@param content representation for the resource
@return an HTTP response with content of the updated or created resource.
|
[
"PUT",
"method",
"for",
"updating",
"or",
"creating",
"an",
"instance",
"of",
"ChatService"
] |
281ce18ff64836fccfb0edab18b8d677f1101a32
|
https://github.com/airomem/airomem/blob/281ce18ff64836fccfb0edab18b8d677f1101a32/airomem-chatsample/airomem-chatsample-web/src/main/java/pl/setblack/chatsample/web/ChatService.java#L60-L64
|
11,417
|
telly/groundy
|
library/src/main/java/com/telly/groundy/GroundyTask.java
|
GroundyTask.callback
|
protected void callback(String name, Bundle resultData) {
if (resultData == null) resultData = new Bundle();
resultData.putString(Groundy.KEY_CALLBACK_NAME, name);
resultData.putSerializable(Groundy.TASK_IMPLEMENTATION, getClass());
send(OnCallback.class, resultData);
}
|
java
|
protected void callback(String name, Bundle resultData) {
if (resultData == null) resultData = new Bundle();
resultData.putString(Groundy.KEY_CALLBACK_NAME, name);
resultData.putSerializable(Groundy.TASK_IMPLEMENTATION, getClass());
send(OnCallback.class, resultData);
}
|
[
"protected",
"void",
"callback",
"(",
"String",
"name",
",",
"Bundle",
"resultData",
")",
"{",
"if",
"(",
"resultData",
"==",
"null",
")",
"resultData",
"=",
"new",
"Bundle",
"(",
")",
";",
"resultData",
".",
"putString",
"(",
"Groundy",
".",
"KEY_CALLBACK_NAME",
",",
"name",
")",
";",
"resultData",
".",
"putSerializable",
"(",
"Groundy",
".",
"TASK_IMPLEMENTATION",
",",
"getClass",
"(",
")",
")",
";",
"send",
"(",
"OnCallback",
".",
"class",
",",
"resultData",
")",
";",
"}"
] |
Sends this data to the callback methods annotated with the specified name.
@param name the name of the callback to invoke
@param resultData optional arguments to send
|
[
"Sends",
"this",
"data",
"to",
"the",
"callback",
"methods",
"annotated",
"with",
"the",
"specified",
"name",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/GroundyTask.java#L242-L247
|
11,418
|
telly/groundy
|
compiler/src/main/java/com/telly/groundy/GroundyCodeGen.java
|
GroundyCodeGen.mergeProxiesWithClassHierarchy
|
private void mergeProxiesWithClassHierarchy() {
for (Map.Entry<HandlerAndTask, Set<ProxyImplContent>> elementSetEntry : implMap.entrySet()) {
final HandlerAndTask handlerAndTask = elementSetEntry.getKey();
// 1. merge super tasks, for same handler
final Set<Element> superTasks = getSuperClasses(handlerAndTask.task);
for (Element superTask : superTasks) {
final HandlerAndTask handlerAndSuperTask = new HandlerAndTask(handlerAndTask.handler, superTask);
if (implMap.containsKey(handlerAndSuperTask)) {
appendNonExistentCallbacks(handlerAndSuperTask, handlerAndTask);
}
}
// 2. merge super handlers, for same task
final Set<Element> superHandlers = getSuperClasses(handlerAndTask.handler);
for (Element superHandler : superHandlers) {
final HandlerAndTask superHandlerAndTask = new HandlerAndTask(superHandler, handlerAndTask.task);
if (implMap.containsKey(superHandlerAndTask)) {
appendNonExistentCallbacks(superHandlerAndTask, handlerAndTask);
}
// 3. merge super handlers, for super tasks
for (Element superTask : superTasks) {
final HandlerAndTask superHandlerAndSuperTask = new HandlerAndTask(superHandler, superTask);
if (implMap.containsKey(superHandlerAndSuperTask)) {
appendNonExistentCallbacks(superHandlerAndSuperTask, handlerAndTask);
}
}
}
}
}
|
java
|
private void mergeProxiesWithClassHierarchy() {
for (Map.Entry<HandlerAndTask, Set<ProxyImplContent>> elementSetEntry : implMap.entrySet()) {
final HandlerAndTask handlerAndTask = elementSetEntry.getKey();
// 1. merge super tasks, for same handler
final Set<Element> superTasks = getSuperClasses(handlerAndTask.task);
for (Element superTask : superTasks) {
final HandlerAndTask handlerAndSuperTask = new HandlerAndTask(handlerAndTask.handler, superTask);
if (implMap.containsKey(handlerAndSuperTask)) {
appendNonExistentCallbacks(handlerAndSuperTask, handlerAndTask);
}
}
// 2. merge super handlers, for same task
final Set<Element> superHandlers = getSuperClasses(handlerAndTask.handler);
for (Element superHandler : superHandlers) {
final HandlerAndTask superHandlerAndTask = new HandlerAndTask(superHandler, handlerAndTask.task);
if (implMap.containsKey(superHandlerAndTask)) {
appendNonExistentCallbacks(superHandlerAndTask, handlerAndTask);
}
// 3. merge super handlers, for super tasks
for (Element superTask : superTasks) {
final HandlerAndTask superHandlerAndSuperTask = new HandlerAndTask(superHandler, superTask);
if (implMap.containsKey(superHandlerAndSuperTask)) {
appendNonExistentCallbacks(superHandlerAndSuperTask, handlerAndTask);
}
}
}
}
}
|
[
"private",
"void",
"mergeProxiesWithClassHierarchy",
"(",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"HandlerAndTask",
",",
"Set",
"<",
"ProxyImplContent",
">",
">",
"elementSetEntry",
":",
"implMap",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"HandlerAndTask",
"handlerAndTask",
"=",
"elementSetEntry",
".",
"getKey",
"(",
")",
";",
"// 1. merge super tasks, for same handler",
"final",
"Set",
"<",
"Element",
">",
"superTasks",
"=",
"getSuperClasses",
"(",
"handlerAndTask",
".",
"task",
")",
";",
"for",
"(",
"Element",
"superTask",
":",
"superTasks",
")",
"{",
"final",
"HandlerAndTask",
"handlerAndSuperTask",
"=",
"new",
"HandlerAndTask",
"(",
"handlerAndTask",
".",
"handler",
",",
"superTask",
")",
";",
"if",
"(",
"implMap",
".",
"containsKey",
"(",
"handlerAndSuperTask",
")",
")",
"{",
"appendNonExistentCallbacks",
"(",
"handlerAndSuperTask",
",",
"handlerAndTask",
")",
";",
"}",
"}",
"// 2. merge super handlers, for same task",
"final",
"Set",
"<",
"Element",
">",
"superHandlers",
"=",
"getSuperClasses",
"(",
"handlerAndTask",
".",
"handler",
")",
";",
"for",
"(",
"Element",
"superHandler",
":",
"superHandlers",
")",
"{",
"final",
"HandlerAndTask",
"superHandlerAndTask",
"=",
"new",
"HandlerAndTask",
"(",
"superHandler",
",",
"handlerAndTask",
".",
"task",
")",
";",
"if",
"(",
"implMap",
".",
"containsKey",
"(",
"superHandlerAndTask",
")",
")",
"{",
"appendNonExistentCallbacks",
"(",
"superHandlerAndTask",
",",
"handlerAndTask",
")",
";",
"}",
"// 3. merge super handlers, for super tasks",
"for",
"(",
"Element",
"superTask",
":",
"superTasks",
")",
"{",
"final",
"HandlerAndTask",
"superHandlerAndSuperTask",
"=",
"new",
"HandlerAndTask",
"(",
"superHandler",
",",
"superTask",
")",
";",
"if",
"(",
"implMap",
".",
"containsKey",
"(",
"superHandlerAndSuperTask",
")",
")",
"{",
"appendNonExistentCallbacks",
"(",
"superHandlerAndSuperTask",
",",
"handlerAndTask",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Merges callbacks implementations taking into account the supper types of the handlers and
the tasks.
1. It will look for callbacks of the super classes of the tasks, in the same handler.
2. It will look for callbacks of the super classes of the handler, that use the same task.
3. It will look for callbacks of the super classes of the handler, that use super classes of the task.
|
[
"Merges",
"callbacks",
"implementations",
"taking",
"into",
"account",
"the",
"supper",
"types",
"of",
"the",
"handlers",
"and",
"the",
"tasks",
".",
"1",
".",
"It",
"will",
"look",
"for",
"callbacks",
"of",
"the",
"super",
"classes",
"of",
"the",
"tasks",
"in",
"the",
"same",
"handler",
".",
"2",
".",
"It",
"will",
"look",
"for",
"callbacks",
"of",
"the",
"super",
"classes",
"of",
"the",
"handler",
"that",
"use",
"the",
"same",
"task",
".",
"3",
".",
"It",
"will",
"look",
"for",
"callbacks",
"of",
"the",
"super",
"classes",
"of",
"the",
"handler",
"that",
"use",
"super",
"classes",
"of",
"the",
"task",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/compiler/src/main/java/com/telly/groundy/GroundyCodeGen.java#L130-L160
|
11,419
|
telly/groundy
|
compiler/src/main/java/com/telly/groundy/GroundyCodeGen.java
|
GroundyCodeGen.appendNonExistentCallbacks
|
private void appendNonExistentCallbacks(HandlerAndTask from, HandlerAndTask to) {
final Set<ProxyImplContent> proxyImplContentsTo = implMap.get(to);
if (proxyImplContentsTo == null) {
return;
}
final Set<ProxyImplContent> proxyImplContentsFrom = implMap.get(from);
if (proxyImplContentsFrom == null) {
return;
}
for (ProxyImplContent proxyImplContentFrom : proxyImplContentsFrom) {
boolean exists = false;
for (ProxyImplContent proxyImplContentTo : proxyImplContentsTo) {
if (proxyImplContentTo.annotation.equals(proxyImplContentFrom.annotation)) {
exists = true;
break;
}
}
if (!exists) {
proxyImplContentsTo.add(proxyImplContentFrom);
}
}
}
|
java
|
private void appendNonExistentCallbacks(HandlerAndTask from, HandlerAndTask to) {
final Set<ProxyImplContent> proxyImplContentsTo = implMap.get(to);
if (proxyImplContentsTo == null) {
return;
}
final Set<ProxyImplContent> proxyImplContentsFrom = implMap.get(from);
if (proxyImplContentsFrom == null) {
return;
}
for (ProxyImplContent proxyImplContentFrom : proxyImplContentsFrom) {
boolean exists = false;
for (ProxyImplContent proxyImplContentTo : proxyImplContentsTo) {
if (proxyImplContentTo.annotation.equals(proxyImplContentFrom.annotation)) {
exists = true;
break;
}
}
if (!exists) {
proxyImplContentsTo.add(proxyImplContentFrom);
}
}
}
|
[
"private",
"void",
"appendNonExistentCallbacks",
"(",
"HandlerAndTask",
"from",
",",
"HandlerAndTask",
"to",
")",
"{",
"final",
"Set",
"<",
"ProxyImplContent",
">",
"proxyImplContentsTo",
"=",
"implMap",
".",
"get",
"(",
"to",
")",
";",
"if",
"(",
"proxyImplContentsTo",
"==",
"null",
")",
"{",
"return",
";",
"}",
"final",
"Set",
"<",
"ProxyImplContent",
">",
"proxyImplContentsFrom",
"=",
"implMap",
".",
"get",
"(",
"from",
")",
";",
"if",
"(",
"proxyImplContentsFrom",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"ProxyImplContent",
"proxyImplContentFrom",
":",
"proxyImplContentsFrom",
")",
"{",
"boolean",
"exists",
"=",
"false",
";",
"for",
"(",
"ProxyImplContent",
"proxyImplContentTo",
":",
"proxyImplContentsTo",
")",
"{",
"if",
"(",
"proxyImplContentTo",
".",
"annotation",
".",
"equals",
"(",
"proxyImplContentFrom",
".",
"annotation",
")",
")",
"{",
"exists",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"exists",
")",
"{",
"proxyImplContentsTo",
".",
"add",
"(",
"proxyImplContentFrom",
")",
";",
"}",
"}",
"}"
] |
Copy all callbacks implementations from -> to the specified set. It makes sure
to copy the callbacks that don't exist already on the destination set.
@param from key for the set of callbacks to copy from
@param to key for the set of callbacks to copy to
|
[
"Copy",
"all",
"callbacks",
"implementations",
"from",
"-",
">",
"to",
"the",
"specified",
"set",
".",
"It",
"makes",
"sure",
"to",
"copy",
"the",
"callbacks",
"that",
"don",
"t",
"exist",
"already",
"on",
"the",
"destination",
"set",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/compiler/src/main/java/com/telly/groundy/GroundyCodeGen.java#L169-L193
|
11,420
|
telly/groundy
|
compiler/src/main/java/com/telly/groundy/GroundyCodeGen.java
|
GroundyCodeGen.getParamNames
|
private static List<NameAndType> getParamNames(Element callbackMethod) {
Element parentClass = callbackMethod.getEnclosingElement();
String methodFullInfo = parentClass + "#" + callbackMethod;
ExecutableElement method = (ExecutableElement) callbackMethod;
if (!method.getModifiers().contains(Modifier.PUBLIC)) {
LOGGER.info(methodFullInfo + " must be public.");
System.exit(-1);
}
if (method.getReturnType().getKind() != TypeKind.VOID) {
LOGGER.info(methodFullInfo + " must return void.");
System.exit(-1);
}
List<NameAndType> paramNames = new ArrayList<NameAndType>();
for (VariableElement param : method.getParameters()) {
Param paramAnnotation = param.getAnnotation(Param.class);
if (paramAnnotation == null) {
LOGGER.info(methodFullInfo
+ ": all parameters must be annotated with the @"
+ Param.class.getName());
System.exit(-1);
}
paramNames.add(new NameAndType(paramAnnotation.value(), param.asType().toString()));
}
return paramNames;
}
|
java
|
private static List<NameAndType> getParamNames(Element callbackMethod) {
Element parentClass = callbackMethod.getEnclosingElement();
String methodFullInfo = parentClass + "#" + callbackMethod;
ExecutableElement method = (ExecutableElement) callbackMethod;
if (!method.getModifiers().contains(Modifier.PUBLIC)) {
LOGGER.info(methodFullInfo + " must be public.");
System.exit(-1);
}
if (method.getReturnType().getKind() != TypeKind.VOID) {
LOGGER.info(methodFullInfo + " must return void.");
System.exit(-1);
}
List<NameAndType> paramNames = new ArrayList<NameAndType>();
for (VariableElement param : method.getParameters()) {
Param paramAnnotation = param.getAnnotation(Param.class);
if (paramAnnotation == null) {
LOGGER.info(methodFullInfo
+ ": all parameters must be annotated with the @"
+ Param.class.getName());
System.exit(-1);
}
paramNames.add(new NameAndType(paramAnnotation.value(), param.asType().toString()));
}
return paramNames;
}
|
[
"private",
"static",
"List",
"<",
"NameAndType",
">",
"getParamNames",
"(",
"Element",
"callbackMethod",
")",
"{",
"Element",
"parentClass",
"=",
"callbackMethod",
".",
"getEnclosingElement",
"(",
")",
";",
"String",
"methodFullInfo",
"=",
"parentClass",
"+",
"\"#\"",
"+",
"callbackMethod",
";",
"ExecutableElement",
"method",
"=",
"(",
"ExecutableElement",
")",
"callbackMethod",
";",
"if",
"(",
"!",
"method",
".",
"getModifiers",
"(",
")",
".",
"contains",
"(",
"Modifier",
".",
"PUBLIC",
")",
")",
"{",
"LOGGER",
".",
"info",
"(",
"methodFullInfo",
"+",
"\" must be public.\"",
")",
";",
"System",
".",
"exit",
"(",
"-",
"1",
")",
";",
"}",
"if",
"(",
"method",
".",
"getReturnType",
"(",
")",
".",
"getKind",
"(",
")",
"!=",
"TypeKind",
".",
"VOID",
")",
"{",
"LOGGER",
".",
"info",
"(",
"methodFullInfo",
"+",
"\" must return void.\"",
")",
";",
"System",
".",
"exit",
"(",
"-",
"1",
")",
";",
"}",
"List",
"<",
"NameAndType",
">",
"paramNames",
"=",
"new",
"ArrayList",
"<",
"NameAndType",
">",
"(",
")",
";",
"for",
"(",
"VariableElement",
"param",
":",
"method",
".",
"getParameters",
"(",
")",
")",
"{",
"Param",
"paramAnnotation",
"=",
"param",
".",
"getAnnotation",
"(",
"Param",
".",
"class",
")",
";",
"if",
"(",
"paramAnnotation",
"==",
"null",
")",
"{",
"LOGGER",
".",
"info",
"(",
"methodFullInfo",
"+",
"\": all parameters must be annotated with the @\"",
"+",
"Param",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"System",
".",
"exit",
"(",
"-",
"1",
")",
";",
"}",
"paramNames",
".",
"add",
"(",
"new",
"NameAndType",
"(",
"paramAnnotation",
".",
"value",
"(",
")",
",",
"param",
".",
"asType",
"(",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"return",
"paramNames",
";",
"}"
] |
Makes sure method is public, returns void and all its parameters are annotated too.
|
[
"Makes",
"sure",
"method",
"is",
"public",
"returns",
"void",
"and",
"all",
"its",
"parameters",
"are",
"annotated",
"too",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/compiler/src/main/java/com/telly/groundy/GroundyCodeGen.java#L443-L472
|
11,421
|
ralscha/extclassgenerator
|
src/main/java/ch/rasc/extclassgenerator/ReferenceBean.java
|
ReferenceBean.hasAnyProperties
|
public boolean hasAnyProperties() {
return StringUtils.hasText(this.type) || StringUtils.hasText(this.association)
|| StringUtils.hasText(this.child) || StringUtils.hasText(this.parent)
|| StringUtils.hasText(this.role) || StringUtils.hasText(this.inverse);
}
|
java
|
public boolean hasAnyProperties() {
return StringUtils.hasText(this.type) || StringUtils.hasText(this.association)
|| StringUtils.hasText(this.child) || StringUtils.hasText(this.parent)
|| StringUtils.hasText(this.role) || StringUtils.hasText(this.inverse);
}
|
[
"public",
"boolean",
"hasAnyProperties",
"(",
")",
"{",
"return",
"StringUtils",
".",
"hasText",
"(",
"this",
".",
"type",
")",
"||",
"StringUtils",
".",
"hasText",
"(",
"this",
".",
"association",
")",
"||",
"StringUtils",
".",
"hasText",
"(",
"this",
".",
"child",
")",
"||",
"StringUtils",
".",
"hasText",
"(",
"this",
".",
"parent",
")",
"||",
"StringUtils",
".",
"hasText",
"(",
"this",
".",
"role",
")",
"||",
"StringUtils",
".",
"hasText",
"(",
"this",
".",
"inverse",
")",
";",
"}"
] |
Tests if something is set.
|
[
"Tests",
"if",
"something",
"is",
"set",
"."
] |
6f106cf5ca83ef004225a3512e2291dfd028cf07
|
https://github.com/ralscha/extclassgenerator/blob/6f106cf5ca83ef004225a3512e2291dfd028cf07/src/main/java/ch/rasc/extclassgenerator/ReferenceBean.java#L47-L51
|
11,422
|
eirbjo/jetty-console
|
jetty-console-maven-plugin/src/main/java/org/simplericity/jettyconsole/CreateDescriptorMojo.java
|
CreateDescriptorMojo.hasSlf4jBinding
|
private boolean hasSlf4jBinding(File file) throws MojoExecutionException {
try (JarFile jarFile = new JarFile(file)){
return jarFile.getEntry("org/slf4j/impl/StaticLoggerBinder.class") != null;
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
|
java
|
private boolean hasSlf4jBinding(File file) throws MojoExecutionException {
try (JarFile jarFile = new JarFile(file)){
return jarFile.getEntry("org/slf4j/impl/StaticLoggerBinder.class") != null;
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
|
[
"private",
"boolean",
"hasSlf4jBinding",
"(",
"File",
"file",
")",
"throws",
"MojoExecutionException",
"{",
"try",
"(",
"JarFile",
"jarFile",
"=",
"new",
"JarFile",
"(",
"file",
")",
")",
"{",
"return",
"jarFile",
".",
"getEntry",
"(",
"\"org/slf4j/impl/StaticLoggerBinder.class\"",
")",
"!=",
"null",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Returns true if the given jar file contains an SLF4J binding
@param file the file
@return true if the jar file contains an SLF4J binding
|
[
"Returns",
"true",
"if",
"the",
"given",
"jar",
"file",
"contains",
"an",
"SLF4J",
"binding"
] |
5bd32ecab12837394dd45fd15c51c3934afcd76b
|
https://github.com/eirbjo/jetty-console/blob/5bd32ecab12837394dd45fd15c51c3934afcd76b/jetty-console-maven-plugin/src/main/java/org/simplericity/jettyconsole/CreateDescriptorMojo.java#L283-L289
|
11,423
|
phax/ph-ebinterface
|
src/main/java/com/helger/ebinterface/visualization/VisualizationManager.java
|
VisualizationManager.getXSLTTemplates
|
@Nullable
public static Templates getXSLTTemplates (@Nonnull final EEbInterfaceVersion eVersion)
{
final String sNamespaceURI = eVersion.getNamespaceURI ();
final Templates ret = s_aRWLock.readLocked ( () -> s_aTemplates.get (sNamespaceURI));
if (ret != null)
return ret;
return s_aRWLock.writeLocked ( () -> {
// Try again in write lock
Templates ret2 = s_aTemplates.get (sNamespaceURI);
if (ret2 == null)
{
// Definitely not present - init
final IReadableResource aXSLTRes = eVersion.getXSLTResource ();
ret2 = XMLTransformerFactory.newTemplates (aXSLTRes);
if (ret2 == null)
LOGGER.error ("Failed to parse XSLT template " + aXSLTRes);
else
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Compiled XSLT template " + aXSLTRes);
s_aTemplates.put (sNamespaceURI, ret2);
}
return ret2;
});
}
|
java
|
@Nullable
public static Templates getXSLTTemplates (@Nonnull final EEbInterfaceVersion eVersion)
{
final String sNamespaceURI = eVersion.getNamespaceURI ();
final Templates ret = s_aRWLock.readLocked ( () -> s_aTemplates.get (sNamespaceURI));
if (ret != null)
return ret;
return s_aRWLock.writeLocked ( () -> {
// Try again in write lock
Templates ret2 = s_aTemplates.get (sNamespaceURI);
if (ret2 == null)
{
// Definitely not present - init
final IReadableResource aXSLTRes = eVersion.getXSLTResource ();
ret2 = XMLTransformerFactory.newTemplates (aXSLTRes);
if (ret2 == null)
LOGGER.error ("Failed to parse XSLT template " + aXSLTRes);
else
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Compiled XSLT template " + aXSLTRes);
s_aTemplates.put (sNamespaceURI, ret2);
}
return ret2;
});
}
|
[
"@",
"Nullable",
"public",
"static",
"Templates",
"getXSLTTemplates",
"(",
"@",
"Nonnull",
"final",
"EEbInterfaceVersion",
"eVersion",
")",
"{",
"final",
"String",
"sNamespaceURI",
"=",
"eVersion",
".",
"getNamespaceURI",
"(",
")",
";",
"final",
"Templates",
"ret",
"=",
"s_aRWLock",
".",
"readLocked",
"(",
"(",
")",
"->",
"s_aTemplates",
".",
"get",
"(",
"sNamespaceURI",
")",
")",
";",
"if",
"(",
"ret",
"!=",
"null",
")",
"return",
"ret",
";",
"return",
"s_aRWLock",
".",
"writeLocked",
"(",
"(",
")",
"->",
"{",
"// Try again in write lock",
"Templates",
"ret2",
"=",
"s_aTemplates",
".",
"get",
"(",
"sNamespaceURI",
")",
";",
"if",
"(",
"ret2",
"==",
"null",
")",
"{",
"// Definitely not present - init",
"final",
"IReadableResource",
"aXSLTRes",
"=",
"eVersion",
".",
"getXSLTResource",
"(",
")",
";",
"ret2",
"=",
"XMLTransformerFactory",
".",
"newTemplates",
"(",
"aXSLTRes",
")",
";",
"if",
"(",
"ret2",
"==",
"null",
")",
"LOGGER",
".",
"error",
"(",
"\"Failed to parse XSLT template \"",
"+",
"aXSLTRes",
")",
";",
"else",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"LOGGER",
".",
"debug",
"(",
"\"Compiled XSLT template \"",
"+",
"aXSLTRes",
")",
";",
"s_aTemplates",
".",
"put",
"(",
"sNamespaceURI",
",",
"ret2",
")",
";",
"}",
"return",
"ret2",
";",
"}",
")",
";",
"}"
] |
Get the precompiled XSLT template to be used. It is lazily initialized upon
first call.
@param eVersion
The ebInterface version to be used. May not be <code>null</code>.
@return The XSLT {@link Templates} to be used to visualize invoices or
<code>null</code> if the template is buggy!
|
[
"Get",
"the",
"precompiled",
"XSLT",
"template",
"to",
"be",
"used",
".",
"It",
"is",
"lazily",
"initialized",
"upon",
"first",
"call",
"."
] |
e3d2381f25c2fdfcc98acff2509bf5f33752d087
|
https://github.com/phax/ph-ebinterface/blob/e3d2381f25c2fdfcc98acff2509bf5f33752d087/src/main/java/com/helger/ebinterface/visualization/VisualizationManager.java#L75-L100
|
11,424
|
phax/ph-ebinterface
|
src/main/java/com/helger/ebinterface/visualization/VisualizationManager.java
|
VisualizationManager.visualize
|
@Nonnull
public static ESuccess visualize (@Nonnull final EEbInterfaceVersion eVersion,
@Nonnull final Source aSource,
@Nonnull final Result aResult)
{
ValueEnforcer.notNull (eVersion, "version");
// Get cache XSL templates
final Templates aTemplates = getXSLTTemplates (eVersion);
if (aTemplates == null)
return ESuccess.FAILURE;
// Start the main transformation
try
{
final Transformer aTransformer = aTemplates.newTransformer ();
aTransformer.transform (aSource, aResult);
return ESuccess.SUCCESS;
}
catch (final TransformerException ex)
{
LOGGER.error ("Failed to apply transformation for ebInterface " + eVersion + " invoice", ex);
return ESuccess.FAILURE;
}
}
|
java
|
@Nonnull
public static ESuccess visualize (@Nonnull final EEbInterfaceVersion eVersion,
@Nonnull final Source aSource,
@Nonnull final Result aResult)
{
ValueEnforcer.notNull (eVersion, "version");
// Get cache XSL templates
final Templates aTemplates = getXSLTTemplates (eVersion);
if (aTemplates == null)
return ESuccess.FAILURE;
// Start the main transformation
try
{
final Transformer aTransformer = aTemplates.newTransformer ();
aTransformer.transform (aSource, aResult);
return ESuccess.SUCCESS;
}
catch (final TransformerException ex)
{
LOGGER.error ("Failed to apply transformation for ebInterface " + eVersion + " invoice", ex);
return ESuccess.FAILURE;
}
}
|
[
"@",
"Nonnull",
"public",
"static",
"ESuccess",
"visualize",
"(",
"@",
"Nonnull",
"final",
"EEbInterfaceVersion",
"eVersion",
",",
"@",
"Nonnull",
"final",
"Source",
"aSource",
",",
"@",
"Nonnull",
"final",
"Result",
"aResult",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"eVersion",
",",
"\"version\"",
")",
";",
"// Get cache XSL templates",
"final",
"Templates",
"aTemplates",
"=",
"getXSLTTemplates",
"(",
"eVersion",
")",
";",
"if",
"(",
"aTemplates",
"==",
"null",
")",
"return",
"ESuccess",
".",
"FAILURE",
";",
"// Start the main transformation",
"try",
"{",
"final",
"Transformer",
"aTransformer",
"=",
"aTemplates",
".",
"newTransformer",
"(",
")",
";",
"aTransformer",
".",
"transform",
"(",
"aSource",
",",
"aResult",
")",
";",
"return",
"ESuccess",
".",
"SUCCESS",
";",
"}",
"catch",
"(",
"final",
"TransformerException",
"ex",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Failed to apply transformation for ebInterface \"",
"+",
"eVersion",
"+",
"\" invoice\"",
",",
"ex",
")",
";",
"return",
"ESuccess",
".",
"FAILURE",
";",
"}",
"}"
] |
Visualize a source to a result for a certain ebInterface version using
XSLT. This is the most generic method.
@param eVersion
ebInterface version to use.
@param aSource
Source.
@param aResult
Destination
@return {@link ESuccess}
|
[
"Visualize",
"a",
"source",
"to",
"a",
"result",
"for",
"a",
"certain",
"ebInterface",
"version",
"using",
"XSLT",
".",
"This",
"is",
"the",
"most",
"generic",
"method",
"."
] |
e3d2381f25c2fdfcc98acff2509bf5f33752d087
|
https://github.com/phax/ph-ebinterface/blob/e3d2381f25c2fdfcc98acff2509bf5f33752d087/src/main/java/com/helger/ebinterface/visualization/VisualizationManager.java#L114-L138
|
11,425
|
telly/groundy
|
library/src/main/java/com/telly/groundy/util/DownloadUtils.java
|
DownloadUtils.getDownloadListenerForTask
|
public static DownloadProgressListener getDownloadListenerForTask(final GroundyTask groundyTask) {
return new DownloadProgressListener() {
@Override
public void onProgress(String url, int progress) {
groundyTask.updateProgress(progress);
}
};
}
|
java
|
public static DownloadProgressListener getDownloadListenerForTask(final GroundyTask groundyTask) {
return new DownloadProgressListener() {
@Override
public void onProgress(String url, int progress) {
groundyTask.updateProgress(progress);
}
};
}
|
[
"public",
"static",
"DownloadProgressListener",
"getDownloadListenerForTask",
"(",
"final",
"GroundyTask",
"groundyTask",
")",
"{",
"return",
"new",
"DownloadProgressListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onProgress",
"(",
"String",
"url",
",",
"int",
"progress",
")",
"{",
"groundyTask",
".",
"updateProgress",
"(",
"progress",
")",
";",
"}",
"}",
";",
"}"
] |
Returns a progress listener that will post progress to the specified groundyTask.
@param groundyTask the groundyTask to post progress to. Cannot be null.
@return a progress listener
|
[
"Returns",
"a",
"progress",
"listener",
"that",
"will",
"post",
"progress",
"to",
"the",
"specified",
"groundyTask",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/util/DownloadUtils.java#L102-L109
|
11,426
|
Terracotta-OSS/statistics
|
src/main/java/org/terracotta/context/query/Matchers.java
|
Matchers.subclassOf
|
public static Matcher<Class<?>> subclassOf(final Class<?> klazz) {
return new Matcher<Class<?>>() {
@Override
protected boolean matchesSafely(Class<?> t) {
return klazz.isAssignableFrom(t);
}
@Override
public String toString() {
return "a subtype of " + klazz;
}
};
}
|
java
|
public static Matcher<Class<?>> subclassOf(final Class<?> klazz) {
return new Matcher<Class<?>>() {
@Override
protected boolean matchesSafely(Class<?> t) {
return klazz.isAssignableFrom(t);
}
@Override
public String toString() {
return "a subtype of " + klazz;
}
};
}
|
[
"public",
"static",
"Matcher",
"<",
"Class",
"<",
"?",
">",
">",
"subclassOf",
"(",
"final",
"Class",
"<",
"?",
">",
"klazz",
")",
"{",
"return",
"new",
"Matcher",
"<",
"Class",
"<",
"?",
">",
">",
"(",
")",
"{",
"@",
"Override",
"protected",
"boolean",
"matchesSafely",
"(",
"Class",
"<",
"?",
">",
"t",
")",
"{",
"return",
"klazz",
".",
"isAssignableFrom",
"(",
"t",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"a subtype of \"",
"+",
"klazz",
";",
"}",
"}",
";",
"}"
] |
Returns a matcher that matches classes that are sub-types of the supplied
class.
@param klazz a potential super-type
@return a {@code Class<?>} matcher
|
[
"Returns",
"a",
"matcher",
"that",
"matches",
"classes",
"that",
"are",
"sub",
"-",
"types",
"of",
"the",
"supplied",
"class",
"."
] |
d24e4989b8c8dbe4f5210e49c7945d51b6585881
|
https://github.com/Terracotta-OSS/statistics/blob/d24e4989b8c8dbe4f5210e49c7945d51b6585881/src/main/java/org/terracotta/context/query/Matchers.java#L107-L120
|
11,427
|
Terracotta-OSS/statistics
|
src/main/java/org/terracotta/context/query/Matchers.java
|
Matchers.hasAttribute
|
public static Matcher<Map<String, Object>> hasAttribute(final String key, final Object value) {
return new Matcher<Map<String, Object>>() {
@Override
protected boolean matchesSafely(Map<String, Object> object) {
return object.containsKey(key) && value.equals(object.get(key));
}
};
}
|
java
|
public static Matcher<Map<String, Object>> hasAttribute(final String key, final Object value) {
return new Matcher<Map<String, Object>>() {
@Override
protected boolean matchesSafely(Map<String, Object> object) {
return object.containsKey(key) && value.equals(object.get(key));
}
};
}
|
[
"public",
"static",
"Matcher",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"hasAttribute",
"(",
"final",
"String",
"key",
",",
"final",
"Object",
"value",
")",
"{",
"return",
"new",
"Matcher",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"(",
")",
"{",
"@",
"Override",
"protected",
"boolean",
"matchesSafely",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"object",
")",
"{",
"return",
"object",
".",
"containsKey",
"(",
"key",
")",
"&&",
"value",
".",
"equals",
"(",
"object",
".",
"get",
"(",
"key",
")",
")",
";",
"}",
"}",
";",
"}"
] |
Returns a matcher that matches attribute maps that include the given
attribute entry.
@param key attribute name
@param value attribute value
@return a {@code Map<String, Object>} matcher
|
[
"Returns",
"a",
"matcher",
"that",
"matches",
"attribute",
"maps",
"that",
"include",
"the",
"given",
"attribute",
"entry",
"."
] |
d24e4989b8c8dbe4f5210e49c7945d51b6585881
|
https://github.com/Terracotta-OSS/statistics/blob/d24e4989b8c8dbe4f5210e49c7945d51b6585881/src/main/java/org/terracotta/context/query/Matchers.java#L130-L138
|
11,428
|
jboss/jboss-el-api_spec
|
src/main/java/javax/el/ELProcessor.java
|
ELProcessor.getValue
|
public Object getValue(String expression, Class<?> expectedType) {
ValueExpression exp = factory.createValueExpression(
elManager.getELContext(),
bracket(expression), expectedType);
return exp.getValue(elManager.getELContext());
}
|
java
|
public Object getValue(String expression, Class<?> expectedType) {
ValueExpression exp = factory.createValueExpression(
elManager.getELContext(),
bracket(expression), expectedType);
return exp.getValue(elManager.getELContext());
}
|
[
"public",
"Object",
"getValue",
"(",
"String",
"expression",
",",
"Class",
"<",
"?",
">",
"expectedType",
")",
"{",
"ValueExpression",
"exp",
"=",
"factory",
".",
"createValueExpression",
"(",
"elManager",
".",
"getELContext",
"(",
")",
",",
"bracket",
"(",
"expression",
")",
",",
"expectedType",
")",
";",
"return",
"exp",
".",
"getValue",
"(",
"elManager",
".",
"getELContext",
"(",
")",
")",
";",
"}"
] |
Evaluates an EL expression, and coerces the result to the specified type.
@param expression The EL expression to be evaluated.
@param expectedType Specifies the type that the resultant evaluation
will be coerced to.
@return The result of the expression evaluation.
|
[
"Evaluates",
"an",
"EL",
"expression",
"and",
"coerces",
"the",
"result",
"to",
"the",
"specified",
"type",
"."
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELProcessor.java#L125-L130
|
11,429
|
jboss/jboss-el-api_spec
|
src/main/java/javax/el/ELProcessor.java
|
ELProcessor.defineFunction
|
public void defineFunction(String prefix, String function, Method method)
throws NoSuchMethodException {
if (prefix == null || function == null || method == null) {
throw new NullPointerException("Null argument for defineFunction");
}
if (! Modifier.isStatic(method.getModifiers())) {
throw new NoSuchMethodException("The method specified in defineFunction must be static: " + method);
}
if (function.equals("")) {
function = method.getName();
}
elManager.mapFunction(prefix, function, method);
}
|
java
|
public void defineFunction(String prefix, String function, Method method)
throws NoSuchMethodException {
if (prefix == null || function == null || method == null) {
throw new NullPointerException("Null argument for defineFunction");
}
if (! Modifier.isStatic(method.getModifiers())) {
throw new NoSuchMethodException("The method specified in defineFunction must be static: " + method);
}
if (function.equals("")) {
function = method.getName();
}
elManager.mapFunction(prefix, function, method);
}
|
[
"public",
"void",
"defineFunction",
"(",
"String",
"prefix",
",",
"String",
"function",
",",
"Method",
"method",
")",
"throws",
"NoSuchMethodException",
"{",
"if",
"(",
"prefix",
"==",
"null",
"||",
"function",
"==",
"null",
"||",
"method",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Null argument for defineFunction\"",
")",
";",
"}",
"if",
"(",
"!",
"Modifier",
".",
"isStatic",
"(",
"method",
".",
"getModifiers",
"(",
")",
")",
")",
"{",
"throw",
"new",
"NoSuchMethodException",
"(",
"\"The method specified in defineFunction must be static: \"",
"+",
"method",
")",
";",
"}",
"if",
"(",
"function",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"function",
"=",
"method",
".",
"getName",
"(",
")",
";",
"}",
"elManager",
".",
"mapFunction",
"(",
"prefix",
",",
"function",
",",
"method",
")",
";",
"}"
] |
Define an EL function in the local function mapper.
@param prefix The namespace for the function or "" for no namesapce.
@param function The name of the function.
If empty (""), the method name is used as the function name.
@param method The <code>java.lang.reflect.Method</code> instance of
the method that implements the function.
@throws NullPointerException if any of the arguments is null.
@throws NoSuchMethodException if the method is not a static method
|
[
"Define",
"an",
"EL",
"function",
"in",
"the",
"local",
"function",
"mapper",
"."
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELProcessor.java#L257-L269
|
11,430
|
rpau/javalang
|
src/main/java/org/walkmod/javalang/actions/ReplaceAction.java
|
ReplaceAction.getText
|
public String getText(String indentation, char indentationChar) {
newCode = FormatterHelper.indent(
newNode.getPrettySource(indentationChar, indentationLevel, indentationSize, acceptedComments),
indentation, indentationChar, indentationLevel, indentationSize, requiresExtraIndentationOnFirstLine());
return newCode;
}
|
java
|
public String getText(String indentation, char indentationChar) {
newCode = FormatterHelper.indent(
newNode.getPrettySource(indentationChar, indentationLevel, indentationSize, acceptedComments),
indentation, indentationChar, indentationLevel, indentationSize, requiresExtraIndentationOnFirstLine());
return newCode;
}
|
[
"public",
"String",
"getText",
"(",
"String",
"indentation",
",",
"char",
"indentationChar",
")",
"{",
"newCode",
"=",
"FormatterHelper",
".",
"indent",
"(",
"newNode",
".",
"getPrettySource",
"(",
"indentationChar",
",",
"indentationLevel",
",",
"indentationSize",
",",
"acceptedComments",
")",
",",
"indentation",
",",
"indentationChar",
",",
"indentationLevel",
",",
"indentationSize",
",",
"requiresExtraIndentationOnFirstLine",
"(",
")",
")",
";",
"return",
"newCode",
";",
"}"
] |
Returns the new text to insert with the appropriate indentation and comments
@param indentation
the existing indentation at the file. It never should be null and it is needed for
files that mix tabs and spaces in the same line.
@param indentationChar
the used indentation char (' ', or '\t')
@return the new text that replaces the existing one
|
[
"Returns",
"the",
"new",
"text",
"to",
"insert",
"with",
"the",
"appropriate",
"indentation",
"and",
"comments"
] |
17ab1d6cbe7527a2f272049c4958354328de2171
|
https://github.com/rpau/javalang/blob/17ab1d6cbe7527a2f272049c4958354328de2171/src/main/java/org/walkmod/javalang/actions/ReplaceAction.java#L105-L112
|
11,431
|
jboss/jboss-el-api_spec
|
src/main/java/javax/el/ELContext.java
|
ELContext.getContext
|
public Object getContext(Class key) {
if(key == null) {
throw new NullPointerException();
}
return map.get(key);
}
|
java
|
public Object getContext(Class key) {
if(key == null) {
throw new NullPointerException();
}
return map.get(key);
}
|
[
"public",
"Object",
"getContext",
"(",
"Class",
"key",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"return",
"map",
".",
"get",
"(",
"key",
")",
";",
"}"
] |
Returns the context object associated with the given key.
<p>The <code>ELContext</code> maintains a collection of context objects
relevant to the evaluation of an expression. These context objects
are used by <code>ELResolver</code>s. This method is used to
retrieve the context with the given key from the collection.</p>
<p>By convention, the object returned will be of the type specified by
the <code>key</code>. However, this is not required and the key is
used strictly as a unique identifier.</p>
@param key The unique identifier that was used to associate the
context object with this <code>ELContext</code>.
@return The context object associated with the given key, or null
if no such context was found.
@throws NullPointerException if key is null.
|
[
"Returns",
"the",
"context",
"object",
"associated",
"with",
"the",
"given",
"key",
"."
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELContext.java#L219-L224
|
11,432
|
jboss/jboss-el-api_spec
|
src/main/java/javax/el/ELContext.java
|
ELContext.addEvaluationListener
|
public void addEvaluationListener(EvaluationListener listener) {
if (listeners == null) {
listeners = new ArrayList<EvaluationListener>();
}
listeners.add(listener);
}
|
java
|
public void addEvaluationListener(EvaluationListener listener) {
if (listeners == null) {
listeners = new ArrayList<EvaluationListener>();
}
listeners.add(listener);
}
|
[
"public",
"void",
"addEvaluationListener",
"(",
"EvaluationListener",
"listener",
")",
"{",
"if",
"(",
"listeners",
"==",
"null",
")",
"{",
"listeners",
"=",
"new",
"ArrayList",
"<",
"EvaluationListener",
">",
"(",
")",
";",
"}",
"listeners",
".",
"add",
"(",
"listener",
")",
";",
"}"
] |
Registers an evaluation listener to the ELContext.
@param listener The listener to be added.
@since EL 3.0
|
[
"Registers",
"an",
"evaluation",
"listener",
"to",
"the",
"ELContext",
"."
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELContext.java#L315-L320
|
11,433
|
jboss/jboss-el-api_spec
|
src/main/java/javax/el/ELContext.java
|
ELContext.notifyBeforeEvaluation
|
public void notifyBeforeEvaluation(String expr) {
if (getEvaluationListeners() == null)
return;
for (EvaluationListener listener: getEvaluationListeners()) {
listener.beforeEvaluation(this, expr);
}
}
|
java
|
public void notifyBeforeEvaluation(String expr) {
if (getEvaluationListeners() == null)
return;
for (EvaluationListener listener: getEvaluationListeners()) {
listener.beforeEvaluation(this, expr);
}
}
|
[
"public",
"void",
"notifyBeforeEvaluation",
"(",
"String",
"expr",
")",
"{",
"if",
"(",
"getEvaluationListeners",
"(",
")",
"==",
"null",
")",
"return",
";",
"for",
"(",
"EvaluationListener",
"listener",
":",
"getEvaluationListeners",
"(",
")",
")",
"{",
"listener",
".",
"beforeEvaluation",
"(",
"this",
",",
"expr",
")",
";",
"}",
"}"
] |
Notifies the listeners before an EL expression is evaluated
@param expr The EL expression string to be evaluated
|
[
"Notifies",
"the",
"listeners",
"before",
"an",
"EL",
"expression",
"is",
"evaluated"
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELContext.java#L336-L342
|
11,434
|
jboss/jboss-el-api_spec
|
src/main/java/javax/el/ELContext.java
|
ELContext.notifyAfterEvaluation
|
public void notifyAfterEvaluation(String expr) {
if (getEvaluationListeners() == null)
return;
for (EvaluationListener listener: getEvaluationListeners()) {
listener.afterEvaluation(this, expr);
}
}
|
java
|
public void notifyAfterEvaluation(String expr) {
if (getEvaluationListeners() == null)
return;
for (EvaluationListener listener: getEvaluationListeners()) {
listener.afterEvaluation(this, expr);
}
}
|
[
"public",
"void",
"notifyAfterEvaluation",
"(",
"String",
"expr",
")",
"{",
"if",
"(",
"getEvaluationListeners",
"(",
")",
"==",
"null",
")",
"return",
";",
"for",
"(",
"EvaluationListener",
"listener",
":",
"getEvaluationListeners",
"(",
")",
")",
"{",
"listener",
".",
"afterEvaluation",
"(",
"this",
",",
"expr",
")",
";",
"}",
"}"
] |
Notifies the listeners after an EL expression is evaluated
@param expr The EL expression string that has been evaluated
|
[
"Notifies",
"the",
"listeners",
"after",
"an",
"EL",
"expression",
"is",
"evaluated"
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELContext.java#L348-L354
|
11,435
|
jboss/jboss-el-api_spec
|
src/main/java/javax/el/ELContext.java
|
ELContext.isLambdaArgument
|
public boolean isLambdaArgument(String arg) {
if (lambdaArgs == null) {
return false;
}
for (int i = lambdaArgs.size() - 1; i >= 0; i--) {
Map<String, Object> lmap = lambdaArgs.elementAt(i);
if (lmap.containsKey(arg)) {
return true;
}
}
return false;
}
|
java
|
public boolean isLambdaArgument(String arg) {
if (lambdaArgs == null) {
return false;
}
for (int i = lambdaArgs.size() - 1; i >= 0; i--) {
Map<String, Object> lmap = lambdaArgs.elementAt(i);
if (lmap.containsKey(arg)) {
return true;
}
}
return false;
}
|
[
"public",
"boolean",
"isLambdaArgument",
"(",
"String",
"arg",
")",
"{",
"if",
"(",
"lambdaArgs",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"lambdaArgs",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"lmap",
"=",
"lambdaArgs",
".",
"elementAt",
"(",
"i",
")",
";",
"if",
"(",
"lmap",
".",
"containsKey",
"(",
"arg",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Inquires if the name is a LambdaArgument
@param arg A possible Lambda formal parameter name
@return true if arg is a LambdaArgument, false otherwise.
|
[
"Inquires",
"if",
"the",
"name",
"is",
"a",
"LambdaArgument"
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELContext.java#L374-L386
|
11,436
|
jboss/jboss-el-api_spec
|
src/main/java/javax/el/ELContext.java
|
ELContext.getLambdaArgument
|
public Object getLambdaArgument(String arg) {
if (lambdaArgs == null) {
return null;
}
for (int i = lambdaArgs.size() - 1; i >= 0; i--) {
Map<String, Object> lmap = lambdaArgs.elementAt(i);
Object v = lmap.get(arg);
if (v != null) {
return v;
}
}
return null;
}
|
java
|
public Object getLambdaArgument(String arg) {
if (lambdaArgs == null) {
return null;
}
for (int i = lambdaArgs.size() - 1; i >= 0; i--) {
Map<String, Object> lmap = lambdaArgs.elementAt(i);
Object v = lmap.get(arg);
if (v != null) {
return v;
}
}
return null;
}
|
[
"public",
"Object",
"getLambdaArgument",
"(",
"String",
"arg",
")",
"{",
"if",
"(",
"lambdaArgs",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"lambdaArgs",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"lmap",
"=",
"lambdaArgs",
".",
"elementAt",
"(",
"i",
")",
";",
"Object",
"v",
"=",
"lmap",
".",
"get",
"(",
"arg",
")",
";",
"if",
"(",
"v",
"!=",
"null",
")",
"{",
"return",
"v",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Retrieves the Lambda argument associated with a formal parameter.
If the Lambda expression is nested within other Lambda expressions, the
arguments for the current Lambda expression is first searched, and if
not found, the arguments for the immediate nesting Lambda expression
then searched, and so on.
@param arg The formal parameter for the Lambda argument
@return The object associated with formal parameter. Null if
no object has been associated with the parameter.
@since EL 3.0
|
[
"Retrieves",
"the",
"Lambda",
"argument",
"associated",
"with",
"a",
"formal",
"parameter",
".",
"If",
"the",
"Lambda",
"expression",
"is",
"nested",
"within",
"other",
"Lambda",
"expressions",
"the",
"arguments",
"for",
"the",
"current",
"Lambda",
"expression",
"is",
"first",
"searched",
"and",
"if",
"not",
"found",
"the",
"arguments",
"for",
"the",
"immediate",
"nesting",
"Lambda",
"expression",
"then",
"searched",
"and",
"so",
"on",
"."
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELContext.java#L400-L413
|
11,437
|
jboss/jboss-el-api_spec
|
src/main/java/javax/el/ELContext.java
|
ELContext.enterLambdaScope
|
public void enterLambdaScope(Map<String,Object> args) {
if (lambdaArgs == null) {
lambdaArgs = new Stack<Map<String,Object>>();
}
lambdaArgs.push(args);
}
|
java
|
public void enterLambdaScope(Map<String,Object> args) {
if (lambdaArgs == null) {
lambdaArgs = new Stack<Map<String,Object>>();
}
lambdaArgs.push(args);
}
|
[
"public",
"void",
"enterLambdaScope",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"args",
")",
"{",
"if",
"(",
"lambdaArgs",
"==",
"null",
")",
"{",
"lambdaArgs",
"=",
"new",
"Stack",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"(",
")",
";",
"}",
"lambdaArgs",
".",
"push",
"(",
"args",
")",
";",
"}"
] |
Installs a Lambda argument map, in preparation for the evaluation
of a Lambda expression. The arguments in the map will be in scope
during the evaluation of the Lambda expression.
@param args The Lambda arguments map
@since EL 3.0
|
[
"Installs",
"a",
"Lambda",
"argument",
"map",
"in",
"preparation",
"for",
"the",
"evaluation",
"of",
"a",
"Lambda",
"expression",
".",
"The",
"arguments",
"in",
"the",
"map",
"will",
"be",
"in",
"scope",
"during",
"the",
"evaluation",
"of",
"the",
"Lambda",
"expression",
"."
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELContext.java#L422-L427
|
11,438
|
rpau/javalang
|
src/main/java/org/walkmod/javalang/ast/CompilationUnit.java
|
CompilationUnit.setPackage
|
public void setPackage(PackageDeclaration pakage) {
if (this.pakage != null) {
updateReferences(this.pakage);
}
this.pakage = pakage;
setAsParentNodeOf(pakage);
}
|
java
|
public void setPackage(PackageDeclaration pakage) {
if (this.pakage != null) {
updateReferences(this.pakage);
}
this.pakage = pakage;
setAsParentNodeOf(pakage);
}
|
[
"public",
"void",
"setPackage",
"(",
"PackageDeclaration",
"pakage",
")",
"{",
"if",
"(",
"this",
".",
"pakage",
"!=",
"null",
")",
"{",
"updateReferences",
"(",
"this",
".",
"pakage",
")",
";",
"}",
"this",
".",
"pakage",
"=",
"pakage",
";",
"setAsParentNodeOf",
"(",
"pakage",
")",
";",
"}"
] |
Sets or clear the package declarations of this compilation unit.
@param pakage
the pakage declaration to set or <code>null</code> to default package
|
[
"Sets",
"or",
"clear",
"the",
"package",
"declarations",
"of",
"this",
"compilation",
"unit",
"."
] |
17ab1d6cbe7527a2f272049c4958354328de2171
|
https://github.com/rpau/javalang/blob/17ab1d6cbe7527a2f272049c4958354328de2171/src/main/java/org/walkmod/javalang/ast/CompilationUnit.java#L240-L246
|
11,439
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/subset/neigh/SingleSwapNeighbourhood.java
|
SingleSwapNeighbourhood.getAllMoves
|
@Override
public List<SubsetMove> getAllMoves(SubsetSolution solution) {
// get set of candidate IDs for removal and addition (possibly fixed IDs are discarded)
Set<Integer> removeCandidates = getRemoveCandidates(solution);
Set<Integer> addCandidates = getAddCandidates(solution);
// first check if swaps are possible, for efficiency (avoids superfluous loop iterations)
if(removeCandidates.isEmpty() || addCandidates.isEmpty()){
// no swap moves can be applied, return empty set
return Collections.emptyList();
}
// create swap move for all combinations of add and remove candidates
return addCandidates.stream()
.flatMap(add -> removeCandidates.stream().map(remove -> new SwapMove(add, remove)))
.collect(Collectors.toList());
}
|
java
|
@Override
public List<SubsetMove> getAllMoves(SubsetSolution solution) {
// get set of candidate IDs for removal and addition (possibly fixed IDs are discarded)
Set<Integer> removeCandidates = getRemoveCandidates(solution);
Set<Integer> addCandidates = getAddCandidates(solution);
// first check if swaps are possible, for efficiency (avoids superfluous loop iterations)
if(removeCandidates.isEmpty() || addCandidates.isEmpty()){
// no swap moves can be applied, return empty set
return Collections.emptyList();
}
// create swap move for all combinations of add and remove candidates
return addCandidates.stream()
.flatMap(add -> removeCandidates.stream().map(remove -> new SwapMove(add, remove)))
.collect(Collectors.toList());
}
|
[
"@",
"Override",
"public",
"List",
"<",
"SubsetMove",
">",
"getAllMoves",
"(",
"SubsetSolution",
"solution",
")",
"{",
"// get set of candidate IDs for removal and addition (possibly fixed IDs are discarded)",
"Set",
"<",
"Integer",
">",
"removeCandidates",
"=",
"getRemoveCandidates",
"(",
"solution",
")",
";",
"Set",
"<",
"Integer",
">",
"addCandidates",
"=",
"getAddCandidates",
"(",
"solution",
")",
";",
"// first check if swaps are possible, for efficiency (avoids superfluous loop iterations)",
"if",
"(",
"removeCandidates",
".",
"isEmpty",
"(",
")",
"||",
"addCandidates",
".",
"isEmpty",
"(",
")",
")",
"{",
"// no swap moves can be applied, return empty set",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"// create swap move for all combinations of add and remove candidates",
"return",
"addCandidates",
".",
"stream",
"(",
")",
".",
"flatMap",
"(",
"add",
"->",
"removeCandidates",
".",
"stream",
"(",
")",
".",
"map",
"(",
"remove",
"->",
"new",
"SwapMove",
"(",
"add",
",",
"remove",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] |
Generates a list of all possible swap moves that transform the given subset solution by removing a single ID from
the current selection and replacing it with a new ID which is currently not selected. Possible fixed IDs are not
considered to be swapped. May return an empty list if no swap moves can be generated.
@param solution solution for which all possible swap moves are generated
@return list of all swap moves, may be empty
|
[
"Generates",
"a",
"list",
"of",
"all",
"possible",
"swap",
"moves",
"that",
"transform",
"the",
"given",
"subset",
"solution",
"by",
"removing",
"a",
"single",
"ID",
"from",
"the",
"current",
"selection",
"and",
"replacing",
"it",
"with",
"a",
"new",
"ID",
"which",
"is",
"currently",
"not",
"selected",
".",
"Possible",
"fixed",
"IDs",
"are",
"not",
"considered",
"to",
"be",
"swapped",
".",
"May",
"return",
"an",
"empty",
"list",
"if",
"no",
"swap",
"moves",
"can",
"be",
"generated",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/neigh/SingleSwapNeighbourhood.java#L97-L111
|
11,440
|
rpau/javalang
|
src/main/java/org/walkmod/javalang/ast/PackageDeclaration.java
|
PackageDeclaration.setName
|
public void setName(NameExpr name) {
if (this.name != null) {
updateReferences(this.name);
}
this.name = name;
setAsParentNodeOf(name);
}
|
java
|
public void setName(NameExpr name) {
if (this.name != null) {
updateReferences(this.name);
}
this.name = name;
setAsParentNodeOf(name);
}
|
[
"public",
"void",
"setName",
"(",
"NameExpr",
"name",
")",
"{",
"if",
"(",
"this",
".",
"name",
"!=",
"null",
")",
"{",
"updateReferences",
"(",
"this",
".",
"name",
")",
";",
"}",
"this",
".",
"name",
"=",
"name",
";",
"setAsParentNodeOf",
"(",
"name",
")",
";",
"}"
] |
Sets the name of this package declaration.
@param name
the name to set
|
[
"Sets",
"the",
"name",
"of",
"this",
"package",
"declaration",
"."
] |
17ab1d6cbe7527a2f272049c4958354328de2171
|
https://github.com/rpau/javalang/blob/17ab1d6cbe7527a2f272049c4958354328de2171/src/main/java/org/walkmod/javalang/ast/PackageDeclaration.java#L149-L155
|
11,441
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/algo/ParallelTempering.java
|
ParallelTempering.searchStep
|
@Override
protected void searchStep() {
// submit replicas for execution in thread pool
// (future returns index of respective replica)
for(int i=0; i < replicas.size(); i++){
futures.add(pool.submit(replicas.get(i), i));
}
// logger.debug("{}: started {} Metropolis replicas", this, futures.size());
// wait for completion of all replicas and remove corresponding future
while(!futures.isEmpty()){
// remove next future from queue and wait until it has completed
try{
int i = futures.poll().get();
// logger.debug("{}: {}/{} replicas finished", this, replicas.size()-futures.size(), replicas.size());
// update total number of accepted/rejected moves
incNumAcceptedMoves(replicas.get(i).getNumAcceptedMoves());
incNumRejectedMoves(replicas.get(i).getNumRejectedMoves());
} catch (InterruptedException | ExecutionException ex){
throw new SearchException("An error occured during concurrent execution of Metropolis replicas "
+ "in the parallel tempering algorithm.", ex);
}
}
// consider swapping solutions of adjacent replicas
for(int i=swapBase; i<replicas.size()-1; i+=2){
MetropolisSearch<SolutionType> r1 = replicas.get(i);
MetropolisSearch<SolutionType> r2 = replicas.get(i+1);
// compute delta
double delta = computeDelta(r2.getCurrentSolutionEvaluation(), r1.getCurrentSolutionEvaluation());
// check if solutions should be swapped
boolean swap = false;
if(delta >= 0){
// always swap
swap = true;
} else {
// compute factor based on difference in temperature
double b1 = 1.0 / (r1.getTemperature());
double b2 = 1.0 / (r2.getTemperature());
double diffb = b1 - b2;
// randomized swap (with probability p)
double p = Math.exp(diffb * delta);
// generate random number
double r = getRandom().nextDouble();
// swap with probability p
if(r < p){
swap = true;
}
}
// swap solutions
if(swap){
SolutionType r1Sol = r1.getCurrentSolution();
Evaluation r1Eval = r1.getCurrentSolutionEvaluation();
Validation r1Val = r1.getCurrentSolutionValidation();
r1.setCurrentSolution(
r2.getCurrentSolution(),
r2.getCurrentSolutionEvaluation(),
r2.getCurrentSolutionValidation()
);
r2.setCurrentSolution(r1Sol, r1Eval, r1Val);
}
}
// flip swap base
swapBase = 1 - swapBase;
}
|
java
|
@Override
protected void searchStep() {
// submit replicas for execution in thread pool
// (future returns index of respective replica)
for(int i=0; i < replicas.size(); i++){
futures.add(pool.submit(replicas.get(i), i));
}
// logger.debug("{}: started {} Metropolis replicas", this, futures.size());
// wait for completion of all replicas and remove corresponding future
while(!futures.isEmpty()){
// remove next future from queue and wait until it has completed
try{
int i = futures.poll().get();
// logger.debug("{}: {}/{} replicas finished", this, replicas.size()-futures.size(), replicas.size());
// update total number of accepted/rejected moves
incNumAcceptedMoves(replicas.get(i).getNumAcceptedMoves());
incNumRejectedMoves(replicas.get(i).getNumRejectedMoves());
} catch (InterruptedException | ExecutionException ex){
throw new SearchException("An error occured during concurrent execution of Metropolis replicas "
+ "in the parallel tempering algorithm.", ex);
}
}
// consider swapping solutions of adjacent replicas
for(int i=swapBase; i<replicas.size()-1; i+=2){
MetropolisSearch<SolutionType> r1 = replicas.get(i);
MetropolisSearch<SolutionType> r2 = replicas.get(i+1);
// compute delta
double delta = computeDelta(r2.getCurrentSolutionEvaluation(), r1.getCurrentSolutionEvaluation());
// check if solutions should be swapped
boolean swap = false;
if(delta >= 0){
// always swap
swap = true;
} else {
// compute factor based on difference in temperature
double b1 = 1.0 / (r1.getTemperature());
double b2 = 1.0 / (r2.getTemperature());
double diffb = b1 - b2;
// randomized swap (with probability p)
double p = Math.exp(diffb * delta);
// generate random number
double r = getRandom().nextDouble();
// swap with probability p
if(r < p){
swap = true;
}
}
// swap solutions
if(swap){
SolutionType r1Sol = r1.getCurrentSolution();
Evaluation r1Eval = r1.getCurrentSolutionEvaluation();
Validation r1Val = r1.getCurrentSolutionValidation();
r1.setCurrentSolution(
r2.getCurrentSolution(),
r2.getCurrentSolutionEvaluation(),
r2.getCurrentSolutionValidation()
);
r2.setCurrentSolution(r1Sol, r1Eval, r1Val);
}
}
// flip swap base
swapBase = 1 - swapBase;
}
|
[
"@",
"Override",
"protected",
"void",
"searchStep",
"(",
")",
"{",
"// submit replicas for execution in thread pool",
"// (future returns index of respective replica)",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"replicas",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"futures",
".",
"add",
"(",
"pool",
".",
"submit",
"(",
"replicas",
".",
"get",
"(",
"i",
")",
",",
"i",
")",
")",
";",
"}",
"// logger.debug(\"{}: started {} Metropolis replicas\", this, futures.size());",
"// wait for completion of all replicas and remove corresponding future",
"while",
"(",
"!",
"futures",
".",
"isEmpty",
"(",
")",
")",
"{",
"// remove next future from queue and wait until it has completed",
"try",
"{",
"int",
"i",
"=",
"futures",
".",
"poll",
"(",
")",
".",
"get",
"(",
")",
";",
"// logger.debug(\"{}: {}/{} replicas finished\", this, replicas.size()-futures.size(), replicas.size());",
"// update total number of accepted/rejected moves",
"incNumAcceptedMoves",
"(",
"replicas",
".",
"get",
"(",
"i",
")",
".",
"getNumAcceptedMoves",
"(",
")",
")",
";",
"incNumRejectedMoves",
"(",
"replicas",
".",
"get",
"(",
"i",
")",
".",
"getNumRejectedMoves",
"(",
")",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"|",
"ExecutionException",
"ex",
")",
"{",
"throw",
"new",
"SearchException",
"(",
"\"An error occured during concurrent execution of Metropolis replicas \"",
"+",
"\"in the parallel tempering algorithm.\"",
",",
"ex",
")",
";",
"}",
"}",
"// consider swapping solutions of adjacent replicas",
"for",
"(",
"int",
"i",
"=",
"swapBase",
";",
"i",
"<",
"replicas",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
"+=",
"2",
")",
"{",
"MetropolisSearch",
"<",
"SolutionType",
">",
"r1",
"=",
"replicas",
".",
"get",
"(",
"i",
")",
";",
"MetropolisSearch",
"<",
"SolutionType",
">",
"r2",
"=",
"replicas",
".",
"get",
"(",
"i",
"+",
"1",
")",
";",
"// compute delta",
"double",
"delta",
"=",
"computeDelta",
"(",
"r2",
".",
"getCurrentSolutionEvaluation",
"(",
")",
",",
"r1",
".",
"getCurrentSolutionEvaluation",
"(",
")",
")",
";",
"// check if solutions should be swapped",
"boolean",
"swap",
"=",
"false",
";",
"if",
"(",
"delta",
">=",
"0",
")",
"{",
"// always swap",
"swap",
"=",
"true",
";",
"}",
"else",
"{",
"// compute factor based on difference in temperature",
"double",
"b1",
"=",
"1.0",
"/",
"(",
"r1",
".",
"getTemperature",
"(",
")",
")",
";",
"double",
"b2",
"=",
"1.0",
"/",
"(",
"r2",
".",
"getTemperature",
"(",
")",
")",
";",
"double",
"diffb",
"=",
"b1",
"-",
"b2",
";",
"// randomized swap (with probability p)",
"double",
"p",
"=",
"Math",
".",
"exp",
"(",
"diffb",
"*",
"delta",
")",
";",
"// generate random number",
"double",
"r",
"=",
"getRandom",
"(",
")",
".",
"nextDouble",
"(",
")",
";",
"// swap with probability p",
"if",
"(",
"r",
"<",
"p",
")",
"{",
"swap",
"=",
"true",
";",
"}",
"}",
"// swap solutions",
"if",
"(",
"swap",
")",
"{",
"SolutionType",
"r1Sol",
"=",
"r1",
".",
"getCurrentSolution",
"(",
")",
";",
"Evaluation",
"r1Eval",
"=",
"r1",
".",
"getCurrentSolutionEvaluation",
"(",
")",
";",
"Validation",
"r1Val",
"=",
"r1",
".",
"getCurrentSolutionValidation",
"(",
")",
";",
"r1",
".",
"setCurrentSolution",
"(",
"r2",
".",
"getCurrentSolution",
"(",
")",
",",
"r2",
".",
"getCurrentSolutionEvaluation",
"(",
")",
",",
"r2",
".",
"getCurrentSolutionValidation",
"(",
")",
")",
";",
"r2",
".",
"setCurrentSolution",
"(",
"r1Sol",
",",
"r1Eval",
",",
"r1Val",
")",
";",
"}",
"}",
"// flip swap base",
"swapBase",
"=",
"1",
"-",
"swapBase",
";",
"}"
] |
In each search step, every replica performs several steps after which solutions of adjacent
replicas may be swapped.
@throws SearchException if an error occurs during concurrent execution of the Metropolis replicas
@throws JamesRuntimeException if depending on malfunctioning components (problem,
neighbourhood, replicas, ...)
|
[
"In",
"each",
"search",
"step",
"every",
"replica",
"performs",
"several",
"steps",
"after",
"which",
"solutions",
"of",
"adjacent",
"replicas",
"may",
"be",
"swapped",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/algo/ParallelTempering.java#L370-L432
|
11,442
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/algo/ParallelTempering.java
|
ParallelTempering.searchDisposed
|
@Override
protected void searchDisposed(){
// dispose replicas
replicas.forEach(r -> r.dispose());
// shut down thread pool
pool.shutdown();
// dispose super
super.searchDisposed();
}
|
java
|
@Override
protected void searchDisposed(){
// dispose replicas
replicas.forEach(r -> r.dispose());
// shut down thread pool
pool.shutdown();
// dispose super
super.searchDisposed();
}
|
[
"@",
"Override",
"protected",
"void",
"searchDisposed",
"(",
")",
"{",
"// dispose replicas",
"replicas",
".",
"forEach",
"(",
"r",
"->",
"r",
".",
"dispose",
"(",
")",
")",
";",
"// shut down thread pool",
"pool",
".",
"shutdown",
"(",
")",
";",
"// dispose super",
"super",
".",
"searchDisposed",
"(",
")",
";",
"}"
] |
When disposing a parallel tempering search, it will dispose each contained Metropolis replica and will
shut down the thread pool used for concurrent execution of replicas.
|
[
"When",
"disposing",
"a",
"parallel",
"tempering",
"search",
"it",
"will",
"dispose",
"each",
"contained",
"Metropolis",
"replica",
"and",
"will",
"shut",
"down",
"the",
"thread",
"pool",
"used",
"for",
"concurrent",
"execution",
"of",
"replicas",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/algo/ParallelTempering.java#L438-L446
|
11,443
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/TiffDocument.java
|
TiffDocument.getIfdCount
|
public int getIfdCount() {
int c = 0;
if (metadata != null && metadata.contains("IFD"))
c = getMetadataList("IFD").size();
return c;
}
|
java
|
public int getIfdCount() {
int c = 0;
if (metadata != null && metadata.contains("IFD"))
c = getMetadataList("IFD").size();
return c;
}
|
[
"public",
"int",
"getIfdCount",
"(",
")",
"{",
"int",
"c",
"=",
"0",
";",
"if",
"(",
"metadata",
"!=",
"null",
"&&",
"metadata",
".",
"contains",
"(",
"\"IFD\"",
")",
")",
"c",
"=",
"getMetadataList",
"(",
"\"IFD\"",
")",
".",
"size",
"(",
")",
";",
"return",
"c",
";",
"}"
] |
Gets the ifd count.
@return the ifd count
|
[
"Gets",
"the",
"ifd",
"count",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/TiffDocument.java#L156-L161
|
11,444
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/TiffDocument.java
|
TiffDocument.getMainImagesCount
|
public int getMainImagesCount() {
int count = 0;
List<TiffObject> list = new ArrayList<>();
list.addAll(getMetadataList("IFD"));
list.addAll(getMetadataList("SubIFDs"));
for (TiffObject to : list) {
if (to instanceof IFD) {
IFD ifd = (IFD) to;
if (ifd.isImage() && !ifd.isThumbnail())
count++;
}
}
return count;
}
|
java
|
public int getMainImagesCount() {
int count = 0;
List<TiffObject> list = new ArrayList<>();
list.addAll(getMetadataList("IFD"));
list.addAll(getMetadataList("SubIFDs"));
for (TiffObject to : list) {
if (to instanceof IFD) {
IFD ifd = (IFD) to;
if (ifd.isImage() && !ifd.isThumbnail())
count++;
}
}
return count;
}
|
[
"public",
"int",
"getMainImagesCount",
"(",
")",
"{",
"int",
"count",
"=",
"0",
";",
"List",
"<",
"TiffObject",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"list",
".",
"addAll",
"(",
"getMetadataList",
"(",
"\"IFD\"",
")",
")",
";",
"list",
".",
"addAll",
"(",
"getMetadataList",
"(",
"\"SubIFDs\"",
")",
")",
";",
"for",
"(",
"TiffObject",
"to",
":",
"list",
")",
"{",
"if",
"(",
"to",
"instanceof",
"IFD",
")",
"{",
"IFD",
"ifd",
"=",
"(",
"IFD",
")",
"to",
";",
"if",
"(",
"ifd",
".",
"isImage",
"(",
")",
"&&",
"!",
"ifd",
".",
"isThumbnail",
"(",
")",
")",
"count",
"++",
";",
"}",
"}",
"return",
"count",
";",
"}"
] |
Gets the main images count.
@return the ifd count
|
[
"Gets",
"the",
"main",
"images",
"count",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/TiffDocument.java#L190-L205
|
11,445
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/TiffDocument.java
|
TiffDocument.getSubIfdCount
|
public int getSubIfdCount() {
int c = 0;
if (metadata != null && metadata.contains("SubIFDs"))
c = getMetadataList("SubIFDs").size();
return c;
}
|
java
|
public int getSubIfdCount() {
int c = 0;
if (metadata != null && metadata.contains("SubIFDs"))
c = getMetadataList("SubIFDs").size();
return c;
}
|
[
"public",
"int",
"getSubIfdCount",
"(",
")",
"{",
"int",
"c",
"=",
"0",
";",
"if",
"(",
"metadata",
"!=",
"null",
"&&",
"metadata",
".",
"contains",
"(",
"\"SubIFDs\"",
")",
")",
"c",
"=",
"getMetadataList",
"(",
"\"SubIFDs\"",
")",
".",
"size",
"(",
")",
";",
"return",
"c",
";",
"}"
] |
Gets the Subifd count.
@return the Subifd count
|
[
"Gets",
"the",
"Subifd",
"count",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/TiffDocument.java#L234-L239
|
11,446
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/TiffDocument.java
|
TiffDocument.getIfds
|
public List<TiffObject> getIfds() {
List<TiffObject> l = new ArrayList<TiffObject>();
if (metadata != null && metadata.contains("IFD"))
l = getMetadataList("IFD");
return l;
}
|
java
|
public List<TiffObject> getIfds() {
List<TiffObject> l = new ArrayList<TiffObject>();
if (metadata != null && metadata.contains("IFD"))
l = getMetadataList("IFD");
return l;
}
|
[
"public",
"List",
"<",
"TiffObject",
">",
"getIfds",
"(",
")",
"{",
"List",
"<",
"TiffObject",
">",
"l",
"=",
"new",
"ArrayList",
"<",
"TiffObject",
">",
"(",
")",
";",
"if",
"(",
"metadata",
"!=",
"null",
"&&",
"metadata",
".",
"contains",
"(",
"\"IFD\"",
")",
")",
"l",
"=",
"getMetadataList",
"(",
"\"IFD\"",
")",
";",
"return",
"l",
";",
"}"
] |
Returns a list of ifds including exifds.
@return the ifds list
|
[
"Returns",
"a",
"list",
"of",
"ifds",
"including",
"exifds",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/TiffDocument.java#L255-L260
|
11,447
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/TiffDocument.java
|
TiffDocument.getImageIfds
|
public List<TiffObject> getImageIfds() {
List<TiffObject> l = new ArrayList<TiffObject>();
IFD oifd = this.firstIFD;
while (oifd != null) {
if (oifd.isImage()) {
if (oifd.hasSubIFD()) {
try {
long length = oifd.getMetadata().get("ImageLength").getFirstNumericValue();
long width = oifd.getMetadata().get("ImageWidth").getFirstNumericValue();
long sublength =
oifd.getsubIFD().getMetadata().get("ImageLength").getFirstNumericValue();
long subwidth = oifd.getsubIFD().getMetadata().get("ImageWidth").getFirstNumericValue();
if (sublength > length && subwidth > width) {
l.add(oifd.getsubIFD());
} else {
l.add(oifd);
}
} catch (Exception ex) {
l.add(oifd);
}
} else {
l.add(oifd);
}
}
oifd = oifd.getNextIFD();
}
return l;
}
|
java
|
public List<TiffObject> getImageIfds() {
List<TiffObject> l = new ArrayList<TiffObject>();
IFD oifd = this.firstIFD;
while (oifd != null) {
if (oifd.isImage()) {
if (oifd.hasSubIFD()) {
try {
long length = oifd.getMetadata().get("ImageLength").getFirstNumericValue();
long width = oifd.getMetadata().get("ImageWidth").getFirstNumericValue();
long sublength =
oifd.getsubIFD().getMetadata().get("ImageLength").getFirstNumericValue();
long subwidth = oifd.getsubIFD().getMetadata().get("ImageWidth").getFirstNumericValue();
if (sublength > length && subwidth > width) {
l.add(oifd.getsubIFD());
} else {
l.add(oifd);
}
} catch (Exception ex) {
l.add(oifd);
}
} else {
l.add(oifd);
}
}
oifd = oifd.getNextIFD();
}
return l;
}
|
[
"public",
"List",
"<",
"TiffObject",
">",
"getImageIfds",
"(",
")",
"{",
"List",
"<",
"TiffObject",
">",
"l",
"=",
"new",
"ArrayList",
"<",
"TiffObject",
">",
"(",
")",
";",
"IFD",
"oifd",
"=",
"this",
".",
"firstIFD",
";",
"while",
"(",
"oifd",
"!=",
"null",
")",
"{",
"if",
"(",
"oifd",
".",
"isImage",
"(",
")",
")",
"{",
"if",
"(",
"oifd",
".",
"hasSubIFD",
"(",
")",
")",
"{",
"try",
"{",
"long",
"length",
"=",
"oifd",
".",
"getMetadata",
"(",
")",
".",
"get",
"(",
"\"ImageLength\"",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"long",
"width",
"=",
"oifd",
".",
"getMetadata",
"(",
")",
".",
"get",
"(",
"\"ImageWidth\"",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"long",
"sublength",
"=",
"oifd",
".",
"getsubIFD",
"(",
")",
".",
"getMetadata",
"(",
")",
".",
"get",
"(",
"\"ImageLength\"",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"long",
"subwidth",
"=",
"oifd",
".",
"getsubIFD",
"(",
")",
".",
"getMetadata",
"(",
")",
".",
"get",
"(",
"\"ImageWidth\"",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"if",
"(",
"sublength",
">",
"length",
"&&",
"subwidth",
">",
"width",
")",
"{",
"l",
".",
"add",
"(",
"oifd",
".",
"getsubIFD",
"(",
")",
")",
";",
"}",
"else",
"{",
"l",
".",
"add",
"(",
"oifd",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"l",
".",
"add",
"(",
"oifd",
")",
";",
"}",
"}",
"else",
"{",
"l",
".",
"add",
"(",
"oifd",
")",
";",
"}",
"}",
"oifd",
"=",
"oifd",
".",
"getNextIFD",
"(",
")",
";",
"}",
"return",
"l",
";",
"}"
] |
Returns a list of ifds representing Images.
@return the ifds list
|
[
"Returns",
"a",
"list",
"of",
"ifds",
"representing",
"Images",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/TiffDocument.java#L267-L294
|
11,448
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/TiffDocument.java
|
TiffDocument.getIfdsAndSubIfds
|
public List<TiffObject> getIfdsAndSubIfds() {
List<TiffObject> all = new ArrayList<TiffObject>();
all.addAll(getMetadataList("IFD"));
all.addAll(getMetadataList("SubIFDs"));
return all;
}
|
java
|
public List<TiffObject> getIfdsAndSubIfds() {
List<TiffObject> all = new ArrayList<TiffObject>();
all.addAll(getMetadataList("IFD"));
all.addAll(getMetadataList("SubIFDs"));
return all;
}
|
[
"public",
"List",
"<",
"TiffObject",
">",
"getIfdsAndSubIfds",
"(",
")",
"{",
"List",
"<",
"TiffObject",
">",
"all",
"=",
"new",
"ArrayList",
"<",
"TiffObject",
">",
"(",
")",
";",
"all",
".",
"addAll",
"(",
"getMetadataList",
"(",
"\"IFD\"",
")",
")",
";",
"all",
".",
"addAll",
"(",
"getMetadataList",
"(",
"\"SubIFDs\"",
")",
")",
";",
"return",
"all",
";",
"}"
] |
Returns a list of subifds.
@return the subifds list
|
[
"Returns",
"a",
"list",
"of",
"subifds",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/TiffDocument.java#L322-L327
|
11,449
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/TiffDocument.java
|
TiffDocument.getMetadataList
|
public List<TiffObject> getMetadataList(String name) {
List<TiffObject> l = new ArrayList<TiffObject>();
if (metadata == null)
createMetadataDictionary();
if (metadata.contains(name))
l = metadata.getList(name);
return l;
}
|
java
|
public List<TiffObject> getMetadataList(String name) {
List<TiffObject> l = new ArrayList<TiffObject>();
if (metadata == null)
createMetadataDictionary();
if (metadata.contains(name))
l = metadata.getList(name);
return l;
}
|
[
"public",
"List",
"<",
"TiffObject",
">",
"getMetadataList",
"(",
"String",
"name",
")",
"{",
"List",
"<",
"TiffObject",
">",
"l",
"=",
"new",
"ArrayList",
"<",
"TiffObject",
">",
"(",
")",
";",
"if",
"(",
"metadata",
"==",
"null",
")",
"createMetadataDictionary",
"(",
")",
";",
"if",
"(",
"metadata",
".",
"contains",
"(",
"name",
")",
")",
"l",
"=",
"metadata",
".",
"getList",
"(",
"name",
")",
";",
"return",
"l",
";",
"}"
] |
Gets the metadata ok a given class name.
@param name the class name
@return the list of metadata that matches with the class name
|
[
"Gets",
"the",
"metadata",
"ok",
"a",
"given",
"class",
"name",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/TiffDocument.java#L386-L393
|
11,450
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/TiffDocument.java
|
TiffDocument.addMetadataFromIFD
|
private void addMetadataFromIFD(IFD ifd, String key, boolean exif) {
metadata.add(key, ifd);
for (TagValue tag : ifd.getMetadata().getTags()) {
if (tag.getCardinality() == 1) {
abstractTiffType t = tag.getValue().get(0);
if (t.isIFD()) {
addMetadataFromIFD((IFD) t, key, true);
} else if (t.containsMetadata()) {
try {
Metadata meta = t.createMetadata();
metadata.addMetadata(meta);
} catch (Exception ex) {
// TODO: What?
}
} else {
if (exif)
t.setContainer("EXIF");
metadata.add(tag.getName(), t);
}
} else {
if (exif)
tag.setContainer("EXIF");
metadata.add(tag.getName(), tag);
}
}
if (ifd.hasNextIFD()) {
addMetadataFromIFD(ifd.getNextIFD(), key, false);
}
}
|
java
|
private void addMetadataFromIFD(IFD ifd, String key, boolean exif) {
metadata.add(key, ifd);
for (TagValue tag : ifd.getMetadata().getTags()) {
if (tag.getCardinality() == 1) {
abstractTiffType t = tag.getValue().get(0);
if (t.isIFD()) {
addMetadataFromIFD((IFD) t, key, true);
} else if (t.containsMetadata()) {
try {
Metadata meta = t.createMetadata();
metadata.addMetadata(meta);
} catch (Exception ex) {
// TODO: What?
}
} else {
if (exif)
t.setContainer("EXIF");
metadata.add(tag.getName(), t);
}
} else {
if (exif)
tag.setContainer("EXIF");
metadata.add(tag.getName(), tag);
}
}
if (ifd.hasNextIFD()) {
addMetadataFromIFD(ifd.getNextIFD(), key, false);
}
}
|
[
"private",
"void",
"addMetadataFromIFD",
"(",
"IFD",
"ifd",
",",
"String",
"key",
",",
"boolean",
"exif",
")",
"{",
"metadata",
".",
"add",
"(",
"key",
",",
"ifd",
")",
";",
"for",
"(",
"TagValue",
"tag",
":",
"ifd",
".",
"getMetadata",
"(",
")",
".",
"getTags",
"(",
")",
")",
"{",
"if",
"(",
"tag",
".",
"getCardinality",
"(",
")",
"==",
"1",
")",
"{",
"abstractTiffType",
"t",
"=",
"tag",
".",
"getValue",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"if",
"(",
"t",
".",
"isIFD",
"(",
")",
")",
"{",
"addMetadataFromIFD",
"(",
"(",
"IFD",
")",
"t",
",",
"key",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"t",
".",
"containsMetadata",
"(",
")",
")",
"{",
"try",
"{",
"Metadata",
"meta",
"=",
"t",
".",
"createMetadata",
"(",
")",
";",
"metadata",
".",
"addMetadata",
"(",
"meta",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"// TODO: What?",
"}",
"}",
"else",
"{",
"if",
"(",
"exif",
")",
"t",
".",
"setContainer",
"(",
"\"EXIF\"",
")",
";",
"metadata",
".",
"add",
"(",
"tag",
".",
"getName",
"(",
")",
",",
"t",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"exif",
")",
"tag",
".",
"setContainer",
"(",
"\"EXIF\"",
")",
";",
"metadata",
".",
"add",
"(",
"tag",
".",
"getName",
"(",
")",
",",
"tag",
")",
";",
"}",
"}",
"if",
"(",
"ifd",
".",
"hasNextIFD",
"(",
")",
")",
"{",
"addMetadataFromIFD",
"(",
"ifd",
".",
"getNextIFD",
"(",
")",
",",
"key",
",",
"false",
")",
";",
"}",
"}"
] |
Adds the metadata from ifd.
@param ifd the ifd
@param key the key
@param exif the exif
@the tiff tags io exception
|
[
"Adds",
"the",
"metadata",
"from",
"ifd",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/TiffDocument.java#L413-L441
|
11,451
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/TiffDocument.java
|
TiffDocument.printMetadata
|
public void printMetadata() {
if (metadata == null)
createMetadataDictionary();
System.out.println("METADATA");
// if (metadata.getCreator() != null) System.out.println("Creator:" + metadata.getCreator());
for (String name : metadata.keySet()) {
String mult = "";
if (getMetadataList(name).size() > 1)
mult = "(x" + getMetadataList(name).size() + ")";
if (metadata.getMetadataObject(name).isDublinCore())
System.out.println("[DC]");
System.out.println(name + mult + ": "
+ getMetadataSingleString(name));
}
}
|
java
|
public void printMetadata() {
if (metadata == null)
createMetadataDictionary();
System.out.println("METADATA");
// if (metadata.getCreator() != null) System.out.println("Creator:" + metadata.getCreator());
for (String name : metadata.keySet()) {
String mult = "";
if (getMetadataList(name).size() > 1)
mult = "(x" + getMetadataList(name).size() + ")";
if (metadata.getMetadataObject(name).isDublinCore())
System.out.println("[DC]");
System.out.println(name + mult + ": "
+ getMetadataSingleString(name));
}
}
|
[
"public",
"void",
"printMetadata",
"(",
")",
"{",
"if",
"(",
"metadata",
"==",
"null",
")",
"createMetadataDictionary",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"METADATA\"",
")",
";",
"// if (metadata.getCreator() != null) System.out.println(\"Creator:\" + metadata.getCreator());",
"for",
"(",
"String",
"name",
":",
"metadata",
".",
"keySet",
"(",
")",
")",
"{",
"String",
"mult",
"=",
"\"\"",
";",
"if",
"(",
"getMetadataList",
"(",
"name",
")",
".",
"size",
"(",
")",
">",
"1",
")",
"mult",
"=",
"\"(x\"",
"+",
"getMetadataList",
"(",
"name",
")",
".",
"size",
"(",
")",
"+",
"\")\"",
";",
"if",
"(",
"metadata",
".",
"getMetadataObject",
"(",
"name",
")",
".",
"isDublinCore",
"(",
")",
")",
"System",
".",
"out",
".",
"println",
"(",
"\"[DC]\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"name",
"+",
"mult",
"+",
"\": \"",
"+",
"getMetadataSingleString",
"(",
"name",
")",
")",
";",
"}",
"}"
] |
Prints the metadata.
|
[
"Prints",
"the",
"metadata",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/TiffDocument.java#L446-L460
|
11,452
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/algo/tabu/FullTabuMemory.java
|
FullTabuMemory.isTabu
|
@Override
public boolean isTabu(Move<? super SolutionType> move, SolutionType currentSolution) {
// apply move
move.apply(currentSolution);
// check: contained in tabu memory?
boolean tabu = memory.contains(currentSolution);
// undo move
move.undo(currentSolution);
// return result
return tabu;
}
|
java
|
@Override
public boolean isTabu(Move<? super SolutionType> move, SolutionType currentSolution) {
// apply move
move.apply(currentSolution);
// check: contained in tabu memory?
boolean tabu = memory.contains(currentSolution);
// undo move
move.undo(currentSolution);
// return result
return tabu;
}
|
[
"@",
"Override",
"public",
"boolean",
"isTabu",
"(",
"Move",
"<",
"?",
"super",
"SolutionType",
">",
"move",
",",
"SolutionType",
"currentSolution",
")",
"{",
"// apply move",
"move",
".",
"apply",
"(",
"currentSolution",
")",
";",
"// check: contained in tabu memory?",
"boolean",
"tabu",
"=",
"memory",
".",
"contains",
"(",
"currentSolution",
")",
";",
"// undo move",
"move",
".",
"undo",
"(",
"currentSolution",
")",
";",
"// return result",
"return",
"tabu",
";",
"}"
] |
Verifies whether the given move is tabu by applying it to the current solution and checking if the obtained
neighbour is currently contained in the tabu memory. If not, the move is allowed. Before returning, the move
is undone to restore the original state of the current solution.
@param move move to be applied to the current solution
@param currentSolution current solution
@return <code>true</code> if the neighbour obtained by applying the given move to the current solution is
currently already contained in the tabu memory
|
[
"Verifies",
"whether",
"the",
"given",
"move",
"is",
"tabu",
"by",
"applying",
"it",
"to",
"the",
"current",
"solution",
"and",
"checking",
"if",
"the",
"obtained",
"neighbour",
"is",
"currently",
"contained",
"in",
"the",
"tabu",
"memory",
".",
"If",
"not",
"the",
"move",
"is",
"allowed",
".",
"Before",
"returning",
"the",
"move",
"is",
"undone",
"to",
"restore",
"the",
"original",
"state",
"of",
"the",
"current",
"solution",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/algo/tabu/FullTabuMemory.java#L67-L77
|
11,453
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/algo/tabu/FullTabuMemory.java
|
FullTabuMemory.registerVisitedSolution
|
@Override
public void registerVisitedSolution(SolutionType visitedSolution, Move<? super SolutionType> appliedMove) {
// store deep copy of newly visited solution
memory.add(Solution.checkedCopy(visitedSolution));
}
|
java
|
@Override
public void registerVisitedSolution(SolutionType visitedSolution, Move<? super SolutionType> appliedMove) {
// store deep copy of newly visited solution
memory.add(Solution.checkedCopy(visitedSolution));
}
|
[
"@",
"Override",
"public",
"void",
"registerVisitedSolution",
"(",
"SolutionType",
"visitedSolution",
",",
"Move",
"<",
"?",
"super",
"SolutionType",
">",
"appliedMove",
")",
"{",
"// store deep copy of newly visited solution",
"memory",
".",
"add",
"(",
"Solution",
".",
"checkedCopy",
"(",
"visitedSolution",
")",
")",
";",
"}"
] |
A newly visited solution is registered by storing a deep copy of this solution in the full tabu memory.
@param visitedSolution newly visited solution (copied to memory)
@param appliedMove applied move (not used here, allowed to be <code>null</code>)
|
[
"A",
"newly",
"visited",
"solution",
"is",
"registered",
"by",
"storing",
"a",
"deep",
"copy",
"of",
"this",
"solution",
"in",
"the",
"full",
"tabu",
"memory",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/algo/tabu/FullTabuMemory.java#L85-L89
|
11,454
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/subset/neigh/SingleAdditionNeighbourhood.java
|
SingleAdditionNeighbourhood.getAllMoves
|
@Override
public List<SubsetMove> getAllMoves(SubsetSolution solution) {
// check size limit
if(maxSizeReached(solution)){
return Collections.emptyList();
}
// get set of candidate IDs for addition (possibly fixed IDs are discarded)
Set<Integer> addCandidates = getAddCandidates(solution);
// check if there are any candidates to be added
if(addCandidates.isEmpty()){
return Collections.emptyList();
}
// create addition move for all add candidates
return addCandidates.stream()
.map(add -> new AdditionMove(add))
.collect(Collectors.toList());
}
|
java
|
@Override
public List<SubsetMove> getAllMoves(SubsetSolution solution) {
// check size limit
if(maxSizeReached(solution)){
return Collections.emptyList();
}
// get set of candidate IDs for addition (possibly fixed IDs are discarded)
Set<Integer> addCandidates = getAddCandidates(solution);
// check if there are any candidates to be added
if(addCandidates.isEmpty()){
return Collections.emptyList();
}
// create addition move for all add candidates
return addCandidates.stream()
.map(add -> new AdditionMove(add))
.collect(Collectors.toList());
}
|
[
"@",
"Override",
"public",
"List",
"<",
"SubsetMove",
">",
"getAllMoves",
"(",
"SubsetSolution",
"solution",
")",
"{",
"// check size limit",
"if",
"(",
"maxSizeReached",
"(",
"solution",
")",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"// get set of candidate IDs for addition (possibly fixed IDs are discarded)",
"Set",
"<",
"Integer",
">",
"addCandidates",
"=",
"getAddCandidates",
"(",
"solution",
")",
";",
"// check if there are any candidates to be added",
"if",
"(",
"addCandidates",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"// create addition move for all add candidates",
"return",
"addCandidates",
".",
"stream",
"(",
")",
".",
"map",
"(",
"add",
"->",
"new",
"AdditionMove",
"(",
"add",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] |
Generates a list of all possible addition moves that add a single ID to the selection of a given
subset solution. Possible fixed IDs are not considered to be added and the maximum subset size
is taken into account. May return an empty list if no addition moves can be generated.
@param solution solution for which all possible addition moves are generated
@return list of all addition moves, may be empty
|
[
"Generates",
"a",
"list",
"of",
"all",
"possible",
"addition",
"moves",
"that",
"add",
"a",
"single",
"ID",
"to",
"the",
"selection",
"of",
"a",
"given",
"subset",
"solution",
".",
"Possible",
"fixed",
"IDs",
"are",
"not",
"considered",
"to",
"be",
"added",
"and",
"the",
"maximum",
"subset",
"size",
"is",
"taken",
"into",
"account",
".",
"May",
"return",
"an",
"empty",
"list",
"if",
"no",
"addition",
"moves",
"can",
"be",
"generated",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/neigh/SingleAdditionNeighbourhood.java#L131-L147
|
11,455
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/stopcriteria/MinDelta.java
|
MinDelta.searchShouldStop
|
@Override
public boolean searchShouldStop(Search<?> search) {
return search.getMinDelta() != JamesConstants.INVALID_DELTA && search.getMinDelta() < minDelta;
}
|
java
|
@Override
public boolean searchShouldStop(Search<?> search) {
return search.getMinDelta() != JamesConstants.INVALID_DELTA && search.getMinDelta() < minDelta;
}
|
[
"@",
"Override",
"public",
"boolean",
"searchShouldStop",
"(",
"Search",
"<",
"?",
">",
"search",
")",
"{",
"return",
"search",
".",
"getMinDelta",
"(",
")",
"!=",
"JamesConstants",
".",
"INVALID_DELTA",
"&&",
"search",
".",
"getMinDelta",
"(",
")",
"<",
"minDelta",
";",
"}"
] |
Checks whether the minimum delta observed during the current run of the given
search is still above the required minimum.
@param search search for which the minimum delta has to be checked
@return <code>true</code> in case of a minimum delta below the required minimum
|
[
"Checks",
"whether",
"the",
"minimum",
"delta",
"observed",
"during",
"the",
"current",
"run",
"of",
"the",
"given",
"search",
"is",
"still",
"above",
"the",
"required",
"minimum",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/stopcriteria/MinDelta.java#L60-L63
|
11,456
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/TiffTags.java
|
TiffTags.generateTagRules
|
protected void generateTagRules() throws ReadTagsIOException {
try {
PrintWriter writer = new PrintWriter("typecheck.xml", "UTF-8");
for (int tagId : tagMap.keySet()) {
Tag tag = tagMap.get(tagId);
writer.println(" <rule context=\"tag[id=" + tag.getId() + "]\">");
String typeRule = "";
for (String tagType : tag.getType()) {
if (typeRule.length() > 0)
typeRule += " || ";
typeRule += "{type=='" + tagType + "'}";
}
writer.println(" <assert test=\"" + typeRule + "\">Tag type does not match</assert>");
writer.println(" </rule>");
}
writer.close();
writer = new PrintWriter("cardinalitycheck.xml", "UTF-8");
for (int tagId : tagMap.keySet()) {
Tag tag = tagMap.get(tagId);
if (tag.getCardinality().length() > 0 && !tag.getCardinality().equals("N")) {
try {
int card = Integer.parseInt(tag.getCardinality());
writer.println(" <rule context=\"tag[id=" + tag.getId() + "]\">");
String typeRule = "{cardinality==" + card + "}";
writer.println(" <assert test=\"" + typeRule
+ "\">Tag cardinality does not match</assert>");
writer.println(" </rule>");
} catch (Exception ex) {
// TODO: Deal with formulas
System.err.println("Formula in tag " + tag.getName() + ": " + tag.getCardinality());
}
}
}
writer.close();
} catch (Exception ex) {
throw new ReadTagsIOException();
}
}
|
java
|
protected void generateTagRules() throws ReadTagsIOException {
try {
PrintWriter writer = new PrintWriter("typecheck.xml", "UTF-8");
for (int tagId : tagMap.keySet()) {
Tag tag = tagMap.get(tagId);
writer.println(" <rule context=\"tag[id=" + tag.getId() + "]\">");
String typeRule = "";
for (String tagType : tag.getType()) {
if (typeRule.length() > 0)
typeRule += " || ";
typeRule += "{type=='" + tagType + "'}";
}
writer.println(" <assert test=\"" + typeRule + "\">Tag type does not match</assert>");
writer.println(" </rule>");
}
writer.close();
writer = new PrintWriter("cardinalitycheck.xml", "UTF-8");
for (int tagId : tagMap.keySet()) {
Tag tag = tagMap.get(tagId);
if (tag.getCardinality().length() > 0 && !tag.getCardinality().equals("N")) {
try {
int card = Integer.parseInt(tag.getCardinality());
writer.println(" <rule context=\"tag[id=" + tag.getId() + "]\">");
String typeRule = "{cardinality==" + card + "}";
writer.println(" <assert test=\"" + typeRule
+ "\">Tag cardinality does not match</assert>");
writer.println(" </rule>");
} catch (Exception ex) {
// TODO: Deal with formulas
System.err.println("Formula in tag " + tag.getName() + ": " + tag.getCardinality());
}
}
}
writer.close();
} catch (Exception ex) {
throw new ReadTagsIOException();
}
}
|
[
"protected",
"void",
"generateTagRules",
"(",
")",
"throws",
"ReadTagsIOException",
"{",
"try",
"{",
"PrintWriter",
"writer",
"=",
"new",
"PrintWriter",
"(",
"\"typecheck.xml\"",
",",
"\"UTF-8\"",
")",
";",
"for",
"(",
"int",
"tagId",
":",
"tagMap",
".",
"keySet",
"(",
")",
")",
"{",
"Tag",
"tag",
"=",
"tagMap",
".",
"get",
"(",
"tagId",
")",
";",
"writer",
".",
"println",
"(",
"\" <rule context=\\\"tag[id=\"",
"+",
"tag",
".",
"getId",
"(",
")",
"+",
"\"]\\\">\"",
")",
";",
"String",
"typeRule",
"=",
"\"\"",
";",
"for",
"(",
"String",
"tagType",
":",
"tag",
".",
"getType",
"(",
")",
")",
"{",
"if",
"(",
"typeRule",
".",
"length",
"(",
")",
">",
"0",
")",
"typeRule",
"+=",
"\" || \"",
";",
"typeRule",
"+=",
"\"{type=='\"",
"+",
"tagType",
"+",
"\"'}\"",
";",
"}",
"writer",
".",
"println",
"(",
"\" <assert test=\\\"\"",
"+",
"typeRule",
"+",
"\"\\\">Tag type does not match</assert>\"",
")",
";",
"writer",
".",
"println",
"(",
"\" </rule>\"",
")",
";",
"}",
"writer",
".",
"close",
"(",
")",
";",
"writer",
"=",
"new",
"PrintWriter",
"(",
"\"cardinalitycheck.xml\"",
",",
"\"UTF-8\"",
")",
";",
"for",
"(",
"int",
"tagId",
":",
"tagMap",
".",
"keySet",
"(",
")",
")",
"{",
"Tag",
"tag",
"=",
"tagMap",
".",
"get",
"(",
"tagId",
")",
";",
"if",
"(",
"tag",
".",
"getCardinality",
"(",
")",
".",
"length",
"(",
")",
">",
"0",
"&&",
"!",
"tag",
".",
"getCardinality",
"(",
")",
".",
"equals",
"(",
"\"N\"",
")",
")",
"{",
"try",
"{",
"int",
"card",
"=",
"Integer",
".",
"parseInt",
"(",
"tag",
".",
"getCardinality",
"(",
")",
")",
";",
"writer",
".",
"println",
"(",
"\" <rule context=\\\"tag[id=\"",
"+",
"tag",
".",
"getId",
"(",
")",
"+",
"\"]\\\">\"",
")",
";",
"String",
"typeRule",
"=",
"\"{cardinality==\"",
"+",
"card",
"+",
"\"}\"",
";",
"writer",
".",
"println",
"(",
"\" <assert test=\\\"\"",
"+",
"typeRule",
"+",
"\"\\\">Tag cardinality does not match</assert>\"",
")",
";",
"writer",
".",
"println",
"(",
"\" </rule>\"",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"// TODO: Deal with formulas",
"System",
".",
"err",
".",
"println",
"(",
"\"Formula in tag \"",
"+",
"tag",
".",
"getName",
"(",
")",
"+",
"\": \"",
"+",
"tag",
".",
"getCardinality",
"(",
")",
")",
";",
"}",
"}",
"}",
"writer",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"ReadTagsIOException",
"(",
")",
";",
"}",
"}"
] |
Generate tag rules.
@throws ReadTagsIOException the read tags io exception
|
[
"Generate",
"tag",
"rules",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/TiffTags.java#L213-L251
|
11,457
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/TiffTags.java
|
TiffTags.getTagId
|
public static int getTagId(String name) {
int id = -1;
try {
if (instance == null)
getTiffTags();
} catch (ReadTagsIOException e) {
/*Nothing to be shown*/
}
if (tagNames.containsKey(name))
id = tagNames.get(name).getId();
return id;
}
|
java
|
public static int getTagId(String name) {
int id = -1;
try {
if (instance == null)
getTiffTags();
} catch (ReadTagsIOException e) {
/*Nothing to be shown*/
}
if (tagNames.containsKey(name))
id = tagNames.get(name).getId();
return id;
}
|
[
"public",
"static",
"int",
"getTagId",
"(",
"String",
"name",
")",
"{",
"int",
"id",
"=",
"-",
"1",
";",
"try",
"{",
"if",
"(",
"instance",
"==",
"null",
")",
"getTiffTags",
"(",
")",
";",
"}",
"catch",
"(",
"ReadTagsIOException",
"e",
")",
"{",
"/*Nothing to be shown*/",
"}",
"if",
"(",
"tagNames",
".",
"containsKey",
"(",
"name",
")",
")",
"id",
"=",
"tagNames",
".",
"get",
"(",
"name",
")",
".",
"getId",
"(",
")",
";",
"return",
"id",
";",
"}"
] |
Gets the tag id.
@param name the name
@return the tag id
|
[
"Gets",
"the",
"tag",
"id",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/TiffTags.java#L322-L333
|
11,458
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/Metadata.java
|
Metadata.get
|
public TiffObject get(String name) {
TiffObject result = null;
String container = null;
ArrayList<TiffObject> found = new ArrayList<>();
if (contains(name)) {
// Find objects with this exact name
if (metadata.get(name).getObjectList().size() == 1) {
found.add(getFirst(name));
} else {
for (TiffObject to : metadata.get(name).getObjectList()) {
found.add(to);
}
}
} else {
// Find objects with similar or equivalent name
for (String key : metadata.keySet()) {
boolean similar = key.toLowerCase().equals(name.toLowerCase());
if (!similar) similar = name.toLowerCase().equals("date") && key.toLowerCase().equals("datetime");
if (!similar) similar = name.toLowerCase().equals("date") && key.toLowerCase().equals("creatordate");
if (!similar) similar = name.toLowerCase().equals("description") && key.toLowerCase().equals("imagedescription");
if (!similar) similar = name.toLowerCase().equals("creator") && key.toLowerCase().equals("artist");
if (!similar) similar = name.toLowerCase().equals("creator") && key.toLowerCase().equals("creatortool");
if (similar) {
for (TiffObject to : metadata.get(key).getObjectList()) {
found.add(to);
}
}
}
}
// Return the most prioritary result
if (found.size()==1) {
result = found.get(0);
} else {
for (TiffObject to : found) {
if (result == null) {
result = to;
container = to.getContainer();
} else if (to.getContainer() != null) {
// Preferences in (descending) order: EXIF, XMP, IPTC, Tiff tag
if (container == null || to.getContainer().equals("EXIF")
|| (to.getContainer().equals("XMP") && container.equals("IPTC"))) {
result = to;
container = to.getContainer();
}
}
}
}
return result;
}
|
java
|
public TiffObject get(String name) {
TiffObject result = null;
String container = null;
ArrayList<TiffObject> found = new ArrayList<>();
if (contains(name)) {
// Find objects with this exact name
if (metadata.get(name).getObjectList().size() == 1) {
found.add(getFirst(name));
} else {
for (TiffObject to : metadata.get(name).getObjectList()) {
found.add(to);
}
}
} else {
// Find objects with similar or equivalent name
for (String key : metadata.keySet()) {
boolean similar = key.toLowerCase().equals(name.toLowerCase());
if (!similar) similar = name.toLowerCase().equals("date") && key.toLowerCase().equals("datetime");
if (!similar) similar = name.toLowerCase().equals("date") && key.toLowerCase().equals("creatordate");
if (!similar) similar = name.toLowerCase().equals("description") && key.toLowerCase().equals("imagedescription");
if (!similar) similar = name.toLowerCase().equals("creator") && key.toLowerCase().equals("artist");
if (!similar) similar = name.toLowerCase().equals("creator") && key.toLowerCase().equals("creatortool");
if (similar) {
for (TiffObject to : metadata.get(key).getObjectList()) {
found.add(to);
}
}
}
}
// Return the most prioritary result
if (found.size()==1) {
result = found.get(0);
} else {
for (TiffObject to : found) {
if (result == null) {
result = to;
container = to.getContainer();
} else if (to.getContainer() != null) {
// Preferences in (descending) order: EXIF, XMP, IPTC, Tiff tag
if (container == null || to.getContainer().equals("EXIF")
|| (to.getContainer().equals("XMP") && container.equals("IPTC"))) {
result = to;
container = to.getContainer();
}
}
}
}
return result;
}
|
[
"public",
"TiffObject",
"get",
"(",
"String",
"name",
")",
"{",
"TiffObject",
"result",
"=",
"null",
";",
"String",
"container",
"=",
"null",
";",
"ArrayList",
"<",
"TiffObject",
">",
"found",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"contains",
"(",
"name",
")",
")",
"{",
"// Find objects with this exact name",
"if",
"(",
"metadata",
".",
"get",
"(",
"name",
")",
".",
"getObjectList",
"(",
")",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"found",
".",
"add",
"(",
"getFirst",
"(",
"name",
")",
")",
";",
"}",
"else",
"{",
"for",
"(",
"TiffObject",
"to",
":",
"metadata",
".",
"get",
"(",
"name",
")",
".",
"getObjectList",
"(",
")",
")",
"{",
"found",
".",
"add",
"(",
"to",
")",
";",
"}",
"}",
"}",
"else",
"{",
"// Find objects with similar or equivalent name",
"for",
"(",
"String",
"key",
":",
"metadata",
".",
"keySet",
"(",
")",
")",
"{",
"boolean",
"similar",
"=",
"key",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"name",
".",
"toLowerCase",
"(",
")",
")",
";",
"if",
"(",
"!",
"similar",
")",
"similar",
"=",
"name",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"date\"",
")",
"&&",
"key",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"datetime\"",
")",
";",
"if",
"(",
"!",
"similar",
")",
"similar",
"=",
"name",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"date\"",
")",
"&&",
"key",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"creatordate\"",
")",
";",
"if",
"(",
"!",
"similar",
")",
"similar",
"=",
"name",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"description\"",
")",
"&&",
"key",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"imagedescription\"",
")",
";",
"if",
"(",
"!",
"similar",
")",
"similar",
"=",
"name",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"creator\"",
")",
"&&",
"key",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"artist\"",
")",
";",
"if",
"(",
"!",
"similar",
")",
"similar",
"=",
"name",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"creator\"",
")",
"&&",
"key",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"creatortool\"",
")",
";",
"if",
"(",
"similar",
")",
"{",
"for",
"(",
"TiffObject",
"to",
":",
"metadata",
".",
"get",
"(",
"key",
")",
".",
"getObjectList",
"(",
")",
")",
"{",
"found",
".",
"add",
"(",
"to",
")",
";",
"}",
"}",
"}",
"}",
"// Return the most prioritary result",
"if",
"(",
"found",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"result",
"=",
"found",
".",
"get",
"(",
"0",
")",
";",
"}",
"else",
"{",
"for",
"(",
"TiffObject",
"to",
":",
"found",
")",
"{",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"result",
"=",
"to",
";",
"container",
"=",
"to",
".",
"getContainer",
"(",
")",
";",
"}",
"else",
"if",
"(",
"to",
".",
"getContainer",
"(",
")",
"!=",
"null",
")",
"{",
"// Preferences in (descending) order: EXIF, XMP, IPTC, Tiff tag",
"if",
"(",
"container",
"==",
"null",
"||",
"to",
".",
"getContainer",
"(",
")",
".",
"equals",
"(",
"\"EXIF\"",
")",
"||",
"(",
"to",
".",
"getContainer",
"(",
")",
".",
"equals",
"(",
"\"XMP\"",
")",
"&&",
"container",
".",
"equals",
"(",
"\"IPTC\"",
")",
")",
")",
"{",
"result",
"=",
"to",
";",
"container",
"=",
"to",
".",
"getContainer",
"(",
")",
";",
"}",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] |
Gets a metadata value, returning the appropriate value when multiple are found.
@param name the name of the metadata.
@return the tiff object with the value of the metadata.
|
[
"Gets",
"a",
"metadata",
"value",
"returning",
"the",
"appropriate",
"value",
"when",
"multiple",
"are",
"found",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/Metadata.java#L116-L167
|
11,459
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/Metadata.java
|
Metadata.addMetadata
|
public void addMetadata(Metadata meta) {
for (String k : meta.keySet()) {
for (TiffObject to : meta.getList(k)) {
add(k, to, meta.getMetadataObject(k).isDublinCore(), meta.getMetadataObject(k).getPath());
}
}
}
|
java
|
public void addMetadata(Metadata meta) {
for (String k : meta.keySet()) {
for (TiffObject to : meta.getList(k)) {
add(k, to, meta.getMetadataObject(k).isDublinCore(), meta.getMetadataObject(k).getPath());
}
}
}
|
[
"public",
"void",
"addMetadata",
"(",
"Metadata",
"meta",
")",
"{",
"for",
"(",
"String",
"k",
":",
"meta",
".",
"keySet",
"(",
")",
")",
"{",
"for",
"(",
"TiffObject",
"to",
":",
"meta",
".",
"getList",
"(",
"k",
")",
")",
"{",
"add",
"(",
"k",
",",
"to",
",",
"meta",
".",
"getMetadataObject",
"(",
"k",
")",
".",
"isDublinCore",
"(",
")",
",",
"meta",
".",
"getMetadataObject",
"(",
"k",
")",
".",
"getPath",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Adds a complete dictionary to the current one.
@param meta the metadata dictionary to add
|
[
"Adds",
"a",
"complete",
"dictionary",
"to",
"the",
"current",
"one",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/Metadata.java#L213-L219
|
11,460
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/reader/TiffReader.java
|
TiffReader.readFile
|
public int readFile(String filename, boolean validate) {
int result = 0;
try {
if (Files.exists(Paths.get(filename))) {
data = new TiffInputStream(new File(filename));
tiffModel = new TiffDocument();
validation = new ValidationResult(validate);
tiffModel.setSize(data.size());
boolean correctHeader = readHeader();
if (correctHeader) {
if (tiffModel.getMagicNumber() < 42) {
validation
.addError("Incorrect tiff magic number", "Header", tiffModel.getMagicNumber());
} else if (tiffModel.getMagicNumber() == 43) {
validation.addErrorLoc("Big tiff file not yet supported", "Header");
} else if (validation.isCorrect()) {
readIFDs();
if (validate) {
BaselineProfile bp = new BaselineProfile(tiffModel);
bp.validate();
getBaselineValidation().add(bp.getValidation());
}
}
}
if (getBaselineValidation().getFatalError()) {
tiffModel.setFatalError(true, getBaselineValidation().getFatalErrorMessage());
}
data.close();
} else {
// File not found
result = -1;
tiffModel.setFatalError(true, "File not found");
}
} catch (Exception ex) {
// IO exception
result = -2;
tiffModel.setFatalError(true, "IO Exception");
}
return result;
}
|
java
|
public int readFile(String filename, boolean validate) {
int result = 0;
try {
if (Files.exists(Paths.get(filename))) {
data = new TiffInputStream(new File(filename));
tiffModel = new TiffDocument();
validation = new ValidationResult(validate);
tiffModel.setSize(data.size());
boolean correctHeader = readHeader();
if (correctHeader) {
if (tiffModel.getMagicNumber() < 42) {
validation
.addError("Incorrect tiff magic number", "Header", tiffModel.getMagicNumber());
} else if (tiffModel.getMagicNumber() == 43) {
validation.addErrorLoc("Big tiff file not yet supported", "Header");
} else if (validation.isCorrect()) {
readIFDs();
if (validate) {
BaselineProfile bp = new BaselineProfile(tiffModel);
bp.validate();
getBaselineValidation().add(bp.getValidation());
}
}
}
if (getBaselineValidation().getFatalError()) {
tiffModel.setFatalError(true, getBaselineValidation().getFatalErrorMessage());
}
data.close();
} else {
// File not found
result = -1;
tiffModel.setFatalError(true, "File not found");
}
} catch (Exception ex) {
// IO exception
result = -2;
tiffModel.setFatalError(true, "IO Exception");
}
return result;
}
|
[
"public",
"int",
"readFile",
"(",
"String",
"filename",
",",
"boolean",
"validate",
")",
"{",
"int",
"result",
"=",
"0",
";",
"try",
"{",
"if",
"(",
"Files",
".",
"exists",
"(",
"Paths",
".",
"get",
"(",
"filename",
")",
")",
")",
"{",
"data",
"=",
"new",
"TiffInputStream",
"(",
"new",
"File",
"(",
"filename",
")",
")",
";",
"tiffModel",
"=",
"new",
"TiffDocument",
"(",
")",
";",
"validation",
"=",
"new",
"ValidationResult",
"(",
"validate",
")",
";",
"tiffModel",
".",
"setSize",
"(",
"data",
".",
"size",
"(",
")",
")",
";",
"boolean",
"correctHeader",
"=",
"readHeader",
"(",
")",
";",
"if",
"(",
"correctHeader",
")",
"{",
"if",
"(",
"tiffModel",
".",
"getMagicNumber",
"(",
")",
"<",
"42",
")",
"{",
"validation",
".",
"addError",
"(",
"\"Incorrect tiff magic number\"",
",",
"\"Header\"",
",",
"tiffModel",
".",
"getMagicNumber",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"tiffModel",
".",
"getMagicNumber",
"(",
")",
"==",
"43",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Big tiff file not yet supported\"",
",",
"\"Header\"",
")",
";",
"}",
"else",
"if",
"(",
"validation",
".",
"isCorrect",
"(",
")",
")",
"{",
"readIFDs",
"(",
")",
";",
"if",
"(",
"validate",
")",
"{",
"BaselineProfile",
"bp",
"=",
"new",
"BaselineProfile",
"(",
"tiffModel",
")",
";",
"bp",
".",
"validate",
"(",
")",
";",
"getBaselineValidation",
"(",
")",
".",
"add",
"(",
"bp",
".",
"getValidation",
"(",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"getBaselineValidation",
"(",
")",
".",
"getFatalError",
"(",
")",
")",
"{",
"tiffModel",
".",
"setFatalError",
"(",
"true",
",",
"getBaselineValidation",
"(",
")",
".",
"getFatalErrorMessage",
"(",
")",
")",
";",
"}",
"data",
".",
"close",
"(",
")",
";",
"}",
"else",
"{",
"// File not found",
"result",
"=",
"-",
"1",
";",
"tiffModel",
".",
"setFatalError",
"(",
"true",
",",
"\"File not found\"",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"// IO exception",
"result",
"=",
"-",
"2",
";",
"tiffModel",
".",
"setFatalError",
"(",
"true",
",",
"\"IO Exception\"",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Parses a Tiff File and create an internal model representation.
@param filename the Tiff filename
@return Error code (0: successful, -1: file not found, -2: IO exception)
|
[
"Parses",
"a",
"Tiff",
"File",
"and",
"create",
"an",
"internal",
"model",
"representation",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/reader/TiffReader.java#L168-L213
|
11,461
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/reader/TiffReader.java
|
TiffReader.readHeader
|
private boolean readHeader() {
boolean correct = true;
ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
int c1 = 0;
int c2 = 0;
try {
c1 = data.readByte().toInt();
c2 = data.readByte().toInt();
} catch (Exception ex) {
validation.addErrorLoc("Header IO Exception", "Header");
}
// read the first two bytes, in order to know the byte ordering
if (c1 == 'I' && c2 == 'I') {
byteOrder = ByteOrder.LITTLE_ENDIAN;
} else if (c1 == 'M' && c2 == 'M') {
byteOrder = ByteOrder.BIG_ENDIAN;
}
else if (byteOrderErrorTolerance > 0 && c1 == 'i' && c2 == 'i') {
validation.addWarning("Byte Order in lower case", "" + c1 + c2, "Header");
byteOrder = ByteOrder.LITTLE_ENDIAN;
} else if (byteOrderErrorTolerance > 0 && c1 == 'm' && c2 == 'm') {
validation.addWarning("Byte Order in lower case", "" + c1 + c2, "Header");
byteOrder = ByteOrder.BIG_ENDIAN;
} else if (byteOrderErrorTolerance > 1) {
validation.addWarning("Non-sense Byte Order. Trying Little Endian.", "" + c1 + c2, "Header");
byteOrder = ByteOrder.LITTLE_ENDIAN;
} else {
validation.addErrorLoc("Invalid Byte Order " + c1 + c2, "Header");
correct = false;
}
if (correct) {
tiffModel.setByteOrder(byteOrder);
data.setByteOrder(byteOrder);
try {
// read magic number
int magic = data.readShort().toInt();
tiffModel.setMagicNumber(magic);
} catch (Exception ex) {
validation.addErrorLoc("Magic number parsing error", "Header");
correct = false;
}
}
return correct;
}
|
java
|
private boolean readHeader() {
boolean correct = true;
ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
int c1 = 0;
int c2 = 0;
try {
c1 = data.readByte().toInt();
c2 = data.readByte().toInt();
} catch (Exception ex) {
validation.addErrorLoc("Header IO Exception", "Header");
}
// read the first two bytes, in order to know the byte ordering
if (c1 == 'I' && c2 == 'I') {
byteOrder = ByteOrder.LITTLE_ENDIAN;
} else if (c1 == 'M' && c2 == 'M') {
byteOrder = ByteOrder.BIG_ENDIAN;
}
else if (byteOrderErrorTolerance > 0 && c1 == 'i' && c2 == 'i') {
validation.addWarning("Byte Order in lower case", "" + c1 + c2, "Header");
byteOrder = ByteOrder.LITTLE_ENDIAN;
} else if (byteOrderErrorTolerance > 0 && c1 == 'm' && c2 == 'm') {
validation.addWarning("Byte Order in lower case", "" + c1 + c2, "Header");
byteOrder = ByteOrder.BIG_ENDIAN;
} else if (byteOrderErrorTolerance > 1) {
validation.addWarning("Non-sense Byte Order. Trying Little Endian.", "" + c1 + c2, "Header");
byteOrder = ByteOrder.LITTLE_ENDIAN;
} else {
validation.addErrorLoc("Invalid Byte Order " + c1 + c2, "Header");
correct = false;
}
if (correct) {
tiffModel.setByteOrder(byteOrder);
data.setByteOrder(byteOrder);
try {
// read magic number
int magic = data.readShort().toInt();
tiffModel.setMagicNumber(magic);
} catch (Exception ex) {
validation.addErrorLoc("Magic number parsing error", "Header");
correct = false;
}
}
return correct;
}
|
[
"private",
"boolean",
"readHeader",
"(",
")",
"{",
"boolean",
"correct",
"=",
"true",
";",
"ByteOrder",
"byteOrder",
"=",
"ByteOrder",
".",
"LITTLE_ENDIAN",
";",
"int",
"c1",
"=",
"0",
";",
"int",
"c2",
"=",
"0",
";",
"try",
"{",
"c1",
"=",
"data",
".",
"readByte",
"(",
")",
".",
"toInt",
"(",
")",
";",
"c2",
"=",
"data",
".",
"readByte",
"(",
")",
".",
"toInt",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Header IO Exception\"",
",",
"\"Header\"",
")",
";",
"}",
"// read the first two bytes, in order to know the byte ordering",
"if",
"(",
"c1",
"==",
"'",
"'",
"&&",
"c2",
"==",
"'",
"'",
")",
"{",
"byteOrder",
"=",
"ByteOrder",
".",
"LITTLE_ENDIAN",
";",
"}",
"else",
"if",
"(",
"c1",
"==",
"'",
"'",
"&&",
"c2",
"==",
"'",
"'",
")",
"{",
"byteOrder",
"=",
"ByteOrder",
".",
"BIG_ENDIAN",
";",
"}",
"else",
"if",
"(",
"byteOrderErrorTolerance",
">",
"0",
"&&",
"c1",
"==",
"'",
"'",
"&&",
"c2",
"==",
"'",
"'",
")",
"{",
"validation",
".",
"addWarning",
"(",
"\"Byte Order in lower case\"",
",",
"\"\"",
"+",
"c1",
"+",
"c2",
",",
"\"Header\"",
")",
";",
"byteOrder",
"=",
"ByteOrder",
".",
"LITTLE_ENDIAN",
";",
"}",
"else",
"if",
"(",
"byteOrderErrorTolerance",
">",
"0",
"&&",
"c1",
"==",
"'",
"'",
"&&",
"c2",
"==",
"'",
"'",
")",
"{",
"validation",
".",
"addWarning",
"(",
"\"Byte Order in lower case\"",
",",
"\"\"",
"+",
"c1",
"+",
"c2",
",",
"\"Header\"",
")",
";",
"byteOrder",
"=",
"ByteOrder",
".",
"BIG_ENDIAN",
";",
"}",
"else",
"if",
"(",
"byteOrderErrorTolerance",
">",
"1",
")",
"{",
"validation",
".",
"addWarning",
"(",
"\"Non-sense Byte Order. Trying Little Endian.\"",
",",
"\"\"",
"+",
"c1",
"+",
"c2",
",",
"\"Header\"",
")",
";",
"byteOrder",
"=",
"ByteOrder",
".",
"LITTLE_ENDIAN",
";",
"}",
"else",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Invalid Byte Order \"",
"+",
"c1",
"+",
"c2",
",",
"\"Header\"",
")",
";",
"correct",
"=",
"false",
";",
"}",
"if",
"(",
"correct",
")",
"{",
"tiffModel",
".",
"setByteOrder",
"(",
"byteOrder",
")",
";",
"data",
".",
"setByteOrder",
"(",
"byteOrder",
")",
";",
"try",
"{",
"// read magic number",
"int",
"magic",
"=",
"data",
".",
"readShort",
"(",
")",
".",
"toInt",
"(",
")",
";",
"tiffModel",
".",
"setMagicNumber",
"(",
"magic",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Magic number parsing error\"",
",",
"\"Header\"",
")",
";",
"correct",
"=",
"false",
";",
"}",
"}",
"return",
"correct",
";",
"}"
] |
Reads the Tiff header.
@return true, if successful
|
[
"Reads",
"the",
"Tiff",
"header",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/reader/TiffReader.java#L220-L265
|
11,462
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/reader/TiffReader.java
|
TiffReader.readIFDs
|
private void readIFDs() {
int offset0 = 0;
try {
// The pointer to the first IFD is located in bytes 4-7
offset0 = data.readLong(4).toInt();
tiffModel.setFirstIFDOffset(offset0);
if (offset0 == 0)
validation.addErrorLoc("There is no first IFD", "Header");
else if (offset0 > data.size())
validation.addErrorLoc("Incorrect offset", "Header");
} catch (Exception ex) {
validation.addErrorLoc("IO exception", "Header");
}
if (validation.isCorrect()) {
int nifd = 1;
try {
IfdReader ifd0 = readIFD(offset0, true, 0);
HashSet<Integer> usedOffsets = new HashSet<Integer>();
usedOffsets.add(offset0);
if (ifd0.getIfd() == null) {
validation.addErrorLoc("Parsing error in first IFD", "IFD" + 0);
} else {
IFD iifd = ifd0.getIfd();
iifd.setNextOffset(ifd0.getNextIfdOffset());
tiffModel.addIfd0(iifd);
IfdReader current_ifd = ifd0;
// Read next IFDs
boolean stop = false;
while (current_ifd.getNextIfdOffset() > 0 && !stop) {
if (usedOffsets.contains(current_ifd.getNextIfdOffset())) {
// Circular reference
validation.addErrorLoc("IFD offset already used", "IFD" + nifd);
stop = true;
} else if (current_ifd.getNextIfdOffset() > data.size()) {
validation.addErrorLoc("Incorrect offset", "IFD" + nifd);
stop = true;
} else {
usedOffsets.add(current_ifd.getNextIfdOffset());
IfdReader next_ifd = readIFD(current_ifd.getNextIfdOffset(), true, nifd);
if (next_ifd == null) {
validation.addErrorLoc("Parsing error in IFD " + nifd, "IFD" + nifd);
stop = true;
} else {
iifd = next_ifd.getIfd();
iifd.setNextOffset(next_ifd.getNextIfdOffset());
current_ifd.getIfd().setNextIFD(iifd);
current_ifd = next_ifd;
}
nifd++;
}
}
}
} catch (Exception ex) {
validation.addErrorLoc("IFD parsing error", "IFD" + nifd);
}
try {
tiffModel.createMetadataDictionary();
} catch (Exception ex) {
}
}
}
|
java
|
private void readIFDs() {
int offset0 = 0;
try {
// The pointer to the first IFD is located in bytes 4-7
offset0 = data.readLong(4).toInt();
tiffModel.setFirstIFDOffset(offset0);
if (offset0 == 0)
validation.addErrorLoc("There is no first IFD", "Header");
else if (offset0 > data.size())
validation.addErrorLoc("Incorrect offset", "Header");
} catch (Exception ex) {
validation.addErrorLoc("IO exception", "Header");
}
if (validation.isCorrect()) {
int nifd = 1;
try {
IfdReader ifd0 = readIFD(offset0, true, 0);
HashSet<Integer> usedOffsets = new HashSet<Integer>();
usedOffsets.add(offset0);
if (ifd0.getIfd() == null) {
validation.addErrorLoc("Parsing error in first IFD", "IFD" + 0);
} else {
IFD iifd = ifd0.getIfd();
iifd.setNextOffset(ifd0.getNextIfdOffset());
tiffModel.addIfd0(iifd);
IfdReader current_ifd = ifd0;
// Read next IFDs
boolean stop = false;
while (current_ifd.getNextIfdOffset() > 0 && !stop) {
if (usedOffsets.contains(current_ifd.getNextIfdOffset())) {
// Circular reference
validation.addErrorLoc("IFD offset already used", "IFD" + nifd);
stop = true;
} else if (current_ifd.getNextIfdOffset() > data.size()) {
validation.addErrorLoc("Incorrect offset", "IFD" + nifd);
stop = true;
} else {
usedOffsets.add(current_ifd.getNextIfdOffset());
IfdReader next_ifd = readIFD(current_ifd.getNextIfdOffset(), true, nifd);
if (next_ifd == null) {
validation.addErrorLoc("Parsing error in IFD " + nifd, "IFD" + nifd);
stop = true;
} else {
iifd = next_ifd.getIfd();
iifd.setNextOffset(next_ifd.getNextIfdOffset());
current_ifd.getIfd().setNextIFD(iifd);
current_ifd = next_ifd;
}
nifd++;
}
}
}
} catch (Exception ex) {
validation.addErrorLoc("IFD parsing error", "IFD" + nifd);
}
try {
tiffModel.createMetadataDictionary();
} catch (Exception ex) {
}
}
}
|
[
"private",
"void",
"readIFDs",
"(",
")",
"{",
"int",
"offset0",
"=",
"0",
";",
"try",
"{",
"// The pointer to the first IFD is located in bytes 4-7",
"offset0",
"=",
"data",
".",
"readLong",
"(",
"4",
")",
".",
"toInt",
"(",
")",
";",
"tiffModel",
".",
"setFirstIFDOffset",
"(",
"offset0",
")",
";",
"if",
"(",
"offset0",
"==",
"0",
")",
"validation",
".",
"addErrorLoc",
"(",
"\"There is no first IFD\"",
",",
"\"Header\"",
")",
";",
"else",
"if",
"(",
"offset0",
">",
"data",
".",
"size",
"(",
")",
")",
"validation",
".",
"addErrorLoc",
"(",
"\"Incorrect offset\"",
",",
"\"Header\"",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"IO exception\"",
",",
"\"Header\"",
")",
";",
"}",
"if",
"(",
"validation",
".",
"isCorrect",
"(",
")",
")",
"{",
"int",
"nifd",
"=",
"1",
";",
"try",
"{",
"IfdReader",
"ifd0",
"=",
"readIFD",
"(",
"offset0",
",",
"true",
",",
"0",
")",
";",
"HashSet",
"<",
"Integer",
">",
"usedOffsets",
"=",
"new",
"HashSet",
"<",
"Integer",
">",
"(",
")",
";",
"usedOffsets",
".",
"add",
"(",
"offset0",
")",
";",
"if",
"(",
"ifd0",
".",
"getIfd",
"(",
")",
"==",
"null",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Parsing error in first IFD\"",
",",
"\"IFD\"",
"+",
"0",
")",
";",
"}",
"else",
"{",
"IFD",
"iifd",
"=",
"ifd0",
".",
"getIfd",
"(",
")",
";",
"iifd",
".",
"setNextOffset",
"(",
"ifd0",
".",
"getNextIfdOffset",
"(",
")",
")",
";",
"tiffModel",
".",
"addIfd0",
"(",
"iifd",
")",
";",
"IfdReader",
"current_ifd",
"=",
"ifd0",
";",
"// Read next IFDs",
"boolean",
"stop",
"=",
"false",
";",
"while",
"(",
"current_ifd",
".",
"getNextIfdOffset",
"(",
")",
">",
"0",
"&&",
"!",
"stop",
")",
"{",
"if",
"(",
"usedOffsets",
".",
"contains",
"(",
"current_ifd",
".",
"getNextIfdOffset",
"(",
")",
")",
")",
"{",
"// Circular reference",
"validation",
".",
"addErrorLoc",
"(",
"\"IFD offset already used\"",
",",
"\"IFD\"",
"+",
"nifd",
")",
";",
"stop",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"current_ifd",
".",
"getNextIfdOffset",
"(",
")",
">",
"data",
".",
"size",
"(",
")",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Incorrect offset\"",
",",
"\"IFD\"",
"+",
"nifd",
")",
";",
"stop",
"=",
"true",
";",
"}",
"else",
"{",
"usedOffsets",
".",
"add",
"(",
"current_ifd",
".",
"getNextIfdOffset",
"(",
")",
")",
";",
"IfdReader",
"next_ifd",
"=",
"readIFD",
"(",
"current_ifd",
".",
"getNextIfdOffset",
"(",
")",
",",
"true",
",",
"nifd",
")",
";",
"if",
"(",
"next_ifd",
"==",
"null",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Parsing error in IFD \"",
"+",
"nifd",
",",
"\"IFD\"",
"+",
"nifd",
")",
";",
"stop",
"=",
"true",
";",
"}",
"else",
"{",
"iifd",
"=",
"next_ifd",
".",
"getIfd",
"(",
")",
";",
"iifd",
".",
"setNextOffset",
"(",
"next_ifd",
".",
"getNextIfdOffset",
"(",
")",
")",
";",
"current_ifd",
".",
"getIfd",
"(",
")",
".",
"setNextIFD",
"(",
"iifd",
")",
";",
"current_ifd",
"=",
"next_ifd",
";",
"}",
"nifd",
"++",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"IFD parsing error\"",
",",
"\"IFD\"",
"+",
"nifd",
")",
";",
"}",
"try",
"{",
"tiffModel",
".",
"createMetadataDictionary",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"}",
"}"
] |
Read the IFDs contained in the Tiff file.
|
[
"Read",
"the",
"IFDs",
"contained",
"in",
"the",
"Tiff",
"file",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/reader/TiffReader.java#L270-L334
|
11,463
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/reader/TiffReader.java
|
TiffReader.checkType
|
private boolean checkType(int tagid, int tagType, int n) {
if (TiffTags.hasTag(tagid) && !TiffTags.getTag(tagid).getName().equals("IPTC")) {
boolean found = false;
String stagType = TiffTags.getTagTypeName(tagType);
if (stagType != null) {
if (stagType.equals("SUBIFD"))
stagType = "IFD";
if (stagType.equals("UNDEFINED"))
stagType = "BYTE";
for (String vType : TiffTags.getTag(tagid).getType()) {
String vType2 = vType;
if (vType2.equals("UNDEFINED"))
vType2 = "BYTE";
if (vType2.equals(stagType)) {
found = true;
}
}
}
if (!found) {
validation.addError("Incorrect type for tag " + TiffTags.getTag(tagid).getName(),
"IFD" + n, stagType);
return false;
}
return true;
}
return false;
}
|
java
|
private boolean checkType(int tagid, int tagType, int n) {
if (TiffTags.hasTag(tagid) && !TiffTags.getTag(tagid).getName().equals("IPTC")) {
boolean found = false;
String stagType = TiffTags.getTagTypeName(tagType);
if (stagType != null) {
if (stagType.equals("SUBIFD"))
stagType = "IFD";
if (stagType.equals("UNDEFINED"))
stagType = "BYTE";
for (String vType : TiffTags.getTag(tagid).getType()) {
String vType2 = vType;
if (vType2.equals("UNDEFINED"))
vType2 = "BYTE";
if (vType2.equals(stagType)) {
found = true;
}
}
}
if (!found) {
validation.addError("Incorrect type for tag " + TiffTags.getTag(tagid).getName(),
"IFD" + n, stagType);
return false;
}
return true;
}
return false;
}
|
[
"private",
"boolean",
"checkType",
"(",
"int",
"tagid",
",",
"int",
"tagType",
",",
"int",
"n",
")",
"{",
"if",
"(",
"TiffTags",
".",
"hasTag",
"(",
"tagid",
")",
"&&",
"!",
"TiffTags",
".",
"getTag",
"(",
"tagid",
")",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"\"IPTC\"",
")",
")",
"{",
"boolean",
"found",
"=",
"false",
";",
"String",
"stagType",
"=",
"TiffTags",
".",
"getTagTypeName",
"(",
"tagType",
")",
";",
"if",
"(",
"stagType",
"!=",
"null",
")",
"{",
"if",
"(",
"stagType",
".",
"equals",
"(",
"\"SUBIFD\"",
")",
")",
"stagType",
"=",
"\"IFD\"",
";",
"if",
"(",
"stagType",
".",
"equals",
"(",
"\"UNDEFINED\"",
")",
")",
"stagType",
"=",
"\"BYTE\"",
";",
"for",
"(",
"String",
"vType",
":",
"TiffTags",
".",
"getTag",
"(",
"tagid",
")",
".",
"getType",
"(",
")",
")",
"{",
"String",
"vType2",
"=",
"vType",
";",
"if",
"(",
"vType2",
".",
"equals",
"(",
"\"UNDEFINED\"",
")",
")",
"vType2",
"=",
"\"BYTE\"",
";",
"if",
"(",
"vType2",
".",
"equals",
"(",
"stagType",
")",
")",
"{",
"found",
"=",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"{",
"validation",
".",
"addError",
"(",
"\"Incorrect type for tag \"",
"+",
"TiffTags",
".",
"getTag",
"(",
"tagid",
")",
".",
"getName",
"(",
")",
",",
"\"IFD\"",
"+",
"n",
",",
"stagType",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check tag type.
@param tagid the tagid
@param tagType the tag type
@param n the n
|
[
"Check",
"tag",
"type",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/reader/TiffReader.java#L437-L463
|
11,464
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/IfdTags.java
|
IfdTags.addTag
|
public void addTag(TagValue tag) {
//int pos = 0;
//while (pos < tags.size() && tags.get(pos).getId() < tag.getId()) pos++;
//tags.add(pos, tag);
tags.add(tag);
if (!hashTagsId.containsKey(tag.getId())) {
hashTagsId.put(tag.getId(), tag);
}
Tag t = TiffTags.getTag(tag.getId());
if (t != null) {
if (hashTagsName.containsKey(t.getName())) {
hashTagsName.put(t.getName(), tag);
}
}
}
|
java
|
public void addTag(TagValue tag) {
//int pos = 0;
//while (pos < tags.size() && tags.get(pos).getId() < tag.getId()) pos++;
//tags.add(pos, tag);
tags.add(tag);
if (!hashTagsId.containsKey(tag.getId())) {
hashTagsId.put(tag.getId(), tag);
}
Tag t = TiffTags.getTag(tag.getId());
if (t != null) {
if (hashTagsName.containsKey(t.getName())) {
hashTagsName.put(t.getName(), tag);
}
}
}
|
[
"public",
"void",
"addTag",
"(",
"TagValue",
"tag",
")",
"{",
"//int pos = 0;",
"//while (pos < tags.size() && tags.get(pos).getId() < tag.getId()) pos++;",
"//tags.add(pos, tag);",
"tags",
".",
"add",
"(",
"tag",
")",
";",
"if",
"(",
"!",
"hashTagsId",
".",
"containsKey",
"(",
"tag",
".",
"getId",
"(",
")",
")",
")",
"{",
"hashTagsId",
".",
"put",
"(",
"tag",
".",
"getId",
"(",
")",
",",
"tag",
")",
";",
"}",
"Tag",
"t",
"=",
"TiffTags",
".",
"getTag",
"(",
"tag",
".",
"getId",
"(",
")",
")",
";",
"if",
"(",
"t",
"!=",
"null",
")",
"{",
"if",
"(",
"hashTagsName",
".",
"containsKey",
"(",
"t",
".",
"getName",
"(",
")",
")",
")",
"{",
"hashTagsName",
".",
"put",
"(",
"t",
".",
"getName",
"(",
")",
",",
"tag",
")",
";",
"}",
"}",
"}"
] |
Adds a tag to the set.
@param tag the tag to add
|
[
"Adds",
"a",
"tag",
"to",
"the",
"set",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/IfdTags.java#L70-L84
|
11,465
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/stopcriteria/StopCriterionChecker.java
|
StopCriterionChecker.startChecking
|
public void startChecking() {
// synchronize with other attempts to update the running task
synchronized(runningTaskLock){
// check if not already active
if(runningTask == null) {
// only activate if at least one stop criterion has been set
if(!stopCriteria.isEmpty()){
// schedule periodical check
runningTask = new StopCriterionCheckTask();
runningTaskFuture = SCHEDULER.scheduleWithFixedDelay(runningTask, period, period, periodTimeUnit);
// log
LOGGER.debug("Stop criterion checker for search {} activated", search);
}
} else {
// issue a warning
LOGGER.warn("Attempted to activate already active stop criterion checker for search {}", search);
}
}
}
|
java
|
public void startChecking() {
// synchronize with other attempts to update the running task
synchronized(runningTaskLock){
// check if not already active
if(runningTask == null) {
// only activate if at least one stop criterion has been set
if(!stopCriteria.isEmpty()){
// schedule periodical check
runningTask = new StopCriterionCheckTask();
runningTaskFuture = SCHEDULER.scheduleWithFixedDelay(runningTask, period, period, periodTimeUnit);
// log
LOGGER.debug("Stop criterion checker for search {} activated", search);
}
} else {
// issue a warning
LOGGER.warn("Attempted to activate already active stop criterion checker for search {}", search);
}
}
}
|
[
"public",
"void",
"startChecking",
"(",
")",
"{",
"// synchronize with other attempts to update the running task",
"synchronized",
"(",
"runningTaskLock",
")",
"{",
"// check if not already active",
"if",
"(",
"runningTask",
"==",
"null",
")",
"{",
"// only activate if at least one stop criterion has been set",
"if",
"(",
"!",
"stopCriteria",
".",
"isEmpty",
"(",
")",
")",
"{",
"// schedule periodical check",
"runningTask",
"=",
"new",
"StopCriterionCheckTask",
"(",
")",
";",
"runningTaskFuture",
"=",
"SCHEDULER",
".",
"scheduleWithFixedDelay",
"(",
"runningTask",
",",
"period",
",",
"period",
",",
"periodTimeUnit",
")",
";",
"// log",
"LOGGER",
".",
"debug",
"(",
"\"Stop criterion checker for search {} activated\"",
",",
"search",
")",
";",
"}",
"}",
"else",
"{",
"// issue a warning",
"LOGGER",
".",
"warn",
"(",
"\"Attempted to activate already active stop criterion checker for search {}\"",
",",
"search",
")",
";",
"}",
"}",
"}"
] |
Start checking the stop criteria, in a separate background thread. If the stop criterion checker is
already active, or if no stop criteria have been added, calling this method does not have any effect.
|
[
"Start",
"checking",
"the",
"stop",
"criteria",
"in",
"a",
"separate",
"background",
"thread",
".",
"If",
"the",
"stop",
"criterion",
"checker",
"is",
"already",
"active",
"or",
"if",
"no",
"stop",
"criteria",
"have",
"been",
"added",
"calling",
"this",
"method",
"does",
"not",
"have",
"any",
"effect",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/stopcriteria/StopCriterionChecker.java#L143-L161
|
11,466
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/stopcriteria/StopCriterionChecker.java
|
StopCriterionChecker.stopChecking
|
public void stopChecking() {
// synchronize with other attempts to update the running task
synchronized(runningTaskLock){
if(runningTask != null) {
// cancel task (let it complete its current run if running)
runningTaskFuture.cancel(false);
// log
LOGGER.debug("Stop criterion checker for search {} deactivated", search);
// discard task
runningTask = null;
runningTaskFuture = null;
}
}
}
|
java
|
public void stopChecking() {
// synchronize with other attempts to update the running task
synchronized(runningTaskLock){
if(runningTask != null) {
// cancel task (let it complete its current run if running)
runningTaskFuture.cancel(false);
// log
LOGGER.debug("Stop criterion checker for search {} deactivated", search);
// discard task
runningTask = null;
runningTaskFuture = null;
}
}
}
|
[
"public",
"void",
"stopChecking",
"(",
")",
"{",
"// synchronize with other attempts to update the running task",
"synchronized",
"(",
"runningTaskLock",
")",
"{",
"if",
"(",
"runningTask",
"!=",
"null",
")",
"{",
"// cancel task (let it complete its current run if running)",
"runningTaskFuture",
".",
"cancel",
"(",
"false",
")",
";",
"// log",
"LOGGER",
".",
"debug",
"(",
"\"Stop criterion checker for search {} deactivated\"",
",",
"search",
")",
";",
"// discard task",
"runningTask",
"=",
"null",
";",
"runningTaskFuture",
"=",
"null",
";",
"}",
"}",
"}"
] |
Instructs the stop criterion checker to stop checking. In case the checker is not active,
calling this method does not have any effect.
|
[
"Instructs",
"the",
"stop",
"criterion",
"checker",
"to",
"stop",
"checking",
".",
"In",
"case",
"the",
"checker",
"is",
"not",
"active",
"calling",
"this",
"method",
"does",
"not",
"have",
"any",
"effect",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/stopcriteria/StopCriterionChecker.java#L167-L180
|
11,467
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/stopcriteria/StopCriterionChecker.java
|
StopCriterionChecker.stopCriterionSatisfied
|
public boolean stopCriterionSatisfied(){
int i = 0;
while (i < stopCriteria.size() && !stopCriteria.get(i).searchShouldStop(search)) {
i++;
}
return i < stopCriteria.size();
}
|
java
|
public boolean stopCriterionSatisfied(){
int i = 0;
while (i < stopCriteria.size() && !stopCriteria.get(i).searchShouldStop(search)) {
i++;
}
return i < stopCriteria.size();
}
|
[
"public",
"boolean",
"stopCriterionSatisfied",
"(",
")",
"{",
"int",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"stopCriteria",
".",
"size",
"(",
")",
"&&",
"!",
"stopCriteria",
".",
"get",
"(",
"i",
")",
".",
"searchShouldStop",
"(",
"search",
")",
")",
"{",
"i",
"++",
";",
"}",
"return",
"i",
"<",
"stopCriteria",
".",
"size",
"(",
")",
";",
"}"
] |
Check whether at least one stop criterion is satisfied.
@return <code>true</code> if a stop condition is satisfied
|
[
"Check",
"whether",
"at",
"least",
"one",
"stop",
"criterion",
"is",
"satisfied",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/stopcriteria/StopCriterionChecker.java#L187-L193
|
11,468
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java
|
Base64Slow.encode
|
public static String encode(String string, String enc) throws UnsupportedEncodingException {
return new String(encode(string.getBytes(enc)), enc);
}
|
java
|
public static String encode(String string, String enc) throws UnsupportedEncodingException {
return new String(encode(string.getBytes(enc)), enc);
}
|
[
"public",
"static",
"String",
"encode",
"(",
"String",
"string",
",",
"String",
"enc",
")",
"throws",
"UnsupportedEncodingException",
"{",
"return",
"new",
"String",
"(",
"encode",
"(",
"string",
".",
"getBytes",
"(",
"enc",
")",
")",
",",
"enc",
")",
";",
"}"
] |
Encode a String in Base64. No line breaks or other white space are inserted into the encoded
data.
@param string The data to encode.
@param enc Character encoding to use when converting to and from bytes.
@return An encoded String.
@throws UnsupportedEncodingException if the character encoding specified is not supported.
@since ostermillerutils 1.00.00
|
[
"Encode",
"a",
"String",
"in",
"Base64",
".",
"No",
"line",
"breaks",
"or",
"other",
"white",
"space",
"are",
"inserted",
"into",
"the",
"encoded",
"data",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java#L254-L256
|
11,469
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java
|
Base64Slow.encode
|
public static void encode(InputStream in, OutputStream out) throws IOException {
encode(in, out, true);
}
|
java
|
public static void encode(InputStream in, OutputStream out) throws IOException {
encode(in, out, true);
}
|
[
"public",
"static",
"void",
"encode",
"(",
"InputStream",
"in",
",",
"OutputStream",
"out",
")",
"throws",
"IOException",
"{",
"encode",
"(",
"in",
",",
"out",
",",
"true",
")",
";",
"}"
] |
Encode data from the InputStream to the OutputStream in Base64. Line breaks are inserted every
76 characters in the output.
@param in Stream from which to read data that needs to be encoded.
@param out Stream to which to write encoded data.
@throws IOException if there is a problem reading or writing.
@since ostermillerutils 1.00.00
|
[
"Encode",
"data",
"from",
"the",
"InputStream",
"to",
"the",
"OutputStream",
"in",
"Base64",
".",
"Line",
"breaks",
"are",
"inserted",
"every",
"76",
"characters",
"in",
"the",
"output",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java#L341-L343
|
11,470
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java
|
Base64Slow.encode
|
public static void encode(InputStream in, OutputStream out, boolean lineBreaks)
throws IOException {
// Base64 encoding converts three bytes of input to
// four bytes of output
int[] inBuffer = new int[3];
int lineCount = 0;
boolean done = false;
while (!done && (inBuffer[0] = in.read()) != END_OF_INPUT) {
// Fill the buffer
inBuffer[1] = in.read();
inBuffer[2] = in.read();
// Calculate the out Buffer
// The first byte of our in buffer will always be valid
// but we must check to make sure the other two bytes
// are not END_OF_INPUT before using them.
// The basic idea is that the three bytes get split into
// four bytes along these lines:
// [AAAAAABB] [BBBBCCCC] [CCDDDDDD]
// [xxAAAAAA] [xxBBBBBB] [xxCCCCCC] [xxDDDDDD]
// bytes are considered to be zero when absent.
// the four bytes are then mapped to common ASCII symbols
// A's: first six bits of first byte
out.write(base64Chars[inBuffer[0] >> 2]);
if (inBuffer[1] != END_OF_INPUT) {
// B's: last two bits of first byte, first four bits of second byte
out.write(base64Chars[((inBuffer[0] << 4) & 0x30) | (inBuffer[1] >> 4)]);
if (inBuffer[2] != END_OF_INPUT) {
// C's: last four bits of second byte, first two bits of third byte
out.write(base64Chars[((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6)]);
// D's: last six bits of third byte
out.write(base64Chars[inBuffer[2] & 0x3F]);
} else {
// C's: last four bits of second byte
out.write(base64Chars[((inBuffer[1] << 2) & 0x3c)]);
// an equals sign for a character that is not a Base64 character
out.write('=');
done = true;
}
} else {
// B's: last two bits of first byte
out.write(base64Chars[((inBuffer[0] << 4) & 0x30)]);
// an equal signs for characters that is not a Base64 characters
out.write('=');
out.write('=');
done = true;
}
lineCount += 4;
if (lineBreaks && lineCount >= 76) {
out.write('\n');
lineCount = 0;
}
}
if (lineBreaks && lineCount >= 1) {
out.write('\n');
lineCount = 0;
}
out.flush();
}
|
java
|
public static void encode(InputStream in, OutputStream out, boolean lineBreaks)
throws IOException {
// Base64 encoding converts three bytes of input to
// four bytes of output
int[] inBuffer = new int[3];
int lineCount = 0;
boolean done = false;
while (!done && (inBuffer[0] = in.read()) != END_OF_INPUT) {
// Fill the buffer
inBuffer[1] = in.read();
inBuffer[2] = in.read();
// Calculate the out Buffer
// The first byte of our in buffer will always be valid
// but we must check to make sure the other two bytes
// are not END_OF_INPUT before using them.
// The basic idea is that the three bytes get split into
// four bytes along these lines:
// [AAAAAABB] [BBBBCCCC] [CCDDDDDD]
// [xxAAAAAA] [xxBBBBBB] [xxCCCCCC] [xxDDDDDD]
// bytes are considered to be zero when absent.
// the four bytes are then mapped to common ASCII symbols
// A's: first six bits of first byte
out.write(base64Chars[inBuffer[0] >> 2]);
if (inBuffer[1] != END_OF_INPUT) {
// B's: last two bits of first byte, first four bits of second byte
out.write(base64Chars[((inBuffer[0] << 4) & 0x30) | (inBuffer[1] >> 4)]);
if (inBuffer[2] != END_OF_INPUT) {
// C's: last four bits of second byte, first two bits of third byte
out.write(base64Chars[((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6)]);
// D's: last six bits of third byte
out.write(base64Chars[inBuffer[2] & 0x3F]);
} else {
// C's: last four bits of second byte
out.write(base64Chars[((inBuffer[1] << 2) & 0x3c)]);
// an equals sign for a character that is not a Base64 character
out.write('=');
done = true;
}
} else {
// B's: last two bits of first byte
out.write(base64Chars[((inBuffer[0] << 4) & 0x30)]);
// an equal signs for characters that is not a Base64 characters
out.write('=');
out.write('=');
done = true;
}
lineCount += 4;
if (lineBreaks && lineCount >= 76) {
out.write('\n');
lineCount = 0;
}
}
if (lineBreaks && lineCount >= 1) {
out.write('\n');
lineCount = 0;
}
out.flush();
}
|
[
"public",
"static",
"void",
"encode",
"(",
"InputStream",
"in",
",",
"OutputStream",
"out",
",",
"boolean",
"lineBreaks",
")",
"throws",
"IOException",
"{",
"// Base64 encoding converts three bytes of input to",
"// four bytes of output",
"int",
"[",
"]",
"inBuffer",
"=",
"new",
"int",
"[",
"3",
"]",
";",
"int",
"lineCount",
"=",
"0",
";",
"boolean",
"done",
"=",
"false",
";",
"while",
"(",
"!",
"done",
"&&",
"(",
"inBuffer",
"[",
"0",
"]",
"=",
"in",
".",
"read",
"(",
")",
")",
"!=",
"END_OF_INPUT",
")",
"{",
"// Fill the buffer",
"inBuffer",
"[",
"1",
"]",
"=",
"in",
".",
"read",
"(",
")",
";",
"inBuffer",
"[",
"2",
"]",
"=",
"in",
".",
"read",
"(",
")",
";",
"// Calculate the out Buffer",
"// The first byte of our in buffer will always be valid",
"// but we must check to make sure the other two bytes",
"// are not END_OF_INPUT before using them.",
"// The basic idea is that the three bytes get split into",
"// four bytes along these lines:",
"// [AAAAAABB] [BBBBCCCC] [CCDDDDDD]",
"// [xxAAAAAA] [xxBBBBBB] [xxCCCCCC] [xxDDDDDD]",
"// bytes are considered to be zero when absent.",
"// the four bytes are then mapped to common ASCII symbols",
"// A's: first six bits of first byte",
"out",
".",
"write",
"(",
"base64Chars",
"[",
"inBuffer",
"[",
"0",
"]",
">>",
"2",
"]",
")",
";",
"if",
"(",
"inBuffer",
"[",
"1",
"]",
"!=",
"END_OF_INPUT",
")",
"{",
"// B's: last two bits of first byte, first four bits of second byte",
"out",
".",
"write",
"(",
"base64Chars",
"[",
"(",
"(",
"inBuffer",
"[",
"0",
"]",
"<<",
"4",
")",
"&",
"0x30",
")",
"|",
"(",
"inBuffer",
"[",
"1",
"]",
">>",
"4",
")",
"]",
")",
";",
"if",
"(",
"inBuffer",
"[",
"2",
"]",
"!=",
"END_OF_INPUT",
")",
"{",
"// C's: last four bits of second byte, first two bits of third byte",
"out",
".",
"write",
"(",
"base64Chars",
"[",
"(",
"(",
"inBuffer",
"[",
"1",
"]",
"<<",
"2",
")",
"&",
"0x3c",
")",
"|",
"(",
"inBuffer",
"[",
"2",
"]",
">>",
"6",
")",
"]",
")",
";",
"// D's: last six bits of third byte",
"out",
".",
"write",
"(",
"base64Chars",
"[",
"inBuffer",
"[",
"2",
"]",
"&",
"0x3F",
"]",
")",
";",
"}",
"else",
"{",
"// C's: last four bits of second byte",
"out",
".",
"write",
"(",
"base64Chars",
"[",
"(",
"(",
"inBuffer",
"[",
"1",
"]",
"<<",
"2",
")",
"&",
"0x3c",
")",
"]",
")",
";",
"// an equals sign for a character that is not a Base64 character",
"out",
".",
"write",
"(",
"'",
"'",
")",
";",
"done",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"// B's: last two bits of first byte",
"out",
".",
"write",
"(",
"base64Chars",
"[",
"(",
"(",
"inBuffer",
"[",
"0",
"]",
"<<",
"4",
")",
"&",
"0x30",
")",
"]",
")",
";",
"// an equal signs for characters that is not a Base64 characters",
"out",
".",
"write",
"(",
"'",
"'",
")",
";",
"out",
".",
"write",
"(",
"'",
"'",
")",
";",
"done",
"=",
"true",
";",
"}",
"lineCount",
"+=",
"4",
";",
"if",
"(",
"lineBreaks",
"&&",
"lineCount",
">=",
"76",
")",
"{",
"out",
".",
"write",
"(",
"'",
"'",
")",
";",
"lineCount",
"=",
"0",
";",
"}",
"}",
"if",
"(",
"lineBreaks",
"&&",
"lineCount",
">=",
"1",
")",
"{",
"out",
".",
"write",
"(",
"'",
"'",
")",
";",
"lineCount",
"=",
"0",
";",
"}",
"out",
".",
"flush",
"(",
")",
";",
"}"
] |
Encode data from the InputStream to the OutputStream in Base64.
@param in Stream from which to read data that needs to be encoded.
@param out Stream to which to write encoded data.
@param lineBreaks Whether to insert line breaks every 76 characters in the output.
@throws IOException if there is a problem reading or writing.
@since ostermillerutils 1.00.00
|
[
"Encode",
"data",
"from",
"the",
"InputStream",
"to",
"the",
"OutputStream",
"in",
"Base64",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java#L354-L414
|
11,471
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java
|
Base64Slow.decode
|
public static void decode(byte[] bytes, OutputStream out) throws IOException {
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
decode(in, out, false);
}
|
java
|
public static void decode(byte[] bytes, OutputStream out) throws IOException {
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
decode(in, out, false);
}
|
[
"public",
"static",
"void",
"decode",
"(",
"byte",
"[",
"]",
"bytes",
",",
"OutputStream",
"out",
")",
"throws",
"IOException",
"{",
"ByteArrayInputStream",
"in",
"=",
"new",
"ByteArrayInputStream",
"(",
"bytes",
")",
";",
"decode",
"(",
"in",
",",
"out",
",",
"false",
")",
";",
"}"
] |
Decode Base64 encoded bytes to the an OutputStream. Characters that are not part of the Base64
alphabet are ignored in the input.
@param bytes The data to decode.
@param out Stream to which to write decoded data.
@throws IOException if an IO error occurs.
@since ostermillerutils 1.00.00
|
[
"Decode",
"Base64",
"encoded",
"bytes",
"to",
"the",
"an",
"OutputStream",
".",
"Characters",
"that",
"are",
"not",
"part",
"of",
"the",
"Base64",
"alphabet",
"are",
"ignored",
"in",
"the",
"input",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java#L645-L648
|
11,472
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java
|
Base64Slow.decodeToBytes
|
public static byte[] decodeToBytes(InputStream in) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
decode(in, out, false);
return out.toByteArray();
}
|
java
|
public static byte[] decodeToBytes(InputStream in) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
decode(in, out, false);
return out.toByteArray();
}
|
[
"public",
"static",
"byte",
"[",
"]",
"decodeToBytes",
"(",
"InputStream",
"in",
")",
"throws",
"IOException",
"{",
"ByteArrayOutputStream",
"out",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"decode",
"(",
"in",
",",
"out",
",",
"false",
")",
";",
"return",
"out",
".",
"toByteArray",
"(",
")",
";",
"}"
] |
Decode Base64 encoded data from the InputStream to a byte array. Characters that are not part
of the Base64 alphabet are ignored in the input.
@param in Stream from which to read data that needs to be decoded.
@return decoded data.
@throws IOException if an IO error occurs.
@since ostermillerutils 1.00.00
|
[
"Decode",
"Base64",
"encoded",
"data",
"from",
"the",
"InputStream",
"to",
"a",
"byte",
"array",
".",
"Characters",
"that",
"are",
"not",
"part",
"of",
"the",
"Base64",
"alphabet",
"are",
"ignored",
"in",
"the",
"input",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java#L713-L717
|
11,473
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java
|
Base64Slow.decodeToString
|
public static String decodeToString(InputStream in, String enc) throws IOException {
return new String(decodeToBytes(in), enc);
}
|
java
|
public static String decodeToString(InputStream in, String enc) throws IOException {
return new String(decodeToBytes(in), enc);
}
|
[
"public",
"static",
"String",
"decodeToString",
"(",
"InputStream",
"in",
",",
"String",
"enc",
")",
"throws",
"IOException",
"{",
"return",
"new",
"String",
"(",
"decodeToBytes",
"(",
"in",
")",
",",
"enc",
")",
";",
"}"
] |
Decode Base64 encoded data from the InputStream to a String. Characters that are not part of
the Base64 alphabet are ignored in the input.
@param in Stream from which to read data that needs to be decoded.
@param enc Character encoding to use when converting bytes to characters.
@return decoded data.
@throws IOException if an IO error occurs.Throws:
@throws UnsupportedEncodingException if the character encoding specified is not supported.
@since ostermillerutils 1.02.16
|
[
"Decode",
"Base64",
"encoded",
"data",
"from",
"the",
"InputStream",
"to",
"a",
"String",
".",
"Characters",
"that",
"are",
"not",
"part",
"of",
"the",
"Base64",
"alphabet",
"are",
"ignored",
"in",
"the",
"input",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java#L744-L746
|
11,474
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/TiffReaderWriter.java
|
TiffReaderWriter.reportResults
|
private static void reportResults(TiffReader tiffReader, int result, String filename,
String output_file) {
TiffDocument to = tiffReader.getModel();
if (output_file != null) {
// TODO: Create xml file with report
} else {
// Display results human readable
switch (result) {
case -1:
System.out.println("File '" + filename + "' does not exist");
break;
case -2:
System.out.println("IO Exception in file '" + filename + "'");
break;
case 0:
if (tiffReader.getBaselineValidation().correct) {
// The file is correct
System.out.println("Everything ok in file '" + filename + "'");
System.out.println("IFDs: " + to.getIfdCount());
System.out.println("SubIFDs: " + to.getSubIfdCount());
to.printMetadata();
TiffEPProfile bpep = new TiffEPProfile(to);
bpep.validate();
bpep.getValidation().printErrors();
TiffITProfile bpit = new TiffITProfile(to, 0);
bpit.validate();
bpit.getValidation().printErrors();
int nifd = 1;
for (TiffObject o : to.getImageIfds()) {
IFD ifd = (IFD) o;
if (ifd != null) {
System.out.println("IFD " + nifd++ + " TAGS:");
ifd.printTags();
}
}
} else {
// The file is not correct
System.out.println("Errors in file '" + filename + "'");
if (to != null) {
System.out.println("IFDs: " + to.getIfdCount());
System.out.println("SubIFDs: " + to.getSubIfdCount());
// int index = 0;
to.printMetadata();
}
tiffReader.getBaselineValidation().printErrors();
}
tiffReader.getBaselineValidation().printWarnings();
break;
default:
System.out.println("Unknown result (" + result + ") in file '" + filename + "'");
break;
}
}
}
|
java
|
private static void reportResults(TiffReader tiffReader, int result, String filename,
String output_file) {
TiffDocument to = tiffReader.getModel();
if (output_file != null) {
// TODO: Create xml file with report
} else {
// Display results human readable
switch (result) {
case -1:
System.out.println("File '" + filename + "' does not exist");
break;
case -2:
System.out.println("IO Exception in file '" + filename + "'");
break;
case 0:
if (tiffReader.getBaselineValidation().correct) {
// The file is correct
System.out.println("Everything ok in file '" + filename + "'");
System.out.println("IFDs: " + to.getIfdCount());
System.out.println("SubIFDs: " + to.getSubIfdCount());
to.printMetadata();
TiffEPProfile bpep = new TiffEPProfile(to);
bpep.validate();
bpep.getValidation().printErrors();
TiffITProfile bpit = new TiffITProfile(to, 0);
bpit.validate();
bpit.getValidation().printErrors();
int nifd = 1;
for (TiffObject o : to.getImageIfds()) {
IFD ifd = (IFD) o;
if (ifd != null) {
System.out.println("IFD " + nifd++ + " TAGS:");
ifd.printTags();
}
}
} else {
// The file is not correct
System.out.println("Errors in file '" + filename + "'");
if (to != null) {
System.out.println("IFDs: " + to.getIfdCount());
System.out.println("SubIFDs: " + to.getSubIfdCount());
// int index = 0;
to.printMetadata();
}
tiffReader.getBaselineValidation().printErrors();
}
tiffReader.getBaselineValidation().printWarnings();
break;
default:
System.out.println("Unknown result (" + result + ") in file '" + filename + "'");
break;
}
}
}
|
[
"private",
"static",
"void",
"reportResults",
"(",
"TiffReader",
"tiffReader",
",",
"int",
"result",
",",
"String",
"filename",
",",
"String",
"output_file",
")",
"{",
"TiffDocument",
"to",
"=",
"tiffReader",
".",
"getModel",
"(",
")",
";",
"if",
"(",
"output_file",
"!=",
"null",
")",
"{",
"// TODO: Create xml file with report",
"}",
"else",
"{",
"// Display results human readable",
"switch",
"(",
"result",
")",
"{",
"case",
"-",
"1",
":",
"System",
".",
"out",
".",
"println",
"(",
"\"File '\"",
"+",
"filename",
"+",
"\"' does not exist\"",
")",
";",
"break",
";",
"case",
"-",
"2",
":",
"System",
".",
"out",
".",
"println",
"(",
"\"IO Exception in file '\"",
"+",
"filename",
"+",
"\"'\"",
")",
";",
"break",
";",
"case",
"0",
":",
"if",
"(",
"tiffReader",
".",
"getBaselineValidation",
"(",
")",
".",
"correct",
")",
"{",
"// The file is correct",
"System",
".",
"out",
".",
"println",
"(",
"\"Everything ok in file '\"",
"+",
"filename",
"+",
"\"'\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"IFDs: \"",
"+",
"to",
".",
"getIfdCount",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"SubIFDs: \"",
"+",
"to",
".",
"getSubIfdCount",
"(",
")",
")",
";",
"to",
".",
"printMetadata",
"(",
")",
";",
"TiffEPProfile",
"bpep",
"=",
"new",
"TiffEPProfile",
"(",
"to",
")",
";",
"bpep",
".",
"validate",
"(",
")",
";",
"bpep",
".",
"getValidation",
"(",
")",
".",
"printErrors",
"(",
")",
";",
"TiffITProfile",
"bpit",
"=",
"new",
"TiffITProfile",
"(",
"to",
",",
"0",
")",
";",
"bpit",
".",
"validate",
"(",
")",
";",
"bpit",
".",
"getValidation",
"(",
")",
".",
"printErrors",
"(",
")",
";",
"int",
"nifd",
"=",
"1",
";",
"for",
"(",
"TiffObject",
"o",
":",
"to",
".",
"getImageIfds",
"(",
")",
")",
"{",
"IFD",
"ifd",
"=",
"(",
"IFD",
")",
"o",
";",
"if",
"(",
"ifd",
"!=",
"null",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"IFD \"",
"+",
"nifd",
"++",
"+",
"\" TAGS:\"",
")",
";",
"ifd",
".",
"printTags",
"(",
")",
";",
"}",
"}",
"}",
"else",
"{",
"// The file is not correct",
"System",
".",
"out",
".",
"println",
"(",
"\"Errors in file '\"",
"+",
"filename",
"+",
"\"'\"",
")",
";",
"if",
"(",
"to",
"!=",
"null",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"IFDs: \"",
"+",
"to",
".",
"getIfdCount",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"SubIFDs: \"",
"+",
"to",
".",
"getSubIfdCount",
"(",
")",
")",
";",
"// int index = 0;",
"to",
".",
"printMetadata",
"(",
")",
";",
"}",
"tiffReader",
".",
"getBaselineValidation",
"(",
")",
".",
"printErrors",
"(",
")",
";",
"}",
"tiffReader",
".",
"getBaselineValidation",
"(",
")",
".",
"printWarnings",
"(",
")",
";",
"break",
";",
"default",
":",
"System",
".",
"out",
".",
"println",
"(",
"\"Unknown result (\"",
"+",
"result",
"+",
"\") in file '\"",
"+",
"filename",
"+",
"\"'\"",
")",
";",
"break",
";",
"}",
"}",
"}"
] |
Report the results of the reading process to the console.
@param tiffReader the tiff reader
@param result the result
@param filename the filename
@param output_file the output_file
|
[
"Report",
"the",
"results",
"of",
"the",
"reading",
"process",
"to",
"the",
"console",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/TiffReaderWriter.java#L143-L200
|
11,475
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSData.java
|
LCMSData.unload
|
public synchronized void unload(LCMSDataSubset subset, Object user, Set<LCMSDataSubset> exclude) {
//System.err.println("=========== UNLOAD (user) CALLED ***********************");
if (!isLoaded(subset)) {
throw new IllegalStateException("LCMSData load/unload methods only"
+ " work for subsets loaded/unloaded using LCMSData API. The"
+ " subset you requested to unload wasn't loaded. If you've"
+ " loaded data into ScanCollection manually, then use"
+ " IScanCollection's API for unloading data manually as"
+ " well.");
}
Set<LCMSDataSubset> userSubsets = cache.getIfPresent(user);
if (userSubsets == null) {
throw new IllegalStateException("The user was not present in cache,"
+ " which means it either has never been there, or has already"
+ " been reclaimed by GC.");
}
if (!userSubsets.contains(subset)) {
throw new IllegalArgumentException("This user has not loaded the subset"
+ " in the first place. The user must load the subset using"
+ " LCMSData API first. Unloading a subset that a user has not"
+ " loaded itself is illegal.");
}
// removing the subset from the user's currently loaded subsets
userSubsets.remove(subset);
// getting subsets loaded by all other users of this LCMSData
ConcurrentMap<Object, Set<LCMSDataSubset>> otherUserMaps = cache.asMap();
HashSet<LCMSDataSubset> otherUsersSubsetsCombined = new HashSet<>();
for (Map.Entry<Object, Set<LCMSDataSubset>> entry : otherUserMaps.entrySet()) {
Object otherUser = entry.getKey();
if (otherUser != user) {
// we need to exclude the user requesting the unloading operation from the
// list of other loaded subsets
Set<LCMSDataSubset> otherUserSubsets = entry.getValue();
otherUsersSubsetsCombined.addAll(otherUserSubsets);
}
}
if (exclude != null) {
otherUsersSubsetsCombined.addAll(exclude);
}
if (otherUsersSubsetsCombined.isEmpty()) {
scans.unloadData(subset);
} else {
scans.unloadData(subset, otherUsersSubsetsCombined);
}
}
|
java
|
public synchronized void unload(LCMSDataSubset subset, Object user, Set<LCMSDataSubset> exclude) {
//System.err.println("=========== UNLOAD (user) CALLED ***********************");
if (!isLoaded(subset)) {
throw new IllegalStateException("LCMSData load/unload methods only"
+ " work for subsets loaded/unloaded using LCMSData API. The"
+ " subset you requested to unload wasn't loaded. If you've"
+ " loaded data into ScanCollection manually, then use"
+ " IScanCollection's API for unloading data manually as"
+ " well.");
}
Set<LCMSDataSubset> userSubsets = cache.getIfPresent(user);
if (userSubsets == null) {
throw new IllegalStateException("The user was not present in cache,"
+ " which means it either has never been there, or has already"
+ " been reclaimed by GC.");
}
if (!userSubsets.contains(subset)) {
throw new IllegalArgumentException("This user has not loaded the subset"
+ " in the first place. The user must load the subset using"
+ " LCMSData API first. Unloading a subset that a user has not"
+ " loaded itself is illegal.");
}
// removing the subset from the user's currently loaded subsets
userSubsets.remove(subset);
// getting subsets loaded by all other users of this LCMSData
ConcurrentMap<Object, Set<LCMSDataSubset>> otherUserMaps = cache.asMap();
HashSet<LCMSDataSubset> otherUsersSubsetsCombined = new HashSet<>();
for (Map.Entry<Object, Set<LCMSDataSubset>> entry : otherUserMaps.entrySet()) {
Object otherUser = entry.getKey();
if (otherUser != user) {
// we need to exclude the user requesting the unloading operation from the
// list of other loaded subsets
Set<LCMSDataSubset> otherUserSubsets = entry.getValue();
otherUsersSubsetsCombined.addAll(otherUserSubsets);
}
}
if (exclude != null) {
otherUsersSubsetsCombined.addAll(exclude);
}
if (otherUsersSubsetsCombined.isEmpty()) {
scans.unloadData(subset);
} else {
scans.unloadData(subset, otherUsersSubsetsCombined);
}
}
|
[
"public",
"synchronized",
"void",
"unload",
"(",
"LCMSDataSubset",
"subset",
",",
"Object",
"user",
",",
"Set",
"<",
"LCMSDataSubset",
">",
"exclude",
")",
"{",
"//System.err.println(\"=========== UNLOAD (user) CALLED ***********************\");",
"if",
"(",
"!",
"isLoaded",
"(",
"subset",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"LCMSData load/unload methods only\"",
"+",
"\" work for subsets loaded/unloaded using LCMSData API. The\"",
"+",
"\" subset you requested to unload wasn't loaded. If you've\"",
"+",
"\" loaded data into ScanCollection manually, then use\"",
"+",
"\" IScanCollection's API for unloading data manually as\"",
"+",
"\" well.\"",
")",
";",
"}",
"Set",
"<",
"LCMSDataSubset",
">",
"userSubsets",
"=",
"cache",
".",
"getIfPresent",
"(",
"user",
")",
";",
"if",
"(",
"userSubsets",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"The user was not present in cache,\"",
"+",
"\" which means it either has never been there, or has already\"",
"+",
"\" been reclaimed by GC.\"",
")",
";",
"}",
"if",
"(",
"!",
"userSubsets",
".",
"contains",
"(",
"subset",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"This user has not loaded the subset\"",
"+",
"\" in the first place. The user must load the subset using\"",
"+",
"\" LCMSData API first. Unloading a subset that a user has not\"",
"+",
"\" loaded itself is illegal.\"",
")",
";",
"}",
"// removing the subset from the user's currently loaded subsets",
"userSubsets",
".",
"remove",
"(",
"subset",
")",
";",
"// getting subsets loaded by all other users of this LCMSData",
"ConcurrentMap",
"<",
"Object",
",",
"Set",
"<",
"LCMSDataSubset",
">",
">",
"otherUserMaps",
"=",
"cache",
".",
"asMap",
"(",
")",
";",
"HashSet",
"<",
"LCMSDataSubset",
">",
"otherUsersSubsetsCombined",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"Set",
"<",
"LCMSDataSubset",
">",
">",
"entry",
":",
"otherUserMaps",
".",
"entrySet",
"(",
")",
")",
"{",
"Object",
"otherUser",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"otherUser",
"!=",
"user",
")",
"{",
"// we need to exclude the user requesting the unloading operation from the",
"// list of other loaded subsets",
"Set",
"<",
"LCMSDataSubset",
">",
"otherUserSubsets",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"otherUsersSubsetsCombined",
".",
"addAll",
"(",
"otherUserSubsets",
")",
";",
"}",
"}",
"if",
"(",
"exclude",
"!=",
"null",
")",
"{",
"otherUsersSubsetsCombined",
".",
"addAll",
"(",
"exclude",
")",
";",
"}",
"if",
"(",
"otherUsersSubsetsCombined",
".",
"isEmpty",
"(",
")",
")",
"{",
"scans",
".",
"unloadData",
"(",
"subset",
")",
";",
"}",
"else",
"{",
"scans",
".",
"unloadData",
"(",
"subset",
",",
"otherUsersSubsetsCombined",
")",
";",
"}",
"}"
] |
Unloads spectra matched by this subset.
@param subset to be unloaded
@param user the user, that has had this subset loaded. If other users have parts of this subset
loaded, those parts won't be unloaded.
@param exclude can be null. If specified, data from these subsets won't be excluded.
|
[
"Unloads",
"spectra",
"matched",
"by",
"this",
"subset",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSData.java#L195-L240
|
11,476
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSData.java
|
LCMSData.unsafeUnload
|
private void unsafeUnload(LCMSDataSubset subset) {
//System.err.println("=========== UNLOAD (unsafe) CALLED ***********************");
// getting subsets loaded by all other users of this LCMSData
ConcurrentMap<Object, Set<LCMSDataSubset>> otherUserMaps = cache.asMap();
HashSet<LCMSDataSubset> otherUsersSubsetsCombined = new HashSet<>();
for (Map.Entry<Object, Set<LCMSDataSubset>> entry : otherUserMaps.entrySet()) {
Set<LCMSDataSubset> otherUserSubsets = entry.getValue();
otherUsersSubsetsCombined.addAll(otherUserSubsets);
// for (LCMSDataSubset otherSubset : otherUserSubsets) {
// if (otherSubset != subset) {
// otherUsersSubsetsCombined.add(otherSubset);
// }
// }
}
if (otherUsersSubsetsCombined.isEmpty()) {
scans.unloadData(subset);
} else {
scans.unloadData(subset, otherUsersSubsetsCombined);
}
}
|
java
|
private void unsafeUnload(LCMSDataSubset subset) {
//System.err.println("=========== UNLOAD (unsafe) CALLED ***********************");
// getting subsets loaded by all other users of this LCMSData
ConcurrentMap<Object, Set<LCMSDataSubset>> otherUserMaps = cache.asMap();
HashSet<LCMSDataSubset> otherUsersSubsetsCombined = new HashSet<>();
for (Map.Entry<Object, Set<LCMSDataSubset>> entry : otherUserMaps.entrySet()) {
Set<LCMSDataSubset> otherUserSubsets = entry.getValue();
otherUsersSubsetsCombined.addAll(otherUserSubsets);
// for (LCMSDataSubset otherSubset : otherUserSubsets) {
// if (otherSubset != subset) {
// otherUsersSubsetsCombined.add(otherSubset);
// }
// }
}
if (otherUsersSubsetsCombined.isEmpty()) {
scans.unloadData(subset);
} else {
scans.unloadData(subset, otherUsersSubsetsCombined);
}
}
|
[
"private",
"void",
"unsafeUnload",
"(",
"LCMSDataSubset",
"subset",
")",
"{",
"//System.err.println(\"=========== UNLOAD (unsafe) CALLED ***********************\");",
"// getting subsets loaded by all other users of this LCMSData",
"ConcurrentMap",
"<",
"Object",
",",
"Set",
"<",
"LCMSDataSubset",
">",
">",
"otherUserMaps",
"=",
"cache",
".",
"asMap",
"(",
")",
";",
"HashSet",
"<",
"LCMSDataSubset",
">",
"otherUsersSubsetsCombined",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"Set",
"<",
"LCMSDataSubset",
">",
">",
"entry",
":",
"otherUserMaps",
".",
"entrySet",
"(",
")",
")",
"{",
"Set",
"<",
"LCMSDataSubset",
">",
"otherUserSubsets",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"otherUsersSubsetsCombined",
".",
"addAll",
"(",
"otherUserSubsets",
")",
";",
"// for (LCMSDataSubset otherSubset : otherUserSubsets) {",
"// if (otherSubset != subset) {",
"// otherUsersSubsetsCombined.add(otherSubset);",
"// }",
"// }",
"}",
"if",
"(",
"otherUsersSubsetsCombined",
".",
"isEmpty",
"(",
")",
")",
"{",
"scans",
".",
"unloadData",
"(",
"subset",
")",
";",
"}",
"else",
"{",
"scans",
".",
"unloadData",
"(",
"subset",
",",
"otherUsersSubsetsCombined",
")",
";",
"}",
"}"
] |
Unloads the subset without checking the user. It's required by our user-tracking automatic
cleanup, if a user was GCed and it hasn't unloaded its subsets, we detect the GC automatically,
and unload all the subsets, used by this killed user. It will still check for other users using
scans from this subset.
|
[
"Unloads",
"the",
"subset",
"without",
"checking",
"the",
"user",
".",
"It",
"s",
"required",
"by",
"our",
"user",
"-",
"tracking",
"automatic",
"cleanup",
"if",
"a",
"user",
"was",
"GCed",
"and",
"it",
"hasn",
"t",
"unloaded",
"its",
"subsets",
"we",
"detect",
"the",
"GC",
"automatically",
"and",
"unload",
"all",
"the",
"subsets",
"used",
"by",
"this",
"killed",
"user",
".",
"It",
"will",
"still",
"check",
"for",
"other",
"users",
"using",
"scans",
"from",
"this",
"subset",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSData.java#L248-L267
|
11,477
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/subset/algo/exh/SubsetSolutionIterator.java
|
SubsetSolutionIterator.next
|
@Override
public SubsetSolution next() {
// get next subset
Set<Integer> subset = subsetIterator.next();
// wrap in subset solution
return new SubsetSolution(IDs, subset);
}
|
java
|
@Override
public SubsetSolution next() {
// get next subset
Set<Integer> subset = subsetIterator.next();
// wrap in subset solution
return new SubsetSolution(IDs, subset);
}
|
[
"@",
"Override",
"public",
"SubsetSolution",
"next",
"(",
")",
"{",
"// get next subset",
"Set",
"<",
"Integer",
">",
"subset",
"=",
"subsetIterator",
".",
"next",
"(",
")",
";",
"// wrap in subset solution",
"return",
"new",
"SubsetSolution",
"(",
"IDs",
",",
"subset",
")",
";",
"}"
] |
Generate the next subset solution. The returned subset will either have the same size as the previously generated solution,
if any, or it will be a larger subset.
@return next subset solution within the size bounds
@throws NoSuchElementException if there is no next solution to be generated
|
[
"Generate",
"the",
"next",
"subset",
"solution",
".",
"The",
"returned",
"subset",
"will",
"either",
"have",
"the",
"same",
"size",
"as",
"the",
"previously",
"generated",
"solution",
"if",
"any",
"or",
"it",
"will",
"be",
"a",
"larger",
"subset",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/algo/exh/SubsetSolutionIterator.java#L94-L100
|
11,478
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/ValidationEvent.java
|
ValidationEvent.printError
|
public void printError() {
System.out.print(description);
if (value != null)
System.out.print(" (" + value + ")");
System.out.println();
}
|
java
|
public void printError() {
System.out.print(description);
if (value != null)
System.out.print(" (" + value + ")");
System.out.println();
}
|
[
"public",
"void",
"printError",
"(",
")",
"{",
"System",
".",
"out",
".",
"print",
"(",
"description",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"System",
".",
"out",
".",
"print",
"(",
"\" (\"",
"+",
"value",
"+",
"\")\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"}"
] |
Prints the error in the console.
|
[
"Prints",
"the",
"error",
"in",
"the",
"console",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/ValidationEvent.java#L91-L96
|
11,479
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/ValidationEvent.java
|
ValidationEvent.printWarning
|
public void printWarning() {
System.out.print("Warning: ");
System.out.print(description);
if (value != null)
System.out.print(" (" + value + ")");
System.out.println();
}
|
java
|
public void printWarning() {
System.out.print("Warning: ");
System.out.print(description);
if (value != null)
System.out.print(" (" + value + ")");
System.out.println();
}
|
[
"public",
"void",
"printWarning",
"(",
")",
"{",
"System",
".",
"out",
".",
"print",
"(",
"\"Warning: \"",
")",
";",
"System",
".",
"out",
".",
"print",
"(",
"description",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"System",
".",
"out",
".",
"print",
"(",
"\" (\"",
"+",
"value",
"+",
"\")\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"}"
] |
Prints the warning in the console.
|
[
"Prints",
"the",
"warning",
"in",
"the",
"console",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/ValidationEvent.java#L101-L107
|
11,480
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/subset/neigh/adv/DisjointMultiSwapNeighbourhood.java
|
DisjointMultiSwapNeighbourhood.numSwaps
|
private int numSwaps(Set<Integer> addCandidates, Set<Integer> deleteCandidates){
return Math.min(addCandidates.size(), Math.min(deleteCandidates.size(), numSwaps));
}
|
java
|
private int numSwaps(Set<Integer> addCandidates, Set<Integer> deleteCandidates){
return Math.min(addCandidates.size(), Math.min(deleteCandidates.size(), numSwaps));
}
|
[
"private",
"int",
"numSwaps",
"(",
"Set",
"<",
"Integer",
">",
"addCandidates",
",",
"Set",
"<",
"Integer",
">",
"deleteCandidates",
")",
"{",
"return",
"Math",
".",
"min",
"(",
"addCandidates",
".",
"size",
"(",
")",
",",
"Math",
".",
"min",
"(",
"deleteCandidates",
".",
"size",
"(",
")",
",",
"numSwaps",
")",
")",
";",
"}"
] |
Infer the number of swaps that will be performed, taking into account the fixed number of desired
swaps as specified at construction and the maximum number of possible swaps for the given subset solution.
@param addCandidates candidate IDs to be added to the selection
@param deleteCandidates candidate IDs to be removed from the selection
@return number of swaps to be performed: desired fixed number if possible, or less (as many as possible)
|
[
"Infer",
"the",
"number",
"of",
"swaps",
"that",
"will",
"be",
"performed",
"taking",
"into",
"account",
"the",
"fixed",
"number",
"of",
"desired",
"swaps",
"as",
"specified",
"at",
"construction",
"and",
"the",
"maximum",
"number",
"of",
"possible",
"swaps",
"for",
"the",
"given",
"subset",
"solution",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/neigh/adv/DisjointMultiSwapNeighbourhood.java#L188-L190
|
11,481
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/TagValue.java
|
TagValue.getDescriptiveValueObject
|
public List<abstractTiffType> getDescriptiveValueObject() {
Tag tag = TiffTags.getTag(id);
if (tag != null) {
if (tag.hasReadableDescription()){
String desc = this.toString();
String tagDescription = tag.getTextDescription(toString());
if (tagDescription != null){
desc = tagDescription;
}
return Arrays.asList(new Text(desc));
} else {
return getValue();
}
}
return null;
}
|
java
|
public List<abstractTiffType> getDescriptiveValueObject() {
Tag tag = TiffTags.getTag(id);
if (tag != null) {
if (tag.hasReadableDescription()){
String desc = this.toString();
String tagDescription = tag.getTextDescription(toString());
if (tagDescription != null){
desc = tagDescription;
}
return Arrays.asList(new Text(desc));
} else {
return getValue();
}
}
return null;
}
|
[
"public",
"List",
"<",
"abstractTiffType",
">",
"getDescriptiveValueObject",
"(",
")",
"{",
"Tag",
"tag",
"=",
"TiffTags",
".",
"getTag",
"(",
"id",
")",
";",
"if",
"(",
"tag",
"!=",
"null",
")",
"{",
"if",
"(",
"tag",
".",
"hasReadableDescription",
"(",
")",
")",
"{",
"String",
"desc",
"=",
"this",
".",
"toString",
"(",
")",
";",
"String",
"tagDescription",
"=",
"tag",
".",
"getTextDescription",
"(",
"toString",
"(",
")",
")",
";",
"if",
"(",
"tagDescription",
"!=",
"null",
")",
"{",
"desc",
"=",
"tagDescription",
";",
"}",
"return",
"Arrays",
".",
"asList",
"(",
"new",
"Text",
"(",
"desc",
")",
")",
";",
"}",
"else",
"{",
"return",
"getValue",
"(",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Gets the descriptive value.
@return the descriptive value
|
[
"Gets",
"the",
"descriptive",
"value",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/TagValue.java#L130-L145
|
11,482
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/TagValue.java
|
TagValue.getFirstNumericValue
|
public long getFirstNumericValue() {
String val = (value != null) ? value.get(0).toString() : readValue.get(0).toString();
if (isInteger(val)) {
return Long.parseLong(val);
} else {
return 0;
}
}
|
java
|
public long getFirstNumericValue() {
String val = (value != null) ? value.get(0).toString() : readValue.get(0).toString();
if (isInteger(val)) {
return Long.parseLong(val);
} else {
return 0;
}
}
|
[
"public",
"long",
"getFirstNumericValue",
"(",
")",
"{",
"String",
"val",
"=",
"(",
"value",
"!=",
"null",
")",
"?",
"value",
".",
"get",
"(",
"0",
")",
".",
"toString",
"(",
")",
":",
"readValue",
".",
"get",
"(",
"0",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"isInteger",
"(",
"val",
")",
")",
"{",
"return",
"Long",
".",
"parseLong",
"(",
"val",
")",
";",
"}",
"else",
"{",
"return",
"0",
";",
"}",
"}"
] |
Gets the first value of the list parsed as a number.
@return the first integer value
|
[
"Gets",
"the",
"first",
"value",
"of",
"the",
"list",
"parsed",
"as",
"a",
"number",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/TagValue.java#L260-L267
|
11,483
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/TagValue.java
|
TagValue.getName
|
public String getName() {
String name = "" + id;
if (TiffTags.hasTag(id))
name = TiffTags.getTag(id).getName();
return name;
}
|
java
|
public String getName() {
String name = "" + id;
if (TiffTags.hasTag(id))
name = TiffTags.getTag(id).getName();
return name;
}
|
[
"public",
"String",
"getName",
"(",
")",
"{",
"String",
"name",
"=",
"\"\"",
"+",
"id",
";",
"if",
"(",
"TiffTags",
".",
"hasTag",
"(",
"id",
")",
")",
"name",
"=",
"TiffTags",
".",
"getTag",
"(",
"id",
")",
".",
"getName",
"(",
")",
";",
"return",
"name",
";",
"}"
] |
Gets the name of the tag.
@return the name
|
[
"Gets",
"the",
"name",
"of",
"the",
"tag",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/TagValue.java#L354-L359
|
11,484
|
maxirosson/jdroid-android
|
jdroid-android-google-inappbilling/src/main/java/com/jdroid/android/google/inappbilling/client/InAppBillingClient.java
|
InAppBillingClient.startSetup
|
@MainThread
public void startSetup() {
try {
LOGGER.debug("Starting in-app billing setup.");
billingClient = BillingClient.newBuilder(AbstractApplication.get()).setListener(this).build();
Runnable runnable = new Runnable() {
@Override
public void run() {
LOGGER.debug("In-app billing setup successful.");
for (ProductType productType : InAppBillingAppModule.get().getInAppBillingContext().getManagedProductTypes()) {
inventory.addProduct(new Product(productType));
}
if (isSubscriptionsSupported()) {
for (ProductType productType : InAppBillingAppModule.get().getInAppBillingContext().getSubscriptionsProductTypes()) {
inventory.addProduct(new Product(productType));
}
}
if (listener != null) {
listener.onSetupFinished();
}
}
};
if (isServiceConnected) {
runnable.run();
} else {
startServiceConnection(runnable);
}
} catch (Exception e) {
AbstractApplication.get().getExceptionHandler().logHandledException(e);
if (listener != null) {
listener.onSetupFailed(new UnexpectedException(e));
}
}
}
|
java
|
@MainThread
public void startSetup() {
try {
LOGGER.debug("Starting in-app billing setup.");
billingClient = BillingClient.newBuilder(AbstractApplication.get()).setListener(this).build();
Runnable runnable = new Runnable() {
@Override
public void run() {
LOGGER.debug("In-app billing setup successful.");
for (ProductType productType : InAppBillingAppModule.get().getInAppBillingContext().getManagedProductTypes()) {
inventory.addProduct(new Product(productType));
}
if (isSubscriptionsSupported()) {
for (ProductType productType : InAppBillingAppModule.get().getInAppBillingContext().getSubscriptionsProductTypes()) {
inventory.addProduct(new Product(productType));
}
}
if (listener != null) {
listener.onSetupFinished();
}
}
};
if (isServiceConnected) {
runnable.run();
} else {
startServiceConnection(runnable);
}
} catch (Exception e) {
AbstractApplication.get().getExceptionHandler().logHandledException(e);
if (listener != null) {
listener.onSetupFailed(new UnexpectedException(e));
}
}
}
|
[
"@",
"MainThread",
"public",
"void",
"startSetup",
"(",
")",
"{",
"try",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Starting in-app billing setup.\"",
")",
";",
"billingClient",
"=",
"BillingClient",
".",
"newBuilder",
"(",
"AbstractApplication",
".",
"get",
"(",
")",
")",
".",
"setListener",
"(",
"this",
")",
".",
"build",
"(",
")",
";",
"Runnable",
"runnable",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"In-app billing setup successful.\"",
")",
";",
"for",
"(",
"ProductType",
"productType",
":",
"InAppBillingAppModule",
".",
"get",
"(",
")",
".",
"getInAppBillingContext",
"(",
")",
".",
"getManagedProductTypes",
"(",
")",
")",
"{",
"inventory",
".",
"addProduct",
"(",
"new",
"Product",
"(",
"productType",
")",
")",
";",
"}",
"if",
"(",
"isSubscriptionsSupported",
"(",
")",
")",
"{",
"for",
"(",
"ProductType",
"productType",
":",
"InAppBillingAppModule",
".",
"get",
"(",
")",
".",
"getInAppBillingContext",
"(",
")",
".",
"getSubscriptionsProductTypes",
"(",
")",
")",
"{",
"inventory",
".",
"addProduct",
"(",
"new",
"Product",
"(",
"productType",
")",
")",
";",
"}",
"}",
"if",
"(",
"listener",
"!=",
"null",
")",
"{",
"listener",
".",
"onSetupFinished",
"(",
")",
";",
"}",
"}",
"}",
";",
"if",
"(",
"isServiceConnected",
")",
"{",
"runnable",
".",
"run",
"(",
")",
";",
"}",
"else",
"{",
"startServiceConnection",
"(",
"runnable",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"AbstractApplication",
".",
"get",
"(",
")",
".",
"getExceptionHandler",
"(",
")",
".",
"logHandledException",
"(",
"e",
")",
";",
"if",
"(",
"listener",
"!=",
"null",
")",
"{",
"listener",
".",
"onSetupFailed",
"(",
"new",
"UnexpectedException",
"(",
"e",
")",
")",
";",
"}",
"}",
"}"
] |
Starts the setup process. This will start up the setup process asynchronously. You will be notified through the
listener when the setup process is complete.
|
[
"Starts",
"the",
"setup",
"process",
".",
"This",
"will",
"start",
"up",
"the",
"setup",
"process",
"asynchronously",
".",
"You",
"will",
"be",
"notified",
"through",
"the",
"listener",
"when",
"the",
"setup",
"process",
"is",
"complete",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-google-inappbilling/src/main/java/com/jdroid/android/google/inappbilling/client/InAppBillingClient.java#L90-L130
|
11,485
|
maxirosson/jdroid-android
|
jdroid-android-google-inappbilling/src/main/java/com/jdroid/android/google/inappbilling/client/InAppBillingClient.java
|
InAppBillingClient.launchPurchaseFlow
|
private void launchPurchaseFlow(Activity activity, Product product, ItemType itemType, String oldProductId) {
executeServiceRequest(new Runnable() {
@Override
public void run() {
if (itemType.equals(ItemType.SUBSCRIPTION) && !isSubscriptionsSupported()) {
LOGGER.debug("Failed in-app purchase flow for product id " + product.getId() + ", item type: " + itemType + ". Subscriptions not supported.");
if (listener != null) {
listener.onPurchaseFailed(InAppBillingErrorCode.SUBSCRIPTIONS_NOT_AVAILABLE.newErrorCodeException());
}
} else {
LOGGER.debug("Launching in-app purchase flow for product id " + product.getId() + ", item type: " + itemType);
String productIdToBuy = InAppBillingAppModule.get().getInAppBillingContext().isStaticResponsesEnabled() ?
product.getProductType().getTestProductId() : product.getId();
BillingFlowParams purchaseParams = BillingFlowParams.newBuilder()
.setSku(productIdToBuy)
.setType(itemType.getType())
.setOldSku(oldProductId)
.build();
int responseCode = billingClient.launchBillingFlow(activity, purchaseParams);
InAppBillingErrorCode inAppBillingErrorCode = InAppBillingErrorCode.findByErrorResponseCode(responseCode);
if (inAppBillingErrorCode != null) {
if (listener != null) {
AbstractApplication.get().getExceptionHandler().logHandledException(inAppBillingErrorCode.newErrorCodeException());
listener.onPurchaseFailed(inAppBillingErrorCode.newErrorCodeException());
}
}
}
}
});
}
|
java
|
private void launchPurchaseFlow(Activity activity, Product product, ItemType itemType, String oldProductId) {
executeServiceRequest(new Runnable() {
@Override
public void run() {
if (itemType.equals(ItemType.SUBSCRIPTION) && !isSubscriptionsSupported()) {
LOGGER.debug("Failed in-app purchase flow for product id " + product.getId() + ", item type: " + itemType + ". Subscriptions not supported.");
if (listener != null) {
listener.onPurchaseFailed(InAppBillingErrorCode.SUBSCRIPTIONS_NOT_AVAILABLE.newErrorCodeException());
}
} else {
LOGGER.debug("Launching in-app purchase flow for product id " + product.getId() + ", item type: " + itemType);
String productIdToBuy = InAppBillingAppModule.get().getInAppBillingContext().isStaticResponsesEnabled() ?
product.getProductType().getTestProductId() : product.getId();
BillingFlowParams purchaseParams = BillingFlowParams.newBuilder()
.setSku(productIdToBuy)
.setType(itemType.getType())
.setOldSku(oldProductId)
.build();
int responseCode = billingClient.launchBillingFlow(activity, purchaseParams);
InAppBillingErrorCode inAppBillingErrorCode = InAppBillingErrorCode.findByErrorResponseCode(responseCode);
if (inAppBillingErrorCode != null) {
if (listener != null) {
AbstractApplication.get().getExceptionHandler().logHandledException(inAppBillingErrorCode.newErrorCodeException());
listener.onPurchaseFailed(inAppBillingErrorCode.newErrorCodeException());
}
}
}
}
});
}
|
[
"private",
"void",
"launchPurchaseFlow",
"(",
"Activity",
"activity",
",",
"Product",
"product",
",",
"ItemType",
"itemType",
",",
"String",
"oldProductId",
")",
"{",
"executeServiceRequest",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"if",
"(",
"itemType",
".",
"equals",
"(",
"ItemType",
".",
"SUBSCRIPTION",
")",
"&&",
"!",
"isSubscriptionsSupported",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Failed in-app purchase flow for product id \"",
"+",
"product",
".",
"getId",
"(",
")",
"+",
"\", item type: \"",
"+",
"itemType",
"+",
"\". Subscriptions not supported.\"",
")",
";",
"if",
"(",
"listener",
"!=",
"null",
")",
"{",
"listener",
".",
"onPurchaseFailed",
"(",
"InAppBillingErrorCode",
".",
"SUBSCRIPTIONS_NOT_AVAILABLE",
".",
"newErrorCodeException",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Launching in-app purchase flow for product id \"",
"+",
"product",
".",
"getId",
"(",
")",
"+",
"\", item type: \"",
"+",
"itemType",
")",
";",
"String",
"productIdToBuy",
"=",
"InAppBillingAppModule",
".",
"get",
"(",
")",
".",
"getInAppBillingContext",
"(",
")",
".",
"isStaticResponsesEnabled",
"(",
")",
"?",
"product",
".",
"getProductType",
"(",
")",
".",
"getTestProductId",
"(",
")",
":",
"product",
".",
"getId",
"(",
")",
";",
"BillingFlowParams",
"purchaseParams",
"=",
"BillingFlowParams",
".",
"newBuilder",
"(",
")",
".",
"setSku",
"(",
"productIdToBuy",
")",
".",
"setType",
"(",
"itemType",
".",
"getType",
"(",
")",
")",
".",
"setOldSku",
"(",
"oldProductId",
")",
".",
"build",
"(",
")",
";",
"int",
"responseCode",
"=",
"billingClient",
".",
"launchBillingFlow",
"(",
"activity",
",",
"purchaseParams",
")",
";",
"InAppBillingErrorCode",
"inAppBillingErrorCode",
"=",
"InAppBillingErrorCode",
".",
"findByErrorResponseCode",
"(",
"responseCode",
")",
";",
"if",
"(",
"inAppBillingErrorCode",
"!=",
"null",
")",
"{",
"if",
"(",
"listener",
"!=",
"null",
")",
"{",
"AbstractApplication",
".",
"get",
"(",
")",
".",
"getExceptionHandler",
"(",
")",
".",
"logHandledException",
"(",
"inAppBillingErrorCode",
".",
"newErrorCodeException",
"(",
")",
")",
";",
"listener",
".",
"onPurchaseFailed",
"(",
"inAppBillingErrorCode",
".",
"newErrorCodeException",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
")",
";",
"}"
] |
Initiate the UI flow for an in-app purchase. Call this method to initiate an in-app purchase, which will involve
bringing up the Google Play screen. The calling activity will be paused while the user interacts with Google
Play
This method MUST be called from the UI thread of the Activity.
@param activity The calling activity.
@param product The product to purchase.
@param itemType indicates if it's a product or a subscription (ITEM_TYPE_INAPP or ITEM_TYPE_SUBS)
@param oldProductId The SKU which the new SKU is replacing or null if there is none
|
[
"Initiate",
"the",
"UI",
"flow",
"for",
"an",
"in",
"-",
"app",
"purchase",
".",
"Call",
"this",
"method",
"to",
"initiate",
"an",
"in",
"-",
"app",
"purchase",
"which",
"will",
"involve",
"bringing",
"up",
"the",
"Google",
"Play",
"screen",
".",
"The",
"calling",
"activity",
"will",
"be",
"paused",
"while",
"the",
"user",
"interacts",
"with",
"Google",
"Play",
"This",
"method",
"MUST",
"be",
"called",
"from",
"the",
"UI",
"thread",
"of",
"the",
"Activity",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-google-inappbilling/src/main/java/com/jdroid/android/google/inappbilling/client/InAppBillingClient.java#L393-L422
|
11,486
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/external/BufferedRandomAccessFile.java
|
BufferedRandomAccessFile.fillBuffer
|
private int fillBuffer() throws IOException {
int n = super.read(buffer, 0, BUF_SIZE);
if (n >= 0) {
real_pos += n;
buf_end = n;
buf_pos = 0;
}
return n;
}
|
java
|
private int fillBuffer() throws IOException {
int n = super.read(buffer, 0, BUF_SIZE);
if (n >= 0) {
real_pos += n;
buf_end = n;
buf_pos = 0;
}
return n;
}
|
[
"private",
"int",
"fillBuffer",
"(",
")",
"throws",
"IOException",
"{",
"int",
"n",
"=",
"super",
".",
"read",
"(",
"buffer",
",",
"0",
",",
"BUF_SIZE",
")",
";",
"if",
"(",
"n",
">=",
"0",
")",
"{",
"real_pos",
"+=",
"n",
";",
"buf_end",
"=",
"n",
";",
"buf_pos",
"=",
"0",
";",
"}",
"return",
"n",
";",
"}"
] |
Reads the next BUF_SIZE bytes into the internal buffer.
|
[
"Reads",
"the",
"next",
"BUF_SIZE",
"bytes",
"into",
"the",
"internal",
"buffer",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/external/BufferedRandomAccessFile.java#L73-L81
|
11,487
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/external/BufferedRandomAccessFile.java
|
BufferedRandomAccessFile.read
|
@Override
public int read(byte b[], int off, int len) throws IOException {
int leftover = buf_end - buf_pos;
if (len <= leftover) {
System.arraycopy(buffer, buf_pos, b, off, len);
buf_pos += len;
return len;
}
for (int i = 0; i < len; i++) {
int c = this.read();
if (c != -1) {
b[off + i] = (byte) c;
} else {
return i;
}
}
return len;
}
|
java
|
@Override
public int read(byte b[], int off, int len) throws IOException {
int leftover = buf_end - buf_pos;
if (len <= leftover) {
System.arraycopy(buffer, buf_pos, b, off, len);
buf_pos += len;
return len;
}
for (int i = 0; i < len; i++) {
int c = this.read();
if (c != -1) {
b[off + i] = (byte) c;
} else {
return i;
}
}
return len;
}
|
[
"@",
"Override",
"public",
"int",
"read",
"(",
"byte",
"b",
"[",
"]",
",",
"int",
"off",
",",
"int",
"len",
")",
"throws",
"IOException",
"{",
"int",
"leftover",
"=",
"buf_end",
"-",
"buf_pos",
";",
"if",
"(",
"len",
"<=",
"leftover",
")",
"{",
"System",
".",
"arraycopy",
"(",
"buffer",
",",
"buf_pos",
",",
"b",
",",
"off",
",",
"len",
")",
";",
"buf_pos",
"+=",
"len",
";",
"return",
"len",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"int",
"c",
"=",
"this",
".",
"read",
"(",
")",
";",
"if",
"(",
"c",
"!=",
"-",
"1",
")",
"{",
"b",
"[",
"off",
"+",
"i",
"]",
"=",
"(",
"byte",
")",
"c",
";",
"}",
"else",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"len",
";",
"}"
] |
Reads the set number of bytes into the passed buffer.
@param b The buffer to read the bytes into.
@param off Byte offset within the file to start reading from
@param len Number of bytes to read into the buffer.
@return Number of bytes read.
|
[
"Reads",
"the",
"set",
"number",
"of",
"bytes",
"into",
"the",
"passed",
"buffer",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/external/BufferedRandomAccessFile.java#L100-L117
|
11,488
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/algo/PipedLocalSearch.java
|
PipedLocalSearch.searchStep
|
@Override
protected void searchStep() {
// execute pipeline
pipeline.stream().forEachOrdered(l -> {
// attach listener
l.addSearchListener(pipelineListener);
// set initial solution (copy!)
l.setCurrentSolution(Solution.checkedCopy(getCurrentSolution()));
// run local search
l.start();
// get best solution found by search l
SolutionType bestSol = l.getBestSolution();
Evaluation bestSolEvaluation = l.getBestSolutionEvaluation();
Validation bestSolValidation = l.getBestSolutionValidation();
// if not null and different from current solution (i.e. improved):
// update current and best solution accordingly
if(bestSol != null && !bestSol.equals(getCurrentSolution())){
updateCurrentAndBestSolution(bestSol, bestSolEvaluation, bestSolValidation);
}
// remove listener
l.removeSearchListener(pipelineListener);
});
// pipeline complete: stop search
stop();
}
|
java
|
@Override
protected void searchStep() {
// execute pipeline
pipeline.stream().forEachOrdered(l -> {
// attach listener
l.addSearchListener(pipelineListener);
// set initial solution (copy!)
l.setCurrentSolution(Solution.checkedCopy(getCurrentSolution()));
// run local search
l.start();
// get best solution found by search l
SolutionType bestSol = l.getBestSolution();
Evaluation bestSolEvaluation = l.getBestSolutionEvaluation();
Validation bestSolValidation = l.getBestSolutionValidation();
// if not null and different from current solution (i.e. improved):
// update current and best solution accordingly
if(bestSol != null && !bestSol.equals(getCurrentSolution())){
updateCurrentAndBestSolution(bestSol, bestSolEvaluation, bestSolValidation);
}
// remove listener
l.removeSearchListener(pipelineListener);
});
// pipeline complete: stop search
stop();
}
|
[
"@",
"Override",
"protected",
"void",
"searchStep",
"(",
")",
"{",
"// execute pipeline",
"pipeline",
".",
"stream",
"(",
")",
".",
"forEachOrdered",
"(",
"l",
"->",
"{",
"// attach listener",
"l",
".",
"addSearchListener",
"(",
"pipelineListener",
")",
";",
"// set initial solution (copy!)",
"l",
".",
"setCurrentSolution",
"(",
"Solution",
".",
"checkedCopy",
"(",
"getCurrentSolution",
"(",
")",
")",
")",
";",
"// run local search",
"l",
".",
"start",
"(",
")",
";",
"// get best solution found by search l",
"SolutionType",
"bestSol",
"=",
"l",
".",
"getBestSolution",
"(",
")",
";",
"Evaluation",
"bestSolEvaluation",
"=",
"l",
".",
"getBestSolutionEvaluation",
"(",
")",
";",
"Validation",
"bestSolValidation",
"=",
"l",
".",
"getBestSolutionValidation",
"(",
")",
";",
"// if not null and different from current solution (i.e. improved):",
"// update current and best solution accordingly",
"if",
"(",
"bestSol",
"!=",
"null",
"&&",
"!",
"bestSol",
".",
"equals",
"(",
"getCurrentSolution",
"(",
")",
")",
")",
"{",
"updateCurrentAndBestSolution",
"(",
"bestSol",
",",
"bestSolEvaluation",
",",
"bestSolValidation",
")",
";",
"}",
"// remove listener",
"l",
".",
"removeSearchListener",
"(",
"pipelineListener",
")",
";",
"}",
")",
";",
"// pipeline complete: stop search",
"stop",
"(",
")",
";",
"}"
] |
Executes all local searches in the pipeline, where the best solution of the previous search is used as initial
solution for the next search. When the entire pipeline has been executed, the search step is complete and the
search terminates.
|
[
"Executes",
"all",
"local",
"searches",
"in",
"the",
"pipeline",
"where",
"the",
"best",
"solution",
"of",
"the",
"previous",
"search",
"is",
"used",
"as",
"initial",
"solution",
"for",
"the",
"next",
"search",
".",
"When",
"the",
"entire",
"pipeline",
"has",
"been",
"executed",
"the",
"search",
"step",
"is",
"complete",
"and",
"the",
"search",
"terminates",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/algo/PipedLocalSearch.java#L161-L185
|
11,489
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/types/IccProfile.java
|
IccProfile.readVersion
|
private void readVersion(TagValue tv) {
int maj = tv.getBytesBigEndian(8, 1); // Major version
int min = (tv.getBytesBigEndian(9, 1) & 0xF0) >> 4; // Minor version (in the first 4 bits of the
// byte)
version = maj + "." + min;
}
|
java
|
private void readVersion(TagValue tv) {
int maj = tv.getBytesBigEndian(8, 1); // Major version
int min = (tv.getBytesBigEndian(9, 1) & 0xF0) >> 4; // Minor version (in the first 4 bits of the
// byte)
version = maj + "." + min;
}
|
[
"private",
"void",
"readVersion",
"(",
"TagValue",
"tv",
")",
"{",
"int",
"maj",
"=",
"tv",
".",
"getBytesBigEndian",
"(",
"8",
",",
"1",
")",
";",
"// Major version",
"int",
"min",
"=",
"(",
"tv",
".",
"getBytesBigEndian",
"(",
"9",
",",
"1",
")",
"&",
"0xF0",
")",
">>",
"4",
";",
"// Minor version (in the first 4 bits of the",
"// byte)",
"version",
"=",
"maj",
"+",
"\".\"",
"+",
"min",
";",
"}"
] |
Read version.
@param tv the tv
|
[
"Read",
"version",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/types/IccProfile.java#L125-L130
|
11,490
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/types/IccProfile.java
|
IccProfile.readClass
|
private void readClass(TagValue tv) {
int profileClass = tv.getBytesBigEndian(12, 4);
String hex = Integer.toHexString(profileClass);
if (hex.equals("73636e72")) {
this.profileClass = ProfileClass.Input;
} else if (hex.equals("6d6e7472")) {
this.profileClass = ProfileClass.Display;
} else if (hex.equals("70727472")) {
this.profileClass = ProfileClass.Output;
} else if (hex.equals("6C696e6b")) {
this.profileClass = ProfileClass.DeviceLink;
} else if (hex.equals("73706163")) {
this.profileClass = ProfileClass.ColorSpace;
} else if (hex.equals("61627374")) {
this.profileClass = ProfileClass.Abstract;
} else if (hex.equals("6e6d636c")) {
this.profileClass = ProfileClass.NamedColor;
} else {
this.profileClass = ProfileClass.Unknown;
}
}
|
java
|
private void readClass(TagValue tv) {
int profileClass = tv.getBytesBigEndian(12, 4);
String hex = Integer.toHexString(profileClass);
if (hex.equals("73636e72")) {
this.profileClass = ProfileClass.Input;
} else if (hex.equals("6d6e7472")) {
this.profileClass = ProfileClass.Display;
} else if (hex.equals("70727472")) {
this.profileClass = ProfileClass.Output;
} else if (hex.equals("6C696e6b")) {
this.profileClass = ProfileClass.DeviceLink;
} else if (hex.equals("73706163")) {
this.profileClass = ProfileClass.ColorSpace;
} else if (hex.equals("61627374")) {
this.profileClass = ProfileClass.Abstract;
} else if (hex.equals("6e6d636c")) {
this.profileClass = ProfileClass.NamedColor;
} else {
this.profileClass = ProfileClass.Unknown;
}
}
|
[
"private",
"void",
"readClass",
"(",
"TagValue",
"tv",
")",
"{",
"int",
"profileClass",
"=",
"tv",
".",
"getBytesBigEndian",
"(",
"12",
",",
"4",
")",
";",
"String",
"hex",
"=",
"Integer",
".",
"toHexString",
"(",
"profileClass",
")",
";",
"if",
"(",
"hex",
".",
"equals",
"(",
"\"73636e72\"",
")",
")",
"{",
"this",
".",
"profileClass",
"=",
"ProfileClass",
".",
"Input",
";",
"}",
"else",
"if",
"(",
"hex",
".",
"equals",
"(",
"\"6d6e7472\"",
")",
")",
"{",
"this",
".",
"profileClass",
"=",
"ProfileClass",
".",
"Display",
";",
"}",
"else",
"if",
"(",
"hex",
".",
"equals",
"(",
"\"70727472\"",
")",
")",
"{",
"this",
".",
"profileClass",
"=",
"ProfileClass",
".",
"Output",
";",
"}",
"else",
"if",
"(",
"hex",
".",
"equals",
"(",
"\"6C696e6b\"",
")",
")",
"{",
"this",
".",
"profileClass",
"=",
"ProfileClass",
".",
"DeviceLink",
";",
"}",
"else",
"if",
"(",
"hex",
".",
"equals",
"(",
"\"73706163\"",
")",
")",
"{",
"this",
".",
"profileClass",
"=",
"ProfileClass",
".",
"ColorSpace",
";",
"}",
"else",
"if",
"(",
"hex",
".",
"equals",
"(",
"\"61627374\"",
")",
")",
"{",
"this",
".",
"profileClass",
"=",
"ProfileClass",
".",
"Abstract",
";",
"}",
"else",
"if",
"(",
"hex",
".",
"equals",
"(",
"\"6e6d636c\"",
")",
")",
"{",
"this",
".",
"profileClass",
"=",
"ProfileClass",
".",
"NamedColor",
";",
"}",
"else",
"{",
"this",
".",
"profileClass",
"=",
"ProfileClass",
".",
"Unknown",
";",
"}",
"}"
] |
Read class.
@param tv the tv
|
[
"Read",
"class",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/types/IccProfile.java#L148-L168
|
11,491
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/types/IccProfile.java
|
IccProfile.readCreator
|
private void readCreator(TagValue tv) {
int creatorSignature = tv.getBytesBigEndian(4, 4);
creator = IccProfileCreators.getIccProfile(creatorSignature);
}
|
java
|
private void readCreator(TagValue tv) {
int creatorSignature = tv.getBytesBigEndian(4, 4);
creator = IccProfileCreators.getIccProfile(creatorSignature);
}
|
[
"private",
"void",
"readCreator",
"(",
"TagValue",
"tv",
")",
"{",
"int",
"creatorSignature",
"=",
"tv",
".",
"getBytesBigEndian",
"(",
"4",
",",
"4",
")",
";",
"creator",
"=",
"IccProfileCreators",
".",
"getIccProfile",
"(",
"creatorSignature",
")",
";",
"}"
] |
Read creator.
@param tv the tv
|
[
"Read",
"creator",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/types/IccProfile.java#L179-L182
|
11,492
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/types/IccProfile.java
|
IccProfile.readDescription
|
private void readDescription(TagValue tv) throws NumberFormatException, IOException {
int index = 128;
int tagCount = tv.getBytesBigEndian(index, 4);
index += 4;
for (int i = 0; i < tagCount; i++) {
int signature = tv.getBytesBigEndian(index, 4);
int tagOffset = tv.getBytesBigEndian(index + 4, 4);
if (Integer.toHexString(signature).equals("64657363")) {
String typedesc = Integer.toHexString(tv.getBytesBigEndian(tagOffset, 4));
if (typedesc.equals("64657363")) {
int size = tv.getBytesBigEndian(tagOffset + 8, 4) - 1;
String s = "";
int j = 0;
int begin = tagOffset + 12;
while (begin + j < begin + size) {
int unicode_char = tv.getBytesBigEndian(begin + j, 1);
s += Character.toString((char) unicode_char);
j++;
}
description = s;
} else {
description = "";
}
}
index += 12;
}
}
|
java
|
private void readDescription(TagValue tv) throws NumberFormatException, IOException {
int index = 128;
int tagCount = tv.getBytesBigEndian(index, 4);
index += 4;
for (int i = 0; i < tagCount; i++) {
int signature = tv.getBytesBigEndian(index, 4);
int tagOffset = tv.getBytesBigEndian(index + 4, 4);
if (Integer.toHexString(signature).equals("64657363")) {
String typedesc = Integer.toHexString(tv.getBytesBigEndian(tagOffset, 4));
if (typedesc.equals("64657363")) {
int size = tv.getBytesBigEndian(tagOffset + 8, 4) - 1;
String s = "";
int j = 0;
int begin = tagOffset + 12;
while (begin + j < begin + size) {
int unicode_char = tv.getBytesBigEndian(begin + j, 1);
s += Character.toString((char) unicode_char);
j++;
}
description = s;
} else {
description = "";
}
}
index += 12;
}
}
|
[
"private",
"void",
"readDescription",
"(",
"TagValue",
"tv",
")",
"throws",
"NumberFormatException",
",",
"IOException",
"{",
"int",
"index",
"=",
"128",
";",
"int",
"tagCount",
"=",
"tv",
".",
"getBytesBigEndian",
"(",
"index",
",",
"4",
")",
";",
"index",
"+=",
"4",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tagCount",
";",
"i",
"++",
")",
"{",
"int",
"signature",
"=",
"tv",
".",
"getBytesBigEndian",
"(",
"index",
",",
"4",
")",
";",
"int",
"tagOffset",
"=",
"tv",
".",
"getBytesBigEndian",
"(",
"index",
"+",
"4",
",",
"4",
")",
";",
"if",
"(",
"Integer",
".",
"toHexString",
"(",
"signature",
")",
".",
"equals",
"(",
"\"64657363\"",
")",
")",
"{",
"String",
"typedesc",
"=",
"Integer",
".",
"toHexString",
"(",
"tv",
".",
"getBytesBigEndian",
"(",
"tagOffset",
",",
"4",
")",
")",
";",
"if",
"(",
"typedesc",
".",
"equals",
"(",
"\"64657363\"",
")",
")",
"{",
"int",
"size",
"=",
"tv",
".",
"getBytesBigEndian",
"(",
"tagOffset",
"+",
"8",
",",
"4",
")",
"-",
"1",
";",
"String",
"s",
"=",
"\"\"",
";",
"int",
"j",
"=",
"0",
";",
"int",
"begin",
"=",
"tagOffset",
"+",
"12",
";",
"while",
"(",
"begin",
"+",
"j",
"<",
"begin",
"+",
"size",
")",
"{",
"int",
"unicode_char",
"=",
"tv",
".",
"getBytesBigEndian",
"(",
"begin",
"+",
"j",
",",
"1",
")",
";",
"s",
"+=",
"Character",
".",
"toString",
"(",
"(",
"char",
")",
"unicode_char",
")",
";",
"j",
"++",
";",
"}",
"description",
"=",
"s",
";",
"}",
"else",
"{",
"description",
"=",
"\"\"",
";",
"}",
"}",
"index",
"+=",
"12",
";",
"}",
"}"
] |
Read description.
@param tv the tag value
@throws IOException exception
@throws NumberFormatException exception
|
[
"Read",
"description",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/types/IccProfile.java#L191-L217
|
11,493
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/types/IccProfile.java
|
IccProfile.read
|
@Override
public void read(TagValue tv) {
readClass(tv);
readVersion(tv);
readCreator(tv);
readEmbedded(tv);
try {
readDescription(tv);
} catch (NumberFormatException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
tv.clear();
tv.add(this);
}
|
java
|
@Override
public void read(TagValue tv) {
readClass(tv);
readVersion(tv);
readCreator(tv);
readEmbedded(tv);
try {
readDescription(tv);
} catch (NumberFormatException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
tv.clear();
tv.add(this);
}
|
[
"@",
"Override",
"public",
"void",
"read",
"(",
"TagValue",
"tv",
")",
"{",
"readClass",
"(",
"tv",
")",
";",
"readVersion",
"(",
"tv",
")",
";",
"readCreator",
"(",
"tv",
")",
";",
"readEmbedded",
"(",
"tv",
")",
";",
"try",
"{",
"readDescription",
"(",
"tv",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"|",
"IOException",
"e",
")",
"{",
"// TODO Auto-generated catch block",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"tv",
".",
"clear",
"(",
")",
";",
"tv",
".",
"add",
"(",
"this",
")",
";",
"}"
] |
Reads the desired values of the ICCProfile.
@param tv the TagValue containing the array of bytes of the ICCProfile
|
[
"Reads",
"the",
"desired",
"values",
"of",
"the",
"ICCProfile",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/types/IccProfile.java#L224-L239
|
11,494
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/fileio/filetypes/mzxml/jaxb/MsRun.java
|
MsRun.getParentFile
|
public List<MsRun.ParentFile> getParentFile() {
if (parentFile == null) {
parentFile = new ArrayList<MsRun.ParentFile>();
}
return this.parentFile;
}
|
java
|
public List<MsRun.ParentFile> getParentFile() {
if (parentFile == null) {
parentFile = new ArrayList<MsRun.ParentFile>();
}
return this.parentFile;
}
|
[
"public",
"List",
"<",
"MsRun",
".",
"ParentFile",
">",
"getParentFile",
"(",
")",
"{",
"if",
"(",
"parentFile",
"==",
"null",
")",
"{",
"parentFile",
"=",
"new",
"ArrayList",
"<",
"MsRun",
".",
"ParentFile",
">",
"(",
")",
";",
"}",
"return",
"this",
".",
"parentFile",
";",
"}"
] |
Gets the value of the parentFile property.
<p>
This accessor method returns a reference to the live list, not a snapshot. Therefore any
modification you make to the returned list will be present inside the JAXB object. This is why
there is not a <CODE>set</CODE> method for the parentFile property.
<p>
For example, to add a new item, do as follows:
<pre>
getParentFile().add(newItem);
</pre>
<p>
Objects of the following type(s) are allowed in the list {@link MsRun.ParentFile }
|
[
"Gets",
"the",
"value",
"of",
"the",
"parentFile",
"property",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/fileio/filetypes/mzxml/jaxb/MsRun.java#L276-L281
|
11,495
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/fileio/filetypes/mzxml/jaxb/MsRun.java
|
MsRun.getMsInstrument
|
public List<MsRun.MsInstrument> getMsInstrument() {
if (msInstrument == null) {
msInstrument = new ArrayList<MsRun.MsInstrument>();
}
return this.msInstrument;
}
|
java
|
public List<MsRun.MsInstrument> getMsInstrument() {
if (msInstrument == null) {
msInstrument = new ArrayList<MsRun.MsInstrument>();
}
return this.msInstrument;
}
|
[
"public",
"List",
"<",
"MsRun",
".",
"MsInstrument",
">",
"getMsInstrument",
"(",
")",
"{",
"if",
"(",
"msInstrument",
"==",
"null",
")",
"{",
"msInstrument",
"=",
"new",
"ArrayList",
"<",
"MsRun",
".",
"MsInstrument",
">",
"(",
")",
";",
"}",
"return",
"this",
".",
"msInstrument",
";",
"}"
] |
Gets the value of the msInstrument property.
<p>
This accessor method returns a reference to the live list, not a snapshot. Therefore any
modification you make to the returned list will be present inside the JAXB object. This is why
there is not a <CODE>set</CODE> method for the msInstrument property.
<p>
For example, to add a new item, do as follows:
<pre>
getMsInstrument().add(newItem);
</pre>
<p>
Objects of the following type(s) are allowed in the list {@link MsRun.MsInstrument }
|
[
"Gets",
"the",
"value",
"of",
"the",
"msInstrument",
"property",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/fileio/filetypes/mzxml/jaxb/MsRun.java#L301-L306
|
11,496
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/fileio/filetypes/mzxml/jaxb/MsRun.java
|
MsRun.getDataProcessing
|
public List<MsRun.DataProcessing> getDataProcessing() {
if (dataProcessing == null) {
dataProcessing = new ArrayList<MsRun.DataProcessing>();
}
return this.dataProcessing;
}
|
java
|
public List<MsRun.DataProcessing> getDataProcessing() {
if (dataProcessing == null) {
dataProcessing = new ArrayList<MsRun.DataProcessing>();
}
return this.dataProcessing;
}
|
[
"public",
"List",
"<",
"MsRun",
".",
"DataProcessing",
">",
"getDataProcessing",
"(",
")",
"{",
"if",
"(",
"dataProcessing",
"==",
"null",
")",
"{",
"dataProcessing",
"=",
"new",
"ArrayList",
"<",
"MsRun",
".",
"DataProcessing",
">",
"(",
")",
";",
"}",
"return",
"this",
".",
"dataProcessing",
";",
"}"
] |
Gets the value of the dataProcessing property.
<p>
This accessor method returns a reference to the live list, not a snapshot. Therefore any
modification you make to the returned list will be present inside the JAXB object. This is why
there is not a <CODE>set</CODE> method for the dataProcessing property.
<p>
For example, to add a new item, do as follows:
<pre>
getDataProcessing().add(newItem);
</pre>
<p>
Objects of the following type(s) are allowed in the list {@link MsRun.DataProcessing }
|
[
"Gets",
"the",
"value",
"of",
"the",
"dataProcessing",
"property",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/fileio/filetypes/mzxml/jaxb/MsRun.java#L326-L331
|
11,497
|
jboss/jboss-el-api_spec
|
src/main/java/org/jboss/el/cache/FactoryFinderCache.java
|
FactoryFinderCache.addCacheEntry
|
public static void addCacheEntry(final ClassLoader classLoader, final String factoryId, final String factoryClassName) {
if (factoryClassName == null) {
CLASS_CACHE.put(new CacheKey(classLoader, factoryId), "");
} else {
CLASS_CACHE.put(new CacheKey(classLoader, factoryId), factoryClassName);
}
}
|
java
|
public static void addCacheEntry(final ClassLoader classLoader, final String factoryId, final String factoryClassName) {
if (factoryClassName == null) {
CLASS_CACHE.put(new CacheKey(classLoader, factoryId), "");
} else {
CLASS_CACHE.put(new CacheKey(classLoader, factoryId), factoryClassName);
}
}
|
[
"public",
"static",
"void",
"addCacheEntry",
"(",
"final",
"ClassLoader",
"classLoader",
",",
"final",
"String",
"factoryId",
",",
"final",
"String",
"factoryClassName",
")",
"{",
"if",
"(",
"factoryClassName",
"==",
"null",
")",
"{",
"CLASS_CACHE",
".",
"put",
"(",
"new",
"CacheKey",
"(",
"classLoader",
",",
"factoryId",
")",
",",
"\"\"",
")",
";",
"}",
"else",
"{",
"CLASS_CACHE",
".",
"put",
"(",
"new",
"CacheKey",
"(",
"classLoader",
",",
"factoryId",
")",
",",
"factoryClassName",
")",
";",
"}",
"}"
] |
Called by the container at deployment time to set the name of a given factory, to remove the need for the
implementation to look it up on every call.
@param classLoader The deployments class loader
@param factoryId The type of factory that is being recorded (at this stage only javax.el.ExpressionFactory has any effect
@param factoryClassName The name of the factory class that is present in the deployment, or null if none is present
|
[
"Called",
"by",
"the",
"container",
"at",
"deployment",
"time",
"to",
"set",
"the",
"name",
"of",
"a",
"given",
"factory",
"to",
"remove",
"the",
"need",
"for",
"the",
"implementation",
"to",
"look",
"it",
"up",
"on",
"every",
"call",
"."
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/org/jboss/el/cache/FactoryFinderCache.java#L47-L53
|
11,498
|
jboss/jboss-el-api_spec
|
src/main/java/org/jboss/el/cache/FactoryFinderCache.java
|
FactoryFinderCache.clearClassLoader
|
public static void clearClassLoader(final ClassLoader classLoader) {
BeanPropertiesCache.clear(classLoader);
final Iterator<Map.Entry<CacheKey, String>> it = CLASS_CACHE.entrySet().iterator();
while (it.hasNext()) {
final CacheKey key = it.next().getKey();
if (key.loader == classLoader) {
it.remove();
}
}
}
|
java
|
public static void clearClassLoader(final ClassLoader classLoader) {
BeanPropertiesCache.clear(classLoader);
final Iterator<Map.Entry<CacheKey, String>> it = CLASS_CACHE.entrySet().iterator();
while (it.hasNext()) {
final CacheKey key = it.next().getKey();
if (key.loader == classLoader) {
it.remove();
}
}
}
|
[
"public",
"static",
"void",
"clearClassLoader",
"(",
"final",
"ClassLoader",
"classLoader",
")",
"{",
"BeanPropertiesCache",
".",
"clear",
"(",
"classLoader",
")",
";",
"final",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"CacheKey",
",",
"String",
">",
">",
"it",
"=",
"CLASS_CACHE",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"final",
"CacheKey",
"key",
"=",
"it",
".",
"next",
"(",
")",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"key",
".",
"loader",
"==",
"classLoader",
")",
"{",
"it",
".",
"remove",
"(",
")",
";",
"}",
"}",
"}"
] |
This should be called by the container on undeploy to remove all references to the given class loader
from the cache.
@param classLoader The class loader to remove
|
[
"This",
"should",
"be",
"called",
"by",
"the",
"container",
"on",
"undeploy",
"to",
"remove",
"all",
"references",
"to",
"the",
"given",
"class",
"loader",
"from",
"the",
"cache",
"."
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/org/jboss/el/cache/FactoryFinderCache.java#L61-L70
|
11,499
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/Tag.java
|
Tag.createValuesDictionary
|
public void createValuesDictionary() {
tagValueDescriptions = new HashMap<String, String>();
if (valueCodes != null && valueDescriptions != null && valueCodes.size() > 0
&& valueCodes.size() == valueDescriptions.size()) {
for (int i = 0; i < valueCodes.size(); i++) {
tagValueDescriptions.put(valueCodes.get(i) + "", valueDescriptions.get(i));
}
}
}
|
java
|
public void createValuesDictionary() {
tagValueDescriptions = new HashMap<String, String>();
if (valueCodes != null && valueDescriptions != null && valueCodes.size() > 0
&& valueCodes.size() == valueDescriptions.size()) {
for (int i = 0; i < valueCodes.size(); i++) {
tagValueDescriptions.put(valueCodes.get(i) + "", valueDescriptions.get(i));
}
}
}
|
[
"public",
"void",
"createValuesDictionary",
"(",
")",
"{",
"tagValueDescriptions",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"valueCodes",
"!=",
"null",
"&&",
"valueDescriptions",
"!=",
"null",
"&&",
"valueCodes",
".",
"size",
"(",
")",
">",
"0",
"&&",
"valueCodes",
".",
"size",
"(",
")",
"==",
"valueDescriptions",
".",
"size",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCodes",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"tagValueDescriptions",
".",
"put",
"(",
"valueCodes",
".",
"get",
"(",
"i",
")",
"+",
"\"\"",
",",
"valueDescriptions",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"}",
"}"
] |
Creates the values dictionary.
|
[
"Creates",
"the",
"values",
"dictionary",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/Tag.java#L110-L118
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.