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,500
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/Tag.java
|
Tag.getTextDescription
|
public String getTextDescription(String encodedValue) {
if (forceDescription != null) {
return forceDescription;
}
String desc = null;
if (tagValueDescriptions.containsKey(encodedValue)) {
desc = tagValueDescriptions.get(encodedValue);
}
return desc;
}
|
java
|
public String getTextDescription(String encodedValue) {
if (forceDescription != null) {
return forceDescription;
}
String desc = null;
if (tagValueDescriptions.containsKey(encodedValue)) {
desc = tagValueDescriptions.get(encodedValue);
}
return desc;
}
|
[
"public",
"String",
"getTextDescription",
"(",
"String",
"encodedValue",
")",
"{",
"if",
"(",
"forceDescription",
"!=",
"null",
")",
"{",
"return",
"forceDescription",
";",
"}",
"String",
"desc",
"=",
"null",
";",
"if",
"(",
"tagValueDescriptions",
".",
"containsKey",
"(",
"encodedValue",
")",
")",
"{",
"desc",
"=",
"tagValueDescriptions",
".",
"get",
"(",
"encodedValue",
")",
";",
"}",
"return",
"desc",
";",
"}"
] |
Gets the tag value description.
@param encodedValue the encoded value
@return the tag value description
|
[
"Gets",
"the",
"tag",
"value",
"description",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/Tag.java#L126-L135
|
11,501
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/profiles/TiffEPProfile.java
|
TiffEPProfile.checkForbiddenTag
|
private void checkForbiddenTag(IfdTags metadata, String tagName, String ext) {
int tagid = TiffTags.getTagId(tagName);
if (metadata.containsTagId(tagid)) {
validation.addErrorLoc("Forbidden tag for TiffEP found " + tagName, ext);
}
}
|
java
|
private void checkForbiddenTag(IfdTags metadata, String tagName, String ext) {
int tagid = TiffTags.getTagId(tagName);
if (metadata.containsTagId(tagid)) {
validation.addErrorLoc("Forbidden tag for TiffEP found " + tagName, ext);
}
}
|
[
"private",
"void",
"checkForbiddenTag",
"(",
"IfdTags",
"metadata",
",",
"String",
"tagName",
",",
"String",
"ext",
")",
"{",
"int",
"tagid",
"=",
"TiffTags",
".",
"getTagId",
"(",
"tagName",
")",
";",
"if",
"(",
"metadata",
".",
"containsTagId",
"(",
"tagid",
")",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Forbidden tag for TiffEP found \"",
"+",
"tagName",
",",
"ext",
")",
";",
"}",
"}"
] |
Check a forbidden tag is not present.
@param metadata the metadata
@param tagName the tag name
@param ext string extension
|
[
"Check",
"a",
"forbidden",
"tag",
"is",
"not",
"present",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/TiffEPProfile.java#L372-L377
|
11,502
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/algo/SteepestDescent.java
|
SteepestDescent.searchStep
|
@Override
protected void searchStep() {
// get best valid move with positive delta
Move<? super SolutionType> move = getBestMove(
getNeighbourhood().getAllMoves(getCurrentSolution()), // generate all moves
true); // only improvements
// found improvement ?
if(move != null){
// accept move
accept(move);
} else {
// no improvement found
stop();
}
}
|
java
|
@Override
protected void searchStep() {
// get best valid move with positive delta
Move<? super SolutionType> move = getBestMove(
getNeighbourhood().getAllMoves(getCurrentSolution()), // generate all moves
true); // only improvements
// found improvement ?
if(move != null){
// accept move
accept(move);
} else {
// no improvement found
stop();
}
}
|
[
"@",
"Override",
"protected",
"void",
"searchStep",
"(",
")",
"{",
"// get best valid move with positive delta",
"Move",
"<",
"?",
"super",
"SolutionType",
">",
"move",
"=",
"getBestMove",
"(",
"getNeighbourhood",
"(",
")",
".",
"getAllMoves",
"(",
"getCurrentSolution",
"(",
")",
")",
",",
"// generate all moves",
"true",
")",
";",
"// only improvements",
"// found improvement ?",
"if",
"(",
"move",
"!=",
"null",
")",
"{",
"// accept move",
"accept",
"(",
"move",
")",
";",
"}",
"else",
"{",
"// no improvement found",
"stop",
"(",
")",
";",
"}",
"}"
] |
Investigates all neighbours of the current solution and adopts the best one as the new current solution,
if it is an improvement. If no improvement is found, the search is requested to stop and no further steps
will be performed.
@throws JamesRuntimeException if depending on malfunctioning components (problem, neighbourhood, ...)
|
[
"Investigates",
"all",
"neighbours",
"of",
"the",
"current",
"solution",
"and",
"adopts",
"the",
"best",
"one",
"as",
"the",
"new",
"current",
"solution",
"if",
"it",
"is",
"an",
"improvement",
".",
"If",
"no",
"improvement",
"is",
"found",
"the",
"search",
"is",
"requested",
"to",
"stop",
"and",
"no",
"further",
"steps",
"will",
"be",
"performed",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/algo/SteepestDescent.java#L71-L85
|
11,503
|
jboss/jboss-el-api_spec
|
src/main/java/javax/el/ELManager.java
|
ELManager.setELContext
|
public ELContext setELContext(ELContext context) {
ELContext prev = elContext;
elContext = new StandardELContext(context);
return prev;
}
|
java
|
public ELContext setELContext(ELContext context) {
ELContext prev = elContext;
elContext = new StandardELContext(context);
return prev;
}
|
[
"public",
"ELContext",
"setELContext",
"(",
"ELContext",
"context",
")",
"{",
"ELContext",
"prev",
"=",
"elContext",
";",
"elContext",
"=",
"new",
"StandardELContext",
"(",
"context",
")",
";",
"return",
"prev",
";",
"}"
] |
Set the ELContext used for parsing and evaluating EL expressions.
The supplied ELContext will not be modified, except for the context
object map.
@param context The new ELContext.
@return The previous ELContext, null if none.
|
[
"Set",
"the",
"ELContext",
"used",
"for",
"parsing",
"and",
"evaluating",
"EL",
"expressions",
".",
"The",
"supplied",
"ELContext",
"will",
"not",
"be",
"modified",
"except",
"for",
"the",
"context",
"object",
"map",
"."
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELManager.java#L85-L89
|
11,504
|
jboss/jboss-el-api_spec
|
src/main/java/javax/el/ELManager.java
|
ELManager.mapFunction
|
public void mapFunction(String prefix, String function, Method meth) {
getELContext().getFunctionMapper().mapFunction(prefix, function, meth);
}
|
java
|
public void mapFunction(String prefix, String function, Method meth) {
getELContext().getFunctionMapper().mapFunction(prefix, function, meth);
}
|
[
"public",
"void",
"mapFunction",
"(",
"String",
"prefix",
",",
"String",
"function",
",",
"Method",
"meth",
")",
"{",
"getELContext",
"(",
")",
".",
"getFunctionMapper",
"(",
")",
".",
"mapFunction",
"(",
"prefix",
",",
"function",
",",
"meth",
")",
";",
"}"
] |
Maps a static method to an EL function.
@param prefix The namespace of the functions, can be "".
@param function The name of the function.
@param meth The static method to be invoked when the function is used.
|
[
"Maps",
"a",
"static",
"method",
"to",
"an",
"EL",
"function",
"."
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELManager.java#L122-L124
|
11,505
|
jboss/jboss-el-api_spec
|
src/main/java/javax/el/ELManager.java
|
ELManager.defineBean
|
public Object defineBean(String name, Object bean) {
Object ret = getELContext().getBeans().get(name);
getELContext().getBeans().put(name, bean);
return ret;
}
|
java
|
public Object defineBean(String name, Object bean) {
Object ret = getELContext().getBeans().get(name);
getELContext().getBeans().put(name, bean);
return ret;
}
|
[
"public",
"Object",
"defineBean",
"(",
"String",
"name",
",",
"Object",
"bean",
")",
"{",
"Object",
"ret",
"=",
"getELContext",
"(",
")",
".",
"getBeans",
"(",
")",
".",
"get",
"(",
"name",
")",
";",
"getELContext",
"(",
")",
".",
"getBeans",
"(",
")",
".",
"put",
"(",
"name",
",",
"bean",
")",
";",
"return",
"ret",
";",
"}"
] |
Define a bean in the local bean repository
@param name The name of the bean
@param bean The bean instance to be defined. If null, the definition
of the bean is removed.
|
[
"Define",
"a",
"bean",
"in",
"the",
"local",
"bean",
"repository"
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELManager.java#L177-L181
|
11,506
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/subset/SubsetProblem.java
|
SubsetProblem.validate
|
@Override
public SubsetValidation validate(SubsetSolution solution){
// check size
boolean validSize = solution.getNumSelectedIDs() >= getMinSubsetSize()
&& solution.getNumSelectedIDs() <= getMaxSubsetSize();
// combine with mandatory constraint validation
if(getMandatoryConstraints().isEmpty()){
// CASE 1: no mandatory constraints -- return constant validation object
return validSize ? UNCONSTRAINED_VALID_SIZE : UNCONSTRAINED_INVALID_SIZE;
} else {
// CASE 2: mandatory constraint(s) -- wrap constraints validation in subset validation
Validation constraintVal = super.validate(solution);
return new SubsetValidation(validSize, constraintVal);
}
}
|
java
|
@Override
public SubsetValidation validate(SubsetSolution solution){
// check size
boolean validSize = solution.getNumSelectedIDs() >= getMinSubsetSize()
&& solution.getNumSelectedIDs() <= getMaxSubsetSize();
// combine with mandatory constraint validation
if(getMandatoryConstraints().isEmpty()){
// CASE 1: no mandatory constraints -- return constant validation object
return validSize ? UNCONSTRAINED_VALID_SIZE : UNCONSTRAINED_INVALID_SIZE;
} else {
// CASE 2: mandatory constraint(s) -- wrap constraints validation in subset validation
Validation constraintVal = super.validate(solution);
return new SubsetValidation(validSize, constraintVal);
}
}
|
[
"@",
"Override",
"public",
"SubsetValidation",
"validate",
"(",
"SubsetSolution",
"solution",
")",
"{",
"// check size",
"boolean",
"validSize",
"=",
"solution",
".",
"getNumSelectedIDs",
"(",
")",
">=",
"getMinSubsetSize",
"(",
")",
"&&",
"solution",
".",
"getNumSelectedIDs",
"(",
")",
"<=",
"getMaxSubsetSize",
"(",
")",
";",
"// combine with mandatory constraint validation",
"if",
"(",
"getMandatoryConstraints",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"// CASE 1: no mandatory constraints -- return constant validation object",
"return",
"validSize",
"?",
"UNCONSTRAINED_VALID_SIZE",
":",
"UNCONSTRAINED_INVALID_SIZE",
";",
"}",
"else",
"{",
"// CASE 2: mandatory constraint(s) -- wrap constraints validation in subset validation",
"Validation",
"constraintVal",
"=",
"super",
".",
"validate",
"(",
"solution",
")",
";",
"return",
"new",
"SubsetValidation",
"(",
"validSize",
",",
"constraintVal",
")",
";",
"}",
"}"
] |
Validate a subset solution. The returned validation object separately indicates whether
the solution passed general mandatory constraint validation and whether it has a valid size.
@param solution solution to validate
@return subset validation
|
[
"Validate",
"a",
"subset",
"solution",
".",
"The",
"returned",
"validation",
"object",
"separately",
"indicates",
"whether",
"the",
"solution",
"passed",
"general",
"mandatory",
"constraint",
"validation",
"and",
"whether",
"it",
"has",
"a",
"valid",
"size",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/SubsetProblem.java#L235-L249
|
11,507
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/subset/SubsetProblem.java
|
SubsetProblem.setMaxSubsetSize
|
public void setMaxSubsetSize(int maxSubsetSize) {
// check size
if(maxSubsetSize < minSubsetSize){
throw new IllegalArgumentException("Error while setting maximum subset size: should be >= minimum subset size.");
}
if(maxSubsetSize > getData().getIDs().size()){
throw new IllegalArgumentException("Error while setting maximum subset size: can not be larger "
+ "than number of items in underlying data.");
}
this.maxSubsetSize = maxSubsetSize;
}
|
java
|
public void setMaxSubsetSize(int maxSubsetSize) {
// check size
if(maxSubsetSize < minSubsetSize){
throw new IllegalArgumentException("Error while setting maximum subset size: should be >= minimum subset size.");
}
if(maxSubsetSize > getData().getIDs().size()){
throw new IllegalArgumentException("Error while setting maximum subset size: can not be larger "
+ "than number of items in underlying data.");
}
this.maxSubsetSize = maxSubsetSize;
}
|
[
"public",
"void",
"setMaxSubsetSize",
"(",
"int",
"maxSubsetSize",
")",
"{",
"// check size",
"if",
"(",
"maxSubsetSize",
"<",
"minSubsetSize",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Error while setting maximum subset size: should be >= minimum subset size.\"",
")",
";",
"}",
"if",
"(",
"maxSubsetSize",
">",
"getData",
"(",
")",
".",
"getIDs",
"(",
")",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Error while setting maximum subset size: can not be larger \"",
"+",
"\"than number of items in underlying data.\"",
")",
";",
"}",
"this",
".",
"maxSubsetSize",
"=",
"maxSubsetSize",
";",
"}"
] |
Set the maximum subset size. Specified size should be ≥ the current minimum subset size
and ≤ the number of items in the underlying data.
@param maxSubsetSize new maximum subset size
@throws IllegalArgumentException if an invalid maximum size is given
|
[
"Set",
"the",
"maximum",
"subset",
"size",
".",
"Specified",
"size",
"should",
"be",
"&ge",
";",
"the",
"current",
"minimum",
"subset",
"size",
"and",
"&le",
";",
"the",
"number",
"of",
"items",
"in",
"the",
"underlying",
"data",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/SubsetProblem.java#L339-L349
|
11,508
|
maxirosson/jdroid-android
|
jdroid-android-core/src/main/java/com/jdroid/android/view/BadgeView.java
|
BadgeView.setNotifications
|
@SuppressLint("SetTextI18n")
public void setNotifications(Integer notifications) {
if ((notifications != null) && (notifications > 0)) {
setVisibility(VISIBLE);
if (notifications > maximum) {
this.setText(maximum + "+");
} else {
this.setText(notifications.toString());
}
} else {
setVisibility(GONE);
}
}
|
java
|
@SuppressLint("SetTextI18n")
public void setNotifications(Integer notifications) {
if ((notifications != null) && (notifications > 0)) {
setVisibility(VISIBLE);
if (notifications > maximum) {
this.setText(maximum + "+");
} else {
this.setText(notifications.toString());
}
} else {
setVisibility(GONE);
}
}
|
[
"@",
"SuppressLint",
"(",
"\"SetTextI18n\"",
")",
"public",
"void",
"setNotifications",
"(",
"Integer",
"notifications",
")",
"{",
"if",
"(",
"(",
"notifications",
"!=",
"null",
")",
"&&",
"(",
"notifications",
">",
"0",
")",
")",
"{",
"setVisibility",
"(",
"VISIBLE",
")",
";",
"if",
"(",
"notifications",
">",
"maximum",
")",
"{",
"this",
".",
"setText",
"(",
"maximum",
"+",
"\"+\"",
")",
";",
"}",
"else",
"{",
"this",
".",
"setText",
"(",
"notifications",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"setVisibility",
"(",
"GONE",
")",
";",
"}",
"}"
] |
Sets a notification number in the badge.
@param notifications
|
[
"Sets",
"a",
"notification",
"number",
"in",
"the",
"badge",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/view/BadgeView.java#L46-L59
|
11,509
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/algo/vns/ReducedVariableNeighbourhoodSearch.java
|
ReducedVariableNeighbourhoodSearch.nextNeighbourhood
|
private void nextNeighbourhood(){
if(cycleNeighbourhoods || k < getNeighbourhoods().size()-1){
// try again with next neighbourhood in next step
k = (k+1) % getNeighbourhoods().size();
} else {
// no next neighbourhood... stop
stop();
}
}
|
java
|
private void nextNeighbourhood(){
if(cycleNeighbourhoods || k < getNeighbourhoods().size()-1){
// try again with next neighbourhood in next step
k = (k+1) % getNeighbourhoods().size();
} else {
// no next neighbourhood... stop
stop();
}
}
|
[
"private",
"void",
"nextNeighbourhood",
"(",
")",
"{",
"if",
"(",
"cycleNeighbourhoods",
"||",
"k",
"<",
"getNeighbourhoods",
"(",
")",
".",
"size",
"(",
")",
"-",
"1",
")",
"{",
"// try again with next neighbourhood in next step",
"k",
"=",
"(",
"k",
"+",
"1",
")",
"%",
"getNeighbourhoods",
"(",
")",
".",
"size",
"(",
")",
";",
"}",
"else",
"{",
"// no next neighbourhood... stop",
"stop",
"(",
")",
";",
"}",
"}"
] |
Switches to the next neighbourhood in the list, if any,
going back to the start if cycling is enabled and all
neighbourhoods have been used.
|
[
"Switches",
"to",
"the",
"next",
"neighbourhood",
"in",
"the",
"list",
"if",
"any",
"going",
"back",
"to",
"the",
"start",
"if",
"cycling",
"is",
"enabled",
"and",
"all",
"neighbourhoods",
"have",
"been",
"used",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/algo/vns/ReducedVariableNeighbourhoodSearch.java#L169-L177
|
11,510
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/fileio/filetypes/mzidentml/MzIdentMLParser.java
|
MzIdentMLParser.parse
|
public static umich.ms.fileio.filetypes.mzidentml.jaxb.standard.MzIdentMLType parse(Path path)
throws FileParsingException {
try {
XMLStreamReader xsr = JaxbUtils.createXmlStreamReader(path, false);
umich.ms.fileio.filetypes.mzidentml.jaxb.standard.MzIdentMLType mzIdentMLType = JaxbUtils
.unmarshal(umich.ms.fileio.filetypes.mzidentml.jaxb.standard.MzIdentMLType.class, xsr);
return mzIdentMLType;
} catch (JAXBException e) {
throw new FileParsingException(
String.format("JAXB parsing of MzIdentML file failed (%s)",
path.toAbsolutePath().toString()), e);
}
}
|
java
|
public static umich.ms.fileio.filetypes.mzidentml.jaxb.standard.MzIdentMLType parse(Path path)
throws FileParsingException {
try {
XMLStreamReader xsr = JaxbUtils.createXmlStreamReader(path, false);
umich.ms.fileio.filetypes.mzidentml.jaxb.standard.MzIdentMLType mzIdentMLType = JaxbUtils
.unmarshal(umich.ms.fileio.filetypes.mzidentml.jaxb.standard.MzIdentMLType.class, xsr);
return mzIdentMLType;
} catch (JAXBException e) {
throw new FileParsingException(
String.format("JAXB parsing of MzIdentML file failed (%s)",
path.toAbsolutePath().toString()), e);
}
}
|
[
"public",
"static",
"umich",
".",
"ms",
".",
"fileio",
".",
"filetypes",
".",
"mzidentml",
".",
"jaxb",
".",
"standard",
".",
"MzIdentMLType",
"parse",
"(",
"Path",
"path",
")",
"throws",
"FileParsingException",
"{",
"try",
"{",
"XMLStreamReader",
"xsr",
"=",
"JaxbUtils",
".",
"createXmlStreamReader",
"(",
"path",
",",
"false",
")",
";",
"umich",
".",
"ms",
".",
"fileio",
".",
"filetypes",
".",
"mzidentml",
".",
"jaxb",
".",
"standard",
".",
"MzIdentMLType",
"mzIdentMLType",
"=",
"JaxbUtils",
".",
"unmarshal",
"(",
"umich",
".",
"ms",
".",
"fileio",
".",
"filetypes",
".",
"mzidentml",
".",
"jaxb",
".",
"standard",
".",
"MzIdentMLType",
".",
"class",
",",
"xsr",
")",
";",
"return",
"mzIdentMLType",
";",
"}",
"catch",
"(",
"JAXBException",
"e",
")",
"{",
"throw",
"new",
"FileParsingException",
"(",
"String",
".",
"format",
"(",
"\"JAXB parsing of MzIdentML file failed (%s)\"",
",",
"path",
".",
"toAbsolutePath",
"(",
")",
".",
"toString",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Will parse the whole file. Might be not very efficient memory-wise.
@param path path to the file to parse
@return auto-generated representation of the file, read the MzIdentML schema for details.
|
[
"Will",
"parse",
"the",
"whole",
"file",
".",
"Might",
"be",
"not",
"very",
"efficient",
"memory",
"-",
"wise",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/fileio/filetypes/mzidentml/MzIdentMLParser.java#L38-L50
|
11,511
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/ValidationResult.java
|
ValidationResult.iaddWarning
|
private void iaddWarning(String desc, String value, String loc) {
if (!validate) return;
ValidationEvent ve = new ValidationEvent(desc, value, loc);
warnings.add(ve);
}
|
java
|
private void iaddWarning(String desc, String value, String loc) {
if (!validate) return;
ValidationEvent ve = new ValidationEvent(desc, value, loc);
warnings.add(ve);
}
|
[
"private",
"void",
"iaddWarning",
"(",
"String",
"desc",
",",
"String",
"value",
",",
"String",
"loc",
")",
"{",
"if",
"(",
"!",
"validate",
")",
"return",
";",
"ValidationEvent",
"ve",
"=",
"new",
"ValidationEvent",
"(",
"desc",
",",
"value",
",",
"loc",
")",
";",
"warnings",
".",
"add",
"(",
"ve",
")",
";",
"}"
] |
Adds a warning.
@param desc warning description
@param value the value that caused the warning
@param loc the location
|
[
"Adds",
"a",
"warning",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/ValidationResult.java#L92-L96
|
11,512
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/ValidationResult.java
|
ValidationResult.addWarning
|
public void addWarning(String desc, String value, String loc) {
iaddWarning(desc, value, loc);
}
|
java
|
public void addWarning(String desc, String value, String loc) {
iaddWarning(desc, value, loc);
}
|
[
"public",
"void",
"addWarning",
"(",
"String",
"desc",
",",
"String",
"value",
",",
"String",
"loc",
")",
"{",
"iaddWarning",
"(",
"desc",
",",
"value",
",",
"loc",
")",
";",
"}"
] |
Adds an warning.
@param desc Warning description
@param value the String that caused the warning
@param loc the location
|
[
"Adds",
"an",
"warning",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/ValidationResult.java#L161-L163
|
11,513
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/ValidationResult.java
|
ValidationResult.add
|
public void add(ValidationResult validation) {
correct &= validation.correct;
if (!validate) return;
errors.addAll(validation.errors);
warnings.addAll(validation.warnings);
}
|
java
|
public void add(ValidationResult validation) {
correct &= validation.correct;
if (!validate) return;
errors.addAll(validation.errors);
warnings.addAll(validation.warnings);
}
|
[
"public",
"void",
"add",
"(",
"ValidationResult",
"validation",
")",
"{",
"correct",
"&=",
"validation",
".",
"correct",
";",
"if",
"(",
"!",
"validate",
")",
"return",
";",
"errors",
".",
"addAll",
"(",
"validation",
".",
"errors",
")",
";",
"warnings",
".",
"addAll",
"(",
"validation",
".",
"warnings",
")",
";",
"}"
] |
Adds a validation result to this.
@param validation the validation to add
|
[
"Adds",
"a",
"validation",
"result",
"to",
"this",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/ValidationResult.java#L170-L175
|
11,514
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/util/MathHelper.java
|
MathHelper.min
|
public static double min(double... nums) {
double min = nums[0];
for (int i = 1; i < nums.length; i++) {
if (nums[i] > min) {
min = nums[i];
}
}
return min;
}
|
java
|
public static double min(double... nums) {
double min = nums[0];
for (int i = 1; i < nums.length; i++) {
if (nums[i] > min) {
min = nums[i];
}
}
return min;
}
|
[
"public",
"static",
"double",
"min",
"(",
"double",
"...",
"nums",
")",
"{",
"double",
"min",
"=",
"nums",
"[",
"0",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"nums",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"nums",
"[",
"i",
"]",
">",
"min",
")",
"{",
"min",
"=",
"nums",
"[",
"i",
"]",
";",
"}",
"}",
"return",
"min",
";",
"}"
] |
Find the minimum in an array of numbers.
|
[
"Find",
"the",
"minimum",
"in",
"an",
"array",
"of",
"numbers",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/util/MathHelper.java#L31-L39
|
11,515
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/fileio/chunk/ChunkedFile.java
|
ChunkedFile.init
|
public void init() throws IOException {
if (!Files.exists(path)) {
throw new FileNotFoundException(
"Could not find a file under path: " + path.toAbsolutePath().toString());
}
if (Files.size(path) == 0) {
throw new IllegalStateException("File size can't be zero for chunked files");
}
chunks = chunkFile();
chunksInUse = new ConcurrentSkipListMap<>();
chunksPreRead = new ConcurrentSkipListMap<>();
chunksScheduled = new ConcurrentSkipListMap<>();
nextChunkNum = new AtomicInteger(-1);
if (raf != null) {
raf.close();
}
execIo = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
execFinalize = Executors.newSingleThreadExecutor();
}
|
java
|
public void init() throws IOException {
if (!Files.exists(path)) {
throw new FileNotFoundException(
"Could not find a file under path: " + path.toAbsolutePath().toString());
}
if (Files.size(path) == 0) {
throw new IllegalStateException("File size can't be zero for chunked files");
}
chunks = chunkFile();
chunksInUse = new ConcurrentSkipListMap<>();
chunksPreRead = new ConcurrentSkipListMap<>();
chunksScheduled = new ConcurrentSkipListMap<>();
nextChunkNum = new AtomicInteger(-1);
if (raf != null) {
raf.close();
}
execIo = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
execFinalize = Executors.newSingleThreadExecutor();
}
|
[
"public",
"void",
"init",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"Files",
".",
"exists",
"(",
"path",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"\"Could not find a file under path: \"",
"+",
"path",
".",
"toAbsolutePath",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"if",
"(",
"Files",
".",
"size",
"(",
"path",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"File size can't be zero for chunked files\"",
")",
";",
"}",
"chunks",
"=",
"chunkFile",
"(",
")",
";",
"chunksInUse",
"=",
"new",
"ConcurrentSkipListMap",
"<>",
"(",
")",
";",
"chunksPreRead",
"=",
"new",
"ConcurrentSkipListMap",
"<>",
"(",
")",
";",
"chunksScheduled",
"=",
"new",
"ConcurrentSkipListMap",
"<>",
"(",
")",
";",
"nextChunkNum",
"=",
"new",
"AtomicInteger",
"(",
"-",
"1",
")",
";",
"if",
"(",
"raf",
"!=",
"null",
")",
"{",
"raf",
".",
"close",
"(",
")",
";",
"}",
"execIo",
"=",
"MoreExecutors",
".",
"listeningDecorator",
"(",
"Executors",
".",
"newSingleThreadExecutor",
"(",
")",
")",
";",
"execFinalize",
"=",
"Executors",
".",
"newSingleThreadExecutor",
"(",
")",
";",
"}"
] |
Check if the file is still valid.
|
[
"Check",
"if",
"the",
"file",
"is",
"still",
"valid",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/fileio/chunk/ChunkedFile.java#L156-L174
|
11,516
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/algo/exh/ExhaustiveSearch.java
|
ExhaustiveSearch.searchStep
|
@Override
protected void searchStep() {
// more solutions to generate ?
if(solutionIterator.hasNext()){
// generate next solution
SolutionType sol = solutionIterator.next();
// update best solution
updateBestSolution(sol);
} else {
// done
stop();
}
}
|
java
|
@Override
protected void searchStep() {
// more solutions to generate ?
if(solutionIterator.hasNext()){
// generate next solution
SolutionType sol = solutionIterator.next();
// update best solution
updateBestSolution(sol);
} else {
// done
stop();
}
}
|
[
"@",
"Override",
"protected",
"void",
"searchStep",
"(",
")",
"{",
"// more solutions to generate ?",
"if",
"(",
"solutionIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"// generate next solution",
"SolutionType",
"sol",
"=",
"solutionIterator",
".",
"next",
"(",
")",
";",
"// update best solution",
"updateBestSolution",
"(",
"sol",
")",
";",
"}",
"else",
"{",
"// done",
"stop",
"(",
")",
";",
"}",
"}"
] |
In every search step it is verified whether there are more solution to be generated using the solution iterator.
If so, the next solution is generated, evaluated, and presented for comparison with the current best solution.
Else, the search stops.
|
[
"In",
"every",
"search",
"step",
"it",
"is",
"verified",
"whether",
"there",
"are",
"more",
"solution",
"to",
"be",
"generated",
"using",
"the",
"solution",
"iterator",
".",
"If",
"so",
"the",
"next",
"solution",
"is",
"generated",
"evaluated",
"and",
"presented",
"for",
"comparison",
"with",
"the",
"current",
"best",
"solution",
".",
"Else",
"the",
"search",
"stops",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/algo/exh/ExhaustiveSearch.java#L80-L92
|
11,517
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/util/Interval1D.java
|
Interval1D.intersects
|
public boolean intersects(Interval1D<V> other) {
if (other.hi.compareTo(this.lo) < 0) {
return false;
}
if (this.hi.compareTo(other.lo) < 0) {
return false;
}
return true;
}
|
java
|
public boolean intersects(Interval1D<V> other) {
if (other.hi.compareTo(this.lo) < 0) {
return false;
}
if (this.hi.compareTo(other.lo) < 0) {
return false;
}
return true;
}
|
[
"public",
"boolean",
"intersects",
"(",
"Interval1D",
"<",
"V",
">",
"other",
")",
"{",
"if",
"(",
"other",
".",
"hi",
".",
"compareTo",
"(",
"this",
".",
"lo",
")",
"<",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"this",
".",
"hi",
".",
"compareTo",
"(",
"other",
".",
"lo",
")",
"<",
"0",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Does this interval intersect that one?
@return true, if intervals share at least one point
|
[
"Does",
"this",
"interval",
"intersect",
"that",
"one?"
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/util/Interval1D.java#L74-L83
|
11,518
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/subset/SubsetSolution.java
|
SubsetSolution.selectAll
|
public boolean selectAll(Collection<Integer> IDs) {
boolean modified = false;
for(int ID : IDs){
if(select(ID)){
modified = true;
}
}
return modified;
}
|
java
|
public boolean selectAll(Collection<Integer> IDs) {
boolean modified = false;
for(int ID : IDs){
if(select(ID)){
modified = true;
}
}
return modified;
}
|
[
"public",
"boolean",
"selectAll",
"(",
"Collection",
"<",
"Integer",
">",
"IDs",
")",
"{",
"boolean",
"modified",
"=",
"false",
";",
"for",
"(",
"int",
"ID",
":",
"IDs",
")",
"{",
"if",
"(",
"select",
"(",
"ID",
")",
")",
"{",
"modified",
"=",
"true",
";",
"}",
"}",
"return",
"modified",
";",
"}"
] |
Select all IDs contained in the given collection. Returns true if the subset solution was modified by this
operation, i.e. if at least one previously unselected ID has been selected.
@param IDs collection of IDs to be selected
@throws SolutionModificationException if the given collection contains at least one ID which does not correspond to an entity
@throws NullPointerException if <code>null</code> is passed or the given collection contains at least one <code>null</code> element
@return true if the subset solution was modified
|
[
"Select",
"all",
"IDs",
"contained",
"in",
"the",
"given",
"collection",
".",
"Returns",
"true",
"if",
"the",
"subset",
"solution",
"was",
"modified",
"by",
"this",
"operation",
"i",
".",
"e",
".",
"if",
"at",
"least",
"one",
"previously",
"unselected",
"ID",
"has",
"been",
"selected",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/SubsetSolution.java#L333-L341
|
11,519
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/subset/SubsetSolution.java
|
SubsetSolution.deselectAll
|
public boolean deselectAll(Collection<Integer> IDs) {
boolean modified = false;
for(int ID : IDs){
if(deselect(ID)){
modified = true;
}
}
return modified;
}
|
java
|
public boolean deselectAll(Collection<Integer> IDs) {
boolean modified = false;
for(int ID : IDs){
if(deselect(ID)){
modified = true;
}
}
return modified;
}
|
[
"public",
"boolean",
"deselectAll",
"(",
"Collection",
"<",
"Integer",
">",
"IDs",
")",
"{",
"boolean",
"modified",
"=",
"false",
";",
"for",
"(",
"int",
"ID",
":",
"IDs",
")",
"{",
"if",
"(",
"deselect",
"(",
"ID",
")",
")",
"{",
"modified",
"=",
"true",
";",
"}",
"}",
"return",
"modified",
";",
"}"
] |
Deselect all IDs contained in the given collection. Returns true if the subset solution was modified by this
operation, i.e. if at least one previously selected ID has been deselected.
@param IDs collection of IDs to be deselected
@throws SolutionModificationException if the given collection contains at least one ID which does not correspond to an entity
@throws NullPointerException if <code>null</code> is passed or the given collection contains at least one <code>null</code> element
@return true if the subset solution was modified
|
[
"Deselect",
"all",
"IDs",
"contained",
"in",
"the",
"given",
"collection",
".",
"Returns",
"true",
"if",
"the",
"subset",
"solution",
"was",
"modified",
"by",
"this",
"operation",
"i",
".",
"e",
".",
"if",
"at",
"least",
"one",
"previously",
"selected",
"ID",
"has",
"been",
"deselected",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/SubsetSolution.java#L352-L360
|
11,520
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/logging/LogHelper.java
|
LogHelper.setJavolutionLogLevel
|
public static final void setJavolutionLogLevel(org.slf4j.Logger log) {
// disable Javolution info-level logging
if (log.isTraceEnabled()) {
javolution.context.LogContext.enter().setLevel(LogContext.Level.DEBUG);
} else if (log.isDebugEnabled()) {
javolution.context.LogContext.enter().setLevel(LogContext.Level.DEBUG);
} else if (log.isInfoEnabled()) {
javolution.context.LogContext.enter().setLevel(LogContext.Level.INFO);
} else if (log.isWarnEnabled()) {
javolution.context.LogContext.enter().setLevel(LogContext.Level.WARNING);
} else if (log.isErrorEnabled()) {
javolution.context.LogContext.enter().setLevel(LogContext.Level.ERROR);
} else {
javolution.context.LogContext.enter().setLevel(LogContext.Level.FATAL);
}
}
|
java
|
public static final void setJavolutionLogLevel(org.slf4j.Logger log) {
// disable Javolution info-level logging
if (log.isTraceEnabled()) {
javolution.context.LogContext.enter().setLevel(LogContext.Level.DEBUG);
} else if (log.isDebugEnabled()) {
javolution.context.LogContext.enter().setLevel(LogContext.Level.DEBUG);
} else if (log.isInfoEnabled()) {
javolution.context.LogContext.enter().setLevel(LogContext.Level.INFO);
} else if (log.isWarnEnabled()) {
javolution.context.LogContext.enter().setLevel(LogContext.Level.WARNING);
} else if (log.isErrorEnabled()) {
javolution.context.LogContext.enter().setLevel(LogContext.Level.ERROR);
} else {
javolution.context.LogContext.enter().setLevel(LogContext.Level.FATAL);
}
}
|
[
"public",
"static",
"final",
"void",
"setJavolutionLogLevel",
"(",
"org",
".",
"slf4j",
".",
"Logger",
"log",
")",
"{",
"// disable Javolution info-level logging",
"if",
"(",
"log",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"javolution",
".",
"context",
".",
"LogContext",
".",
"enter",
"(",
")",
".",
"setLevel",
"(",
"LogContext",
".",
"Level",
".",
"DEBUG",
")",
";",
"}",
"else",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"javolution",
".",
"context",
".",
"LogContext",
".",
"enter",
"(",
")",
".",
"setLevel",
"(",
"LogContext",
".",
"Level",
".",
"DEBUG",
")",
";",
"}",
"else",
"if",
"(",
"log",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"javolution",
".",
"context",
".",
"LogContext",
".",
"enter",
"(",
")",
".",
"setLevel",
"(",
"LogContext",
".",
"Level",
".",
"INFO",
")",
";",
"}",
"else",
"if",
"(",
"log",
".",
"isWarnEnabled",
"(",
")",
")",
"{",
"javolution",
".",
"context",
".",
"LogContext",
".",
"enter",
"(",
")",
".",
"setLevel",
"(",
"LogContext",
".",
"Level",
".",
"WARNING",
")",
";",
"}",
"else",
"if",
"(",
"log",
".",
"isErrorEnabled",
"(",
")",
")",
"{",
"javolution",
".",
"context",
".",
"LogContext",
".",
"enter",
"(",
")",
".",
"setLevel",
"(",
"LogContext",
".",
"Level",
".",
"ERROR",
")",
";",
"}",
"else",
"{",
"javolution",
".",
"context",
".",
"LogContext",
".",
"enter",
"(",
")",
".",
"setLevel",
"(",
"LogContext",
".",
"Level",
".",
"FATAL",
")",
";",
"}",
"}"
] |
Set Javolution log level according to the provided logger.
@param log SLF4J wrapper for many logging frameworks
|
[
"Set",
"Javolution",
"log",
"level",
"according",
"to",
"the",
"provided",
"logger",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/logging/LogHelper.java#L36-L51
|
11,521
|
maxirosson/jdroid-android
|
jdroid-android-sqlite/src/main/java/com/jdroid/android/sqlite/repository/MapRepository.java
|
MapRepository.getChildrenMap
|
public Map<String, String> getChildrenMap(String parentId) {
Map<String, String> map = new HashMap<>();
List<StringEntity> children = getByField(Column.PARENT_ID, parentId);
for (StringEntity stringEntity : children) {
map.put(stringEntity.getId(), stringEntity.getValue());
}
return map;
}
|
java
|
public Map<String, String> getChildrenMap(String parentId) {
Map<String, String> map = new HashMap<>();
List<StringEntity> children = getByField(Column.PARENT_ID, parentId);
for (StringEntity stringEntity : children) {
map.put(stringEntity.getId(), stringEntity.getValue());
}
return map;
}
|
[
"public",
"Map",
"<",
"String",
",",
"String",
">",
"getChildrenMap",
"(",
"String",
"parentId",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"List",
"<",
"StringEntity",
">",
"children",
"=",
"getByField",
"(",
"Column",
".",
"PARENT_ID",
",",
"parentId",
")",
";",
"for",
"(",
"StringEntity",
"stringEntity",
":",
"children",
")",
"{",
"map",
".",
"put",
"(",
"stringEntity",
".",
"getId",
"(",
")",
",",
"stringEntity",
".",
"getValue",
"(",
")",
")",
";",
"}",
"return",
"map",
";",
"}"
] |
This method returns the map of children associated with given parent id.
@param parentId of parent entity.
@return map of children
|
[
"This",
"method",
"returns",
"the",
"map",
"of",
"children",
"associated",
"with",
"given",
"parent",
"id",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-sqlite/src/main/java/com/jdroid/android/sqlite/repository/MapRepository.java#L26-L33
|
11,522
|
maxirosson/jdroid-android
|
jdroid-android-sqlite/src/main/java/com/jdroid/android/sqlite/repository/MapRepository.java
|
MapRepository.replaceMapChildren
|
public void replaceMapChildren(Map<String, String> map, String parentId) {
ArrayList<StringEntity> entities = new ArrayList<>();
for (String key : map.keySet()) {
StringEntity entity = new StringEntity();
entity.setParentId(parentId);
entity.setId(key);
entity.setValue(map.get(key));
entities.add(entity);
}
replaceChildren(entities, parentId);
}
|
java
|
public void replaceMapChildren(Map<String, String> map, String parentId) {
ArrayList<StringEntity> entities = new ArrayList<>();
for (String key : map.keySet()) {
StringEntity entity = new StringEntity();
entity.setParentId(parentId);
entity.setId(key);
entity.setValue(map.get(key));
entities.add(entity);
}
replaceChildren(entities, parentId);
}
|
[
"public",
"void",
"replaceMapChildren",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"map",
",",
"String",
"parentId",
")",
"{",
"ArrayList",
"<",
"StringEntity",
">",
"entities",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"key",
":",
"map",
".",
"keySet",
"(",
")",
")",
"{",
"StringEntity",
"entity",
"=",
"new",
"StringEntity",
"(",
")",
";",
"entity",
".",
"setParentId",
"(",
"parentId",
")",
";",
"entity",
".",
"setId",
"(",
"key",
")",
";",
"entity",
".",
"setValue",
"(",
"map",
".",
"get",
"(",
"key",
")",
")",
";",
"entities",
".",
"add",
"(",
"entity",
")",
";",
"}",
"replaceChildren",
"(",
"entities",
",",
"parentId",
")",
";",
"}"
] |
This method allows to replace all children of a given parent, it will remove any children which are not in the
list, add the new ones and update which are in the list.
@param map map of list to replace.
@param parentId id of parent entity.
|
[
"This",
"method",
"allows",
"to",
"replace",
"all",
"children",
"of",
"a",
"given",
"parent",
"it",
"will",
"remove",
"any",
"children",
"which",
"are",
"not",
"in",
"the",
"list",
"add",
"the",
"new",
"ones",
"and",
"update",
"which",
"are",
"in",
"the",
"list",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-sqlite/src/main/java/com/jdroid/android/sqlite/repository/MapRepository.java#L42-L52
|
11,523
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/algo/vns/VariableNeighbourhoodDescent.java
|
VariableNeighbourhoodDescent.searchStep
|
@Override
protected void searchStep() {
// stop if no more neighbourhoods available
if(k >= getNeighbourhoods().size()){
stop();
} else {
// use k-th neighbourhood to get best valid move with positive delta, if any
Neighbourhood<? super SolutionType> neigh = getNeighbourhoods().get(k);
Move<? super SolutionType> move = getBestMove(
neigh.getAllMoves(getCurrentSolution()), // generate all moves
true); // only improvements
// found improvement ?
if(move != null){
// improvement: accept move and reset k
accept(move);
k = 0;
} else {
// switch to next neighbourhood (to be used in next step)
k++;
}
}
}
|
java
|
@Override
protected void searchStep() {
// stop if no more neighbourhoods available
if(k >= getNeighbourhoods().size()){
stop();
} else {
// use k-th neighbourhood to get best valid move with positive delta, if any
Neighbourhood<? super SolutionType> neigh = getNeighbourhoods().get(k);
Move<? super SolutionType> move = getBestMove(
neigh.getAllMoves(getCurrentSolution()), // generate all moves
true); // only improvements
// found improvement ?
if(move != null){
// improvement: accept move and reset k
accept(move);
k = 0;
} else {
// switch to next neighbourhood (to be used in next step)
k++;
}
}
}
|
[
"@",
"Override",
"protected",
"void",
"searchStep",
"(",
")",
"{",
"// stop if no more neighbourhoods available",
"if",
"(",
"k",
">=",
"getNeighbourhoods",
"(",
")",
".",
"size",
"(",
")",
")",
"{",
"stop",
"(",
")",
";",
"}",
"else",
"{",
"// use k-th neighbourhood to get best valid move with positive delta, if any",
"Neighbourhood",
"<",
"?",
"super",
"SolutionType",
">",
"neigh",
"=",
"getNeighbourhoods",
"(",
")",
".",
"get",
"(",
"k",
")",
";",
"Move",
"<",
"?",
"super",
"SolutionType",
">",
"move",
"=",
"getBestMove",
"(",
"neigh",
".",
"getAllMoves",
"(",
"getCurrentSolution",
"(",
")",
")",
",",
"// generate all moves",
"true",
")",
";",
"// only improvements",
"// found improvement ?",
"if",
"(",
"move",
"!=",
"null",
")",
"{",
"// improvement: accept move and reset k",
"accept",
"(",
"move",
")",
";",
"k",
"=",
"0",
";",
"}",
"else",
"{",
"// switch to next neighbourhood (to be used in next step)",
"k",
"++",
";",
"}",
"}",
"}"
] |
Investigates all neighbours of the current solution, using the k-th neighbourhood, and adopts the best one
as the new current solution, if it is an improvement. If no improvement is found, k is increased. Upon each
improvement, k is reset to 0, and when k has reached the number of available neighbourhoods, the search stops.
@throws JamesRuntimeException if depending on malfunctioning components (problem, neighbourhood, ...)
|
[
"Investigates",
"all",
"neighbours",
"of",
"the",
"current",
"solution",
"using",
"the",
"k",
"-",
"th",
"neighbourhood",
"and",
"adopts",
"the",
"best",
"one",
"as",
"the",
"new",
"current",
"solution",
"if",
"it",
"is",
"an",
"improvement",
".",
"If",
"no",
"improvement",
"is",
"found",
"k",
"is",
"increased",
".",
"Upon",
"each",
"improvement",
"k",
"is",
"reset",
"to",
"0",
"and",
"when",
"k",
"has",
"reached",
"the",
"number",
"of",
"available",
"neighbourhoods",
"the",
"search",
"stops",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/algo/vns/VariableNeighbourhoodDescent.java#L93-L114
|
11,524
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/algo/tabu/TabuSearch.java
|
TabuSearch.accept
|
@Override
protected boolean accept(Move<? super SolutionType> move){
// call super
if(super.accept(move)){
// update tabu memory
tabuMemory.registerVisitedSolution(getCurrentSolution(), move);
// update successful
return true;
} else {
return false;
}
}
|
java
|
@Override
protected boolean accept(Move<? super SolutionType> move){
// call super
if(super.accept(move)){
// update tabu memory
tabuMemory.registerVisitedSolution(getCurrentSolution(), move);
// update successful
return true;
} else {
return false;
}
}
|
[
"@",
"Override",
"protected",
"boolean",
"accept",
"(",
"Move",
"<",
"?",
"super",
"SolutionType",
">",
"move",
")",
"{",
"// call super",
"if",
"(",
"super",
".",
"accept",
"(",
"move",
")",
")",
"{",
"// update tabu memory",
"tabuMemory",
".",
"registerVisitedSolution",
"(",
"getCurrentSolution",
"(",
")",
",",
"move",
")",
";",
"// update successful",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Overrides acceptance of a move to update the tabu memory by registering the newly visited solution.
@param move move to be accepted
@return <code>true</code> if the update was successful, <code>false</code> if the move is invalid
|
[
"Overrides",
"acceptance",
"of",
"a",
"move",
"to",
"update",
"the",
"tabu",
"memory",
"by",
"registering",
"the",
"newly",
"visited",
"solution",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/algo/tabu/TabuSearch.java#L133-L144
|
11,525
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/problems/objectives/evaluations/PenalizedEvaluation.java
|
PenalizedEvaluation.addPenalizingValidation
|
public void addPenalizingValidation(Object key, PenalizingValidation penalizingValidation){
initMapOnce();
penalties.put(key, penalizingValidation);
// update penalized value
if(!penalizingValidation.passed()){
assignedPenalties = true;
double p = penalizingValidation.getPenalty();
penalizedValue += minimizing ? p : -p;
}
}
|
java
|
public void addPenalizingValidation(Object key, PenalizingValidation penalizingValidation){
initMapOnce();
penalties.put(key, penalizingValidation);
// update penalized value
if(!penalizingValidation.passed()){
assignedPenalties = true;
double p = penalizingValidation.getPenalty();
penalizedValue += minimizing ? p : -p;
}
}
|
[
"public",
"void",
"addPenalizingValidation",
"(",
"Object",
"key",
",",
"PenalizingValidation",
"penalizingValidation",
")",
"{",
"initMapOnce",
"(",
")",
";",
"penalties",
".",
"put",
"(",
"key",
",",
"penalizingValidation",
")",
";",
"// update penalized value",
"if",
"(",
"!",
"penalizingValidation",
".",
"passed",
"(",
")",
")",
"{",
"assignedPenalties",
"=",
"true",
";",
"double",
"p",
"=",
"penalizingValidation",
".",
"getPenalty",
"(",
")",
";",
"penalizedValue",
"+=",
"minimizing",
"?",
"p",
":",
"-",
"p",
";",
"}",
"}"
] |
Add a penalty expressed by a penalizing validation object. A key is
required that can be used to retrieve the validation object later.
@param key key used to retrieve the validation object later
@param penalizingValidation penalizing validation that indicates the assigned penalty
|
[
"Add",
"a",
"penalty",
"expressed",
"by",
"a",
"penalizing",
"validation",
"object",
".",
"A",
"key",
"is",
"required",
"that",
"can",
"be",
"used",
"to",
"retrieve",
"the",
"validation",
"object",
"later",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/problems/objectives/evaluations/PenalizedEvaluation.java#L78-L87
|
11,526
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/fileio/filetypes/LCMSDataSourceFactory.java
|
LCMSDataSourceFactory.create
|
public static LCMSDataSource<?> create(Path path) {
path = path.toAbsolutePath();
String lowerCaseName = path.getFileName().toString().toLowerCase();
if (lowerCaseName.endsWith(".mzxml")) {
return new MZXMLFile(path.toString());
} else if (lowerCaseName.endsWith(".mzml")) {
return new MZMLFile(path.toString());
}
return null;
}
|
java
|
public static LCMSDataSource<?> create(Path path) {
path = path.toAbsolutePath();
String lowerCaseName = path.getFileName().toString().toLowerCase();
if (lowerCaseName.endsWith(".mzxml")) {
return new MZXMLFile(path.toString());
} else if (lowerCaseName.endsWith(".mzml")) {
return new MZMLFile(path.toString());
}
return null;
}
|
[
"public",
"static",
"LCMSDataSource",
"<",
"?",
">",
"create",
"(",
"Path",
"path",
")",
"{",
"path",
"=",
"path",
".",
"toAbsolutePath",
"(",
")",
";",
"String",
"lowerCaseName",
"=",
"path",
".",
"getFileName",
"(",
")",
".",
"toString",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"lowerCaseName",
".",
"endsWith",
"(",
"\".mzxml\"",
")",
")",
"{",
"return",
"new",
"MZXMLFile",
"(",
"path",
".",
"toString",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"lowerCaseName",
".",
"endsWith",
"(",
"\".mzml\"",
")",
")",
"{",
"return",
"new",
"MZMLFile",
"(",
"path",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Try and create a data source from a given file path.
@return null if the provided path was not recognized
|
[
"Try",
"and",
"create",
"a",
"data",
"source",
"from",
"a",
"given",
"file",
"path",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/fileio/filetypes/LCMSDataSourceFactory.java#L39-L48
|
11,527
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/cache/SingleEvaluatedMoveCache.java
|
SingleEvaluatedMoveCache.cacheMoveEvaluation
|
@Override
public final void cacheMoveEvaluation(Move<?> move, Evaluation evaluation) {
evaluatedMove = move;
this.evaluation = evaluation;
}
|
java
|
@Override
public final void cacheMoveEvaluation(Move<?> move, Evaluation evaluation) {
evaluatedMove = move;
this.evaluation = evaluation;
}
|
[
"@",
"Override",
"public",
"final",
"void",
"cacheMoveEvaluation",
"(",
"Move",
"<",
"?",
">",
"move",
",",
"Evaluation",
"evaluation",
")",
"{",
"evaluatedMove",
"=",
"move",
";",
"this",
".",
"evaluation",
"=",
"evaluation",
";",
"}"
] |
Cache the given evaluation, discarding any previously cached evaluations.
@param move move applied to the current solution
@param evaluation evaluation of obtained neighbour
|
[
"Cache",
"the",
"given",
"evaluation",
"discarding",
"any",
"previously",
"cached",
"evaluations",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/cache/SingleEvaluatedMoveCache.java#L58-L62
|
11,528
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/cache/SingleEvaluatedMoveCache.java
|
SingleEvaluatedMoveCache.getCachedMoveEvaluation
|
@Override
public final Evaluation getCachedMoveEvaluation(Move<?> move) {
if(evaluatedMove == null || !evaluatedMove.equals(move)){
// cache miss
return null;
} else {
// cache hit
return evaluation;
}
}
|
java
|
@Override
public final Evaluation getCachedMoveEvaluation(Move<?> move) {
if(evaluatedMove == null || !evaluatedMove.equals(move)){
// cache miss
return null;
} else {
// cache hit
return evaluation;
}
}
|
[
"@",
"Override",
"public",
"final",
"Evaluation",
"getCachedMoveEvaluation",
"(",
"Move",
"<",
"?",
">",
"move",
")",
"{",
"if",
"(",
"evaluatedMove",
"==",
"null",
"||",
"!",
"evaluatedMove",
".",
"equals",
"(",
"move",
")",
")",
"{",
"// cache miss",
"return",
"null",
";",
"}",
"else",
"{",
"// cache hit",
"return",
"evaluation",
";",
"}",
"}"
] |
Retrieve a cached evaluation, if still available. If the evaluation of any
other move has been cached at a later point in time, the value for this move
will have been overwritten.
@param move move applied to the current solution
@return cached evaluation of the obtained neighbour, if available, <code>null</code> if not
|
[
"Retrieve",
"a",
"cached",
"evaluation",
"if",
"still",
"available",
".",
"If",
"the",
"evaluation",
"of",
"any",
"other",
"move",
"has",
"been",
"cached",
"at",
"a",
"later",
"point",
"in",
"time",
"the",
"value",
"for",
"this",
"move",
"will",
"have",
"been",
"overwritten",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/cache/SingleEvaluatedMoveCache.java#L72-L81
|
11,529
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/cache/SingleEvaluatedMoveCache.java
|
SingleEvaluatedMoveCache.cacheMoveValidation
|
@Override
public final void cacheMoveValidation(Move<?> move, Validation validation) {
validatedMove = move;
this.validation = validation;
}
|
java
|
@Override
public final void cacheMoveValidation(Move<?> move, Validation validation) {
validatedMove = move;
this.validation = validation;
}
|
[
"@",
"Override",
"public",
"final",
"void",
"cacheMoveValidation",
"(",
"Move",
"<",
"?",
">",
"move",
",",
"Validation",
"validation",
")",
"{",
"validatedMove",
"=",
"move",
";",
"this",
".",
"validation",
"=",
"validation",
";",
"}"
] |
Cache validation of the given move, discarding any previously cached value.
@param move move applied to the current solution
@param validation validation of obtained neighbour
|
[
"Cache",
"validation",
"of",
"the",
"given",
"move",
"discarding",
"any",
"previously",
"cached",
"value",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/cache/SingleEvaluatedMoveCache.java#L89-L93
|
11,530
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/cache/SingleEvaluatedMoveCache.java
|
SingleEvaluatedMoveCache.getCachedMoveValidation
|
@Override
public final Validation getCachedMoveValidation(Move<?> move) {
if(validatedMove == null || !validatedMove.equals(move)){
// cache miss
return null;
} else {
// cache hit
return validation;
}
}
|
java
|
@Override
public final Validation getCachedMoveValidation(Move<?> move) {
if(validatedMove == null || !validatedMove.equals(move)){
// cache miss
return null;
} else {
// cache hit
return validation;
}
}
|
[
"@",
"Override",
"public",
"final",
"Validation",
"getCachedMoveValidation",
"(",
"Move",
"<",
"?",
">",
"move",
")",
"{",
"if",
"(",
"validatedMove",
"==",
"null",
"||",
"!",
"validatedMove",
".",
"equals",
"(",
"move",
")",
")",
"{",
"// cache miss",
"return",
"null",
";",
"}",
"else",
"{",
"// cache hit",
"return",
"validation",
";",
"}",
"}"
] |
Retrieve a cached validation, if still available. If the validation of any other move has
been cached at a later point in time, the value for this move will have been overwritten.
@param move move applied to the current solution
@return cached validation of the obtained neighbour, if available, <code>null</code> if not
|
[
"Retrieve",
"a",
"cached",
"validation",
"if",
"still",
"available",
".",
"If",
"the",
"validation",
"of",
"any",
"other",
"move",
"has",
"been",
"cached",
"at",
"a",
"later",
"point",
"in",
"time",
"the",
"value",
"for",
"this",
"move",
"will",
"have",
"been",
"overwritten",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/cache/SingleEvaluatedMoveCache.java#L102-L111
|
11,531
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/cache/SingleEvaluatedMoveCache.java
|
SingleEvaluatedMoveCache.clear
|
@Override
public final void clear() {
evaluatedMove = null;
evaluation = null;
validatedMove = null;
validation = null;
}
|
java
|
@Override
public final void clear() {
evaluatedMove = null;
evaluation = null;
validatedMove = null;
validation = null;
}
|
[
"@",
"Override",
"public",
"final",
"void",
"clear",
"(",
")",
"{",
"evaluatedMove",
"=",
"null",
";",
"evaluation",
"=",
"null",
";",
"validatedMove",
"=",
"null",
";",
"validation",
"=",
"null",
";",
"}"
] |
Clear all cached values.
|
[
"Clear",
"all",
"cached",
"values",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/cache/SingleEvaluatedMoveCache.java#L116-L122
|
11,532
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/NeighbourhoodSearch.java
|
NeighbourhoodSearch.updateCurrentSolution
|
@Override
protected void updateCurrentSolution(SolutionType solution, Evaluation evaluation, Validation validation){
// call super
super.updateCurrentSolution(solution, evaluation, validation);
// clear evaluated move cache
if(cache != null){
cache.clear();
}
}
|
java
|
@Override
protected void updateCurrentSolution(SolutionType solution, Evaluation evaluation, Validation validation){
// call super
super.updateCurrentSolution(solution, evaluation, validation);
// clear evaluated move cache
if(cache != null){
cache.clear();
}
}
|
[
"@",
"Override",
"protected",
"void",
"updateCurrentSolution",
"(",
"SolutionType",
"solution",
",",
"Evaluation",
"evaluation",
",",
"Validation",
"validation",
")",
"{",
"// call super",
"super",
".",
"updateCurrentSolution",
"(",
"solution",
",",
"evaluation",
",",
"validation",
")",
";",
"// clear evaluated move cache",
"if",
"(",
"cache",
"!=",
"null",
")",
"{",
"cache",
".",
"clear",
"(",
")",
";",
"}",
"}"
] |
When updating the current solution in a neighbourhood search, the evaluated move cache is
cleared because it is no longer valid for the new current solution.
@param solution new current solution
@param evaluation evaluation of new current solution
@param validation validation of new current solution
|
[
"When",
"updating",
"the",
"current",
"solution",
"in",
"a",
"neighbourhood",
"search",
"the",
"evaluated",
"move",
"cache",
"is",
"cleared",
"because",
"it",
"is",
"no",
"longer",
"valid",
"for",
"the",
"new",
"current",
"solution",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/NeighbourhoodSearch.java#L220-L228
|
11,533
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/NeighbourhoodSearch.java
|
NeighbourhoodSearch.evaluate
|
protected Evaluation evaluate(Move<? super SolutionType> move){
Evaluation eval = null;
// check cache
if(cache != null){
eval = cache.getCachedMoveEvaluation(move);
}
if(eval != null){
// cache hit: return cached value
return eval;
} else {
// cache miss: evaluate and cache
eval = getProblem().evaluate(move, getCurrentSolution(), getCurrentSolutionEvaluation());
if(cache != null){
cache.cacheMoveEvaluation(move, eval);
}
return eval;
}
}
|
java
|
protected Evaluation evaluate(Move<? super SolutionType> move){
Evaluation eval = null;
// check cache
if(cache != null){
eval = cache.getCachedMoveEvaluation(move);
}
if(eval != null){
// cache hit: return cached value
return eval;
} else {
// cache miss: evaluate and cache
eval = getProblem().evaluate(move, getCurrentSolution(), getCurrentSolutionEvaluation());
if(cache != null){
cache.cacheMoveEvaluation(move, eval);
}
return eval;
}
}
|
[
"protected",
"Evaluation",
"evaluate",
"(",
"Move",
"<",
"?",
"super",
"SolutionType",
">",
"move",
")",
"{",
"Evaluation",
"eval",
"=",
"null",
";",
"// check cache",
"if",
"(",
"cache",
"!=",
"null",
")",
"{",
"eval",
"=",
"cache",
".",
"getCachedMoveEvaluation",
"(",
"move",
")",
";",
"}",
"if",
"(",
"eval",
"!=",
"null",
")",
"{",
"// cache hit: return cached value",
"return",
"eval",
";",
"}",
"else",
"{",
"// cache miss: evaluate and cache",
"eval",
"=",
"getProblem",
"(",
")",
".",
"evaluate",
"(",
"move",
",",
"getCurrentSolution",
"(",
")",
",",
"getCurrentSolutionEvaluation",
"(",
")",
")",
";",
"if",
"(",
"cache",
"!=",
"null",
")",
"{",
"cache",
".",
"cacheMoveEvaluation",
"(",
"move",
",",
"eval",
")",
";",
"}",
"return",
"eval",
";",
"}",
"}"
] |
Evaluates a move to be applied to the current solution. If this move has been evaluated
before and the obtained evaluation is still available in the cache, the cached evaluation
will be returned. Else, the evaluation will be computed and offered to the cache.
@param move move to be applied to the current solution
@return evaluation of obtained neighbour, possibly retrieved from the evaluated move cache
|
[
"Evaluates",
"a",
"move",
"to",
"be",
"applied",
"to",
"the",
"current",
"solution",
".",
"If",
"this",
"move",
"has",
"been",
"evaluated",
"before",
"and",
"the",
"obtained",
"evaluation",
"is",
"still",
"available",
"in",
"the",
"cache",
"the",
"cached",
"evaluation",
"will",
"be",
"returned",
".",
"Else",
"the",
"evaluation",
"will",
"be",
"computed",
"and",
"offered",
"to",
"the",
"cache",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/NeighbourhoodSearch.java#L238-L255
|
11,534
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/NeighbourhoodSearch.java
|
NeighbourhoodSearch.validate
|
protected Validation validate(Move<? super SolutionType> move){
Validation val = null;
// check cache
if(cache != null){
val = cache.getCachedMoveValidation(move);
}
if(val != null){
// cache hit: return cached value
return val;
} else {
// cache miss: validate and cache
val = getProblem().validate(move, getCurrentSolution(), getCurrentSolutionValidation());
if(cache != null){
cache.cacheMoveValidation(move, val);
}
return val;
}
}
|
java
|
protected Validation validate(Move<? super SolutionType> move){
Validation val = null;
// check cache
if(cache != null){
val = cache.getCachedMoveValidation(move);
}
if(val != null){
// cache hit: return cached value
return val;
} else {
// cache miss: validate and cache
val = getProblem().validate(move, getCurrentSolution(), getCurrentSolutionValidation());
if(cache != null){
cache.cacheMoveValidation(move, val);
}
return val;
}
}
|
[
"protected",
"Validation",
"validate",
"(",
"Move",
"<",
"?",
"super",
"SolutionType",
">",
"move",
")",
"{",
"Validation",
"val",
"=",
"null",
";",
"// check cache",
"if",
"(",
"cache",
"!=",
"null",
")",
"{",
"val",
"=",
"cache",
".",
"getCachedMoveValidation",
"(",
"move",
")",
";",
"}",
"if",
"(",
"val",
"!=",
"null",
")",
"{",
"// cache hit: return cached value",
"return",
"val",
";",
"}",
"else",
"{",
"// cache miss: validate and cache",
"val",
"=",
"getProblem",
"(",
")",
".",
"validate",
"(",
"move",
",",
"getCurrentSolution",
"(",
")",
",",
"getCurrentSolutionValidation",
"(",
")",
")",
";",
"if",
"(",
"cache",
"!=",
"null",
")",
"{",
"cache",
".",
"cacheMoveValidation",
"(",
"move",
",",
"val",
")",
";",
"}",
"return",
"val",
";",
"}",
"}"
] |
Validates a move to be applied to the current solution. If this move has been validated
before and the obtained validation is still available in the cache, the cached validation
will be returned. Else, the validation will be computed and offered to the cache.
@param move move to be applied to the current solution
@return validation of obtained neighbour, possibly retrieved from the evaluated move cache
|
[
"Validates",
"a",
"move",
"to",
"be",
"applied",
"to",
"the",
"current",
"solution",
".",
"If",
"this",
"move",
"has",
"been",
"validated",
"before",
"and",
"the",
"obtained",
"validation",
"is",
"still",
"available",
"in",
"the",
"cache",
"the",
"cached",
"validation",
"will",
"be",
"returned",
".",
"Else",
"the",
"validation",
"will",
"be",
"computed",
"and",
"offered",
"to",
"the",
"cache",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/NeighbourhoodSearch.java#L265-L282
|
11,535
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java
|
BaselineProfile.validate
|
@Override
public void validate() {
int n = 0;
try {
for (TiffObject o : model.getImageIfds()) {
IFD ifd = (IFD) o;
IfdTags metadata = ifd.getMetadata();
validateMetadata(metadata);
checkImage(ifd, n, metadata);
n++;
}
} catch (Exception ex) {
}
}
|
java
|
@Override
public void validate() {
int n = 0;
try {
for (TiffObject o : model.getImageIfds()) {
IFD ifd = (IFD) o;
IfdTags metadata = ifd.getMetadata();
validateMetadata(metadata);
checkImage(ifd, n, metadata);
n++;
}
} catch (Exception ex) {
}
}
|
[
"@",
"Override",
"public",
"void",
"validate",
"(",
")",
"{",
"int",
"n",
"=",
"0",
";",
"try",
"{",
"for",
"(",
"TiffObject",
"o",
":",
"model",
".",
"getImageIfds",
"(",
")",
")",
"{",
"IFD",
"ifd",
"=",
"(",
"IFD",
")",
"o",
";",
"IfdTags",
"metadata",
"=",
"ifd",
".",
"getMetadata",
"(",
")",
";",
"validateMetadata",
"(",
"metadata",
")",
";",
"checkImage",
"(",
"ifd",
",",
"n",
",",
"metadata",
")",
";",
"n",
"++",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"}"
] |
Validates the IFD.
|
[
"Validates",
"the",
"IFD",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java#L115-L129
|
11,536
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java
|
BaselineProfile.validateMetadata
|
public void validateMetadata(IfdTags metadata) {
int prevTagId = 0;
try {
TiffTags.getTiffTags();
} catch (ReadTagsIOException e) {
}
for (TagValue ie : metadata.getTags()) {
if (!TiffTags.tagMap.containsKey(ie.getId())) {
validation.addWarning("Ignoring undefined tag id " + ie.getId(), "", "Metadata");
} else if (!TiffTags.tagTypes.containsKey(ie.getType())) {
validation.addWarning("Ignoring unknown tag type " + ie.getType(), "", "Metadata");
}
else {
Tag t = TiffTags.getTag(ie.getId());
String stype = TiffTags.tagTypes.get(ie.getType());
if (ie.getId() == 320) {
// Colormap length check
long bps = 0;
if (metadata.containsTagId(258))
bps = metadata.get(258).getFirstNumericValue();
long calc = 3 * (long) Math.pow(2, bps);
if (calc != ie.getCardinality()) {
validation.addError("Invalid cardinality for tag "
+ TiffTags.getTag(ie.getId()).getName() + "[" + ie.getCardinality() + "]",
"Metadata", stype);
}
}
try {
// Cardinality check
int card = Integer.parseInt(t.getCardinality());
if (card != ie.getCardinality())
validation.addError("Cardinality for tag " + TiffTags.getTag(ie.getId()).getName()
+ " must be " + card, "Metadata",
ie.getCardinality());
} catch (Exception e) {
// TODO: Deal with formulas?
}
}
if (ie.getId() < prevTagId) {
if (tagOrderTolerance > 0)
validation.addWarning("Tags are not in ascending order", "", "Metadata");
else
validation.addErrorLoc("Tags are not in ascending order", "Metadata");
}
prevTagId = ie.getId();
}
}
|
java
|
public void validateMetadata(IfdTags metadata) {
int prevTagId = 0;
try {
TiffTags.getTiffTags();
} catch (ReadTagsIOException e) {
}
for (TagValue ie : metadata.getTags()) {
if (!TiffTags.tagMap.containsKey(ie.getId())) {
validation.addWarning("Ignoring undefined tag id " + ie.getId(), "", "Metadata");
} else if (!TiffTags.tagTypes.containsKey(ie.getType())) {
validation.addWarning("Ignoring unknown tag type " + ie.getType(), "", "Metadata");
}
else {
Tag t = TiffTags.getTag(ie.getId());
String stype = TiffTags.tagTypes.get(ie.getType());
if (ie.getId() == 320) {
// Colormap length check
long bps = 0;
if (metadata.containsTagId(258))
bps = metadata.get(258).getFirstNumericValue();
long calc = 3 * (long) Math.pow(2, bps);
if (calc != ie.getCardinality()) {
validation.addError("Invalid cardinality for tag "
+ TiffTags.getTag(ie.getId()).getName() + "[" + ie.getCardinality() + "]",
"Metadata", stype);
}
}
try {
// Cardinality check
int card = Integer.parseInt(t.getCardinality());
if (card != ie.getCardinality())
validation.addError("Cardinality for tag " + TiffTags.getTag(ie.getId()).getName()
+ " must be " + card, "Metadata",
ie.getCardinality());
} catch (Exception e) {
// TODO: Deal with formulas?
}
}
if (ie.getId() < prevTagId) {
if (tagOrderTolerance > 0)
validation.addWarning("Tags are not in ascending order", "", "Metadata");
else
validation.addErrorLoc("Tags are not in ascending order", "Metadata");
}
prevTagId = ie.getId();
}
}
|
[
"public",
"void",
"validateMetadata",
"(",
"IfdTags",
"metadata",
")",
"{",
"int",
"prevTagId",
"=",
"0",
";",
"try",
"{",
"TiffTags",
".",
"getTiffTags",
"(",
")",
";",
"}",
"catch",
"(",
"ReadTagsIOException",
"e",
")",
"{",
"}",
"for",
"(",
"TagValue",
"ie",
":",
"metadata",
".",
"getTags",
"(",
")",
")",
"{",
"if",
"(",
"!",
"TiffTags",
".",
"tagMap",
".",
"containsKey",
"(",
"ie",
".",
"getId",
"(",
")",
")",
")",
"{",
"validation",
".",
"addWarning",
"(",
"\"Ignoring undefined tag id \"",
"+",
"ie",
".",
"getId",
"(",
")",
",",
"\"\"",
",",
"\"Metadata\"",
")",
";",
"}",
"else",
"if",
"(",
"!",
"TiffTags",
".",
"tagTypes",
".",
"containsKey",
"(",
"ie",
".",
"getType",
"(",
")",
")",
")",
"{",
"validation",
".",
"addWarning",
"(",
"\"Ignoring unknown tag type \"",
"+",
"ie",
".",
"getType",
"(",
")",
",",
"\"\"",
",",
"\"Metadata\"",
")",
";",
"}",
"else",
"{",
"Tag",
"t",
"=",
"TiffTags",
".",
"getTag",
"(",
"ie",
".",
"getId",
"(",
")",
")",
";",
"String",
"stype",
"=",
"TiffTags",
".",
"tagTypes",
".",
"get",
"(",
"ie",
".",
"getType",
"(",
")",
")",
";",
"if",
"(",
"ie",
".",
"getId",
"(",
")",
"==",
"320",
")",
"{",
"// Colormap length check",
"long",
"bps",
"=",
"0",
";",
"if",
"(",
"metadata",
".",
"containsTagId",
"(",
"258",
")",
")",
"bps",
"=",
"metadata",
".",
"get",
"(",
"258",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"long",
"calc",
"=",
"3",
"*",
"(",
"long",
")",
"Math",
".",
"pow",
"(",
"2",
",",
"bps",
")",
";",
"if",
"(",
"calc",
"!=",
"ie",
".",
"getCardinality",
"(",
")",
")",
"{",
"validation",
".",
"addError",
"(",
"\"Invalid cardinality for tag \"",
"+",
"TiffTags",
".",
"getTag",
"(",
"ie",
".",
"getId",
"(",
")",
")",
".",
"getName",
"(",
")",
"+",
"\"[\"",
"+",
"ie",
".",
"getCardinality",
"(",
")",
"+",
"\"]\"",
",",
"\"Metadata\"",
",",
"stype",
")",
";",
"}",
"}",
"try",
"{",
"// Cardinality check",
"int",
"card",
"=",
"Integer",
".",
"parseInt",
"(",
"t",
".",
"getCardinality",
"(",
")",
")",
";",
"if",
"(",
"card",
"!=",
"ie",
".",
"getCardinality",
"(",
")",
")",
"validation",
".",
"addError",
"(",
"\"Cardinality for tag \"",
"+",
"TiffTags",
".",
"getTag",
"(",
"ie",
".",
"getId",
"(",
")",
")",
".",
"getName",
"(",
")",
"+",
"\" must be \"",
"+",
"card",
",",
"\"Metadata\"",
",",
"ie",
".",
"getCardinality",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// TODO: Deal with formulas?",
"}",
"}",
"if",
"(",
"ie",
".",
"getId",
"(",
")",
"<",
"prevTagId",
")",
"{",
"if",
"(",
"tagOrderTolerance",
">",
"0",
")",
"validation",
".",
"addWarning",
"(",
"\"Tags are not in ascending order\"",
",",
"\"\"",
",",
"\"Metadata\"",
")",
";",
"else",
"validation",
".",
"addErrorLoc",
"(",
"\"Tags are not in ascending order\"",
",",
"\"Metadata\"",
")",
";",
"}",
"prevTagId",
"=",
"ie",
".",
"getId",
"(",
")",
";",
"}",
"}"
] |
Validates that the ifd entries have correct types and cardinalities, as they are defined in the
JSONs tag configuration files.
@param metadata the ifd metadata
|
[
"Validates",
"that",
"the",
"ifd",
"entries",
"have",
"correct",
"types",
"and",
"cardinalities",
"as",
"they",
"are",
"defined",
"in",
"the",
"JSONs",
"tag",
"configuration",
"files",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java#L137-L184
|
11,537
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java
|
BaselineProfile.checkImage
|
public void checkImage(IFD ifd, int n, IfdTags metadata) {
CheckCommonFields(ifd, n, metadata);
if (!metadata.containsTagId(TiffTags.getTagId("PhotometricInterpretation"))) {
validation.addErrorLoc("Missing Photometric Interpretation", "IFD" + n);
} else if (metadata.get(TiffTags.getTagId("PhotometricInterpretation")).getValue().size() != 1) {
validation.addErrorLoc("Invalid Photometric Interpretation", "IFD" + n);
} else {
photometric =
(int) metadata.get(TiffTags.getTagId("PhotometricInterpretation")).getFirstNumericValue();
switch (photometric) {
case 0:
case 1:
if (!metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))
|| metadata.get(TiffTags.getTagId("BitsPerSample")).getFirstNumericValue() == 1) {
type = ImageType.BILEVEL;
CheckBilevelImage(metadata, n);
} else {
type = ImageType.GRAYSCALE;
CheckGrayscaleImage(metadata, n);
}
break;
case 2:
type = ImageType.RGB;
CheckRGBImage(metadata, n);
break;
case 3:
type = ImageType.PALETTE;
CheckPalleteImage(metadata, n);
break;
case 4:
type = ImageType.TRANSPARENCY_MASK;
CheckTransparencyMask(metadata, n);
break;
case 5:
type = ImageType.CMYK;
CheckCMYK(metadata, n);
break;
case 6:
type = ImageType.YCbCr;
CheckYCbCr(metadata, n);
break;
case 8:
case 9:
case 10:
type = ImageType.CIELab;
CheckCIELab(metadata, n);
break;
default:
validation.addWarning("Unknown Photometric Interpretation", "" + photometric, "IFD" + n);
break;
}
}
}
|
java
|
public void checkImage(IFD ifd, int n, IfdTags metadata) {
CheckCommonFields(ifd, n, metadata);
if (!metadata.containsTagId(TiffTags.getTagId("PhotometricInterpretation"))) {
validation.addErrorLoc("Missing Photometric Interpretation", "IFD" + n);
} else if (metadata.get(TiffTags.getTagId("PhotometricInterpretation")).getValue().size() != 1) {
validation.addErrorLoc("Invalid Photometric Interpretation", "IFD" + n);
} else {
photometric =
(int) metadata.get(TiffTags.getTagId("PhotometricInterpretation")).getFirstNumericValue();
switch (photometric) {
case 0:
case 1:
if (!metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))
|| metadata.get(TiffTags.getTagId("BitsPerSample")).getFirstNumericValue() == 1) {
type = ImageType.BILEVEL;
CheckBilevelImage(metadata, n);
} else {
type = ImageType.GRAYSCALE;
CheckGrayscaleImage(metadata, n);
}
break;
case 2:
type = ImageType.RGB;
CheckRGBImage(metadata, n);
break;
case 3:
type = ImageType.PALETTE;
CheckPalleteImage(metadata, n);
break;
case 4:
type = ImageType.TRANSPARENCY_MASK;
CheckTransparencyMask(metadata, n);
break;
case 5:
type = ImageType.CMYK;
CheckCMYK(metadata, n);
break;
case 6:
type = ImageType.YCbCr;
CheckYCbCr(metadata, n);
break;
case 8:
case 9:
case 10:
type = ImageType.CIELab;
CheckCIELab(metadata, n);
break;
default:
validation.addWarning("Unknown Photometric Interpretation", "" + photometric, "IFD" + n);
break;
}
}
}
|
[
"public",
"void",
"checkImage",
"(",
"IFD",
"ifd",
",",
"int",
"n",
",",
"IfdTags",
"metadata",
")",
"{",
"CheckCommonFields",
"(",
"ifd",
",",
"n",
",",
"metadata",
")",
";",
"if",
"(",
"!",
"metadata",
".",
"containsTagId",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"PhotometricInterpretation\"",
")",
")",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Missing Photometric Interpretation\"",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"}",
"else",
"if",
"(",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"PhotometricInterpretation\"",
")",
")",
".",
"getValue",
"(",
")",
".",
"size",
"(",
")",
"!=",
"1",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Invalid Photometric Interpretation\"",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"}",
"else",
"{",
"photometric",
"=",
"(",
"int",
")",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"PhotometricInterpretation\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"switch",
"(",
"photometric",
")",
"{",
"case",
"0",
":",
"case",
"1",
":",
"if",
"(",
"!",
"metadata",
".",
"containsTagId",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
"||",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
"==",
"1",
")",
"{",
"type",
"=",
"ImageType",
".",
"BILEVEL",
";",
"CheckBilevelImage",
"(",
"metadata",
",",
"n",
")",
";",
"}",
"else",
"{",
"type",
"=",
"ImageType",
".",
"GRAYSCALE",
";",
"CheckGrayscaleImage",
"(",
"metadata",
",",
"n",
")",
";",
"}",
"break",
";",
"case",
"2",
":",
"type",
"=",
"ImageType",
".",
"RGB",
";",
"CheckRGBImage",
"(",
"metadata",
",",
"n",
")",
";",
"break",
";",
"case",
"3",
":",
"type",
"=",
"ImageType",
".",
"PALETTE",
";",
"CheckPalleteImage",
"(",
"metadata",
",",
"n",
")",
";",
"break",
";",
"case",
"4",
":",
"type",
"=",
"ImageType",
".",
"TRANSPARENCY_MASK",
";",
"CheckTransparencyMask",
"(",
"metadata",
",",
"n",
")",
";",
"break",
";",
"case",
"5",
":",
"type",
"=",
"ImageType",
".",
"CMYK",
";",
"CheckCMYK",
"(",
"metadata",
",",
"n",
")",
";",
"break",
";",
"case",
"6",
":",
"type",
"=",
"ImageType",
".",
"YCbCr",
";",
"CheckYCbCr",
"(",
"metadata",
",",
"n",
")",
";",
"break",
";",
"case",
"8",
":",
"case",
"9",
":",
"case",
"10",
":",
"type",
"=",
"ImageType",
".",
"CIELab",
";",
"CheckCIELab",
"(",
"metadata",
",",
"n",
")",
";",
"break",
";",
"default",
":",
"validation",
".",
"addWarning",
"(",
"\"Unknown Photometric Interpretation\"",
",",
"\"\"",
"+",
"photometric",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"break",
";",
"}",
"}",
"}"
] |
Check if the tags that define the image are correct and consistent.
@param ifd the ifd
@param n the ifd number
@param metadata the ifd metadata
|
[
"Check",
"if",
"the",
"tags",
"that",
"define",
"the",
"image",
"are",
"correct",
"and",
"consistent",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java#L193-L246
|
11,538
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java
|
BaselineProfile.CheckBilevelImage
|
private void CheckBilevelImage(IfdTags metadata, int n) {
// Compression
long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
// if (comp != 1 && comp != 2 && comp != 32773)
if (comp < 1)
validation.addError("Invalid Compression", "IFD" + n, comp);
}
|
java
|
private void CheckBilevelImage(IfdTags metadata, int n) {
// Compression
long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
// if (comp != 1 && comp != 2 && comp != 32773)
if (comp < 1)
validation.addError("Invalid Compression", "IFD" + n, comp);
}
|
[
"private",
"void",
"CheckBilevelImage",
"(",
"IfdTags",
"metadata",
",",
"int",
"n",
")",
"{",
"// Compression",
"long",
"comp",
"=",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"Compression\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"// if (comp != 1 && comp != 2 && comp != 32773)",
"if",
"(",
"comp",
"<",
"1",
")",
"validation",
".",
"addError",
"(",
"\"Invalid Compression\"",
",",
"\"IFD\"",
"+",
"n",
",",
"comp",
")",
";",
"}"
] |
Check Bilevel Image.
@param metadata the metadata
@param n the IFD number
|
[
"Check",
"Bilevel",
"Image",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java#L254-L260
|
11,539
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java
|
BaselineProfile.CheckGrayscaleImage
|
private void CheckGrayscaleImage(IfdTags metadata, int n) {
// Bits per Sample
long bps = metadata.get(TiffTags.getTagId("BitsPerSample")).getFirstNumericValue();
// if (bps != 4 && bps != 8)
if (bps < 1)
validation.addError("Invalid Bits per Sample", "IFD" + n, bps);
// Compression
long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
// if (comp != 1 && comp != 32773)
if (comp < 1)
validation.addError("Invalid Compression", "IFD" + n, comp);
}
|
java
|
private void CheckGrayscaleImage(IfdTags metadata, int n) {
// Bits per Sample
long bps = metadata.get(TiffTags.getTagId("BitsPerSample")).getFirstNumericValue();
// if (bps != 4 && bps != 8)
if (bps < 1)
validation.addError("Invalid Bits per Sample", "IFD" + n, bps);
// Compression
long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
// if (comp != 1 && comp != 32773)
if (comp < 1)
validation.addError("Invalid Compression", "IFD" + n, comp);
}
|
[
"private",
"void",
"CheckGrayscaleImage",
"(",
"IfdTags",
"metadata",
",",
"int",
"n",
")",
"{",
"// Bits per Sample",
"long",
"bps",
"=",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"// if (bps != 4 && bps != 8)",
"if",
"(",
"bps",
"<",
"1",
")",
"validation",
".",
"addError",
"(",
"\"Invalid Bits per Sample\"",
",",
"\"IFD\"",
"+",
"n",
",",
"bps",
")",
";",
"// Compression",
"long",
"comp",
"=",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"Compression\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"// if (comp != 1 && comp != 32773)",
"if",
"(",
"comp",
"<",
"1",
")",
"validation",
".",
"addError",
"(",
"\"Invalid Compression\"",
",",
"\"IFD\"",
"+",
"n",
",",
"comp",
")",
";",
"}"
] |
Check Grayscale Image.
@param metadata the metadata
@param n the IFD number
|
[
"Check",
"Grayscale",
"Image",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java#L268-L280
|
11,540
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java
|
BaselineProfile.CheckPalleteImage
|
private void CheckPalleteImage(IfdTags metadata, int nifd) {
// Color Map
if (!metadata.containsTagId(TiffTags.getTagId("ColorMap"))) {
validation.addErrorLoc("Missing Color Map", "IFD" + nifd);
} else {
int n = metadata.get(TiffTags.getTagId("ColorMap")).getCardinality();
if (n != 3 * (int) Math.pow(2, metadata.get(TiffTags.getTagId("BitsPerSample"))
.getFirstNumericValue()))
validation.addError("Incorrect Color Map Cardinality", "IFD" + nifd, metadata.get(320)
.getCardinality());
}
// Bits per Sample
long bps = metadata.get(TiffTags.getTagId("BitsPerSample")).getFirstNumericValue();
if (bps != 4 && bps != 8)
validation.addError("Invalid Bits per Sample", "IFD" + nifd, bps);
// Compression
long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
// if (comp != 1 && comp != 32773)
if (comp < 1)
validation.addError("Invalid Compression", "IFD" + nifd, comp);
}
|
java
|
private void CheckPalleteImage(IfdTags metadata, int nifd) {
// Color Map
if (!metadata.containsTagId(TiffTags.getTagId("ColorMap"))) {
validation.addErrorLoc("Missing Color Map", "IFD" + nifd);
} else {
int n = metadata.get(TiffTags.getTagId("ColorMap")).getCardinality();
if (n != 3 * (int) Math.pow(2, metadata.get(TiffTags.getTagId("BitsPerSample"))
.getFirstNumericValue()))
validation.addError("Incorrect Color Map Cardinality", "IFD" + nifd, metadata.get(320)
.getCardinality());
}
// Bits per Sample
long bps = metadata.get(TiffTags.getTagId("BitsPerSample")).getFirstNumericValue();
if (bps != 4 && bps != 8)
validation.addError("Invalid Bits per Sample", "IFD" + nifd, bps);
// Compression
long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
// if (comp != 1 && comp != 32773)
if (comp < 1)
validation.addError("Invalid Compression", "IFD" + nifd, comp);
}
|
[
"private",
"void",
"CheckPalleteImage",
"(",
"IfdTags",
"metadata",
",",
"int",
"nifd",
")",
"{",
"// Color Map",
"if",
"(",
"!",
"metadata",
".",
"containsTagId",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"ColorMap\"",
")",
")",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Missing Color Map\"",
",",
"\"IFD\"",
"+",
"nifd",
")",
";",
"}",
"else",
"{",
"int",
"n",
"=",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"ColorMap\"",
")",
")",
".",
"getCardinality",
"(",
")",
";",
"if",
"(",
"n",
"!=",
"3",
"*",
"(",
"int",
")",
"Math",
".",
"pow",
"(",
"2",
",",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
")",
")",
"validation",
".",
"addError",
"(",
"\"Incorrect Color Map Cardinality\"",
",",
"\"IFD\"",
"+",
"nifd",
",",
"metadata",
".",
"get",
"(",
"320",
")",
".",
"getCardinality",
"(",
")",
")",
";",
"}",
"// Bits per Sample",
"long",
"bps",
"=",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"if",
"(",
"bps",
"!=",
"4",
"&&",
"bps",
"!=",
"8",
")",
"validation",
".",
"addError",
"(",
"\"Invalid Bits per Sample\"",
",",
"\"IFD\"",
"+",
"nifd",
",",
"bps",
")",
";",
"// Compression",
"long",
"comp",
"=",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"Compression\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"// if (comp != 1 && comp != 32773)",
"if",
"(",
"comp",
"<",
"1",
")",
"validation",
".",
"addError",
"(",
"\"Invalid Compression\"",
",",
"\"IFD\"",
"+",
"nifd",
",",
"comp",
")",
";",
"}"
] |
Check Pallete Color Image.
@param metadata the metadata
@param nifd the IFD number
|
[
"Check",
"Pallete",
"Color",
"Image",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java#L288-L310
|
11,541
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java
|
BaselineProfile.CheckTransparencyMask
|
private void CheckTransparencyMask(IfdTags metadata, int n) {
// Samples per pixel
if (!metadata.containsTagId(TiffTags.getTagId("SamplesPerPixel"))) {
validation.addErrorLoc("Missing Samples Per Pixel", "IFD" + n);
} else {
long spp = metadata.get(TiffTags.getTagId("SamplesPerPixel")).getFirstNumericValue();
if (spp != 1) {
validation.addError("Invalid Samples Per Pixel", "IFD" + n, spp);
}
}
// BitsPerSample
if (!metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))) {
validation.addErrorLoc("Missing BitsPerSample", "IFD" + n);
} else {
long bps = metadata.get(TiffTags.getTagId("BitsPerSample")).getFirstNumericValue();
if (bps != 1) {
validation.addError("Invalid BitsPerSample", "IFD" + n, bps);
}
}
}
|
java
|
private void CheckTransparencyMask(IfdTags metadata, int n) {
// Samples per pixel
if (!metadata.containsTagId(TiffTags.getTagId("SamplesPerPixel"))) {
validation.addErrorLoc("Missing Samples Per Pixel", "IFD" + n);
} else {
long spp = metadata.get(TiffTags.getTagId("SamplesPerPixel")).getFirstNumericValue();
if (spp != 1) {
validation.addError("Invalid Samples Per Pixel", "IFD" + n, spp);
}
}
// BitsPerSample
if (!metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))) {
validation.addErrorLoc("Missing BitsPerSample", "IFD" + n);
} else {
long bps = metadata.get(TiffTags.getTagId("BitsPerSample")).getFirstNumericValue();
if (bps != 1) {
validation.addError("Invalid BitsPerSample", "IFD" + n, bps);
}
}
}
|
[
"private",
"void",
"CheckTransparencyMask",
"(",
"IfdTags",
"metadata",
",",
"int",
"n",
")",
"{",
"// Samples per pixel",
"if",
"(",
"!",
"metadata",
".",
"containsTagId",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"SamplesPerPixel\"",
")",
")",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Missing Samples Per Pixel\"",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"}",
"else",
"{",
"long",
"spp",
"=",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"SamplesPerPixel\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"if",
"(",
"spp",
"!=",
"1",
")",
"{",
"validation",
".",
"addError",
"(",
"\"Invalid Samples Per Pixel\"",
",",
"\"IFD\"",
"+",
"n",
",",
"spp",
")",
";",
"}",
"}",
"// BitsPerSample",
"if",
"(",
"!",
"metadata",
".",
"containsTagId",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Missing BitsPerSample\"",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"}",
"else",
"{",
"long",
"bps",
"=",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"if",
"(",
"bps",
"!=",
"1",
")",
"{",
"validation",
".",
"addError",
"(",
"\"Invalid BitsPerSample\"",
",",
"\"IFD\"",
"+",
"n",
",",
"bps",
")",
";",
"}",
"}",
"}"
] |
Check transparency mask.
@param metadata the metadata
@param n the ifd number
|
[
"Check",
"transparency",
"mask",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java#L318-L338
|
11,542
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java
|
BaselineProfile.CheckCMYK
|
private void CheckCMYK(IfdTags metadata, int n) {
// Samples per pixel
if (!metadata.containsTagId(TiffTags.getTagId("SamplesPerPixel"))) {
validation.addErrorLoc("Missing Samples Per Pixel", "IFD" + n);
}
// BitsPerSample
if (!metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))) {
validation.addErrorLoc("Missing BitsPerSample", "IFD" + n);
}
}
|
java
|
private void CheckCMYK(IfdTags metadata, int n) {
// Samples per pixel
if (!metadata.containsTagId(TiffTags.getTagId("SamplesPerPixel"))) {
validation.addErrorLoc("Missing Samples Per Pixel", "IFD" + n);
}
// BitsPerSample
if (!metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))) {
validation.addErrorLoc("Missing BitsPerSample", "IFD" + n);
}
}
|
[
"private",
"void",
"CheckCMYK",
"(",
"IfdTags",
"metadata",
",",
"int",
"n",
")",
"{",
"// Samples per pixel",
"if",
"(",
"!",
"metadata",
".",
"containsTagId",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"SamplesPerPixel\"",
")",
")",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Missing Samples Per Pixel\"",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"}",
"// BitsPerSample",
"if",
"(",
"!",
"metadata",
".",
"containsTagId",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Missing BitsPerSample\"",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"}",
"}"
] |
Check CMYK.
@param metadata the metadata
@param n the ifd number
|
[
"Check",
"CMYK",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java#L346-L356
|
11,543
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java
|
BaselineProfile.CheckYCbCr
|
private void CheckYCbCr(IfdTags metadata, int n) {
// Samples per pixel
if (!metadata.containsTagId(TiffTags.getTagId("SamplesPerPixel"))) {
validation.addErrorLoc("Missing Samples Per Pixel", "IFD" + n);
} else {
long spp = metadata.get(TiffTags.getTagId("SamplesPerPixel")).getFirstNumericValue();
if (spp != 3) {
validation.addError("Invalid Samples Per Pixel", "IFD" + n, spp);
}
}
// BitsPerSample
if (!metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))) {
validation.addErrorLoc("Missing BitsPerSample", "IFD" + n);
} else {
for (abstractTiffType vi : metadata.get(TiffTags.getTagId("BitsPerSample")).getValue()) {
if (vi.toInt() != 8) {
validation.addError("Invalid BitsPerSample", "IFD" + n, vi.toInt());
break;
}
}
}
// Compression
// long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
// if (comp != 1 && comp != 5 && comp != 6)
// validation.addError("Invalid Compression", comp);
// if (!metadata.containsTagId(TiffTags.getTagId("ReferenceBlackWhite")))
// validation.addError("Missing ReferenceBlackWhite");
// if (!metadata.containsTagId(TiffTags.getTagId("YCbCrCoefficients")))
// validation.addError("Missing YCbCr Coefficients");
// if (!metadata.containsTagId(TiffTags.getTagId("YCbCrSubSampling")))
// validation.addError("Missing YCbCr SubSampling");
// if (!metadata.containsTagId(TiffTags.getTagId("YCbCrPositioning")))
// validation.addError("Missing YCbCr Positioning");
}
|
java
|
private void CheckYCbCr(IfdTags metadata, int n) {
// Samples per pixel
if (!metadata.containsTagId(TiffTags.getTagId("SamplesPerPixel"))) {
validation.addErrorLoc("Missing Samples Per Pixel", "IFD" + n);
} else {
long spp = metadata.get(TiffTags.getTagId("SamplesPerPixel")).getFirstNumericValue();
if (spp != 3) {
validation.addError("Invalid Samples Per Pixel", "IFD" + n, spp);
}
}
// BitsPerSample
if (!metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))) {
validation.addErrorLoc("Missing BitsPerSample", "IFD" + n);
} else {
for (abstractTiffType vi : metadata.get(TiffTags.getTagId("BitsPerSample")).getValue()) {
if (vi.toInt() != 8) {
validation.addError("Invalid BitsPerSample", "IFD" + n, vi.toInt());
break;
}
}
}
// Compression
// long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
// if (comp != 1 && comp != 5 && comp != 6)
// validation.addError("Invalid Compression", comp);
// if (!metadata.containsTagId(TiffTags.getTagId("ReferenceBlackWhite")))
// validation.addError("Missing ReferenceBlackWhite");
// if (!metadata.containsTagId(TiffTags.getTagId("YCbCrCoefficients")))
// validation.addError("Missing YCbCr Coefficients");
// if (!metadata.containsTagId(TiffTags.getTagId("YCbCrSubSampling")))
// validation.addError("Missing YCbCr SubSampling");
// if (!metadata.containsTagId(TiffTags.getTagId("YCbCrPositioning")))
// validation.addError("Missing YCbCr Positioning");
}
|
[
"private",
"void",
"CheckYCbCr",
"(",
"IfdTags",
"metadata",
",",
"int",
"n",
")",
"{",
"// Samples per pixel",
"if",
"(",
"!",
"metadata",
".",
"containsTagId",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"SamplesPerPixel\"",
")",
")",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Missing Samples Per Pixel\"",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"}",
"else",
"{",
"long",
"spp",
"=",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"SamplesPerPixel\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"if",
"(",
"spp",
"!=",
"3",
")",
"{",
"validation",
".",
"addError",
"(",
"\"Invalid Samples Per Pixel\"",
",",
"\"IFD\"",
"+",
"n",
",",
"spp",
")",
";",
"}",
"}",
"// BitsPerSample",
"if",
"(",
"!",
"metadata",
".",
"containsTagId",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Missing BitsPerSample\"",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"}",
"else",
"{",
"for",
"(",
"abstractTiffType",
"vi",
":",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
".",
"getValue",
"(",
")",
")",
"{",
"if",
"(",
"vi",
".",
"toInt",
"(",
")",
"!=",
"8",
")",
"{",
"validation",
".",
"addError",
"(",
"\"Invalid BitsPerSample\"",
",",
"\"IFD\"",
"+",
"n",
",",
"vi",
".",
"toInt",
"(",
")",
")",
";",
"break",
";",
"}",
"}",
"}",
"// Compression",
"// long comp = metadata.get(TiffTags.getTagId(\"Compression\")).getFirstNumericValue();",
"// if (comp != 1 && comp != 5 && comp != 6)",
"// validation.addError(\"Invalid Compression\", comp);",
"// if (!metadata.containsTagId(TiffTags.getTagId(\"ReferenceBlackWhite\")))",
"// validation.addError(\"Missing ReferenceBlackWhite\");",
"// if (!metadata.containsTagId(TiffTags.getTagId(\"YCbCrCoefficients\")))",
"// validation.addError(\"Missing YCbCr Coefficients\");",
"// if (!metadata.containsTagId(TiffTags.getTagId(\"YCbCrSubSampling\")))",
"// validation.addError(\"Missing YCbCr SubSampling\");",
"// if (!metadata.containsTagId(TiffTags.getTagId(\"YCbCrPositioning\")))",
"// validation.addError(\"Missing YCbCr Positioning\");",
"}"
] |
Check YCbCr.
@param metadata the metadata
@param n the IFD number
|
[
"Check",
"YCbCr",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java#L364-L403
|
11,544
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java
|
BaselineProfile.CheckCIELab
|
private void CheckCIELab(IfdTags metadata, int n) {
// BitsPerSample
if (!metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))) {
validation.addErrorLoc("Missing BitsPerSample", "IFD" + n);
} else {
for (abstractTiffType vi : metadata.get(TiffTags.getTagId("BitsPerSample")).getValue()) {
if (vi.toInt() != 8) {
validation.addError("Invalid BitsPerSample", "IFD" + n, vi.toInt());
break;
}
}
}
}
|
java
|
private void CheckCIELab(IfdTags metadata, int n) {
// BitsPerSample
if (!metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))) {
validation.addErrorLoc("Missing BitsPerSample", "IFD" + n);
} else {
for (abstractTiffType vi : metadata.get(TiffTags.getTagId("BitsPerSample")).getValue()) {
if (vi.toInt() != 8) {
validation.addError("Invalid BitsPerSample", "IFD" + n, vi.toInt());
break;
}
}
}
}
|
[
"private",
"void",
"CheckCIELab",
"(",
"IfdTags",
"metadata",
",",
"int",
"n",
")",
"{",
"// BitsPerSample",
"if",
"(",
"!",
"metadata",
".",
"containsTagId",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Missing BitsPerSample\"",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"}",
"else",
"{",
"for",
"(",
"abstractTiffType",
"vi",
":",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
".",
"getValue",
"(",
")",
")",
"{",
"if",
"(",
"vi",
".",
"toInt",
"(",
")",
"!=",
"8",
")",
"{",
"validation",
".",
"addError",
"(",
"\"Invalid BitsPerSample\"",
",",
"\"IFD\"",
"+",
"n",
",",
"vi",
".",
"toInt",
"(",
")",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] |
Check CIELab.
@param metadata the metadata
@param n the IFD number
|
[
"Check",
"CIELab",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java#L411-L423
|
11,545
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java
|
BaselineProfile.CheckRGBImage
|
private void CheckRGBImage(IfdTags metadata, int n) {
// Samples per Pixel
long samples = metadata.get(TiffTags.getTagId("SamplesPerPixel")).getFirstNumericValue();
if (samples < 3)
validation.addError("Invalid Samples per Pixel", "IFD" + n, samples);
// Compression
long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
// if (comp != 1 && comp != 32773)
if (comp < 1)
validation.addError("Invalid Compression", "IFD" + n, comp);
}
|
java
|
private void CheckRGBImage(IfdTags metadata, int n) {
// Samples per Pixel
long samples = metadata.get(TiffTags.getTagId("SamplesPerPixel")).getFirstNumericValue();
if (samples < 3)
validation.addError("Invalid Samples per Pixel", "IFD" + n, samples);
// Compression
long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
// if (comp != 1 && comp != 32773)
if (comp < 1)
validation.addError("Invalid Compression", "IFD" + n, comp);
}
|
[
"private",
"void",
"CheckRGBImage",
"(",
"IfdTags",
"metadata",
",",
"int",
"n",
")",
"{",
"// Samples per Pixel",
"long",
"samples",
"=",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"SamplesPerPixel\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"if",
"(",
"samples",
"<",
"3",
")",
"validation",
".",
"addError",
"(",
"\"Invalid Samples per Pixel\"",
",",
"\"IFD\"",
"+",
"n",
",",
"samples",
")",
";",
"// Compression",
"long",
"comp",
"=",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"Compression\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"// if (comp != 1 && comp != 32773)",
"if",
"(",
"comp",
"<",
"1",
")",
"validation",
".",
"addError",
"(",
"\"Invalid Compression\"",
",",
"\"IFD\"",
"+",
"n",
",",
"comp",
")",
";",
"}"
] |
Check RGB Image.
@param metadata the metadata
@param n the IFD number
|
[
"Check",
"RGB",
"Image",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java#L431-L442
|
11,546
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java
|
BaselineProfile.CheckStrips
|
private void CheckStrips(IfdTags metadata, int n) {
long offset;
int id;
// Strip offsets
id = TiffTags.getTagId("StripOffsets");
offset = metadata.get(id).getFirstNumericValue();
int nso = metadata.get(id).getCardinality();
if (offset <= 0)
validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
offset);
// Strip Byte Counts
id = TiffTags.getTagId("StripBYTECount");
offset = metadata.get(id).getFirstNumericValue();
int nsc = metadata.get(id).getCardinality();
if (offset <= 0)
validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
offset);
if (nso != nsc) {
validation.addErrorLoc("Inconsistent strip lengths", "IFD" + n);
}
int pixelSize = 0;
for (int i = 0; i < metadata.get("BitsPerSample").getCardinality(); i++) {
pixelSize += metadata.get("BitsPerSample").getValue().get(i).toInt();
}
if (metadata.get("Compression").getFirstNumericValue() == 1
&& pixelSize >= 8) {
int calculatedImageLength = 0;
for (int i = 0; i < nsc; i++) {
calculatedImageLength += metadata.get(id).getValue().get(i).toInt();
}
if (calculatedImageLength != metadata.get("ImageLength").getFirstNumericValue()
* metadata.get("ImageWidth").getFirstNumericValue() * pixelSize / 8) {
// validation.toString();
validation.addErrorLoc("Calculated and declared image size do not match", "IFD" + n);
}
}
// Rows per Strip
id = TiffTags.getTagId("RowsPerStrip");
if (!metadata.containsTagId(id)) {
if (rowsPerStripTolerance > 0)
validation.addWarning("Missing required field", TiffTags.getTag(id).getName(), "IFD" + n);
else
validation.addError("Missing required field", "IFD" + n, TiffTags.getTag(id).getName());
} else {
offset = metadata.get(id).getFirstNumericValue();
if (offset <= 0)
validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
offset);
}
}
|
java
|
private void CheckStrips(IfdTags metadata, int n) {
long offset;
int id;
// Strip offsets
id = TiffTags.getTagId("StripOffsets");
offset = metadata.get(id).getFirstNumericValue();
int nso = metadata.get(id).getCardinality();
if (offset <= 0)
validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
offset);
// Strip Byte Counts
id = TiffTags.getTagId("StripBYTECount");
offset = metadata.get(id).getFirstNumericValue();
int nsc = metadata.get(id).getCardinality();
if (offset <= 0)
validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
offset);
if (nso != nsc) {
validation.addErrorLoc("Inconsistent strip lengths", "IFD" + n);
}
int pixelSize = 0;
for (int i = 0; i < metadata.get("BitsPerSample").getCardinality(); i++) {
pixelSize += metadata.get("BitsPerSample").getValue().get(i).toInt();
}
if (metadata.get("Compression").getFirstNumericValue() == 1
&& pixelSize >= 8) {
int calculatedImageLength = 0;
for (int i = 0; i < nsc; i++) {
calculatedImageLength += metadata.get(id).getValue().get(i).toInt();
}
if (calculatedImageLength != metadata.get("ImageLength").getFirstNumericValue()
* metadata.get("ImageWidth").getFirstNumericValue() * pixelSize / 8) {
// validation.toString();
validation.addErrorLoc("Calculated and declared image size do not match", "IFD" + n);
}
}
// Rows per Strip
id = TiffTags.getTagId("RowsPerStrip");
if (!metadata.containsTagId(id)) {
if (rowsPerStripTolerance > 0)
validation.addWarning("Missing required field", TiffTags.getTag(id).getName(), "IFD" + n);
else
validation.addError("Missing required field", "IFD" + n, TiffTags.getTag(id).getName());
} else {
offset = metadata.get(id).getFirstNumericValue();
if (offset <= 0)
validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
offset);
}
}
|
[
"private",
"void",
"CheckStrips",
"(",
"IfdTags",
"metadata",
",",
"int",
"n",
")",
"{",
"long",
"offset",
";",
"int",
"id",
";",
"// Strip offsets",
"id",
"=",
"TiffTags",
".",
"getTagId",
"(",
"\"StripOffsets\"",
")",
";",
"offset",
"=",
"metadata",
".",
"get",
"(",
"id",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"int",
"nso",
"=",
"metadata",
".",
"get",
"(",
"id",
")",
".",
"getCardinality",
"(",
")",
";",
"if",
"(",
"offset",
"<=",
"0",
")",
"validation",
".",
"addError",
"(",
"\"Invalid value for field \"",
"+",
"TiffTags",
".",
"getTag",
"(",
"id",
")",
".",
"getName",
"(",
")",
",",
"\"IFD\"",
"+",
"n",
",",
"offset",
")",
";",
"// Strip Byte Counts",
"id",
"=",
"TiffTags",
".",
"getTagId",
"(",
"\"StripBYTECount\"",
")",
";",
"offset",
"=",
"metadata",
".",
"get",
"(",
"id",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"int",
"nsc",
"=",
"metadata",
".",
"get",
"(",
"id",
")",
".",
"getCardinality",
"(",
")",
";",
"if",
"(",
"offset",
"<=",
"0",
")",
"validation",
".",
"addError",
"(",
"\"Invalid value for field \"",
"+",
"TiffTags",
".",
"getTag",
"(",
"id",
")",
".",
"getName",
"(",
")",
",",
"\"IFD\"",
"+",
"n",
",",
"offset",
")",
";",
"if",
"(",
"nso",
"!=",
"nsc",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Inconsistent strip lengths\"",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"}",
"int",
"pixelSize",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"metadata",
".",
"get",
"(",
"\"BitsPerSample\"",
")",
".",
"getCardinality",
"(",
")",
";",
"i",
"++",
")",
"{",
"pixelSize",
"+=",
"metadata",
".",
"get",
"(",
"\"BitsPerSample\"",
")",
".",
"getValue",
"(",
")",
".",
"get",
"(",
"i",
")",
".",
"toInt",
"(",
")",
";",
"}",
"if",
"(",
"metadata",
".",
"get",
"(",
"\"Compression\"",
")",
".",
"getFirstNumericValue",
"(",
")",
"==",
"1",
"&&",
"pixelSize",
">=",
"8",
")",
"{",
"int",
"calculatedImageLength",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nsc",
";",
"i",
"++",
")",
"{",
"calculatedImageLength",
"+=",
"metadata",
".",
"get",
"(",
"id",
")",
".",
"getValue",
"(",
")",
".",
"get",
"(",
"i",
")",
".",
"toInt",
"(",
")",
";",
"}",
"if",
"(",
"calculatedImageLength",
"!=",
"metadata",
".",
"get",
"(",
"\"ImageLength\"",
")",
".",
"getFirstNumericValue",
"(",
")",
"*",
"metadata",
".",
"get",
"(",
"\"ImageWidth\"",
")",
".",
"getFirstNumericValue",
"(",
")",
"*",
"pixelSize",
"/",
"8",
")",
"{",
"// validation.toString();",
"validation",
".",
"addErrorLoc",
"(",
"\"Calculated and declared image size do not match\"",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"}",
"}",
"// Rows per Strip",
"id",
"=",
"TiffTags",
".",
"getTagId",
"(",
"\"RowsPerStrip\"",
")",
";",
"if",
"(",
"!",
"metadata",
".",
"containsTagId",
"(",
"id",
")",
")",
"{",
"if",
"(",
"rowsPerStripTolerance",
">",
"0",
")",
"validation",
".",
"addWarning",
"(",
"\"Missing required field\"",
",",
"TiffTags",
".",
"getTag",
"(",
"id",
")",
".",
"getName",
"(",
")",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"else",
"validation",
".",
"addError",
"(",
"\"Missing required field\"",
",",
"\"IFD\"",
"+",
"n",
",",
"TiffTags",
".",
"getTag",
"(",
"id",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"offset",
"=",
"metadata",
".",
"get",
"(",
"id",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"if",
"(",
"offset",
"<=",
"0",
")",
"validation",
".",
"addError",
"(",
"\"Invalid value for field \"",
"+",
"TiffTags",
".",
"getTag",
"(",
"id",
")",
".",
"getName",
"(",
")",
",",
"\"IFD\"",
"+",
"n",
",",
"offset",
")",
";",
"}",
"}"
] |
Check that the strips containing the image are well-formed.
@param metadata the metadata
@param n the IFD number
|
[
"Check",
"that",
"the",
"strips",
"containing",
"the",
"image",
"are",
"well",
"-",
"formed",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java#L592-L646
|
11,547
|
maxirosson/jdroid-android
|
jdroid-android-core/src/main/java/com/jdroid/android/utils/SharedPreferencesHelper.java
|
SharedPreferencesHelper.loadPreference
|
public String loadPreference(String key, String defaultValue) {
String value = getSharedPreferences().getString(key, defaultValue);
logLoad(key, value);
return value;
}
|
java
|
public String loadPreference(String key, String defaultValue) {
String value = getSharedPreferences().getString(key, defaultValue);
logLoad(key, value);
return value;
}
|
[
"public",
"String",
"loadPreference",
"(",
"String",
"key",
",",
"String",
"defaultValue",
")",
"{",
"String",
"value",
"=",
"getSharedPreferences",
"(",
")",
".",
"getString",
"(",
"key",
",",
"defaultValue",
")",
";",
"logLoad",
"(",
"key",
",",
"value",
")",
";",
"return",
"value",
";",
"}"
] |
Retrieve a string value from the preferences.
@param key The name of the preference to retrieve
@param defaultValue Value to return if this preference does not exist
@return the preference value if it exists, or defaultValue.
|
[
"Retrieve",
"a",
"string",
"value",
"from",
"the",
"preferences",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/utils/SharedPreferencesHelper.java#L179-L183
|
11,548
|
maxirosson/jdroid-android
|
jdroid-android-core/src/main/java/com/jdroid/android/utils/SharedPreferencesHelper.java
|
SharedPreferencesHelper.loadPreferenceAsBoolean
|
public Boolean loadPreferenceAsBoolean(String key, Boolean defaultValue) {
Boolean value = defaultValue;
if (hasPreference(key)) {
value = getSharedPreferences().getBoolean(key, false);
}
logLoad(key, value);
return value;
}
|
java
|
public Boolean loadPreferenceAsBoolean(String key, Boolean defaultValue) {
Boolean value = defaultValue;
if (hasPreference(key)) {
value = getSharedPreferences().getBoolean(key, false);
}
logLoad(key, value);
return value;
}
|
[
"public",
"Boolean",
"loadPreferenceAsBoolean",
"(",
"String",
"key",
",",
"Boolean",
"defaultValue",
")",
"{",
"Boolean",
"value",
"=",
"defaultValue",
";",
"if",
"(",
"hasPreference",
"(",
"key",
")",
")",
"{",
"value",
"=",
"getSharedPreferences",
"(",
")",
".",
"getBoolean",
"(",
"key",
",",
"false",
")",
";",
"}",
"logLoad",
"(",
"key",
",",
"value",
")",
";",
"return",
"value",
";",
"}"
] |
Retrieve a boolean value from the preferences.
@param key The name of the preference to retrieve
@param defaultValue Value to return if this preference does not exist
@return the preference value if it exists, or defaultValue.
|
[
"Retrieve",
"a",
"boolean",
"value",
"from",
"the",
"preferences",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/utils/SharedPreferencesHelper.java#L202-L209
|
11,549
|
maxirosson/jdroid-android
|
jdroid-android-core/src/main/java/com/jdroid/android/utils/SharedPreferencesHelper.java
|
SharedPreferencesHelper.loadPreferenceAsLong
|
public Long loadPreferenceAsLong(String key, Long defaultValue) {
Long value = defaultValue;
if (hasPreference(key)) {
value = getSharedPreferences().getLong(key, 0L);
}
logLoad(key, value);
return value;
}
|
java
|
public Long loadPreferenceAsLong(String key, Long defaultValue) {
Long value = defaultValue;
if (hasPreference(key)) {
value = getSharedPreferences().getLong(key, 0L);
}
logLoad(key, value);
return value;
}
|
[
"public",
"Long",
"loadPreferenceAsLong",
"(",
"String",
"key",
",",
"Long",
"defaultValue",
")",
"{",
"Long",
"value",
"=",
"defaultValue",
";",
"if",
"(",
"hasPreference",
"(",
"key",
")",
")",
"{",
"value",
"=",
"getSharedPreferences",
"(",
")",
".",
"getLong",
"(",
"key",
",",
"0L",
")",
";",
"}",
"logLoad",
"(",
"key",
",",
"value",
")",
";",
"return",
"value",
";",
"}"
] |
Retrieve a long value from the preferences.
@param key The name of the preference to retrieve
@param defaultValue Value to return if this preference does not exist
@return the preference value if it exists, or defaultValue.
|
[
"Retrieve",
"a",
"long",
"value",
"from",
"the",
"preferences",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/utils/SharedPreferencesHelper.java#L228-L236
|
11,550
|
maxirosson/jdroid-android
|
jdroid-android-core/src/main/java/com/jdroid/android/utils/SharedPreferencesHelper.java
|
SharedPreferencesHelper.loadPreferenceAsInteger
|
public Integer loadPreferenceAsInteger(String key, Integer defaultValue) {
Integer value = defaultValue;
if (hasPreference(key)) {
value = getSharedPreferences().getInt(key, 0);
}
logLoad(key, value);
return value;
}
|
java
|
public Integer loadPreferenceAsInteger(String key, Integer defaultValue) {
Integer value = defaultValue;
if (hasPreference(key)) {
value = getSharedPreferences().getInt(key, 0);
}
logLoad(key, value);
return value;
}
|
[
"public",
"Integer",
"loadPreferenceAsInteger",
"(",
"String",
"key",
",",
"Integer",
"defaultValue",
")",
"{",
"Integer",
"value",
"=",
"defaultValue",
";",
"if",
"(",
"hasPreference",
"(",
"key",
")",
")",
"{",
"value",
"=",
"getSharedPreferences",
"(",
")",
".",
"getInt",
"(",
"key",
",",
"0",
")",
";",
"}",
"logLoad",
"(",
"key",
",",
"value",
")",
";",
"return",
"value",
";",
"}"
] |
Retrieve an Integer value from the preferences.
@param key The name of the preference to retrieve
@param defaultValue Value to return if this preference does not exist
@return the preference value if it exists, or defaultValue.
|
[
"Retrieve",
"an",
"Integer",
"value",
"from",
"the",
"preferences",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/utils/SharedPreferencesHelper.java#L255-L262
|
11,551
|
maxirosson/jdroid-android
|
jdroid-android-core/src/main/java/com/jdroid/android/utils/SharedPreferencesHelper.java
|
SharedPreferencesHelper.loadPreferenceAsFloat
|
public Float loadPreferenceAsFloat(String key, Float defaultValue) {
Float value = defaultValue;
if (hasPreference(key)) {
value = getSharedPreferences().getFloat(key, 0);
}
logLoad(key, value);
return value;
}
|
java
|
public Float loadPreferenceAsFloat(String key, Float defaultValue) {
Float value = defaultValue;
if (hasPreference(key)) {
value = getSharedPreferences().getFloat(key, 0);
}
logLoad(key, value);
return value;
}
|
[
"public",
"Float",
"loadPreferenceAsFloat",
"(",
"String",
"key",
",",
"Float",
"defaultValue",
")",
"{",
"Float",
"value",
"=",
"defaultValue",
";",
"if",
"(",
"hasPreference",
"(",
"key",
")",
")",
"{",
"value",
"=",
"getSharedPreferences",
"(",
")",
".",
"getFloat",
"(",
"key",
",",
"0",
")",
";",
"}",
"logLoad",
"(",
"key",
",",
"value",
")",
";",
"return",
"value",
";",
"}"
] |
Retrieve a Float value from the preferences.
@param key The name of the preference to retrieve
@param defaultValue Value to return if this preference does not exist
@return the preference value if it exists, or defaultValue.
|
[
"Retrieve",
"a",
"Float",
"value",
"from",
"the",
"preferences",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/utils/SharedPreferencesHelper.java#L281-L288
|
11,552
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/fileio/filetypes/mzml/MZMLMultiSpectraParser.java
|
MZMLMultiSpectraParser.mapIdRefToInternalScanNum
|
protected int mapIdRefToInternalScanNum(CharArray id) throws FileParsingException {
String idStr = id.toString();
MZMLIndexElement byId = index.getById(idStr);
if (byId == null) {
String msg = String.format("Could not find a mapping from spectrum id"
+ " ref to an internal scan number for"
+ "\n\t file: %s"
+ "\n\t spectrum index of the spectrum in which the error occured: #%d"
+ "\n\t idRef searched for: %s", source.getPath(), vars.spectrumIndex, idStr);
throw new FileParsingException(msg);
}
return byId.getNumber();
}
|
java
|
protected int mapIdRefToInternalScanNum(CharArray id) throws FileParsingException {
String idStr = id.toString();
MZMLIndexElement byId = index.getById(idStr);
if (byId == null) {
String msg = String.format("Could not find a mapping from spectrum id"
+ " ref to an internal scan number for"
+ "\n\t file: %s"
+ "\n\t spectrum index of the spectrum in which the error occured: #%d"
+ "\n\t idRef searched for: %s", source.getPath(), vars.spectrumIndex, idStr);
throw new FileParsingException(msg);
}
return byId.getNumber();
}
|
[
"protected",
"int",
"mapIdRefToInternalScanNum",
"(",
"CharArray",
"id",
")",
"throws",
"FileParsingException",
"{",
"String",
"idStr",
"=",
"id",
".",
"toString",
"(",
")",
";",
"MZMLIndexElement",
"byId",
"=",
"index",
".",
"getById",
"(",
"idStr",
")",
";",
"if",
"(",
"byId",
"==",
"null",
")",
"{",
"String",
"msg",
"=",
"String",
".",
"format",
"(",
"\"Could not find a mapping from spectrum id\"",
"+",
"\" ref to an internal scan number for\"",
"+",
"\"\\n\\t file: %s\"",
"+",
"\"\\n\\t spectrum index of the spectrum in which the error occured: #%d\"",
"+",
"\"\\n\\t idRef searched for: %s\"",
",",
"source",
".",
"getPath",
"(",
")",
",",
"vars",
".",
"spectrumIndex",
",",
"idStr",
")",
";",
"throw",
"new",
"FileParsingException",
"(",
"msg",
")",
";",
"}",
"return",
"byId",
".",
"getNumber",
"(",
")",
";",
"}"
] |
Given a scan ID goes to the index and tries to find a mapping.
@throws umich.ms.fileio.exceptions.FileParsingException in case the mapping can't be done
|
[
"Given",
"a",
"scan",
"ID",
"goes",
"to",
"the",
"index",
"and",
"tries",
"to",
"find",
"a",
"mapping",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/fileio/filetypes/mzml/MZMLMultiSpectraParser.java#L869-L881
|
11,553
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/util/xml/XmlUtils.java
|
XmlUtils.locate
|
public static List<Long> locate(List<byte[]> targets, List<POSITION> locations,
InputStream is, long maxOffset) throws IOException {
if (targets.isEmpty()) {
throw new IllegalArgumentException("Targets argument can't be empty");
}
if (locations.size() != targets.size()) {
throw new IllegalArgumentException("Targets and Locations arguments must be of equal length");
}
for (byte[] target : targets) {
if (target.length == 0) {
throw new IllegalArgumentException("Input Targets must be non-zero length");
}
}
if (maxOffset <= 0) {
maxOffset = Long.MAX_VALUE;
}
long posSource = -1;
int iRead;
byte bRead;
List<Long> result = new ArrayList<>(targets.size());
for (int i = 0; i < targets.size(); i++) {
byte[] target = targets.get(i);
int posTarget = 0;
byte bTarget = target[posTarget];
while ((iRead = is.read()) >= 0) {
posSource++;
if (posSource > maxOffset) {
// reached max allowed offset, returning what we have so far
return result;
}
bRead = (byte) iRead;
if (bRead != bTarget) {
if (posTarget > 0) {
posTarget = 0;
bTarget = target[posTarget];
}
continue;
} else {
posTarget++;
if (posTarget == target.length) {
// the end of target has been reached, add it to result
switch (locations.get(i)) {
case START:
result.add(posSource - target.length + 1);
break;
case END:
result.add(posSource);
break;
default:
throw new IllegalArgumentException("Unsupported ELEMENT_LOCATION");
}
// move to next target
break; // break out of while(is.read())
}
bTarget = target[posTarget];
continue;
}
}
if (iRead < 0 && result.size() != targets.size()) {
// reached EOF without finding all the targets in the input stream
return Collections.emptyList();
}
}
return result;
}
|
java
|
public static List<Long> locate(List<byte[]> targets, List<POSITION> locations,
InputStream is, long maxOffset) throws IOException {
if (targets.isEmpty()) {
throw new IllegalArgumentException("Targets argument can't be empty");
}
if (locations.size() != targets.size()) {
throw new IllegalArgumentException("Targets and Locations arguments must be of equal length");
}
for (byte[] target : targets) {
if (target.length == 0) {
throw new IllegalArgumentException("Input Targets must be non-zero length");
}
}
if (maxOffset <= 0) {
maxOffset = Long.MAX_VALUE;
}
long posSource = -1;
int iRead;
byte bRead;
List<Long> result = new ArrayList<>(targets.size());
for (int i = 0; i < targets.size(); i++) {
byte[] target = targets.get(i);
int posTarget = 0;
byte bTarget = target[posTarget];
while ((iRead = is.read()) >= 0) {
posSource++;
if (posSource > maxOffset) {
// reached max allowed offset, returning what we have so far
return result;
}
bRead = (byte) iRead;
if (bRead != bTarget) {
if (posTarget > 0) {
posTarget = 0;
bTarget = target[posTarget];
}
continue;
} else {
posTarget++;
if (posTarget == target.length) {
// the end of target has been reached, add it to result
switch (locations.get(i)) {
case START:
result.add(posSource - target.length + 1);
break;
case END:
result.add(posSource);
break;
default:
throw new IllegalArgumentException("Unsupported ELEMENT_LOCATION");
}
// move to next target
break; // break out of while(is.read())
}
bTarget = target[posTarget];
continue;
}
}
if (iRead < 0 && result.size() != targets.size()) {
// reached EOF without finding all the targets in the input stream
return Collections.emptyList();
}
}
return result;
}
|
[
"public",
"static",
"List",
"<",
"Long",
">",
"locate",
"(",
"List",
"<",
"byte",
"[",
"]",
">",
"targets",
",",
"List",
"<",
"POSITION",
">",
"locations",
",",
"InputStream",
"is",
",",
"long",
"maxOffset",
")",
"throws",
"IOException",
"{",
"if",
"(",
"targets",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Targets argument can't be empty\"",
")",
";",
"}",
"if",
"(",
"locations",
".",
"size",
"(",
")",
"!=",
"targets",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Targets and Locations arguments must be of equal length\"",
")",
";",
"}",
"for",
"(",
"byte",
"[",
"]",
"target",
":",
"targets",
")",
"{",
"if",
"(",
"target",
".",
"length",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Input Targets must be non-zero length\"",
")",
";",
"}",
"}",
"if",
"(",
"maxOffset",
"<=",
"0",
")",
"{",
"maxOffset",
"=",
"Long",
".",
"MAX_VALUE",
";",
"}",
"long",
"posSource",
"=",
"-",
"1",
";",
"int",
"iRead",
";",
"byte",
"bRead",
";",
"List",
"<",
"Long",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
"targets",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"targets",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"byte",
"[",
"]",
"target",
"=",
"targets",
".",
"get",
"(",
"i",
")",
";",
"int",
"posTarget",
"=",
"0",
";",
"byte",
"bTarget",
"=",
"target",
"[",
"posTarget",
"]",
";",
"while",
"(",
"(",
"iRead",
"=",
"is",
".",
"read",
"(",
")",
")",
">=",
"0",
")",
"{",
"posSource",
"++",
";",
"if",
"(",
"posSource",
">",
"maxOffset",
")",
"{",
"// reached max allowed offset, returning what we have so far\r",
"return",
"result",
";",
"}",
"bRead",
"=",
"(",
"byte",
")",
"iRead",
";",
"if",
"(",
"bRead",
"!=",
"bTarget",
")",
"{",
"if",
"(",
"posTarget",
">",
"0",
")",
"{",
"posTarget",
"=",
"0",
";",
"bTarget",
"=",
"target",
"[",
"posTarget",
"]",
";",
"}",
"continue",
";",
"}",
"else",
"{",
"posTarget",
"++",
";",
"if",
"(",
"posTarget",
"==",
"target",
".",
"length",
")",
"{",
"// the end of target has been reached, add it to result\r",
"switch",
"(",
"locations",
".",
"get",
"(",
"i",
")",
")",
"{",
"case",
"START",
":",
"result",
".",
"add",
"(",
"posSource",
"-",
"target",
".",
"length",
"+",
"1",
")",
";",
"break",
";",
"case",
"END",
":",
"result",
".",
"add",
"(",
"posSource",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported ELEMENT_LOCATION\"",
")",
";",
"}",
"// move to next target\r",
"break",
";",
"// break out of while(is.read())\r",
"}",
"bTarget",
"=",
"target",
"[",
"posTarget",
"]",
";",
"continue",
";",
"}",
"}",
"if",
"(",
"iRead",
"<",
"0",
"&&",
"result",
".",
"size",
"(",
")",
"!=",
"targets",
".",
"size",
"(",
")",
")",
"{",
"// reached EOF without finding all the targets in the input stream\r",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Locates specific sequences of bytes in the input stream.
@param targets Sequences of bytes to be searched for. The returned list will be of the same
size if all are found.
@param is The stream to search in, it won't be buffered, the stream will be left open and at
the position of the last occurrence of the target.
@param maxOffset How far down the stream to search? if maxOffset <= 0, then search indefinitely
up to Long.MAX_VALUE bytes.
@return Empty list if the exact sub-sequence was not found in the stream. An incomplete list of
matches (possibly empty) if the 'maxOffset' has been reached. Otherwise byte offsets in the
input stream will be returned.
@throws IOException In case IO errors occur.
|
[
"Locates",
"specific",
"sequences",
"of",
"bytes",
"in",
"the",
"input",
"stream",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/util/xml/XmlUtils.java#L58-L127
|
11,554
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/util/xml/XmlUtils.java
|
XmlUtils.advanceReaderToNext
|
public static boolean advanceReaderToNext(XMLStreamReader xsr, String tag)
throws javax.xml.stream.XMLStreamException {
if (tag == null) {
throw new IllegalArgumentException("Tag name can't be null");
}
if (xsr == null) {
throw new IllegalArgumentException("Stream Reader can't be null");
}
do {
if (xsr.next() == javax.xml.stream.XMLStreamConstants.END_DOCUMENT) {
return false;
}
} while (!(xsr.isStartElement() && xsr.getLocalName().equals(tag)));
return true;
}
|
java
|
public static boolean advanceReaderToNext(XMLStreamReader xsr, String tag)
throws javax.xml.stream.XMLStreamException {
if (tag == null) {
throw new IllegalArgumentException("Tag name can't be null");
}
if (xsr == null) {
throw new IllegalArgumentException("Stream Reader can't be null");
}
do {
if (xsr.next() == javax.xml.stream.XMLStreamConstants.END_DOCUMENT) {
return false;
}
} while (!(xsr.isStartElement() && xsr.getLocalName().equals(tag)));
return true;
}
|
[
"public",
"static",
"boolean",
"advanceReaderToNext",
"(",
"XMLStreamReader",
"xsr",
",",
"String",
"tag",
")",
"throws",
"javax",
".",
"xml",
".",
"stream",
".",
"XMLStreamException",
"{",
"if",
"(",
"tag",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Tag name can't be null\"",
")",
";",
"}",
"if",
"(",
"xsr",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Stream Reader can't be null\"",
")",
";",
"}",
"do",
"{",
"if",
"(",
"xsr",
".",
"next",
"(",
")",
"==",
"javax",
".",
"xml",
".",
"stream",
".",
"XMLStreamConstants",
".",
"END_DOCUMENT",
")",
"{",
"return",
"false",
";",
"}",
"}",
"while",
"(",
"!",
"(",
"xsr",
".",
"isStartElement",
"(",
")",
"&&",
"xsr",
".",
"getLocalName",
"(",
")",
".",
"equals",
"(",
"tag",
")",
")",
")",
";",
"return",
"true",
";",
"}"
] |
Advances the Stream Reader to the next occurrence of a user-specified tag.
@param xsr The reader to advance.
@param tag The tag to advance to. No brackets, just the name.
@return True if advanced successfully, false when the end of document was successfully reached.
@throws javax.xml.stream.XMLStreamException In all cases other than described by 'return'.
|
[
"Advances",
"the",
"Stream",
"Reader",
"to",
"the",
"next",
"occurrence",
"of",
"a",
"user",
"-",
"specified",
"tag",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/util/xml/XmlUtils.java#L256-L271
|
11,555
|
maxirosson/jdroid-android
|
jdroid-android-core/src/main/java/com/jdroid/android/utils/LocalizationUtils.java
|
LocalizationUtils.getString
|
public static String getString(int resId, Object... args) {
return AbstractApplication.get().getString(resId, args);
}
|
java
|
public static String getString(int resId, Object... args) {
return AbstractApplication.get().getString(resId, args);
}
|
[
"public",
"static",
"String",
"getString",
"(",
"int",
"resId",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"AbstractApplication",
".",
"get",
"(",
")",
".",
"getString",
"(",
"resId",
",",
"args",
")",
";",
"}"
] |
Returns a formatted string, using the localized resource as format and the supplied arguments
@param resId The resource id to obtain the format
@param args arguments to replace format specifiers
@return The localized and formatted string
|
[
"Returns",
"a",
"formatted",
"string",
"using",
"the",
"localized",
"resource",
"as",
"format",
"and",
"the",
"supplied",
"arguments"
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/utils/LocalizationUtils.java#L15-L17
|
11,556
|
matzew/simple-websocket-client
|
src/main/java/net/wessendorf/websocket/SimpleWebSocketClient.java
|
SimpleWebSocketClient.connect
|
public void connect() {
readyState = ReadyState.CONNECTING;
try {
if (webSocketHandler == null) {
webSocketHandler = new WebSocketHandlerAdapter();
}
container.connectToServer(new SimpleWebSocketClientEndpoint(), ClientEndpointConfig.Builder.create().build(), websocketURI);
} catch (Exception e) {
readyState = ReadyState.CLOSED;
// throws DeploymentException, IOException
throw new RuntimeException("could not establish connection");
}
}
|
java
|
public void connect() {
readyState = ReadyState.CONNECTING;
try {
if (webSocketHandler == null) {
webSocketHandler = new WebSocketHandlerAdapter();
}
container.connectToServer(new SimpleWebSocketClientEndpoint(), ClientEndpointConfig.Builder.create().build(), websocketURI);
} catch (Exception e) {
readyState = ReadyState.CLOSED;
// throws DeploymentException, IOException
throw new RuntimeException("could not establish connection");
}
}
|
[
"public",
"void",
"connect",
"(",
")",
"{",
"readyState",
"=",
"ReadyState",
".",
"CONNECTING",
";",
"try",
"{",
"if",
"(",
"webSocketHandler",
"==",
"null",
")",
"{",
"webSocketHandler",
"=",
"new",
"WebSocketHandlerAdapter",
"(",
")",
";",
"}",
"container",
".",
"connectToServer",
"(",
"new",
"SimpleWebSocketClientEndpoint",
"(",
")",
",",
"ClientEndpointConfig",
".",
"Builder",
".",
"create",
"(",
")",
".",
"build",
"(",
")",
",",
"websocketURI",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"readyState",
"=",
"ReadyState",
".",
"CLOSED",
";",
"// throws DeploymentException, IOException",
"throw",
"new",
"RuntimeException",
"(",
"\"could not establish connection\"",
")",
";",
"}",
"}"
] |
Establishes the connection to the given WebSocket Server Address.
|
[
"Establishes",
"the",
"connection",
"to",
"the",
"given",
"WebSocket",
"Server",
"Address",
"."
] |
67c207de9de2310feddf70cf90994b1af028b012
|
https://github.com/matzew/simple-websocket-client/blob/67c207de9de2310feddf70cf90994b1af028b012/src/main/java/net/wessendorf/websocket/SimpleWebSocketClient.java#L82-L99
|
11,557
|
matzew/simple-websocket-client
|
src/main/java/net/wessendorf/websocket/SimpleWebSocketClient.java
|
SimpleWebSocketClient.close
|
public void close() {
readyState = ReadyState.CLOSING;
try {
webSocketSession.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, null));
} catch (IOException e) {
e.printStackTrace();
}
}
|
java
|
public void close() {
readyState = ReadyState.CLOSING;
try {
webSocketSession.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, null));
} catch (IOException e) {
e.printStackTrace();
}
}
|
[
"public",
"void",
"close",
"(",
")",
"{",
"readyState",
"=",
"ReadyState",
".",
"CLOSING",
";",
"try",
"{",
"webSocketSession",
".",
"close",
"(",
"new",
"CloseReason",
"(",
"CloseReason",
".",
"CloseCodes",
".",
"NORMAL_CLOSURE",
",",
"null",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] |
Shutting down the current connection.
|
[
"Shutting",
"down",
"the",
"current",
"connection",
"."
] |
67c207de9de2310feddf70cf90994b1af028b012
|
https://github.com/matzew/simple-websocket-client/blob/67c207de9de2310feddf70cf90994b1af028b012/src/main/java/net/wessendorf/websocket/SimpleWebSocketClient.java#L104-L112
|
11,558
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSRangeSet.java
|
LCMSRangeSet.add
|
public void add(LCMSRange range) {
Integer msLevel = range.getMsLevel();
DoubleRange mzRange = range.getMzRange();
Range<Integer> scanRange = range.getScanRange();
if (msLevel == null) {
// add to the top level range set
anyLvlSet.add(scanRange);
// remove from all underlying sets
for (Map.Entry<Integer, MsLevelRangeSet> lvlMapEntry : lvlMap.entrySet()) {
MsLevelRangeSet msLevelRangeSet = lvlMapEntry.getValue();
msLevelRangeSet.removeFromAll(range);
}
return;
}
TreeRangeSet<Integer> scanRangeLeft = TreeRangeSet.create();
scanRangeLeft.removeAll(anyLvlSet);
if (scanRangeLeft.isEmpty()) {
return; // if there's nothing left in the scan range, just stop
}
MsLevelRangeSet msLvlRanges = lvlMap.get(msLevel);
if (msLvlRanges == null) {
msLvlRanges = new MsLevelRangeSet();
lvlMap.put(msLevel, msLvlRanges);
}
if (mzRange == null) {
// add to any-mz-range range set
msLvlRanges.anyPrecursorSet.addAll(scanRangeLeft);
// remove from all specific mz-range sets
msLvlRanges.removeFromSpecific(range);
return;
}
scanRangeLeft.removeAll(msLvlRanges.anyPrecursorSet);
if (scanRangeLeft.isEmpty()) {
return;
}
RangeSet<Integer> rangeSetForMzRange = msLvlRanges.rngMap.get(mzRange);
if (rangeSetForMzRange == null) {
rangeSetForMzRange = TreeRangeSet.create();
msLvlRanges.rngMap.put(mzRange, rangeSetForMzRange);
}
rangeSetForMzRange.addAll(scanRangeLeft);
}
|
java
|
public void add(LCMSRange range) {
Integer msLevel = range.getMsLevel();
DoubleRange mzRange = range.getMzRange();
Range<Integer> scanRange = range.getScanRange();
if (msLevel == null) {
// add to the top level range set
anyLvlSet.add(scanRange);
// remove from all underlying sets
for (Map.Entry<Integer, MsLevelRangeSet> lvlMapEntry : lvlMap.entrySet()) {
MsLevelRangeSet msLevelRangeSet = lvlMapEntry.getValue();
msLevelRangeSet.removeFromAll(range);
}
return;
}
TreeRangeSet<Integer> scanRangeLeft = TreeRangeSet.create();
scanRangeLeft.removeAll(anyLvlSet);
if (scanRangeLeft.isEmpty()) {
return; // if there's nothing left in the scan range, just stop
}
MsLevelRangeSet msLvlRanges = lvlMap.get(msLevel);
if (msLvlRanges == null) {
msLvlRanges = new MsLevelRangeSet();
lvlMap.put(msLevel, msLvlRanges);
}
if (mzRange == null) {
// add to any-mz-range range set
msLvlRanges.anyPrecursorSet.addAll(scanRangeLeft);
// remove from all specific mz-range sets
msLvlRanges.removeFromSpecific(range);
return;
}
scanRangeLeft.removeAll(msLvlRanges.anyPrecursorSet);
if (scanRangeLeft.isEmpty()) {
return;
}
RangeSet<Integer> rangeSetForMzRange = msLvlRanges.rngMap.get(mzRange);
if (rangeSetForMzRange == null) {
rangeSetForMzRange = TreeRangeSet.create();
msLvlRanges.rngMap.put(mzRange, rangeSetForMzRange);
}
rangeSetForMzRange.addAll(scanRangeLeft);
}
|
[
"public",
"void",
"add",
"(",
"LCMSRange",
"range",
")",
"{",
"Integer",
"msLevel",
"=",
"range",
".",
"getMsLevel",
"(",
")",
";",
"DoubleRange",
"mzRange",
"=",
"range",
".",
"getMzRange",
"(",
")",
";",
"Range",
"<",
"Integer",
">",
"scanRange",
"=",
"range",
".",
"getScanRange",
"(",
")",
";",
"if",
"(",
"msLevel",
"==",
"null",
")",
"{",
"// add to the top level range set",
"anyLvlSet",
".",
"add",
"(",
"scanRange",
")",
";",
"// remove from all underlying sets",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"MsLevelRangeSet",
">",
"lvlMapEntry",
":",
"lvlMap",
".",
"entrySet",
"(",
")",
")",
"{",
"MsLevelRangeSet",
"msLevelRangeSet",
"=",
"lvlMapEntry",
".",
"getValue",
"(",
")",
";",
"msLevelRangeSet",
".",
"removeFromAll",
"(",
"range",
")",
";",
"}",
"return",
";",
"}",
"TreeRangeSet",
"<",
"Integer",
">",
"scanRangeLeft",
"=",
"TreeRangeSet",
".",
"create",
"(",
")",
";",
"scanRangeLeft",
".",
"removeAll",
"(",
"anyLvlSet",
")",
";",
"if",
"(",
"scanRangeLeft",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"// if there's nothing left in the scan range, just stop",
"}",
"MsLevelRangeSet",
"msLvlRanges",
"=",
"lvlMap",
".",
"get",
"(",
"msLevel",
")",
";",
"if",
"(",
"msLvlRanges",
"==",
"null",
")",
"{",
"msLvlRanges",
"=",
"new",
"MsLevelRangeSet",
"(",
")",
";",
"lvlMap",
".",
"put",
"(",
"msLevel",
",",
"msLvlRanges",
")",
";",
"}",
"if",
"(",
"mzRange",
"==",
"null",
")",
"{",
"// add to any-mz-range range set",
"msLvlRanges",
".",
"anyPrecursorSet",
".",
"addAll",
"(",
"scanRangeLeft",
")",
";",
"// remove from all specific mz-range sets",
"msLvlRanges",
".",
"removeFromSpecific",
"(",
"range",
")",
";",
"return",
";",
"}",
"scanRangeLeft",
".",
"removeAll",
"(",
"msLvlRanges",
".",
"anyPrecursorSet",
")",
";",
"if",
"(",
"scanRangeLeft",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"RangeSet",
"<",
"Integer",
">",
"rangeSetForMzRange",
"=",
"msLvlRanges",
".",
"rngMap",
".",
"get",
"(",
"mzRange",
")",
";",
"if",
"(",
"rangeSetForMzRange",
"==",
"null",
")",
"{",
"rangeSetForMzRange",
"=",
"TreeRangeSet",
".",
"create",
"(",
")",
";",
"msLvlRanges",
".",
"rngMap",
".",
"put",
"(",
"mzRange",
",",
"rangeSetForMzRange",
")",
";",
"}",
"rangeSetForMzRange",
".",
"addAll",
"(",
"scanRangeLeft",
")",
";",
"}"
] |
This add method gradually removes scan-ranges from the input range as it descends down the
hierarchy.
|
[
"This",
"add",
"method",
"gradually",
"removes",
"scan",
"-",
"ranges",
"from",
"the",
"input",
"range",
"as",
"it",
"descends",
"down",
"the",
"hierarchy",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSRangeSet.java#L85-L131
|
11,559
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSRangeSet.java
|
LCMSRangeSet.subtract
|
public void subtract(LCMSRangeSet other) {
anyLvlSet.removeAll(other.anyLvlSet);
for (Map.Entry<Integer, MsLevelRangeSet> lvlMapEntry : lvlMap.entrySet()) {
Integer msLevel = lvlMapEntry.getKey();
MsLevelRangeSet msLevelRangeSet = lvlMapEntry.getValue();
// remove any top level scan ranges from the "any precursor" map at
// this ms level
msLevelRangeSet.anyPrecursorSet.removeAll(other.anyLvlSet);
// if the other range set had this level, remove entries contained in it
MsLevelRangeSet otherMsLevelRangeSet = other.lvlMap.get(msLevel);
msLevelRangeSet.anyPrecursorSet.removeAll(otherMsLevelRangeSet.anyPrecursorSet);
for (Map.Entry<DoubleRange, RangeSet<Integer>> rngMapEntry : msLevelRangeSet.rngMap
.entrySet()) {
if (rngMapEntry.getValue().isEmpty()) {
continue;
}
DoubleRange mzRange = rngMapEntry.getKey();
RangeSet<Integer> rangeSet = rngMapEntry.getValue();
rangeSet.removeAll(other.anyLvlSet);
if (!rangeSet.isEmpty()) {
rangeSet.removeAll(otherMsLevelRangeSet.anyPrecursorSet);
}
if (!rangeSet.isEmpty()) {
RangeSet<Integer> otherRangeSetAtMsLevelForPrecursorRange = otherMsLevelRangeSet.rngMap
.get(mzRange);
if (otherRangeSetAtMsLevelForPrecursorRange != null) {
rangeSet.removeAll(otherRangeSetAtMsLevelForPrecursorRange);
}
}
}
}
}
|
java
|
public void subtract(LCMSRangeSet other) {
anyLvlSet.removeAll(other.anyLvlSet);
for (Map.Entry<Integer, MsLevelRangeSet> lvlMapEntry : lvlMap.entrySet()) {
Integer msLevel = lvlMapEntry.getKey();
MsLevelRangeSet msLevelRangeSet = lvlMapEntry.getValue();
// remove any top level scan ranges from the "any precursor" map at
// this ms level
msLevelRangeSet.anyPrecursorSet.removeAll(other.anyLvlSet);
// if the other range set had this level, remove entries contained in it
MsLevelRangeSet otherMsLevelRangeSet = other.lvlMap.get(msLevel);
msLevelRangeSet.anyPrecursorSet.removeAll(otherMsLevelRangeSet.anyPrecursorSet);
for (Map.Entry<DoubleRange, RangeSet<Integer>> rngMapEntry : msLevelRangeSet.rngMap
.entrySet()) {
if (rngMapEntry.getValue().isEmpty()) {
continue;
}
DoubleRange mzRange = rngMapEntry.getKey();
RangeSet<Integer> rangeSet = rngMapEntry.getValue();
rangeSet.removeAll(other.anyLvlSet);
if (!rangeSet.isEmpty()) {
rangeSet.removeAll(otherMsLevelRangeSet.anyPrecursorSet);
}
if (!rangeSet.isEmpty()) {
RangeSet<Integer> otherRangeSetAtMsLevelForPrecursorRange = otherMsLevelRangeSet.rngMap
.get(mzRange);
if (otherRangeSetAtMsLevelForPrecursorRange != null) {
rangeSet.removeAll(otherRangeSetAtMsLevelForPrecursorRange);
}
}
}
}
}
|
[
"public",
"void",
"subtract",
"(",
"LCMSRangeSet",
"other",
")",
"{",
"anyLvlSet",
".",
"removeAll",
"(",
"other",
".",
"anyLvlSet",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"MsLevelRangeSet",
">",
"lvlMapEntry",
":",
"lvlMap",
".",
"entrySet",
"(",
")",
")",
"{",
"Integer",
"msLevel",
"=",
"lvlMapEntry",
".",
"getKey",
"(",
")",
";",
"MsLevelRangeSet",
"msLevelRangeSet",
"=",
"lvlMapEntry",
".",
"getValue",
"(",
")",
";",
"// remove any top level scan ranges from the \"any precursor\" map at",
"// this ms level",
"msLevelRangeSet",
".",
"anyPrecursorSet",
".",
"removeAll",
"(",
"other",
".",
"anyLvlSet",
")",
";",
"// if the other range set had this level, remove entries contained in it",
"MsLevelRangeSet",
"otherMsLevelRangeSet",
"=",
"other",
".",
"lvlMap",
".",
"get",
"(",
"msLevel",
")",
";",
"msLevelRangeSet",
".",
"anyPrecursorSet",
".",
"removeAll",
"(",
"otherMsLevelRangeSet",
".",
"anyPrecursorSet",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"DoubleRange",
",",
"RangeSet",
"<",
"Integer",
">",
">",
"rngMapEntry",
":",
"msLevelRangeSet",
".",
"rngMap",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"rngMapEntry",
".",
"getValue",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"continue",
";",
"}",
"DoubleRange",
"mzRange",
"=",
"rngMapEntry",
".",
"getKey",
"(",
")",
";",
"RangeSet",
"<",
"Integer",
">",
"rangeSet",
"=",
"rngMapEntry",
".",
"getValue",
"(",
")",
";",
"rangeSet",
".",
"removeAll",
"(",
"other",
".",
"anyLvlSet",
")",
";",
"if",
"(",
"!",
"rangeSet",
".",
"isEmpty",
"(",
")",
")",
"{",
"rangeSet",
".",
"removeAll",
"(",
"otherMsLevelRangeSet",
".",
"anyPrecursorSet",
")",
";",
"}",
"if",
"(",
"!",
"rangeSet",
".",
"isEmpty",
"(",
")",
")",
"{",
"RangeSet",
"<",
"Integer",
">",
"otherRangeSetAtMsLevelForPrecursorRange",
"=",
"otherMsLevelRangeSet",
".",
"rngMap",
".",
"get",
"(",
"mzRange",
")",
";",
"if",
"(",
"otherRangeSetAtMsLevelForPrecursorRange",
"!=",
"null",
")",
"{",
"rangeSet",
".",
"removeAll",
"(",
"otherRangeSetAtMsLevelForPrecursorRange",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Will modify the set. Intended usage - when unloading data in LCMSData, create one range set for
data loaded by other users, then create a separate range set for the LCMSRange that you want to
unload. Subtract the "loaded by others" from the range set you want to unload. Use this range
set for unloading.
|
[
"Will",
"modify",
"the",
"set",
".",
"Intended",
"usage",
"-",
"when",
"unloading",
"data",
"in",
"LCMSData",
"create",
"one",
"range",
"set",
"for",
"data",
"loaded",
"by",
"other",
"users",
"then",
"create",
"a",
"separate",
"range",
"set",
"for",
"the",
"LCMSRange",
"that",
"you",
"want",
"to",
"unload",
".",
"Subtract",
"the",
"loaded",
"by",
"others",
"from",
"the",
"range",
"set",
"you",
"want",
"to",
"unload",
".",
"Use",
"this",
"range",
"set",
"for",
"unloading",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSRangeSet.java#L139-L173
|
11,560
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/writer/TiffWriter.java
|
TiffWriter.classifyTags
|
private int classifyTags(IFD ifd, ArrayList<TagValue> oversized, ArrayList<TagValue> undersized) {
int tagValueSize = 4;
int n = 0;
for (TagValue tag : ifd.getMetadata().getTags()) {
int tagsize = getTagSize(tag);
if (tagsize > tagValueSize) {
oversized.add(tag);
} else {
undersized.add(tag);
}
n++;
}
return n;
}
|
java
|
private int classifyTags(IFD ifd, ArrayList<TagValue> oversized, ArrayList<TagValue> undersized) {
int tagValueSize = 4;
int n = 0;
for (TagValue tag : ifd.getMetadata().getTags()) {
int tagsize = getTagSize(tag);
if (tagsize > tagValueSize) {
oversized.add(tag);
} else {
undersized.add(tag);
}
n++;
}
return n;
}
|
[
"private",
"int",
"classifyTags",
"(",
"IFD",
"ifd",
",",
"ArrayList",
"<",
"TagValue",
">",
"oversized",
",",
"ArrayList",
"<",
"TagValue",
">",
"undersized",
")",
"{",
"int",
"tagValueSize",
"=",
"4",
";",
"int",
"n",
"=",
"0",
";",
"for",
"(",
"TagValue",
"tag",
":",
"ifd",
".",
"getMetadata",
"(",
")",
".",
"getTags",
"(",
")",
")",
"{",
"int",
"tagsize",
"=",
"getTagSize",
"(",
"tag",
")",
";",
"if",
"(",
"tagsize",
">",
"tagValueSize",
")",
"{",
"oversized",
".",
"add",
"(",
"tag",
")",
";",
"}",
"else",
"{",
"undersized",
".",
"add",
"(",
"tag",
")",
";",
"}",
"n",
"++",
";",
"}",
"return",
"n",
";",
"}"
] |
Gets the oversized tags.
@param ifd the ifd
@param oversized the oversized
@param undersized the undersized
@return the number of tags
|
[
"Gets",
"the",
"oversized",
"tags",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/writer/TiffWriter.java#L175-L188
|
11,561
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/writer/TiffWriter.java
|
TiffWriter.getTagSize
|
private int getTagSize(TagValue tag) {
int n = tag.getCardinality();
int id = tag.getId();
// Calculate tag size
int type = tag.getType();
if (id == 330) {
// SubIFD
n = 1000;
}
if (id == 700) {
// XMP
if (tag.getValue().size() > 0)
n = tag.getValue().get(0).toString().length();
}
if (id == 33723) {
// IPTC
n = tag.getReadlength();
}
if (id == 34665) {
// EXIF
n = 1000;
}
if (id == 34675) {
// ICC
n = tag.getReadlength();
}
int typeSize = TiffTags.getTypeSize(type);
int tagSize = typeSize * n;
return tagSize;
}
|
java
|
private int getTagSize(TagValue tag) {
int n = tag.getCardinality();
int id = tag.getId();
// Calculate tag size
int type = tag.getType();
if (id == 330) {
// SubIFD
n = 1000;
}
if (id == 700) {
// XMP
if (tag.getValue().size() > 0)
n = tag.getValue().get(0).toString().length();
}
if (id == 33723) {
// IPTC
n = tag.getReadlength();
}
if (id == 34665) {
// EXIF
n = 1000;
}
if (id == 34675) {
// ICC
n = tag.getReadlength();
}
int typeSize = TiffTags.getTypeSize(type);
int tagSize = typeSize * n;
return tagSize;
}
|
[
"private",
"int",
"getTagSize",
"(",
"TagValue",
"tag",
")",
"{",
"int",
"n",
"=",
"tag",
".",
"getCardinality",
"(",
")",
";",
"int",
"id",
"=",
"tag",
".",
"getId",
"(",
")",
";",
"// Calculate tag size",
"int",
"type",
"=",
"tag",
".",
"getType",
"(",
")",
";",
"if",
"(",
"id",
"==",
"330",
")",
"{",
"// SubIFD",
"n",
"=",
"1000",
";",
"}",
"if",
"(",
"id",
"==",
"700",
")",
"{",
"// XMP",
"if",
"(",
"tag",
".",
"getValue",
"(",
")",
".",
"size",
"(",
")",
">",
"0",
")",
"n",
"=",
"tag",
".",
"getValue",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"toString",
"(",
")",
".",
"length",
"(",
")",
";",
"}",
"if",
"(",
"id",
"==",
"33723",
")",
"{",
"// IPTC",
"n",
"=",
"tag",
".",
"getReadlength",
"(",
")",
";",
"}",
"if",
"(",
"id",
"==",
"34665",
")",
"{",
"// EXIF",
"n",
"=",
"1000",
";",
"}",
"if",
"(",
"id",
"==",
"34675",
")",
"{",
"// ICC",
"n",
"=",
"tag",
".",
"getReadlength",
"(",
")",
";",
"}",
"int",
"typeSize",
"=",
"TiffTags",
".",
"getTypeSize",
"(",
"type",
")",
";",
"int",
"tagSize",
"=",
"typeSize",
"*",
"n",
";",
"return",
"tagSize",
";",
"}"
] |
Gets the tag size.
@param tag the tag
@return the tag size
|
[
"Gets",
"the",
"tag",
"size",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/writer/TiffWriter.java#L328-L360
|
11,562
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/writer/TiffWriter.java
|
TiffWriter.writeStripData
|
private ArrayList<Integer> writeStripData(IFD ifd) throws IOException {
ArrayList<Integer> newStripOffsets = new ArrayList<Integer>();
IfdTags metadata = ifd.getMetadata();
TagValue stripOffsets = metadata.get(273);
TagValue stripSizes = metadata.get(279);
for (int i = 0; i < stripOffsets.getCardinality(); i++) {
try {
int pos = (int) data.position();
newStripOffsets.add(pos);
int start = stripOffsets.getValue().get(i).toInt();
int size = stripSizes.getValue().get(i).toInt();
this.input.seekOffset(start);
for (int off = start; off < start + size; off++) {
byte v = this.input.readDirectByte();
data.put(v);
}
if (data.position() % 2 != 0) {
// Correct word alignment
data.put((byte) 0);
}
} catch (Exception ex) {
}
}
return newStripOffsets;
}
|
java
|
private ArrayList<Integer> writeStripData(IFD ifd) throws IOException {
ArrayList<Integer> newStripOffsets = new ArrayList<Integer>();
IfdTags metadata = ifd.getMetadata();
TagValue stripOffsets = metadata.get(273);
TagValue stripSizes = metadata.get(279);
for (int i = 0; i < stripOffsets.getCardinality(); i++) {
try {
int pos = (int) data.position();
newStripOffsets.add(pos);
int start = stripOffsets.getValue().get(i).toInt();
int size = stripSizes.getValue().get(i).toInt();
this.input.seekOffset(start);
for (int off = start; off < start + size; off++) {
byte v = this.input.readDirectByte();
data.put(v);
}
if (data.position() % 2 != 0) {
// Correct word alignment
data.put((byte) 0);
}
} catch (Exception ex) {
}
}
return newStripOffsets;
}
|
[
"private",
"ArrayList",
"<",
"Integer",
">",
"writeStripData",
"(",
"IFD",
"ifd",
")",
"throws",
"IOException",
"{",
"ArrayList",
"<",
"Integer",
">",
"newStripOffsets",
"=",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
")",
";",
"IfdTags",
"metadata",
"=",
"ifd",
".",
"getMetadata",
"(",
")",
";",
"TagValue",
"stripOffsets",
"=",
"metadata",
".",
"get",
"(",
"273",
")",
";",
"TagValue",
"stripSizes",
"=",
"metadata",
".",
"get",
"(",
"279",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"stripOffsets",
".",
"getCardinality",
"(",
")",
";",
"i",
"++",
")",
"{",
"try",
"{",
"int",
"pos",
"=",
"(",
"int",
")",
"data",
".",
"position",
"(",
")",
";",
"newStripOffsets",
".",
"add",
"(",
"pos",
")",
";",
"int",
"start",
"=",
"stripOffsets",
".",
"getValue",
"(",
")",
".",
"get",
"(",
"i",
")",
".",
"toInt",
"(",
")",
";",
"int",
"size",
"=",
"stripSizes",
".",
"getValue",
"(",
")",
".",
"get",
"(",
"i",
")",
".",
"toInt",
"(",
")",
";",
"this",
".",
"input",
".",
"seekOffset",
"(",
"start",
")",
";",
"for",
"(",
"int",
"off",
"=",
"start",
";",
"off",
"<",
"start",
"+",
"size",
";",
"off",
"++",
")",
"{",
"byte",
"v",
"=",
"this",
".",
"input",
".",
"readDirectByte",
"(",
")",
";",
"data",
".",
"put",
"(",
"v",
")",
";",
"}",
"if",
"(",
"data",
".",
"position",
"(",
")",
"%",
"2",
"!=",
"0",
")",
"{",
"// Correct word alignment",
"data",
".",
"put",
"(",
"(",
"byte",
")",
"0",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"}",
"return",
"newStripOffsets",
";",
"}"
] |
Write strip data.
@param ifd the ifd
@return the array list
@throws IOException Signals that an I/O exception has occurred.
|
[
"Write",
"strip",
"data",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/writer/TiffWriter.java#L462-L487
|
11,563
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/writer/TiffWriter.java
|
TiffWriter.writeTileData
|
private ArrayList<Integer> writeTileData(IFD ifd) throws IOException {
ArrayList<Integer> newTileOffsets = new ArrayList<Integer>();
IfdTags metadata = ifd.getMetadata();
TagValue tileOffsets = metadata.get(324);
TagValue tileSizes = metadata.get(325);
for (int i = 0; i < tileOffsets.getCardinality(); i++) {
int pos = (int) data.position();
if (pos % 2 != 0) {
// Correct word alignment
data.put((byte) 0);
pos = (int) data.position();
}
newTileOffsets.add(pos);
this.input.seekOffset(tileOffsets.getValue().get(i).toInt());
for (int j = 0; j < tileSizes.getValue().get(i).toInt(); j++) {
byte v = this.input.readDirectByte();
data.put(v);
}
if (data.position() % 2 != 0) {
// Correct word alignment
data.put((byte) 0);
}
}
return newTileOffsets;
}
|
java
|
private ArrayList<Integer> writeTileData(IFD ifd) throws IOException {
ArrayList<Integer> newTileOffsets = new ArrayList<Integer>();
IfdTags metadata = ifd.getMetadata();
TagValue tileOffsets = metadata.get(324);
TagValue tileSizes = metadata.get(325);
for (int i = 0; i < tileOffsets.getCardinality(); i++) {
int pos = (int) data.position();
if (pos % 2 != 0) {
// Correct word alignment
data.put((byte) 0);
pos = (int) data.position();
}
newTileOffsets.add(pos);
this.input.seekOffset(tileOffsets.getValue().get(i).toInt());
for (int j = 0; j < tileSizes.getValue().get(i).toInt(); j++) {
byte v = this.input.readDirectByte();
data.put(v);
}
if (data.position() % 2 != 0) {
// Correct word alignment
data.put((byte) 0);
}
}
return newTileOffsets;
}
|
[
"private",
"ArrayList",
"<",
"Integer",
">",
"writeTileData",
"(",
"IFD",
"ifd",
")",
"throws",
"IOException",
"{",
"ArrayList",
"<",
"Integer",
">",
"newTileOffsets",
"=",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
")",
";",
"IfdTags",
"metadata",
"=",
"ifd",
".",
"getMetadata",
"(",
")",
";",
"TagValue",
"tileOffsets",
"=",
"metadata",
".",
"get",
"(",
"324",
")",
";",
"TagValue",
"tileSizes",
"=",
"metadata",
".",
"get",
"(",
"325",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tileOffsets",
".",
"getCardinality",
"(",
")",
";",
"i",
"++",
")",
"{",
"int",
"pos",
"=",
"(",
"int",
")",
"data",
".",
"position",
"(",
")",
";",
"if",
"(",
"pos",
"%",
"2",
"!=",
"0",
")",
"{",
"// Correct word alignment",
"data",
".",
"put",
"(",
"(",
"byte",
")",
"0",
")",
";",
"pos",
"=",
"(",
"int",
")",
"data",
".",
"position",
"(",
")",
";",
"}",
"newTileOffsets",
".",
"add",
"(",
"pos",
")",
";",
"this",
".",
"input",
".",
"seekOffset",
"(",
"tileOffsets",
".",
"getValue",
"(",
")",
".",
"get",
"(",
"i",
")",
".",
"toInt",
"(",
")",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"tileSizes",
".",
"getValue",
"(",
")",
".",
"get",
"(",
"i",
")",
".",
"toInt",
"(",
")",
";",
"j",
"++",
")",
"{",
"byte",
"v",
"=",
"this",
".",
"input",
".",
"readDirectByte",
"(",
")",
";",
"data",
".",
"put",
"(",
"v",
")",
";",
"}",
"if",
"(",
"data",
".",
"position",
"(",
")",
"%",
"2",
"!=",
"0",
")",
"{",
"// Correct word alignment",
"data",
".",
"put",
"(",
"(",
"byte",
")",
"0",
")",
";",
"}",
"}",
"return",
"newTileOffsets",
";",
"}"
] |
Write tile data.
@param ifd the ifd
@return the array list
@throws IOException Signals that an I/O exception has occurred.
|
[
"Write",
"tile",
"data",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/writer/TiffWriter.java#L496-L520
|
11,564
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/subset/neigh/SinglePerturbationNeighbourhood.java
|
SinglePerturbationNeighbourhood.getAllMoves
|
@Override
public List<SubsetMove> getAllMoves(SubsetSolution solution) {
// get set of candidate IDs for deletion and addition (fixed IDs are discarded)
Set<Integer> removeCandidates = getRemoveCandidates(solution);
Set<Integer> addCandidates = getAddCandidates(solution);
// create empty list of moves
List<SubsetMove> moves = new ArrayList<>();
// generate all addition moves, if valid
if(canAdd(solution, addCandidates)){
// create addition move for each add candidate
addCandidates.forEach(add -> moves.add(new AdditionMove(add)));
}
// generate all deletion moves, if valid
if(canRemove(solution, removeCandidates)){
// create deletion move for each remove candidate
removeCandidates.forEach(remove -> moves.add(new DeletionMove(remove)));
}
// generate all swap moves, if valid
if(canSwap(solution, addCandidates, removeCandidates)){
// create swap move for each combination of add and remove candidate
addCandidates.forEach(add -> {
removeCandidates.forEach(remove -> {
moves.add(new SwapMove(add, remove));
});
});
}
// return generated moves
return moves;
}
|
java
|
@Override
public List<SubsetMove> getAllMoves(SubsetSolution solution) {
// get set of candidate IDs for deletion and addition (fixed IDs are discarded)
Set<Integer> removeCandidates = getRemoveCandidates(solution);
Set<Integer> addCandidates = getAddCandidates(solution);
// create empty list of moves
List<SubsetMove> moves = new ArrayList<>();
// generate all addition moves, if valid
if(canAdd(solution, addCandidates)){
// create addition move for each add candidate
addCandidates.forEach(add -> moves.add(new AdditionMove(add)));
}
// generate all deletion moves, if valid
if(canRemove(solution, removeCandidates)){
// create deletion move for each remove candidate
removeCandidates.forEach(remove -> moves.add(new DeletionMove(remove)));
}
// generate all swap moves, if valid
if(canSwap(solution, addCandidates, removeCandidates)){
// create swap move for each combination of add and remove candidate
addCandidates.forEach(add -> {
removeCandidates.forEach(remove -> {
moves.add(new SwapMove(add, remove));
});
});
}
// return generated moves
return moves;
}
|
[
"@",
"Override",
"public",
"List",
"<",
"SubsetMove",
">",
"getAllMoves",
"(",
"SubsetSolution",
"solution",
")",
"{",
"// get set of candidate IDs for deletion and addition (fixed IDs are discarded)",
"Set",
"<",
"Integer",
">",
"removeCandidates",
"=",
"getRemoveCandidates",
"(",
"solution",
")",
";",
"Set",
"<",
"Integer",
">",
"addCandidates",
"=",
"getAddCandidates",
"(",
"solution",
")",
";",
"// create empty list of moves",
"List",
"<",
"SubsetMove",
">",
"moves",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"// generate all addition moves, if valid",
"if",
"(",
"canAdd",
"(",
"solution",
",",
"addCandidates",
")",
")",
"{",
"// create addition move for each add candidate",
"addCandidates",
".",
"forEach",
"(",
"add",
"->",
"moves",
".",
"add",
"(",
"new",
"AdditionMove",
"(",
"add",
")",
")",
")",
";",
"}",
"// generate all deletion moves, if valid",
"if",
"(",
"canRemove",
"(",
"solution",
",",
"removeCandidates",
")",
")",
"{",
"// create deletion move for each remove candidate",
"removeCandidates",
".",
"forEach",
"(",
"remove",
"->",
"moves",
".",
"add",
"(",
"new",
"DeletionMove",
"(",
"remove",
")",
")",
")",
";",
"}",
"// generate all swap moves, if valid",
"if",
"(",
"canSwap",
"(",
"solution",
",",
"addCandidates",
",",
"removeCandidates",
")",
")",
"{",
"// create swap move for each combination of add and remove candidate",
"addCandidates",
".",
"forEach",
"(",
"add",
"->",
"{",
"removeCandidates",
".",
"forEach",
"(",
"remove",
"->",
"{",
"moves",
".",
"add",
"(",
"new",
"SwapMove",
"(",
"add",
",",
"remove",
")",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
"// return generated moves",
"return",
"moves",
";",
"}"
] |
Generate all valid swap, deletion and addition moves that transform the given subset solution into
a neighbour within the minimum and maximum allowed subset size. The returned list may be empty,
if no valid moves exist. If any fixed IDs have been specified, these will not be considered
for deletion nor addition.
@param solution solution for which a set of all valid moves is generated
@return list of all valid swap, deletion and addition moves
|
[
"Generate",
"all",
"valid",
"swap",
"deletion",
"and",
"addition",
"moves",
"that",
"transform",
"the",
"given",
"subset",
"solution",
"into",
"a",
"neighbour",
"within",
"the",
"minimum",
"and",
"maximum",
"allowed",
"subset",
"size",
".",
"The",
"returned",
"list",
"may",
"be",
"empty",
"if",
"no",
"valid",
"moves",
"exist",
".",
"If",
"any",
"fixed",
"IDs",
"have",
"been",
"specified",
"these",
"will",
"not",
"be",
"considered",
"for",
"deletion",
"nor",
"addition",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/neigh/SinglePerturbationNeighbourhood.java#L184-L212
|
11,565
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/subset/neigh/SinglePerturbationNeighbourhood.java
|
SinglePerturbationNeighbourhood.canAdd
|
private boolean canAdd(SubsetSolution solution, Set<Integer> addCandidates){
return !addCandidates.isEmpty()
&& isValidSubsetSize(solution.getNumSelectedIDs()+1);
}
|
java
|
private boolean canAdd(SubsetSolution solution, Set<Integer> addCandidates){
return !addCandidates.isEmpty()
&& isValidSubsetSize(solution.getNumSelectedIDs()+1);
}
|
[
"private",
"boolean",
"canAdd",
"(",
"SubsetSolution",
"solution",
",",
"Set",
"<",
"Integer",
">",
"addCandidates",
")",
"{",
"return",
"!",
"addCandidates",
".",
"isEmpty",
"(",
")",
"&&",
"isValidSubsetSize",
"(",
"solution",
".",
"getNumSelectedIDs",
"(",
")",
"+",
"1",
")",
";",
"}"
] |
Check if it is allowed to add one more item to the selection.
@param solution solution for which moves are generated
@param addCandidates set of candidate IDs to be added
@return <code>true</code> if it is allowed to add an item to the selection
|
[
"Check",
"if",
"it",
"is",
"allowed",
"to",
"add",
"one",
"more",
"item",
"to",
"the",
"selection",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/neigh/SinglePerturbationNeighbourhood.java#L221-L224
|
11,566
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/subset/neigh/SinglePerturbationNeighbourhood.java
|
SinglePerturbationNeighbourhood.canRemove
|
private boolean canRemove(SubsetSolution solution, Set<Integer> deleteCandidates){
return !deleteCandidates.isEmpty()
&& isValidSubsetSize(solution.getNumSelectedIDs()-1);
}
|
java
|
private boolean canRemove(SubsetSolution solution, Set<Integer> deleteCandidates){
return !deleteCandidates.isEmpty()
&& isValidSubsetSize(solution.getNumSelectedIDs()-1);
}
|
[
"private",
"boolean",
"canRemove",
"(",
"SubsetSolution",
"solution",
",",
"Set",
"<",
"Integer",
">",
"deleteCandidates",
")",
"{",
"return",
"!",
"deleteCandidates",
".",
"isEmpty",
"(",
")",
"&&",
"isValidSubsetSize",
"(",
"solution",
".",
"getNumSelectedIDs",
"(",
")",
"-",
"1",
")",
";",
"}"
] |
Check if it is allowed to remove one more item from the selection.
@param solution solution for which moves are generated
@param deleteCandidates set of candidate IDs to be deleted
@return <code>true</code> if it is allowed to remove an item from the selection
|
[
"Check",
"if",
"it",
"is",
"allowed",
"to",
"remove",
"one",
"more",
"item",
"from",
"the",
"selection",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/neigh/SinglePerturbationNeighbourhood.java#L233-L236
|
11,567
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/subset/neigh/SinglePerturbationNeighbourhood.java
|
SinglePerturbationNeighbourhood.canSwap
|
private boolean canSwap(SubsetSolution solution, Set<Integer> addCandidates, Set<Integer> deleteCandidates){
return !addCandidates.isEmpty()
&& !deleteCandidates.isEmpty()
&& isValidSubsetSize(solution.getNumSelectedIDs());
}
|
java
|
private boolean canSwap(SubsetSolution solution, Set<Integer> addCandidates, Set<Integer> deleteCandidates){
return !addCandidates.isEmpty()
&& !deleteCandidates.isEmpty()
&& isValidSubsetSize(solution.getNumSelectedIDs());
}
|
[
"private",
"boolean",
"canSwap",
"(",
"SubsetSolution",
"solution",
",",
"Set",
"<",
"Integer",
">",
"addCandidates",
",",
"Set",
"<",
"Integer",
">",
"deleteCandidates",
")",
"{",
"return",
"!",
"addCandidates",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"deleteCandidates",
".",
"isEmpty",
"(",
")",
"&&",
"isValidSubsetSize",
"(",
"solution",
".",
"getNumSelectedIDs",
"(",
")",
")",
";",
"}"
] |
Check if it is possible to swap a selected and unselected item.
@param solution solution for which moves are generated
@param addCandidates set of candidate IDs to be added
@param deleteCandidates set of candidate IDs to be deleted
@return <code>true</code> if it is possible to perform a swap
|
[
"Check",
"if",
"it",
"is",
"possible",
"to",
"swap",
"a",
"selected",
"and",
"unselected",
"item",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/neigh/SinglePerturbationNeighbourhood.java#L246-L250
|
11,568
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSRange.java
|
LCMSRange.create
|
public static final LCMSRange create(Range<Integer> scanRange, Integer msLevel) {
return new LCMSRange(scanRange, msLevel, null);
}
|
java
|
public static final LCMSRange create(Range<Integer> scanRange, Integer msLevel) {
return new LCMSRange(scanRange, msLevel, null);
}
|
[
"public",
"static",
"final",
"LCMSRange",
"create",
"(",
"Range",
"<",
"Integer",
">",
"scanRange",
",",
"Integer",
"msLevel",
")",
"{",
"return",
"new",
"LCMSRange",
"(",
"scanRange",
",",
"msLevel",
",",
"null",
")",
";",
"}"
] |
A range that will contain all scans with the scan number range, but only at a specific
MS-Level.
@param scanRange null means the whole range of scan numbers in the run
@param msLevel null means any ms-level
|
[
"A",
"range",
"that",
"will",
"contain",
"all",
"scans",
"with",
"the",
"scan",
"number",
"range",
"but",
"only",
"at",
"a",
"specific",
"MS",
"-",
"Level",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSRange.java#L98-L100
|
11,569
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSRange.java
|
LCMSRange.create
|
public static final LCMSRange create(Range<Integer> scanRange, Integer msLevel,
DoubleRange mzRange) {
return new LCMSRange(scanRange, msLevel, mzRange);
}
|
java
|
public static final LCMSRange create(Range<Integer> scanRange, Integer msLevel,
DoubleRange mzRange) {
return new LCMSRange(scanRange, msLevel, mzRange);
}
|
[
"public",
"static",
"final",
"LCMSRange",
"create",
"(",
"Range",
"<",
"Integer",
">",
"scanRange",
",",
"Integer",
"msLevel",
",",
"DoubleRange",
"mzRange",
")",
"{",
"return",
"new",
"LCMSRange",
"(",
"scanRange",
",",
"msLevel",
",",
"mzRange",
")",
";",
"}"
] |
A range, containing all scans within the scan number range at a specific MS-Level and a
specific precursor range.
@param scanRange null means the whole range of scan numbers in the run
@param msLevel null means any ms-level
@param mzRange null means all ranges. You can't use non-null here, if {@code msLevel} is null
|
[
"A",
"range",
"containing",
"all",
"scans",
"within",
"the",
"scan",
"number",
"range",
"at",
"a",
"specific",
"MS",
"-",
"Level",
"and",
"a",
"specific",
"precursor",
"range",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSRange.java#L110-L113
|
11,570
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/problems/constraints/validations/UnanimousValidation.java
|
UnanimousValidation.addValidation
|
public void addValidation(Object key, Validation validation){
initMapOnce();
validations.put(key, validation);
// update aggregated value
passedAll = passedAll && validation.passed();
}
|
java
|
public void addValidation(Object key, Validation validation){
initMapOnce();
validations.put(key, validation);
// update aggregated value
passedAll = passedAll && validation.passed();
}
|
[
"public",
"void",
"addValidation",
"(",
"Object",
"key",
",",
"Validation",
"validation",
")",
"{",
"initMapOnce",
"(",
")",
";",
"validations",
".",
"put",
"(",
"key",
",",
"validation",
")",
";",
"// update aggregated value",
"passedAll",
"=",
"passedAll",
"&&",
"validation",
".",
"passed",
"(",
")",
";",
"}"
] |
Add a validation object. A key is required that can be used to retrieve the validation object.
@param key key used to retrieve the validation object
@param validation validation object
|
[
"Add",
"a",
"validation",
"object",
".",
"A",
"key",
"is",
"required",
"that",
"can",
"be",
"used",
"to",
"retrieve",
"the",
"validation",
"object",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/problems/constraints/validations/UnanimousValidation.java#L60-L65
|
11,571
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/fileio/filetypes/pepxml/PepXmlParser.java
|
PepXmlParser.parse
|
public static MsmsPipelineAnalysis parse(Path path) throws FileParsingException {
try {
XMLStreamReader xsr = JaxbUtils.createXmlStreamReader(path, false);
MsmsPipelineAnalysis msmsPipelineAnalysis = JaxbUtils
.unmarshal(MsmsPipelineAnalysis.class, xsr);
return msmsPipelineAnalysis;
} catch (JAXBException e) {
throw new FileParsingException(
String
.format("JAXB parsing of PepXML file failed (%s)", path.toAbsolutePath().toString()),
e);
}
}
|
java
|
public static MsmsPipelineAnalysis parse(Path path) throws FileParsingException {
try {
XMLStreamReader xsr = JaxbUtils.createXmlStreamReader(path, false);
MsmsPipelineAnalysis msmsPipelineAnalysis = JaxbUtils
.unmarshal(MsmsPipelineAnalysis.class, xsr);
return msmsPipelineAnalysis;
} catch (JAXBException e) {
throw new FileParsingException(
String
.format("JAXB parsing of PepXML file failed (%s)", path.toAbsolutePath().toString()),
e);
}
}
|
[
"public",
"static",
"MsmsPipelineAnalysis",
"parse",
"(",
"Path",
"path",
")",
"throws",
"FileParsingException",
"{",
"try",
"{",
"XMLStreamReader",
"xsr",
"=",
"JaxbUtils",
".",
"createXmlStreamReader",
"(",
"path",
",",
"false",
")",
";",
"MsmsPipelineAnalysis",
"msmsPipelineAnalysis",
"=",
"JaxbUtils",
".",
"unmarshal",
"(",
"MsmsPipelineAnalysis",
".",
"class",
",",
"xsr",
")",
";",
"return",
"msmsPipelineAnalysis",
";",
"}",
"catch",
"(",
"JAXBException",
"e",
")",
"{",
"throw",
"new",
"FileParsingException",
"(",
"String",
".",
"format",
"(",
"\"JAXB parsing of PepXML file failed (%s)\"",
",",
"path",
".",
"toAbsolutePath",
"(",
")",
".",
"toString",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"}"
] |
The simplest method to parse the whole MsmsPipelineAnalysis from a file.
@param path Path to the file
@return MsmsPipelineAnalysis
|
[
"The",
"simplest",
"method",
"to",
"parse",
"the",
"whole",
"MsmsPipelineAnalysis",
"from",
"a",
"file",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/fileio/filetypes/pepxml/PepXmlParser.java#L50-L63
|
11,572
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSDataSubset.java
|
LCMSDataSubset.merge
|
public LCMSDataSubset merge(LCMSDataSubset other) {
LCMSDataSubset merged = new LCMSDataSubset();
Set<Integer> msLvlsThis = getMsLvls();
Set<Integer> msLvlsThat = other.getMsLvls();
// only merge if both are not null, otherwise null signifies the whole
// run, so we can keep it null in the merged version
if (msLvlsThis != null && msLvlsThat != null) {
HashSet<Integer> mergedMsLvls = new HashSet<>(msLvlsThis);
mergedMsLvls.addAll(msLvlsThat);
merged.setMsLvls(mergedMsLvls);
}
// merge mz ranges
List<DoubleRange> mzRangesThis = getMzRanges();
List<DoubleRange> mzRangesThat = other.getMzRanges();
if (mzRangesThis != null && mzRangesThat != null) {
ArrayList<DoubleRange> mergedMzRanges = new ArrayList<>(mzRangesThis);
mergedMzRanges.addAll(mzRangesThat);
merged.setMzRanges(mergedMzRanges);
}
// compare scan number ranges
Integer scanNumLoThis = getScanNumLo();
Integer scanNumLoThat = other.getScanNumLo();
if (scanNumLoThis != null && scanNumLoThat != null) {
merged.setScanNumLo(Math.min(scanNumLoThis, scanNumLoThat));
}
Integer scanNumHiThis = getScanNumHi();
Integer scanNumHiThat = other.getScanNumHi();
if (scanNumHiThis != null && scanNumHiThat != null) {
merged.setScanNumHi(Math.max(scanNumHiThis, scanNumHiThat));
}
return merged;
}
|
java
|
public LCMSDataSubset merge(LCMSDataSubset other) {
LCMSDataSubset merged = new LCMSDataSubset();
Set<Integer> msLvlsThis = getMsLvls();
Set<Integer> msLvlsThat = other.getMsLvls();
// only merge if both are not null, otherwise null signifies the whole
// run, so we can keep it null in the merged version
if (msLvlsThis != null && msLvlsThat != null) {
HashSet<Integer> mergedMsLvls = new HashSet<>(msLvlsThis);
mergedMsLvls.addAll(msLvlsThat);
merged.setMsLvls(mergedMsLvls);
}
// merge mz ranges
List<DoubleRange> mzRangesThis = getMzRanges();
List<DoubleRange> mzRangesThat = other.getMzRanges();
if (mzRangesThis != null && mzRangesThat != null) {
ArrayList<DoubleRange> mergedMzRanges = new ArrayList<>(mzRangesThis);
mergedMzRanges.addAll(mzRangesThat);
merged.setMzRanges(mergedMzRanges);
}
// compare scan number ranges
Integer scanNumLoThis = getScanNumLo();
Integer scanNumLoThat = other.getScanNumLo();
if (scanNumLoThis != null && scanNumLoThat != null) {
merged.setScanNumLo(Math.min(scanNumLoThis, scanNumLoThat));
}
Integer scanNumHiThis = getScanNumHi();
Integer scanNumHiThat = other.getScanNumHi();
if (scanNumHiThis != null && scanNumHiThat != null) {
merged.setScanNumHi(Math.max(scanNumHiThis, scanNumHiThat));
}
return merged;
}
|
[
"public",
"LCMSDataSubset",
"merge",
"(",
"LCMSDataSubset",
"other",
")",
"{",
"LCMSDataSubset",
"merged",
"=",
"new",
"LCMSDataSubset",
"(",
")",
";",
"Set",
"<",
"Integer",
">",
"msLvlsThis",
"=",
"getMsLvls",
"(",
")",
";",
"Set",
"<",
"Integer",
">",
"msLvlsThat",
"=",
"other",
".",
"getMsLvls",
"(",
")",
";",
"// only merge if both are not null, otherwise null signifies the whole",
"// run, so we can keep it null in the merged version",
"if",
"(",
"msLvlsThis",
"!=",
"null",
"&&",
"msLvlsThat",
"!=",
"null",
")",
"{",
"HashSet",
"<",
"Integer",
">",
"mergedMsLvls",
"=",
"new",
"HashSet",
"<>",
"(",
"msLvlsThis",
")",
";",
"mergedMsLvls",
".",
"addAll",
"(",
"msLvlsThat",
")",
";",
"merged",
".",
"setMsLvls",
"(",
"mergedMsLvls",
")",
";",
"}",
"// merge mz ranges",
"List",
"<",
"DoubleRange",
">",
"mzRangesThis",
"=",
"getMzRanges",
"(",
")",
";",
"List",
"<",
"DoubleRange",
">",
"mzRangesThat",
"=",
"other",
".",
"getMzRanges",
"(",
")",
";",
"if",
"(",
"mzRangesThis",
"!=",
"null",
"&&",
"mzRangesThat",
"!=",
"null",
")",
"{",
"ArrayList",
"<",
"DoubleRange",
">",
"mergedMzRanges",
"=",
"new",
"ArrayList",
"<>",
"(",
"mzRangesThis",
")",
";",
"mergedMzRanges",
".",
"addAll",
"(",
"mzRangesThat",
")",
";",
"merged",
".",
"setMzRanges",
"(",
"mergedMzRanges",
")",
";",
"}",
"// compare scan number ranges",
"Integer",
"scanNumLoThis",
"=",
"getScanNumLo",
"(",
")",
";",
"Integer",
"scanNumLoThat",
"=",
"other",
".",
"getScanNumLo",
"(",
")",
";",
"if",
"(",
"scanNumLoThis",
"!=",
"null",
"&&",
"scanNumLoThat",
"!=",
"null",
")",
"{",
"merged",
".",
"setScanNumLo",
"(",
"Math",
".",
"min",
"(",
"scanNumLoThis",
",",
"scanNumLoThat",
")",
")",
";",
"}",
"Integer",
"scanNumHiThis",
"=",
"getScanNumHi",
"(",
")",
";",
"Integer",
"scanNumHiThat",
"=",
"other",
".",
"getScanNumHi",
"(",
")",
";",
"if",
"(",
"scanNumHiThis",
"!=",
"null",
"&&",
"scanNumHiThat",
"!=",
"null",
")",
"{",
"merged",
".",
"setScanNumHi",
"(",
"Math",
".",
"max",
"(",
"scanNumHiThis",
",",
"scanNumHiThat",
")",
")",
";",
"}",
"return",
"merged",
";",
"}"
] |
Doesn't modify original values, always returns a new one.
@return a new instance of LCMSDataSubset, even if this subset {@link
#contains(umich.ms.datatypes.LCMSDataSubset) } the other one.
|
[
"Doesn",
"t",
"modify",
"original",
"values",
"always",
"returns",
"a",
"new",
"one",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSDataSubset.java#L235-L270
|
11,573
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/Search.java
|
Search.addStopCriterion
|
public void addStopCriterion(StopCriterion stopCriterion){
// acquire status lock
synchronized(statusLock){
// assert idle
assertIdle("Cannot add stop criterion.");
// pass stop criterion to checker (throws error if incompatible)
stopCriterionChecker.add(stopCriterion);
// log
LOGGER.debug("{}: added stop criterion {}", this, stopCriterion);
}
}
|
java
|
public void addStopCriterion(StopCriterion stopCriterion){
// acquire status lock
synchronized(statusLock){
// assert idle
assertIdle("Cannot add stop criterion.");
// pass stop criterion to checker (throws error if incompatible)
stopCriterionChecker.add(stopCriterion);
// log
LOGGER.debug("{}: added stop criterion {}", this, stopCriterion);
}
}
|
[
"public",
"void",
"addStopCriterion",
"(",
"StopCriterion",
"stopCriterion",
")",
"{",
"// acquire status lock",
"synchronized",
"(",
"statusLock",
")",
"{",
"// assert idle",
"assertIdle",
"(",
"\"Cannot add stop criterion.\"",
")",
";",
"// pass stop criterion to checker (throws error if incompatible)",
"stopCriterionChecker",
".",
"add",
"(",
"stopCriterion",
")",
";",
"// log",
"LOGGER",
".",
"debug",
"(",
"\"{}: added stop criterion {}\"",
",",
"this",
",",
"stopCriterion",
")",
";",
"}",
"}"
] |
Adds a stop criterion used to decide when the search should stop running. It is verified whether the given
stop criterion is compatible with the search and if not, an exception is thrown. Note that this method can
only be called when the search is idle.
@param stopCriterion stop criterion used to decide when the search should stop running
@throws IncompatibleStopCriterionException if the given stop criterion is incompatible with the search
@throws SearchException if the search is not idle
|
[
"Adds",
"a",
"stop",
"criterion",
"used",
"to",
"decide",
"when",
"the",
"search",
"should",
"stop",
"running",
".",
"It",
"is",
"verified",
"whether",
"the",
"given",
"stop",
"criterion",
"is",
"compatible",
"with",
"the",
"search",
"and",
"if",
"not",
"an",
"exception",
"is",
"thrown",
".",
"Note",
"that",
"this",
"method",
"can",
"only",
"be",
"called",
"when",
"the",
"search",
"is",
"idle",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/Search.java#L529-L539
|
11,574
|
maxirosson/jdroid-android
|
jdroid-android-core/src/main/java/com/jdroid/android/utils/TooltipHelper.java
|
TooltipHelper.showCheatSheet
|
private static boolean showCheatSheet(View view, CharSequence text) {
if (TextUtils.isEmpty(text)) {
return false;
}
final int[] screenPos = new int[2]; // origin is device display
final Rect displayFrame = new Rect(); // includes decorations (e.g. status bar)
view.getLocationOnScreen(screenPos);
view.getWindowVisibleDisplayFrame(displayFrame);
final Context context = view.getContext();
final int viewWidth = view.getWidth();
final int viewHeight = view.getHeight();
final int viewCenterX = screenPos[0] + (viewWidth / 2);
final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
final int estimatedToastHeight = (int)(ESTIMATED_TOAST_HEIGHT_DPS * context.getResources().getDisplayMetrics().density);
Toast cheatSheet = Toast.makeText(context, text, Toast.LENGTH_SHORT);
boolean showBelow = screenPos[1] < estimatedToastHeight;
if (showBelow) {
// Show below
// Offsets are after decorations (e.g. status bar) are factored in
cheatSheet.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, viewCenterX - (screenWidth / 2),
(screenPos[1] - displayFrame.top) + viewHeight);
} else {
// Show above
// Offsets are after decorations (e.g. status bar) are factored in
cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, viewCenterX - (screenWidth / 2),
displayFrame.bottom - screenPos[1]);
}
cheatSheet.show();
return true;
}
|
java
|
private static boolean showCheatSheet(View view, CharSequence text) {
if (TextUtils.isEmpty(text)) {
return false;
}
final int[] screenPos = new int[2]; // origin is device display
final Rect displayFrame = new Rect(); // includes decorations (e.g. status bar)
view.getLocationOnScreen(screenPos);
view.getWindowVisibleDisplayFrame(displayFrame);
final Context context = view.getContext();
final int viewWidth = view.getWidth();
final int viewHeight = view.getHeight();
final int viewCenterX = screenPos[0] + (viewWidth / 2);
final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
final int estimatedToastHeight = (int)(ESTIMATED_TOAST_HEIGHT_DPS * context.getResources().getDisplayMetrics().density);
Toast cheatSheet = Toast.makeText(context, text, Toast.LENGTH_SHORT);
boolean showBelow = screenPos[1] < estimatedToastHeight;
if (showBelow) {
// Show below
// Offsets are after decorations (e.g. status bar) are factored in
cheatSheet.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, viewCenterX - (screenWidth / 2),
(screenPos[1] - displayFrame.top) + viewHeight);
} else {
// Show above
// Offsets are after decorations (e.g. status bar) are factored in
cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, viewCenterX - (screenWidth / 2),
displayFrame.bottom - screenPos[1]);
}
cheatSheet.show();
return true;
}
|
[
"private",
"static",
"boolean",
"showCheatSheet",
"(",
"View",
"view",
",",
"CharSequence",
"text",
")",
"{",
"if",
"(",
"TextUtils",
".",
"isEmpty",
"(",
"text",
")",
")",
"{",
"return",
"false",
";",
"}",
"final",
"int",
"[",
"]",
"screenPos",
"=",
"new",
"int",
"[",
"2",
"]",
";",
"// origin is device display",
"final",
"Rect",
"displayFrame",
"=",
"new",
"Rect",
"(",
")",
";",
"// includes decorations (e.g. status bar)",
"view",
".",
"getLocationOnScreen",
"(",
"screenPos",
")",
";",
"view",
".",
"getWindowVisibleDisplayFrame",
"(",
"displayFrame",
")",
";",
"final",
"Context",
"context",
"=",
"view",
".",
"getContext",
"(",
")",
";",
"final",
"int",
"viewWidth",
"=",
"view",
".",
"getWidth",
"(",
")",
";",
"final",
"int",
"viewHeight",
"=",
"view",
".",
"getHeight",
"(",
")",
";",
"final",
"int",
"viewCenterX",
"=",
"screenPos",
"[",
"0",
"]",
"+",
"(",
"viewWidth",
"/",
"2",
")",
";",
"final",
"int",
"screenWidth",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"getDisplayMetrics",
"(",
")",
".",
"widthPixels",
";",
"final",
"int",
"estimatedToastHeight",
"=",
"(",
"int",
")",
"(",
"ESTIMATED_TOAST_HEIGHT_DPS",
"*",
"context",
".",
"getResources",
"(",
")",
".",
"getDisplayMetrics",
"(",
")",
".",
"density",
")",
";",
"Toast",
"cheatSheet",
"=",
"Toast",
".",
"makeText",
"(",
"context",
",",
"text",
",",
"Toast",
".",
"LENGTH_SHORT",
")",
";",
"boolean",
"showBelow",
"=",
"screenPos",
"[",
"1",
"]",
"<",
"estimatedToastHeight",
";",
"if",
"(",
"showBelow",
")",
"{",
"// Show below",
"// Offsets are after decorations (e.g. status bar) are factored in",
"cheatSheet",
".",
"setGravity",
"(",
"Gravity",
".",
"TOP",
"|",
"Gravity",
".",
"CENTER_HORIZONTAL",
",",
"viewCenterX",
"-",
"(",
"screenWidth",
"/",
"2",
")",
",",
"(",
"screenPos",
"[",
"1",
"]",
"-",
"displayFrame",
".",
"top",
")",
"+",
"viewHeight",
")",
";",
"}",
"else",
"{",
"// Show above",
"// Offsets are after decorations (e.g. status bar) are factored in",
"cheatSheet",
".",
"setGravity",
"(",
"Gravity",
".",
"BOTTOM",
"|",
"Gravity",
".",
"CENTER_HORIZONTAL",
",",
"viewCenterX",
"-",
"(",
"screenWidth",
"/",
"2",
")",
",",
"displayFrame",
".",
"bottom",
"-",
"screenPos",
"[",
"1",
"]",
")",
";",
"}",
"cheatSheet",
".",
"show",
"(",
")",
";",
"return",
"true",
";",
"}"
] |
Internal helper method to show the cheat sheet toast.
|
[
"Internal",
"helper",
"method",
"to",
"show",
"the",
"cheat",
"sheet",
"toast",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/utils/TooltipHelper.java#L93-L126
|
11,575
|
maxirosson/jdroid-android
|
jdroid-android-core/src/main/java/com/jdroid/android/location/LocationHelper.java
|
LocationHelper.startLocalization
|
@RequiresPermission(anyOf = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION })
public synchronized void startLocalization() {
if (!started && hasSignificantlyOlderLocation()) {
started = true;
// get all enabled providers
List<String> enabledProviders = locationManager.getProviders(true);
boolean gpsProviderEnabled = enabledProviders != null && enabledProviders.contains(LocationManager.GPS_PROVIDER);
boolean networkProviderEnabled = enabledProviders != null && enabledProviders.contains(LocationManager.NETWORK_PROVIDER);
if (gpsProviderEnabled || networkProviderEnabled) {
if (gpsProviderEnabled) {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, LOCATION_MIN_TIME, 0, this);
}
if (networkProviderEnabled) {
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, LOCATION_MIN_TIME, 0, this);
}
AlarmUtils.scheduleElapsedRealtimeAlarm(SystemClock.elapsedRealtime() + LOCATION_MAX_TIME,
getCancelPendingIntent());
LOGGER.info("Localization started");
} else {
started = false;
LOGGER.info("All providers disabled");
}
}
}
|
java
|
@RequiresPermission(anyOf = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION })
public synchronized void startLocalization() {
if (!started && hasSignificantlyOlderLocation()) {
started = true;
// get all enabled providers
List<String> enabledProviders = locationManager.getProviders(true);
boolean gpsProviderEnabled = enabledProviders != null && enabledProviders.contains(LocationManager.GPS_PROVIDER);
boolean networkProviderEnabled = enabledProviders != null && enabledProviders.contains(LocationManager.NETWORK_PROVIDER);
if (gpsProviderEnabled || networkProviderEnabled) {
if (gpsProviderEnabled) {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, LOCATION_MIN_TIME, 0, this);
}
if (networkProviderEnabled) {
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, LOCATION_MIN_TIME, 0, this);
}
AlarmUtils.scheduleElapsedRealtimeAlarm(SystemClock.elapsedRealtime() + LOCATION_MAX_TIME,
getCancelPendingIntent());
LOGGER.info("Localization started");
} else {
started = false;
LOGGER.info("All providers disabled");
}
}
}
|
[
"@",
"RequiresPermission",
"(",
"anyOf",
"=",
"{",
"Manifest",
".",
"permission",
".",
"ACCESS_COARSE_LOCATION",
",",
"Manifest",
".",
"permission",
".",
"ACCESS_FINE_LOCATION",
"}",
")",
"public",
"synchronized",
"void",
"startLocalization",
"(",
")",
"{",
"if",
"(",
"!",
"started",
"&&",
"hasSignificantlyOlderLocation",
"(",
")",
")",
"{",
"started",
"=",
"true",
";",
"// get all enabled providers",
"List",
"<",
"String",
">",
"enabledProviders",
"=",
"locationManager",
".",
"getProviders",
"(",
"true",
")",
";",
"boolean",
"gpsProviderEnabled",
"=",
"enabledProviders",
"!=",
"null",
"&&",
"enabledProviders",
".",
"contains",
"(",
"LocationManager",
".",
"GPS_PROVIDER",
")",
";",
"boolean",
"networkProviderEnabled",
"=",
"enabledProviders",
"!=",
"null",
"&&",
"enabledProviders",
".",
"contains",
"(",
"LocationManager",
".",
"NETWORK_PROVIDER",
")",
";",
"if",
"(",
"gpsProviderEnabled",
"||",
"networkProviderEnabled",
")",
"{",
"if",
"(",
"gpsProviderEnabled",
")",
"{",
"locationManager",
".",
"requestLocationUpdates",
"(",
"LocationManager",
".",
"GPS_PROVIDER",
",",
"LOCATION_MIN_TIME",
",",
"0",
",",
"this",
")",
";",
"}",
"if",
"(",
"networkProviderEnabled",
")",
"{",
"locationManager",
".",
"requestLocationUpdates",
"(",
"LocationManager",
".",
"NETWORK_PROVIDER",
",",
"LOCATION_MIN_TIME",
",",
"0",
",",
"this",
")",
";",
"}",
"AlarmUtils",
".",
"scheduleElapsedRealtimeAlarm",
"(",
"SystemClock",
".",
"elapsedRealtime",
"(",
")",
"+",
"LOCATION_MAX_TIME",
",",
"getCancelPendingIntent",
"(",
")",
")",
";",
"LOGGER",
".",
"info",
"(",
"\"Localization started\"",
")",
";",
"}",
"else",
"{",
"started",
"=",
"false",
";",
"LOGGER",
".",
"info",
"(",
"\"All providers disabled\"",
")",
";",
"}",
"}",
"}"
] |
Register the listener with the Location Manager to receive location updates
|
[
"Register",
"the",
"listener",
"with",
"the",
"Location",
"Manager",
"to",
"receive",
"location",
"updates"
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/location/LocationHelper.java#L78-L107
|
11,576
|
maxirosson/jdroid-android
|
jdroid-android-core/src/main/java/com/jdroid/android/location/LocationHelper.java
|
LocationHelper.stopLocalization
|
@RequiresPermission(anyOf = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION })
public synchronized void stopLocalization() {
if (started) {
AlarmUtils.cancelAlarm(getCancelPendingIntent());
locationManager.removeUpdates(this);
if (location == null) {
location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location == null) {
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
}
locationTime = DateUtils.nowMillis();
}
started = false;
LOGGER.info("Localization stopped");
}
}
|
java
|
@RequiresPermission(anyOf = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION })
public synchronized void stopLocalization() {
if (started) {
AlarmUtils.cancelAlarm(getCancelPendingIntent());
locationManager.removeUpdates(this);
if (location == null) {
location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location == null) {
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
}
locationTime = DateUtils.nowMillis();
}
started = false;
LOGGER.info("Localization stopped");
}
}
|
[
"@",
"RequiresPermission",
"(",
"anyOf",
"=",
"{",
"Manifest",
".",
"permission",
".",
"ACCESS_COARSE_LOCATION",
",",
"Manifest",
".",
"permission",
".",
"ACCESS_FINE_LOCATION",
"}",
")",
"public",
"synchronized",
"void",
"stopLocalization",
"(",
")",
"{",
"if",
"(",
"started",
")",
"{",
"AlarmUtils",
".",
"cancelAlarm",
"(",
"getCancelPendingIntent",
"(",
")",
")",
";",
"locationManager",
".",
"removeUpdates",
"(",
"this",
")",
";",
"if",
"(",
"location",
"==",
"null",
")",
"{",
"location",
"=",
"locationManager",
".",
"getLastKnownLocation",
"(",
"LocationManager",
".",
"GPS_PROVIDER",
")",
";",
"if",
"(",
"location",
"==",
"null",
")",
"{",
"location",
"=",
"locationManager",
".",
"getLastKnownLocation",
"(",
"LocationManager",
".",
"NETWORK_PROVIDER",
")",
";",
"}",
"locationTime",
"=",
"DateUtils",
".",
"nowMillis",
"(",
")",
";",
"}",
"started",
"=",
"false",
";",
"LOGGER",
".",
"info",
"(",
"\"Localization stopped\"",
")",
";",
"}",
"}"
] |
Remove the listener to receive location updates
|
[
"Remove",
"the",
"listener",
"to",
"receive",
"location",
"updates"
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/location/LocationHelper.java#L118-L133
|
11,577
|
matzew/simple-websocket-client
|
src/main/java/net/wessendorf/websocket/WebSocketUtil.java
|
WebSocketUtil.containsWebSocketScheme
|
public static boolean containsWebSocketScheme(URI uri) {
Objects.requireNonNull(uri, "no URI object given");
final String scheme = uri.getScheme();
if (scheme != null && (scheme.equals(WS_SCHEME) || scheme.equals(WSS_SCHEME))) {
return true;
}
return false;
}
|
java
|
public static boolean containsWebSocketScheme(URI uri) {
Objects.requireNonNull(uri, "no URI object given");
final String scheme = uri.getScheme();
if (scheme != null && (scheme.equals(WS_SCHEME) || scheme.equals(WSS_SCHEME))) {
return true;
}
return false;
}
|
[
"public",
"static",
"boolean",
"containsWebSocketScheme",
"(",
"URI",
"uri",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"uri",
",",
"\"no URI object given\"",
")",
";",
"final",
"String",
"scheme",
"=",
"uri",
".",
"getScheme",
"(",
")",
";",
"if",
"(",
"scheme",
"!=",
"null",
"&&",
"(",
"scheme",
".",
"equals",
"(",
"WS_SCHEME",
")",
"||",
"scheme",
".",
"equals",
"(",
"WSS_SCHEME",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if the given URI is a contains a valid WebSocket scheme
|
[
"Checks",
"if",
"the",
"given",
"URI",
"is",
"a",
"contains",
"a",
"valid",
"WebSocket",
"scheme"
] |
67c207de9de2310feddf70cf90994b1af028b012
|
https://github.com/matzew/simple-websocket-client/blob/67c207de9de2310feddf70cf90994b1af028b012/src/main/java/net/wessendorf/websocket/WebSocketUtil.java#L38-L47
|
11,578
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/lcmsrun/LCMSRunInfo.java
|
LCMSRunInfo.createDummyInfo
|
public static LCMSRunInfo createDummyInfo() {
LCMSRunInfo lcmsRunInfo = new LCMSRunInfo();
lcmsRunInfo.addInstrument(Instrument.getDummy(), Instrument.ID_UNKNOWN);
return lcmsRunInfo;
}
|
java
|
public static LCMSRunInfo createDummyInfo() {
LCMSRunInfo lcmsRunInfo = new LCMSRunInfo();
lcmsRunInfo.addInstrument(Instrument.getDummy(), Instrument.ID_UNKNOWN);
return lcmsRunInfo;
}
|
[
"public",
"static",
"LCMSRunInfo",
"createDummyInfo",
"(",
")",
"{",
"LCMSRunInfo",
"lcmsRunInfo",
"=",
"new",
"LCMSRunInfo",
"(",
")",
";",
"lcmsRunInfo",
".",
"addInstrument",
"(",
"Instrument",
".",
"getDummy",
"(",
")",
",",
"Instrument",
".",
"ID_UNKNOWN",
")",
";",
"return",
"lcmsRunInfo",
";",
"}"
] |
Only use if you can't get real run info.
|
[
"Only",
"use",
"if",
"you",
"can",
"t",
"get",
"real",
"run",
"info",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/lcmsrun/LCMSRunInfo.java#L51-L55
|
11,579
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/lcmsrun/LCMSRunInfo.java
|
LCMSRunInfo.addInstrument
|
public void addInstrument(Instrument instrument, String id) {
if (instrument == null || id == null) {
throw new IllegalArgumentException("Instruemnt and ID must be non-null values.");
}
if (instruments.size() == 0) {
defaultInstrumentID = id;
} else if (instruments.size() > 0 && !isDefaultExplicitlySet) {
unsetDefaultInstrument();
}
instruments.put(id, instrument);
}
|
java
|
public void addInstrument(Instrument instrument, String id) {
if (instrument == null || id == null) {
throw new IllegalArgumentException("Instruemnt and ID must be non-null values.");
}
if (instruments.size() == 0) {
defaultInstrumentID = id;
} else if (instruments.size() > 0 && !isDefaultExplicitlySet) {
unsetDefaultInstrument();
}
instruments.put(id, instrument);
}
|
[
"public",
"void",
"addInstrument",
"(",
"Instrument",
"instrument",
",",
"String",
"id",
")",
"{",
"if",
"(",
"instrument",
"==",
"null",
"||",
"id",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Instruemnt and ID must be non-null values.\"",
")",
";",
"}",
"if",
"(",
"instruments",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"defaultInstrumentID",
"=",
"id",
";",
"}",
"else",
"if",
"(",
"instruments",
".",
"size",
"(",
")",
">",
"0",
"&&",
"!",
"isDefaultExplicitlySet",
")",
"{",
"unsetDefaultInstrument",
"(",
")",
";",
"}",
"instruments",
".",
"put",
"(",
"id",
",",
"instrument",
")",
";",
"}"
] |
If only one instrument is added, it will be set as the default instrument, all the scans, that
you add to the ScanCollection will implicitly refer to this one instrument.
@param id some identifier for mapping instruments. Instrumnt list is normally stored at the
beginning of the run file, so it's a mapping from this list, to instrument ID specified for
each spectrumRef.
|
[
"If",
"only",
"one",
"instrument",
"is",
"added",
"it",
"will",
"be",
"set",
"as",
"the",
"default",
"instrument",
"all",
"the",
"scans",
"that",
"you",
"add",
"to",
"the",
"ScanCollection",
"will",
"implicitly",
"refer",
"to",
"this",
"one",
"instrument",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/lcmsrun/LCMSRunInfo.java#L82-L93
|
11,580
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/lcmsrun/LCMSRunInfo.java
|
LCMSRunInfo.setDefaultInstrumentID
|
public void setDefaultInstrumentID(String id) {
if (id == null) {
unsetDefaultInstrument();
return;
}
if (instruments.containsKey(id)) {
defaultInstrumentID = id;
isDefaultExplicitlySet = true;
} else {
throw new IllegalArgumentException(
"The instrument map did not contain provided instrument ID, " +
"have you added the instrument first?");
}
}
|
java
|
public void setDefaultInstrumentID(String id) {
if (id == null) {
unsetDefaultInstrument();
return;
}
if (instruments.containsKey(id)) {
defaultInstrumentID = id;
isDefaultExplicitlySet = true;
} else {
throw new IllegalArgumentException(
"The instrument map did not contain provided instrument ID, " +
"have you added the instrument first?");
}
}
|
[
"public",
"void",
"setDefaultInstrumentID",
"(",
"String",
"id",
")",
"{",
"if",
"(",
"id",
"==",
"null",
")",
"{",
"unsetDefaultInstrument",
"(",
")",
";",
"return",
";",
"}",
"if",
"(",
"instruments",
".",
"containsKey",
"(",
"id",
")",
")",
"{",
"defaultInstrumentID",
"=",
"id",
";",
"isDefaultExplicitlySet",
"=",
"true",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The instrument map did not contain provided instrument ID, \"",
"+",
"\"have you added the instrument first?\"",
")",
";",
"}",
"}"
] |
Call with null parameter to unset.
@param id this id must be present in the run info already.
|
[
"Call",
"with",
"null",
"parameter",
"to",
"unset",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/lcmsrun/LCMSRunInfo.java#L143-L157
|
11,581
|
jboss/jboss-el-api_spec
|
src/main/java/javax/el/ListELResolver.java
|
ListELResolver.getType
|
public Class<?> getType(ELContext context,
Object base,
Object property) {
if (context == null) {
throw new NullPointerException();
}
if (base != null && base instanceof List) {
context.setPropertyResolved(true);
List list = (List) base;
int index = toInteger(property);
if (index < 0 || index >= list.size()) {
throw new PropertyNotFoundException();
}
return Object.class;
}
return null;
}
|
java
|
public Class<?> getType(ELContext context,
Object base,
Object property) {
if (context == null) {
throw new NullPointerException();
}
if (base != null && base instanceof List) {
context.setPropertyResolved(true);
List list = (List) base;
int index = toInteger(property);
if (index < 0 || index >= list.size()) {
throw new PropertyNotFoundException();
}
return Object.class;
}
return null;
}
|
[
"public",
"Class",
"<",
"?",
">",
"getType",
"(",
"ELContext",
"context",
",",
"Object",
"base",
",",
"Object",
"property",
")",
"{",
"if",
"(",
"context",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"if",
"(",
"base",
"!=",
"null",
"&&",
"base",
"instanceof",
"List",
")",
"{",
"context",
".",
"setPropertyResolved",
"(",
"true",
")",
";",
"List",
"list",
"=",
"(",
"List",
")",
"base",
";",
"int",
"index",
"=",
"toInteger",
"(",
"property",
")",
";",
"if",
"(",
"index",
"<",
"0",
"||",
"index",
">=",
"list",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"PropertyNotFoundException",
"(",
")",
";",
"}",
"return",
"Object",
".",
"class",
";",
"}",
"return",
"null",
";",
"}"
] |
If the base object is a list, returns the most general acceptable type
for a value in this list.
<p>If the base is a <code>List</code>, the <code>propertyResolved</code>
property of the <code>ELContext</code> object must be set to
<code>true</code> by this resolver, before returning. If this property
is not <code>true</code> after this method is called, the caller
should ignore the return value.</p>
<p>Assuming the base is a <code>List</code>, this method will always
return <code>Object.class</code>. This is because <code>List</code>s
accept any object as an element.</p>
@param context The context of this evaluation.
@param base The list to analyze. Only bases of type <code>List</code>
are handled by this resolver.
@param property The index of the element in the list to return the
acceptable type for. Will be coerced into an integer, but
otherwise ignored by this resolver.
@return If the <code>propertyResolved</code> property of
<code>ELContext</code> was set to <code>true</code>, then
the most general acceptable type; otherwise undefined.
@throws PropertyNotFoundException if the given index is out of
bounds for this list.
@throws NullPointerException if context is <code>null</code>
@throws ELException if an exception was thrown while performing
the property or variable resolution. The thrown exception
must be included as the cause property of this exception, if
available.
|
[
"If",
"the",
"base",
"object",
"is",
"a",
"list",
"returns",
"the",
"most",
"general",
"acceptable",
"type",
"for",
"a",
"value",
"in",
"this",
"list",
"."
] |
4cef117cae3ccf9f76439845687a8d219ad2eb43
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ListELResolver.java#L141-L159
|
11,582
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/subset/neigh/moves/SwapMove.java
|
SwapMove.undo
|
@Override
public void undo(SubsetSolution solution) {
// re-add deleted ID
solution.select(delete);
// remove newly added ID
solution.deselect(add);
}
|
java
|
@Override
public void undo(SubsetSolution solution) {
// re-add deleted ID
solution.select(delete);
// remove newly added ID
solution.deselect(add);
}
|
[
"@",
"Override",
"public",
"void",
"undo",
"(",
"SubsetSolution",
"solution",
")",
"{",
"// re-add deleted ID",
"solution",
".",
"select",
"(",
"delete",
")",
";",
"// remove newly added ID",
"solution",
".",
"deselect",
"(",
"add",
")",
";",
"}"
] |
Undo this swap move after it has been successfully applied to the given subset solution,
by removing the newly added ID and re-adding the deleted ID.
@param solution solution to which the move has been applied
|
[
"Undo",
"this",
"swap",
"move",
"after",
"it",
"has",
"been",
"successfully",
"applied",
"to",
"the",
"given",
"subset",
"solution",
"by",
"removing",
"the",
"newly",
"added",
"ID",
"and",
"re",
"-",
"adding",
"the",
"deleted",
"ID",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/neigh/moves/SwapMove.java#L84-L90
|
11,583
|
maxirosson/jdroid-android
|
jdroid-android-core/src/main/java/com/jdroid/android/usecase/AbstractUseCase.java
|
AbstractUseCase.run
|
@Override
public final void run() {
LOGGER.debug("Executing " + getClass().getSimpleName());
markAsInProgress();
if (!Lists.isNullOrEmpty(listeners)) {
Runnable startUseCaseRunnable = new Runnable() {
@Override
public void run() {
for (UseCaseListener listener : listeners) {
notifyUseCaseStart(listener);
}
}
};
if (handler != null) {
handler.post(startUseCaseRunnable);
} else {
startUseCaseRunnable.run();
}
}
Trace trace = null;
if (timingTrackingEnabled()) {
trace = TraceHelper.startTrace(getClass());
}
try {
LOGGER.debug("Started " + getClass().getSimpleName());
executionTime = null;
startTime = DateUtils.nowMillis();
doExecute();
executionTime = DateUtils.nowMillis() - startTime;
LOGGER.debug("Finished " + getClass().getSimpleName() + ". Execution time: " + DateUtils.formatDuration(executionTime));
if (trace != null) {
trace.putAttribute("result", "success");
trace.incrementMetric("successes", 1);
}
markAsSuccessful();
if (!Lists.isNullOrEmpty(listeners)) {
Runnable finishedUseCaseRunnable = new Runnable() {
@Override
public void run() {
for (UseCaseListener listener : listeners) {
notifyFinishedUseCase(listener);
}
markAsNotified();
}
};
if (handler != null) {
handler.post(finishedUseCaseRunnable);
} else {
finishedUseCaseRunnable.run();
}
}
} catch (RuntimeException e) {
if (trace != null) {
trace.putAttribute("result", "failure");
trace.incrementMetric("failures", 1);
}
final AbstractException abstractException = wrapException(e);
markAsFailed(abstractException);
logHandledException(abstractException);
if (!Lists.isNullOrEmpty(listeners)) {
Runnable finishedFailedUseCaseRunnable = new Runnable() {
@Override
public void run() {
for (UseCaseListener listener : listeners) {
notifyFailedUseCase(abstractException, listener);
}
markAsNotified();
}
};
if (handler != null) {
handler.post(finishedFailedUseCaseRunnable);
} else {
finishedFailedUseCaseRunnable.run();
}
}
} finally {
if (trace != null) {
trace.stop();
}
}
}
|
java
|
@Override
public final void run() {
LOGGER.debug("Executing " + getClass().getSimpleName());
markAsInProgress();
if (!Lists.isNullOrEmpty(listeners)) {
Runnable startUseCaseRunnable = new Runnable() {
@Override
public void run() {
for (UseCaseListener listener : listeners) {
notifyUseCaseStart(listener);
}
}
};
if (handler != null) {
handler.post(startUseCaseRunnable);
} else {
startUseCaseRunnable.run();
}
}
Trace trace = null;
if (timingTrackingEnabled()) {
trace = TraceHelper.startTrace(getClass());
}
try {
LOGGER.debug("Started " + getClass().getSimpleName());
executionTime = null;
startTime = DateUtils.nowMillis();
doExecute();
executionTime = DateUtils.nowMillis() - startTime;
LOGGER.debug("Finished " + getClass().getSimpleName() + ". Execution time: " + DateUtils.formatDuration(executionTime));
if (trace != null) {
trace.putAttribute("result", "success");
trace.incrementMetric("successes", 1);
}
markAsSuccessful();
if (!Lists.isNullOrEmpty(listeners)) {
Runnable finishedUseCaseRunnable = new Runnable() {
@Override
public void run() {
for (UseCaseListener listener : listeners) {
notifyFinishedUseCase(listener);
}
markAsNotified();
}
};
if (handler != null) {
handler.post(finishedUseCaseRunnable);
} else {
finishedUseCaseRunnable.run();
}
}
} catch (RuntimeException e) {
if (trace != null) {
trace.putAttribute("result", "failure");
trace.incrementMetric("failures", 1);
}
final AbstractException abstractException = wrapException(e);
markAsFailed(abstractException);
logHandledException(abstractException);
if (!Lists.isNullOrEmpty(listeners)) {
Runnable finishedFailedUseCaseRunnable = new Runnable() {
@Override
public void run() {
for (UseCaseListener listener : listeners) {
notifyFailedUseCase(abstractException, listener);
}
markAsNotified();
}
};
if (handler != null) {
handler.post(finishedFailedUseCaseRunnable);
} else {
finishedFailedUseCaseRunnable.run();
}
}
} finally {
if (trace != null) {
trace.stop();
}
}
}
|
[
"@",
"Override",
"public",
"final",
"void",
"run",
"(",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Executing \"",
"+",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"markAsInProgress",
"(",
")",
";",
"if",
"(",
"!",
"Lists",
".",
"isNullOrEmpty",
"(",
"listeners",
")",
")",
"{",
"Runnable",
"startUseCaseRunnable",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"for",
"(",
"UseCaseListener",
"listener",
":",
"listeners",
")",
"{",
"notifyUseCaseStart",
"(",
"listener",
")",
";",
"}",
"}",
"}",
";",
"if",
"(",
"handler",
"!=",
"null",
")",
"{",
"handler",
".",
"post",
"(",
"startUseCaseRunnable",
")",
";",
"}",
"else",
"{",
"startUseCaseRunnable",
".",
"run",
"(",
")",
";",
"}",
"}",
"Trace",
"trace",
"=",
"null",
";",
"if",
"(",
"timingTrackingEnabled",
"(",
")",
")",
"{",
"trace",
"=",
"TraceHelper",
".",
"startTrace",
"(",
"getClass",
"(",
")",
")",
";",
"}",
"try",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Started \"",
"+",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"executionTime",
"=",
"null",
";",
"startTime",
"=",
"DateUtils",
".",
"nowMillis",
"(",
")",
";",
"doExecute",
"(",
")",
";",
"executionTime",
"=",
"DateUtils",
".",
"nowMillis",
"(",
")",
"-",
"startTime",
";",
"LOGGER",
".",
"debug",
"(",
"\"Finished \"",
"+",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
"+",
"\". Execution time: \"",
"+",
"DateUtils",
".",
"formatDuration",
"(",
"executionTime",
")",
")",
";",
"if",
"(",
"trace",
"!=",
"null",
")",
"{",
"trace",
".",
"putAttribute",
"(",
"\"result\"",
",",
"\"success\"",
")",
";",
"trace",
".",
"incrementMetric",
"(",
"\"successes\"",
",",
"1",
")",
";",
"}",
"markAsSuccessful",
"(",
")",
";",
"if",
"(",
"!",
"Lists",
".",
"isNullOrEmpty",
"(",
"listeners",
")",
")",
"{",
"Runnable",
"finishedUseCaseRunnable",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"for",
"(",
"UseCaseListener",
"listener",
":",
"listeners",
")",
"{",
"notifyFinishedUseCase",
"(",
"listener",
")",
";",
"}",
"markAsNotified",
"(",
")",
";",
"}",
"}",
";",
"if",
"(",
"handler",
"!=",
"null",
")",
"{",
"handler",
".",
"post",
"(",
"finishedUseCaseRunnable",
")",
";",
"}",
"else",
"{",
"finishedUseCaseRunnable",
".",
"run",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"if",
"(",
"trace",
"!=",
"null",
")",
"{",
"trace",
".",
"putAttribute",
"(",
"\"result\"",
",",
"\"failure\"",
")",
";",
"trace",
".",
"incrementMetric",
"(",
"\"failures\"",
",",
"1",
")",
";",
"}",
"final",
"AbstractException",
"abstractException",
"=",
"wrapException",
"(",
"e",
")",
";",
"markAsFailed",
"(",
"abstractException",
")",
";",
"logHandledException",
"(",
"abstractException",
")",
";",
"if",
"(",
"!",
"Lists",
".",
"isNullOrEmpty",
"(",
"listeners",
")",
")",
"{",
"Runnable",
"finishedFailedUseCaseRunnable",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"for",
"(",
"UseCaseListener",
"listener",
":",
"listeners",
")",
"{",
"notifyFailedUseCase",
"(",
"abstractException",
",",
"listener",
")",
";",
"}",
"markAsNotified",
"(",
")",
";",
"}",
"}",
";",
"if",
"(",
"handler",
"!=",
"null",
")",
"{",
"handler",
".",
"post",
"(",
"finishedFailedUseCaseRunnable",
")",
";",
"}",
"else",
"{",
"finishedFailedUseCaseRunnable",
".",
"run",
"(",
")",
";",
"}",
"}",
"}",
"finally",
"{",
"if",
"(",
"trace",
"!=",
"null",
")",
"{",
"trace",
".",
"stop",
"(",
")",
";",
"}",
"}",
"}"
] |
Executes the use case.
|
[
"Executes",
"the",
"use",
"case",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/usecase/AbstractUseCase.java#L54-L144
|
11,584
|
maxirosson/jdroid-android
|
jdroid-android-core/src/main/java/com/jdroid/android/utils/AndroidEncryptionUtils.java
|
AndroidEncryptionUtils.encrypt
|
public static String encrypt(String cleartext) {
if (cleartext != null) {
byte[] result = doFinal(Base64.decode(getBase64Key(), Base64.DEFAULT), Cipher.ENCRYPT_MODE,
cleartext.getBytes());
return Base64.encodeToString(result, Base64.DEFAULT);
}
return null;
}
|
java
|
public static String encrypt(String cleartext) {
if (cleartext != null) {
byte[] result = doFinal(Base64.decode(getBase64Key(), Base64.DEFAULT), Cipher.ENCRYPT_MODE,
cleartext.getBytes());
return Base64.encodeToString(result, Base64.DEFAULT);
}
return null;
}
|
[
"public",
"static",
"String",
"encrypt",
"(",
"String",
"cleartext",
")",
"{",
"if",
"(",
"cleartext",
"!=",
"null",
")",
"{",
"byte",
"[",
"]",
"result",
"=",
"doFinal",
"(",
"Base64",
".",
"decode",
"(",
"getBase64Key",
"(",
")",
",",
"Base64",
".",
"DEFAULT",
")",
",",
"Cipher",
".",
"ENCRYPT_MODE",
",",
"cleartext",
".",
"getBytes",
"(",
")",
")",
";",
"return",
"Base64",
".",
"encodeToString",
"(",
"result",
",",
"Base64",
".",
"DEFAULT",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the data encrypted. Avoid calling this method on the UI thread if possible, since it may access to shared
preferences.
@param cleartext
@return encrypted data
|
[
"Returns",
"the",
"data",
"encrypted",
".",
"Avoid",
"calling",
"this",
"method",
"on",
"the",
"UI",
"thread",
"if",
"possible",
"since",
"it",
"may",
"access",
"to",
"shared",
"preferences",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/utils/AndroidEncryptionUtils.java#L39-L46
|
11,585
|
maxirosson/jdroid-android
|
jdroid-android-core/src/main/java/com/jdroid/android/utils/AndroidEncryptionUtils.java
|
AndroidEncryptionUtils.decrypt
|
public static String decrypt(String base64Encrypted) {
if (base64Encrypted != null) {
byte[] enc = Base64.decode(base64Encrypted, Base64.DEFAULT);
byte[] result = doFinal(Base64.decode(getBase64Key(), Base64.DEFAULT), Cipher.DECRYPT_MODE, enc);
return new String(result);
}
return null;
}
|
java
|
public static String decrypt(String base64Encrypted) {
if (base64Encrypted != null) {
byte[] enc = Base64.decode(base64Encrypted, Base64.DEFAULT);
byte[] result = doFinal(Base64.decode(getBase64Key(), Base64.DEFAULT), Cipher.DECRYPT_MODE, enc);
return new String(result);
}
return null;
}
|
[
"public",
"static",
"String",
"decrypt",
"(",
"String",
"base64Encrypted",
")",
"{",
"if",
"(",
"base64Encrypted",
"!=",
"null",
")",
"{",
"byte",
"[",
"]",
"enc",
"=",
"Base64",
".",
"decode",
"(",
"base64Encrypted",
",",
"Base64",
".",
"DEFAULT",
")",
";",
"byte",
"[",
"]",
"result",
"=",
"doFinal",
"(",
"Base64",
".",
"decode",
"(",
"getBase64Key",
"(",
")",
",",
"Base64",
".",
"DEFAULT",
")",
",",
"Cipher",
".",
"DECRYPT_MODE",
",",
"enc",
")",
";",
"return",
"new",
"String",
"(",
"result",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the original data. Avoid calling this method on the UI thread if possible, since it may access to shared
preferences.
@param base64Encrypted
@return the original data
|
[
"Returns",
"the",
"original",
"data",
".",
"Avoid",
"calling",
"this",
"method",
"on",
"the",
"UI",
"thread",
"if",
"possible",
"since",
"it",
"may",
"access",
"to",
"shared",
"preferences",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/utils/AndroidEncryptionUtils.java#L55-L62
|
11,586
|
maxirosson/jdroid-android
|
jdroid-android-core/src/main/java/com/jdroid/android/utils/AndroidEncryptionUtils.java
|
AndroidEncryptionUtils.generateShaHash
|
public static String generateShaHash(String text) {
try {
MessageDigest digest = MessageDigest.getInstance(SHA_ALGORITHM);
byte[] bytes = text.getBytes(UTF_8);
bytes = digest.digest(bytes);
return toHexEncode(bytes);
} catch (Exception e) {
throw new UnexpectedException(e);
}
}
|
java
|
public static String generateShaHash(String text) {
try {
MessageDigest digest = MessageDigest.getInstance(SHA_ALGORITHM);
byte[] bytes = text.getBytes(UTF_8);
bytes = digest.digest(bytes);
return toHexEncode(bytes);
} catch (Exception e) {
throw new UnexpectedException(e);
}
}
|
[
"public",
"static",
"String",
"generateShaHash",
"(",
"String",
"text",
")",
"{",
"try",
"{",
"MessageDigest",
"digest",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"SHA_ALGORITHM",
")",
";",
"byte",
"[",
"]",
"bytes",
"=",
"text",
".",
"getBytes",
"(",
"UTF_8",
")",
";",
"bytes",
"=",
"digest",
".",
"digest",
"(",
"bytes",
")",
";",
"return",
"toHexEncode",
"(",
"bytes",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"UnexpectedException",
"(",
"e",
")",
";",
"}",
"}"
] |
Generates the SHA hash for the input string.
@param text the input string to hash
@return the hash for the input string in hexadecimal encoding
|
[
"Generates",
"the",
"SHA",
"hash",
"for",
"the",
"input",
"string",
"."
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/utils/AndroidEncryptionUtils.java#L123-L132
|
11,587
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/subset/neigh/moves/GeneralSubsetMove.java
|
GeneralSubsetMove.undo
|
@Override
public void undo(SubsetSolution solution) {
// remove all added IDs
solution.deselectAll(add);
// add all removed IDs
solution.selectAll(delete);
}
|
java
|
@Override
public void undo(SubsetSolution solution) {
// remove all added IDs
solution.deselectAll(add);
// add all removed IDs
solution.selectAll(delete);
}
|
[
"@",
"Override",
"public",
"void",
"undo",
"(",
"SubsetSolution",
"solution",
")",
"{",
"// remove all added IDs",
"solution",
".",
"deselectAll",
"(",
"add",
")",
";",
"// add all removed IDs",
"solution",
".",
"selectAll",
"(",
"delete",
")",
";",
"}"
] |
Undo this move after it has been successfully applied to the given subset solution,
by removing all added IDs and adding all removed IDs. If the subset solution has been
modified since successful application of this move, the result of this operation is
undefined.
@param solution solution to which the move has been successfully applied
|
[
"Undo",
"this",
"move",
"after",
"it",
"has",
"been",
"successfully",
"applied",
"to",
"the",
"given",
"subset",
"solution",
"by",
"removing",
"all",
"added",
"IDs",
"and",
"adding",
"all",
"removed",
"IDs",
".",
"If",
"the",
"subset",
"solution",
"has",
"been",
"modified",
"since",
"successful",
"application",
"of",
"this",
"move",
"the",
"result",
"of",
"this",
"operation",
"is",
"undefined",
"."
] |
4e85c20c142902373e5b5e8b5d12a2558650f66d
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/neigh/moves/GeneralSubsetMove.java#L128-L134
|
11,588
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/types/IPTC.java
|
IPTC.createMetadata
|
@Override
public Metadata createMetadata() {
Metadata metadata = new Metadata();
try {
for (DataSet ds : iimFile.getDataSets()) {
Object value = "";
try {
value = ds.getValue();
} catch (Exception ex) {
}
DataSetInfo info = ds.getInfo();
//System.out.println(info.toString() + " " + info.getName() + ": " + value);
metadata.add(info.getName(), new Text(value.toString()));
}
} catch (Exception ex) {
/*Nothing to be shown*/
}
return metadata;
}
|
java
|
@Override
public Metadata createMetadata() {
Metadata metadata = new Metadata();
try {
for (DataSet ds : iimFile.getDataSets()) {
Object value = "";
try {
value = ds.getValue();
} catch (Exception ex) {
}
DataSetInfo info = ds.getInfo();
//System.out.println(info.toString() + " " + info.getName() + ": " + value);
metadata.add(info.getName(), new Text(value.toString()));
}
} catch (Exception ex) {
/*Nothing to be shown*/
}
return metadata;
}
|
[
"@",
"Override",
"public",
"Metadata",
"createMetadata",
"(",
")",
"{",
"Metadata",
"metadata",
"=",
"new",
"Metadata",
"(",
")",
";",
"try",
"{",
"for",
"(",
"DataSet",
"ds",
":",
"iimFile",
".",
"getDataSets",
"(",
")",
")",
"{",
"Object",
"value",
"=",
"\"\"",
";",
"try",
"{",
"value",
"=",
"ds",
".",
"getValue",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"DataSetInfo",
"info",
"=",
"ds",
".",
"getInfo",
"(",
")",
";",
"//System.out.println(info.toString() + \" \" + info.getName() + \": \" + value);",
"metadata",
".",
"add",
"(",
"info",
".",
"getName",
"(",
")",
",",
"new",
"Text",
"(",
"value",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"/*Nothing to be shown*/",
"}",
"return",
"metadata",
";",
"}"
] |
Creates the metadata.
@return the hash map
|
[
"Creates",
"the",
"metadata",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/types/IPTC.java#L119-L140
|
11,589
|
EasyinnovaSL/Tiff-Library-4J
|
src/main/java/com/easyinnova/tiff/model/types/IPTC.java
|
IPTC.read
|
public void read(TagValue tv, String filename) {
originalValue = tv.getValue();
File file = new File(filename);
IIMReader reader = null;
SubIIMInputStream subStream = null;
try {
int offset = tv.getReadOffset();
int length = tv.getReadlength();
subStream = new SubIIMInputStream(new FileIIMInputStream(file), offset, length);
reader = new IIMReader(subStream, new IIMDataSetInfoFactory());
IIMFile iimFileReader = new IIMFile();
iimFileReader.readFrom(reader, 0);
List<DataSet> lds = new ArrayList<DataSet>();
for (DataSet ds : iimFileReader.getDataSets()) {
ds.getData();
lds.add(ds);
}
iimFile = new IIMFile();
iimFile.setDataSets(lds);
tv.reset();
tv.add(this);
reader.close();
subStream.close();
} catch (IOException e) {
//e.printStackTrace();
try {
reader.close();
subStream.close();
} catch (Exception ex) {
}
} catch (InvalidDataSetException e) {
//e.printStackTrace();
try {
reader.close();
subStream.close();
} catch (Exception ex) {
}
}
}
|
java
|
public void read(TagValue tv, String filename) {
originalValue = tv.getValue();
File file = new File(filename);
IIMReader reader = null;
SubIIMInputStream subStream = null;
try {
int offset = tv.getReadOffset();
int length = tv.getReadlength();
subStream = new SubIIMInputStream(new FileIIMInputStream(file), offset, length);
reader = new IIMReader(subStream, new IIMDataSetInfoFactory());
IIMFile iimFileReader = new IIMFile();
iimFileReader.readFrom(reader, 0);
List<DataSet> lds = new ArrayList<DataSet>();
for (DataSet ds : iimFileReader.getDataSets()) {
ds.getData();
lds.add(ds);
}
iimFile = new IIMFile();
iimFile.setDataSets(lds);
tv.reset();
tv.add(this);
reader.close();
subStream.close();
} catch (IOException e) {
//e.printStackTrace();
try {
reader.close();
subStream.close();
} catch (Exception ex) {
}
} catch (InvalidDataSetException e) {
//e.printStackTrace();
try {
reader.close();
subStream.close();
} catch (Exception ex) {
}
}
}
|
[
"public",
"void",
"read",
"(",
"TagValue",
"tv",
",",
"String",
"filename",
")",
"{",
"originalValue",
"=",
"tv",
".",
"getValue",
"(",
")",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"filename",
")",
";",
"IIMReader",
"reader",
"=",
"null",
";",
"SubIIMInputStream",
"subStream",
"=",
"null",
";",
"try",
"{",
"int",
"offset",
"=",
"tv",
".",
"getReadOffset",
"(",
")",
";",
"int",
"length",
"=",
"tv",
".",
"getReadlength",
"(",
")",
";",
"subStream",
"=",
"new",
"SubIIMInputStream",
"(",
"new",
"FileIIMInputStream",
"(",
"file",
")",
",",
"offset",
",",
"length",
")",
";",
"reader",
"=",
"new",
"IIMReader",
"(",
"subStream",
",",
"new",
"IIMDataSetInfoFactory",
"(",
")",
")",
";",
"IIMFile",
"iimFileReader",
"=",
"new",
"IIMFile",
"(",
")",
";",
"iimFileReader",
".",
"readFrom",
"(",
"reader",
",",
"0",
")",
";",
"List",
"<",
"DataSet",
">",
"lds",
"=",
"new",
"ArrayList",
"<",
"DataSet",
">",
"(",
")",
";",
"for",
"(",
"DataSet",
"ds",
":",
"iimFileReader",
".",
"getDataSets",
"(",
")",
")",
"{",
"ds",
".",
"getData",
"(",
")",
";",
"lds",
".",
"add",
"(",
"ds",
")",
";",
"}",
"iimFile",
"=",
"new",
"IIMFile",
"(",
")",
";",
"iimFile",
".",
"setDataSets",
"(",
"lds",
")",
";",
"tv",
".",
"reset",
"(",
")",
";",
"tv",
".",
"add",
"(",
"this",
")",
";",
"reader",
".",
"close",
"(",
")",
";",
"subStream",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"//e.printStackTrace();",
"try",
"{",
"reader",
".",
"close",
"(",
")",
";",
"subStream",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"}",
"catch",
"(",
"InvalidDataSetException",
"e",
")",
"{",
"//e.printStackTrace();",
"try",
"{",
"reader",
".",
"close",
"(",
")",
";",
"subStream",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"}",
"}"
] |
Reads the IPTC.
@param tv the TagValue containing the array of bytes of the IPTC
|
[
"Reads",
"the",
"IPTC",
"."
] |
682605d3ed207a66213278c054c98f1b909472b7
|
https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/types/IPTC.java#L266-L311
|
11,590
|
maxirosson/jdroid-android
|
jdroid-android-firebase-fcm/src/main/java/com/jdroid/android/firebase/fcm/FcmListenerResolver.java
|
FcmListenerResolver.onMessageReceived
|
public void onMessageReceived(RemoteMessage remoteMessage) {
if (LoggerUtils.isEnabled()) {
StringBuilder builder = new StringBuilder();
builder.append("Message received. ");
builder.append("from: ");
builder.append(remoteMessage.getFrom());
if (remoteMessage.getMessageType() != null) {
builder.append(", ");
builder.append("message type: ");
builder.append(remoteMessage.getMessageType());
}
if (remoteMessage.getData() != null & !remoteMessage.getData().isEmpty()) {
builder.append(", ");
builder.append("data: ");
builder.append(remoteMessage.getData());
}
LOGGER.info(builder.toString());
}
FcmMessageResolver fcmResolver = AbstractFcmAppModule.get().getFcmMessageResolver();
if (fcmResolver != null) {
FcmMessage fcmMessage = null;
try {
fcmMessage = fcmResolver.resolve(remoteMessage);
} catch (Exception e) {
AbstractApplication.get().getExceptionHandler().logHandledException("Error when resolving FCM message", e);
return;
}
if (fcmMessage != null) {
try {
fcmMessage.handle(remoteMessage);
} catch (Exception e) {
AbstractApplication.get().getExceptionHandler().logHandledException("Error when handling FCM message", e);
}
} else {
LOGGER.warn("The FCM message was not resolved");
}
} else {
LOGGER.warn("A FCM message was received, but not resolved is configured");
}
for (FcmEventsListener fcmEventsListener : FcmContext.getFcmEventsListeners()) {
try {
fcmEventsListener.onMessageReceived(remoteMessage);
} catch (Exception e) {
AbstractApplication.get().getExceptionHandler().logHandledException(e);
}
}
}
|
java
|
public void onMessageReceived(RemoteMessage remoteMessage) {
if (LoggerUtils.isEnabled()) {
StringBuilder builder = new StringBuilder();
builder.append("Message received. ");
builder.append("from: ");
builder.append(remoteMessage.getFrom());
if (remoteMessage.getMessageType() != null) {
builder.append(", ");
builder.append("message type: ");
builder.append(remoteMessage.getMessageType());
}
if (remoteMessage.getData() != null & !remoteMessage.getData().isEmpty()) {
builder.append(", ");
builder.append("data: ");
builder.append(remoteMessage.getData());
}
LOGGER.info(builder.toString());
}
FcmMessageResolver fcmResolver = AbstractFcmAppModule.get().getFcmMessageResolver();
if (fcmResolver != null) {
FcmMessage fcmMessage = null;
try {
fcmMessage = fcmResolver.resolve(remoteMessage);
} catch (Exception e) {
AbstractApplication.get().getExceptionHandler().logHandledException("Error when resolving FCM message", e);
return;
}
if (fcmMessage != null) {
try {
fcmMessage.handle(remoteMessage);
} catch (Exception e) {
AbstractApplication.get().getExceptionHandler().logHandledException("Error when handling FCM message", e);
}
} else {
LOGGER.warn("The FCM message was not resolved");
}
} else {
LOGGER.warn("A FCM message was received, but not resolved is configured");
}
for (FcmEventsListener fcmEventsListener : FcmContext.getFcmEventsListeners()) {
try {
fcmEventsListener.onMessageReceived(remoteMessage);
} catch (Exception e) {
AbstractApplication.get().getExceptionHandler().logHandledException(e);
}
}
}
|
[
"public",
"void",
"onMessageReceived",
"(",
"RemoteMessage",
"remoteMessage",
")",
"{",
"if",
"(",
"LoggerUtils",
".",
"isEnabled",
"(",
")",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"\"Message received. \"",
")",
";",
"builder",
".",
"append",
"(",
"\"from: \"",
")",
";",
"builder",
".",
"append",
"(",
"remoteMessage",
".",
"getFrom",
"(",
")",
")",
";",
"if",
"(",
"remoteMessage",
".",
"getMessageType",
"(",
")",
"!=",
"null",
")",
"{",
"builder",
".",
"append",
"(",
"\", \"",
")",
";",
"builder",
".",
"append",
"(",
"\"message type: \"",
")",
";",
"builder",
".",
"append",
"(",
"remoteMessage",
".",
"getMessageType",
"(",
")",
")",
";",
"}",
"if",
"(",
"remoteMessage",
".",
"getData",
"(",
")",
"!=",
"null",
"&",
"!",
"remoteMessage",
".",
"getData",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"builder",
".",
"append",
"(",
"\", \"",
")",
";",
"builder",
".",
"append",
"(",
"\"data: \"",
")",
";",
"builder",
".",
"append",
"(",
"remoteMessage",
".",
"getData",
"(",
")",
")",
";",
"}",
"LOGGER",
".",
"info",
"(",
"builder",
".",
"toString",
"(",
")",
")",
";",
"}",
"FcmMessageResolver",
"fcmResolver",
"=",
"AbstractFcmAppModule",
".",
"get",
"(",
")",
".",
"getFcmMessageResolver",
"(",
")",
";",
"if",
"(",
"fcmResolver",
"!=",
"null",
")",
"{",
"FcmMessage",
"fcmMessage",
"=",
"null",
";",
"try",
"{",
"fcmMessage",
"=",
"fcmResolver",
".",
"resolve",
"(",
"remoteMessage",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"AbstractApplication",
".",
"get",
"(",
")",
".",
"getExceptionHandler",
"(",
")",
".",
"logHandledException",
"(",
"\"Error when resolving FCM message\"",
",",
"e",
")",
";",
"return",
";",
"}",
"if",
"(",
"fcmMessage",
"!=",
"null",
")",
"{",
"try",
"{",
"fcmMessage",
".",
"handle",
"(",
"remoteMessage",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"AbstractApplication",
".",
"get",
"(",
")",
".",
"getExceptionHandler",
"(",
")",
".",
"logHandledException",
"(",
"\"Error when handling FCM message\"",
",",
"e",
")",
";",
"}",
"}",
"else",
"{",
"LOGGER",
".",
"warn",
"(",
"\"The FCM message was not resolved\"",
")",
";",
"}",
"}",
"else",
"{",
"LOGGER",
".",
"warn",
"(",
"\"A FCM message was received, but not resolved is configured\"",
")",
";",
"}",
"for",
"(",
"FcmEventsListener",
"fcmEventsListener",
":",
"FcmContext",
".",
"getFcmEventsListeners",
"(",
")",
")",
"{",
"try",
"{",
"fcmEventsListener",
".",
"onMessageReceived",
"(",
"remoteMessage",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"AbstractApplication",
".",
"get",
"(",
")",
".",
"getExceptionHandler",
"(",
")",
".",
"logHandledException",
"(",
"e",
")",
";",
"}",
"}",
"}"
] |
Called when message is received. Since Android O, have a guaranteed life cycle limited to 10 seconds for this method execution
|
[
"Called",
"when",
"message",
"is",
"received",
".",
"Since",
"Android",
"O",
"have",
"a",
"guaranteed",
"life",
"cycle",
"limited",
"to",
"10",
"seconds",
"for",
"this",
"method",
"execution"
] |
1ba9cae56a16fa36bdb2c9c04379853f0300707f
|
https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-firebase-fcm/src/main/java/com/jdroid/android/firebase/fcm/FcmListenerResolver.java#L16-L68
|
11,591
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java
|
ScanCollectionDefault.getScanByNum
|
@Override
public IScan getScanByNum(int scanNum) {
IScan scan = getNum2scan().get(scanNum);
if (scan != null) {
return scan;
}
return null;
}
|
java
|
@Override
public IScan getScanByNum(int scanNum) {
IScan scan = getNum2scan().get(scanNum);
if (scan != null) {
return scan;
}
return null;
}
|
[
"@",
"Override",
"public",
"IScan",
"getScanByNum",
"(",
"int",
"scanNum",
")",
"{",
"IScan",
"scan",
"=",
"getNum2scan",
"(",
")",
".",
"get",
"(",
"scanNum",
")",
";",
"if",
"(",
"scan",
"!=",
"null",
")",
"{",
"return",
"scan",
";",
"}",
"return",
"null",
";",
"}"
] |
The name says it all.
@param scanNum Scan number as it was in the original MS file
@return Scan or null, if no such scan number exists in this ScanCollection
|
[
"The",
"name",
"says",
"it",
"all",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java#L338-L345
|
11,592
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java
|
ScanCollectionDefault.getScanByNumLower
|
@Override
public IScan getScanByNumLower(int scanNum) {
IScan scan = getNum2scan().lowerEntry(scanNum).getValue();
if (scan != null) {
return scan;
}
return null;
}
|
java
|
@Override
public IScan getScanByNumLower(int scanNum) {
IScan scan = getNum2scan().lowerEntry(scanNum).getValue();
if (scan != null) {
return scan;
}
return null;
}
|
[
"@",
"Override",
"public",
"IScan",
"getScanByNumLower",
"(",
"int",
"scanNum",
")",
"{",
"IScan",
"scan",
"=",
"getNum2scan",
"(",
")",
".",
"lowerEntry",
"(",
"scanNum",
")",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"scan",
"!=",
"null",
")",
"{",
"return",
"scan",
";",
"}",
"return",
"null",
";",
"}"
] |
Scan with closest Number STRICTLY less than the provided one is returned.
@param scanNum scan number
@return Scan or null, if the ScanCollection didn't have any scans with numbers <= than this one
|
[
"Scan",
"with",
"closest",
"Number",
"STRICTLY",
"less",
"than",
"the",
"provided",
"one",
"is",
"returned",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java#L353-L360
|
11,593
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java
|
ScanCollectionDefault.getScanByNumUpper
|
@Override
public IScan getScanByNumUpper(int scanNum) {
IScan scan = getNum2scan().ceilingEntry(scanNum).getValue();
if (scan != null) {
return scan;
}
return null;
}
|
java
|
@Override
public IScan getScanByNumUpper(int scanNum) {
IScan scan = getNum2scan().ceilingEntry(scanNum).getValue();
if (scan != null) {
return scan;
}
return null;
}
|
[
"@",
"Override",
"public",
"IScan",
"getScanByNumUpper",
"(",
"int",
"scanNum",
")",
"{",
"IScan",
"scan",
"=",
"getNum2scan",
"(",
")",
".",
"ceilingEntry",
"(",
"scanNum",
")",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"scan",
"!=",
"null",
")",
"{",
"return",
"scan",
";",
"}",
"return",
"null",
";",
"}"
] |
Scan with the closest Number greater or equal to the provided one is returned.
@param scanNum scan number
@return Scan or null, if the ScanCollection didn't have any scans with numbers >= than this
one
|
[
"Scan",
"with",
"the",
"closest",
"Number",
"greater",
"or",
"equal",
"to",
"the",
"provided",
"one",
"is",
"returned",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java#L369-L376
|
11,594
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java
|
ScanCollectionDefault.getScanByNumClosest
|
@Override
public IScan getScanByNumClosest(int scanNum) {
IScan result = null;
Map.Entry<Integer, IScan> lower = getNum2scan().lowerEntry(scanNum);
Map.Entry<Integer, IScan> upper = getNum2scan().ceilingEntry(scanNum);
if (upper != null && lower != null) {
result =
Integer.compare(lower.getKey(), upper.getKey()) > 0 ? lower.getValue() : upper.getValue();
} else if (upper != null) {
result = upper.getValue();
} else if (lower != null) {
result = lower.getValue();
}
return result;
}
|
java
|
@Override
public IScan getScanByNumClosest(int scanNum) {
IScan result = null;
Map.Entry<Integer, IScan> lower = getNum2scan().lowerEntry(scanNum);
Map.Entry<Integer, IScan> upper = getNum2scan().ceilingEntry(scanNum);
if (upper != null && lower != null) {
result =
Integer.compare(lower.getKey(), upper.getKey()) > 0 ? lower.getValue() : upper.getValue();
} else if (upper != null) {
result = upper.getValue();
} else if (lower != null) {
result = lower.getValue();
}
return result;
}
|
[
"@",
"Override",
"public",
"IScan",
"getScanByNumClosest",
"(",
"int",
"scanNum",
")",
"{",
"IScan",
"result",
"=",
"null",
";",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"IScan",
">",
"lower",
"=",
"getNum2scan",
"(",
")",
".",
"lowerEntry",
"(",
"scanNum",
")",
";",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"IScan",
">",
"upper",
"=",
"getNum2scan",
"(",
")",
".",
"ceilingEntry",
"(",
"scanNum",
")",
";",
"if",
"(",
"upper",
"!=",
"null",
"&&",
"lower",
"!=",
"null",
")",
"{",
"result",
"=",
"Integer",
".",
"compare",
"(",
"lower",
".",
"getKey",
"(",
")",
",",
"upper",
".",
"getKey",
"(",
")",
")",
">",
"0",
"?",
"lower",
".",
"getValue",
"(",
")",
":",
"upper",
".",
"getValue",
"(",
")",
";",
"}",
"else",
"if",
"(",
"upper",
"!=",
"null",
")",
"{",
"result",
"=",
"upper",
".",
"getValue",
"(",
")",
";",
"}",
"else",
"if",
"(",
"lower",
"!=",
"null",
")",
"{",
"result",
"=",
"lower",
".",
"getValue",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Scan with the closest Number is returned.
@param scanNum scan number
@return null might be returned in an extreme case when the scan collection is empty.
|
[
"Scan",
"with",
"the",
"closest",
"Number",
"is",
"returned",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java#L384-L398
|
11,595
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java
|
ScanCollectionDefault.getScansByRtLower
|
@Override
public List<IScan> getScansByRtLower(double rt) {
Map.Entry<Double, List<IScan>> lowerEntry = getRt2scan().lowerEntry(rt);
if (lowerEntry == null) {
return null;
}
List<IScan> scans = lowerEntry.getValue();
if (scans != null) {
return scans;
}
return null;
}
|
java
|
@Override
public List<IScan> getScansByRtLower(double rt) {
Map.Entry<Double, List<IScan>> lowerEntry = getRt2scan().lowerEntry(rt);
if (lowerEntry == null) {
return null;
}
List<IScan> scans = lowerEntry.getValue();
if (scans != null) {
return scans;
}
return null;
}
|
[
"@",
"Override",
"public",
"List",
"<",
"IScan",
">",
"getScansByRtLower",
"(",
"double",
"rt",
")",
"{",
"Map",
".",
"Entry",
"<",
"Double",
",",
"List",
"<",
"IScan",
">",
">",
"lowerEntry",
"=",
"getRt2scan",
"(",
")",
".",
"lowerEntry",
"(",
"rt",
")",
";",
"if",
"(",
"lowerEntry",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"List",
"<",
"IScan",
">",
"scans",
"=",
"lowerEntry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"scans",
"!=",
"null",
")",
"{",
"return",
"scans",
";",
"}",
"return",
"null",
";",
"}"
] |
Scan List with closest RT less or equal to the provided one are returned.
|
[
"Scan",
"List",
"with",
"closest",
"RT",
"less",
"or",
"equal",
"to",
"the",
"provided",
"one",
"are",
"returned",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java#L418-L429
|
11,596
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java
|
ScanCollectionDefault.getScansByRtUpper
|
@Override
public List<IScan> getScansByRtUpper(double rt) {
Map.Entry<Double, List<IScan>> ceilingEntry = getMapRt2scan().ceilingEntry(rt);
if (ceilingEntry == null) {
return null;
}
List<IScan> scans = ceilingEntry.getValue();
if (scans != null) {
return scans;
}
return null;
}
|
java
|
@Override
public List<IScan> getScansByRtUpper(double rt) {
Map.Entry<Double, List<IScan>> ceilingEntry = getMapRt2scan().ceilingEntry(rt);
if (ceilingEntry == null) {
return null;
}
List<IScan> scans = ceilingEntry.getValue();
if (scans != null) {
return scans;
}
return null;
}
|
[
"@",
"Override",
"public",
"List",
"<",
"IScan",
">",
"getScansByRtUpper",
"(",
"double",
"rt",
")",
"{",
"Map",
".",
"Entry",
"<",
"Double",
",",
"List",
"<",
"IScan",
">",
">",
"ceilingEntry",
"=",
"getMapRt2scan",
"(",
")",
".",
"ceilingEntry",
"(",
"rt",
")",
";",
"if",
"(",
"ceilingEntry",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"List",
"<",
"IScan",
">",
"scans",
"=",
"ceilingEntry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"scans",
"!=",
"null",
")",
"{",
"return",
"scans",
";",
"}",
"return",
"null",
";",
"}"
] |
Scan List with the closest RT greater or equal to the provided one are returned.
|
[
"Scan",
"List",
"with",
"the",
"closest",
"RT",
"greater",
"or",
"equal",
"to",
"the",
"provided",
"one",
"are",
"returned",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java#L434-L445
|
11,597
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java
|
ScanCollectionDefault.getScansByRtClosest
|
@Override
public List<IScan> getScansByRtClosest(double rt) {
List<IScan> result = null;
Map.Entry<Double, List<IScan>> lower = getMapRt2scan().lowerEntry(rt);
Map.Entry<Double, List<IScan>> upper = getMapRt2scan().ceilingEntry(rt);
if (upper != null && lower != null) {
if (Math.abs(rt - lower.getKey()) <= Math.abs(rt - upper.getKey())) {
result = lower.getValue();
} else {
result = upper.getValue();
}
// result = Double.compare(lower.getKey(), upper.getKey()) > 0 ? lower.getValue() : upper.getValue();
} else if (upper != null) {
result = upper.getValue();
} else if (lower != null) {
result = lower.getValue();
}
return result;
}
|
java
|
@Override
public List<IScan> getScansByRtClosest(double rt) {
List<IScan> result = null;
Map.Entry<Double, List<IScan>> lower = getMapRt2scan().lowerEntry(rt);
Map.Entry<Double, List<IScan>> upper = getMapRt2scan().ceilingEntry(rt);
if (upper != null && lower != null) {
if (Math.abs(rt - lower.getKey()) <= Math.abs(rt - upper.getKey())) {
result = lower.getValue();
} else {
result = upper.getValue();
}
// result = Double.compare(lower.getKey(), upper.getKey()) > 0 ? lower.getValue() : upper.getValue();
} else if (upper != null) {
result = upper.getValue();
} else if (lower != null) {
result = lower.getValue();
}
return result;
}
|
[
"@",
"Override",
"public",
"List",
"<",
"IScan",
">",
"getScansByRtClosest",
"(",
"double",
"rt",
")",
"{",
"List",
"<",
"IScan",
">",
"result",
"=",
"null",
";",
"Map",
".",
"Entry",
"<",
"Double",
",",
"List",
"<",
"IScan",
">",
">",
"lower",
"=",
"getMapRt2scan",
"(",
")",
".",
"lowerEntry",
"(",
"rt",
")",
";",
"Map",
".",
"Entry",
"<",
"Double",
",",
"List",
"<",
"IScan",
">",
">",
"upper",
"=",
"getMapRt2scan",
"(",
")",
".",
"ceilingEntry",
"(",
"rt",
")",
";",
"if",
"(",
"upper",
"!=",
"null",
"&&",
"lower",
"!=",
"null",
")",
"{",
"if",
"(",
"Math",
".",
"abs",
"(",
"rt",
"-",
"lower",
".",
"getKey",
"(",
")",
")",
"<=",
"Math",
".",
"abs",
"(",
"rt",
"-",
"upper",
".",
"getKey",
"(",
")",
")",
")",
"{",
"result",
"=",
"lower",
".",
"getValue",
"(",
")",
";",
"}",
"else",
"{",
"result",
"=",
"upper",
".",
"getValue",
"(",
")",
";",
"}",
"// result = Double.compare(lower.getKey(), upper.getKey()) > 0 ? lower.getValue() : upper.getValue();",
"}",
"else",
"if",
"(",
"upper",
"!=",
"null",
")",
"{",
"result",
"=",
"upper",
".",
"getValue",
"(",
")",
";",
"}",
"else",
"if",
"(",
"lower",
"!=",
"null",
")",
"{",
"result",
"=",
"lower",
".",
"getValue",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Scans with the closest RT are returned.
@return null if no scans were found at all, but this should only happen if your ScanCollection
is empty.
|
[
"Scans",
"with",
"the",
"closest",
"RT",
"are",
"returned",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java#L453-L471
|
11,598
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java
|
ScanCollectionDefault.getScanCountAtMsLevel
|
@Override
public Integer getScanCountAtMsLevel(int msLevel) {
TreeMap<Integer, IScan> msLevelScanMap = getMapMsLevel2index().get(msLevel).getNum2scan();
if (msLevelScanMap != null) {
return msLevelScanMap.size();
}
return null;
}
|
java
|
@Override
public Integer getScanCountAtMsLevel(int msLevel) {
TreeMap<Integer, IScan> msLevelScanMap = getMapMsLevel2index().get(msLevel).getNum2scan();
if (msLevelScanMap != null) {
return msLevelScanMap.size();
}
return null;
}
|
[
"@",
"Override",
"public",
"Integer",
"getScanCountAtMsLevel",
"(",
"int",
"msLevel",
")",
"{",
"TreeMap",
"<",
"Integer",
",",
"IScan",
">",
"msLevelScanMap",
"=",
"getMapMsLevel2index",
"(",
")",
".",
"get",
"(",
"msLevel",
")",
".",
"getNum2scan",
"(",
")",
";",
"if",
"(",
"msLevelScanMap",
"!=",
"null",
")",
"{",
"return",
"msLevelScanMap",
".",
"size",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
If the msLevel doesn't exist in this ScanCollectionDefault, returns null
@return null, if msLevel doesn't exist. Actual number of scans otherwise.
|
[
"If",
"the",
"msLevel",
"doesn",
"t",
"exist",
"in",
"this",
"ScanCollectionDefault",
"returns",
"null"
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java#L599-L606
|
11,599
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java
|
ScanCollectionDefault.getScansInSubsetByNumber
|
private NavigableMap<Integer, IScan> getScansInSubsetByNumber(
NavigableMap<Integer, IScan> scanMap, LCMSDataSubset subset) {
NavigableMap<Integer, IScan> scansInSubsetByNumber = scanMap;
if (subset.getScanNumLo() != null) {
scansInSubsetByNumber
.subMap(subset.getScanNumLo(), true, scansInSubsetByNumber.lastKey(), true);
}
if (subset.getScanNumHi() != null) {
scansInSubsetByNumber
.subMap(scansInSubsetByNumber.firstKey(), true, subset.getScanNumHi(), true);
}
return scansInSubsetByNumber;
}
|
java
|
private NavigableMap<Integer, IScan> getScansInSubsetByNumber(
NavigableMap<Integer, IScan> scanMap, LCMSDataSubset subset) {
NavigableMap<Integer, IScan> scansInSubsetByNumber = scanMap;
if (subset.getScanNumLo() != null) {
scansInSubsetByNumber
.subMap(subset.getScanNumLo(), true, scansInSubsetByNumber.lastKey(), true);
}
if (subset.getScanNumHi() != null) {
scansInSubsetByNumber
.subMap(scansInSubsetByNumber.firstKey(), true, subset.getScanNumHi(), true);
}
return scansInSubsetByNumber;
}
|
[
"private",
"NavigableMap",
"<",
"Integer",
",",
"IScan",
">",
"getScansInSubsetByNumber",
"(",
"NavigableMap",
"<",
"Integer",
",",
"IScan",
">",
"scanMap",
",",
"LCMSDataSubset",
"subset",
")",
"{",
"NavigableMap",
"<",
"Integer",
",",
"IScan",
">",
"scansInSubsetByNumber",
"=",
"scanMap",
";",
"if",
"(",
"subset",
".",
"getScanNumLo",
"(",
")",
"!=",
"null",
")",
"{",
"scansInSubsetByNumber",
".",
"subMap",
"(",
"subset",
".",
"getScanNumLo",
"(",
")",
",",
"true",
",",
"scansInSubsetByNumber",
".",
"lastKey",
"(",
")",
",",
"true",
")",
";",
"}",
"if",
"(",
"subset",
".",
"getScanNumHi",
"(",
")",
"!=",
"null",
")",
"{",
"scansInSubsetByNumber",
".",
"subMap",
"(",
"scansInSubsetByNumber",
".",
"firstKey",
"(",
")",
",",
"true",
",",
"subset",
".",
"getScanNumHi",
"(",
")",
",",
"true",
")",
";",
"}",
"return",
"scansInSubsetByNumber",
";",
"}"
] |
It won't filter the scanMap according the the full subset predicate, it only selects scan
number range. Further checks for ms-levels and precursor ranges is required. It's just a
convenience method.
@param scanMap use {@link #getMapNum2scan() } for the broadest use
@param subset only scan numbers will be used for filtering the scanMap
|
[
"It",
"won",
"t",
"filter",
"the",
"scanMap",
"according",
"the",
"the",
"full",
"subset",
"predicate",
"it",
"only",
"selects",
"scan",
"number",
"range",
".",
"Further",
"checks",
"for",
"ms",
"-",
"levels",
"and",
"precursor",
"ranges",
"is",
"required",
".",
"It",
"s",
"just",
"a",
"convenience",
"method",
"."
] |
e53ae6be982e2de3123292be7d5297715bec70bb
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/scancollection/impl/ScanCollectionDefault.java#L750-L762
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.