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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
9,900
|
DjDCH/Log4j-StaticShutdown
|
src/main/java/com/djdch/log4j/StaticShutdownCallbackRegistry.java
|
StaticShutdownCallbackRegistry.run
|
@Override
public void run() {
if (state.compareAndSet(State.STARTED, State.STOPPING)) {
for (final Runnable hook : hooks) {
try {
hook.run();
} catch (final Throwable t) {
LOGGER.error(SHUTDOWN_HOOK_MARKER, "Caught exception executing shutdown hook {}", hook, t);
}
}
state.set(State.STOPPED);
}
}
|
java
|
@Override
public void run() {
if (state.compareAndSet(State.STARTED, State.STOPPING)) {
for (final Runnable hook : hooks) {
try {
hook.run();
} catch (final Throwable t) {
LOGGER.error(SHUTDOWN_HOOK_MARKER, "Caught exception executing shutdown hook {}", hook, t);
}
}
state.set(State.STOPPED);
}
}
|
[
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"if",
"(",
"state",
".",
"compareAndSet",
"(",
"State",
".",
"STARTED",
",",
"State",
".",
"STOPPING",
")",
")",
"{",
"for",
"(",
"final",
"Runnable",
"hook",
":",
"hooks",
")",
"{",
"try",
"{",
"hook",
".",
"run",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"Throwable",
"t",
")",
"{",
"LOGGER",
".",
"error",
"(",
"SHUTDOWN_HOOK_MARKER",
",",
"\"Caught exception executing shutdown hook {}\"",
",",
"hook",
",",
"t",
")",
";",
"}",
"}",
"state",
".",
"set",
"(",
"State",
".",
"STOPPED",
")",
";",
"}",
"}"
] |
Executes the registered shutdown callbacks.
|
[
"Executes",
"the",
"registered",
"shutdown",
"callbacks",
"."
] |
4b3b30742950d1834f0613d241c58097e2d313b7
|
https://github.com/DjDCH/Log4j-StaticShutdown/blob/4b3b30742950d1834f0613d241c58097e2d313b7/src/main/java/com/djdch/log4j/StaticShutdownCallbackRegistry.java#L54-L66
|
9,901
|
flexguse/validation-violation-checker
|
src/main/java/de/flexguse/util/junit/ValidationViolationChecker.java
|
ValidationViolationChecker.checkExpectedValidationViolations
|
public void checkExpectedValidationViolations(
Set<ConstraintViolation<T>> violations,
List<String> expectedValidationViolations) {
if (violations != null && expectedValidationViolations != null) {
List<String> givenViolations = new ArrayList<String>();
for (ConstraintViolation<T> violation : violations) {
givenViolations.add(violation.getMessageTemplate());
}
checkViolations(givenViolations, expectedValidationViolations);
}
}
|
java
|
public void checkExpectedValidationViolations(
Set<ConstraintViolation<T>> violations,
List<String> expectedValidationViolations) {
if (violations != null && expectedValidationViolations != null) {
List<String> givenViolations = new ArrayList<String>();
for (ConstraintViolation<T> violation : violations) {
givenViolations.add(violation.getMessageTemplate());
}
checkViolations(givenViolations, expectedValidationViolations);
}
}
|
[
"public",
"void",
"checkExpectedValidationViolations",
"(",
"Set",
"<",
"ConstraintViolation",
"<",
"T",
">",
">",
"violations",
",",
"List",
"<",
"String",
">",
"expectedValidationViolations",
")",
"{",
"if",
"(",
"violations",
"!=",
"null",
"&&",
"expectedValidationViolations",
"!=",
"null",
")",
"{",
"List",
"<",
"String",
">",
"givenViolations",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"ConstraintViolation",
"<",
"T",
">",
"violation",
":",
"violations",
")",
"{",
"givenViolations",
".",
"add",
"(",
"violation",
".",
"getMessageTemplate",
"(",
")",
")",
";",
"}",
"checkViolations",
"(",
"givenViolations",
",",
"expectedValidationViolations",
")",
";",
"}",
"}"
] |
This method checks the violations against expected violations.
@param violations
validation violations
@param expectedValidationViolations
list of expected validation violation message templates
|
[
"This",
"method",
"checks",
"the",
"violations",
"against",
"expected",
"violations",
"."
] |
6005adfaedd9a23cf3821b91ce5e43c6a498bb8d
|
https://github.com/flexguse/validation-violation-checker/blob/6005adfaedd9a23cf3821b91ce5e43c6a498bb8d/src/main/java/de/flexguse/util/junit/ValidationViolationChecker.java#L57-L71
|
9,902
|
flexguse/validation-violation-checker
|
src/main/java/de/flexguse/util/junit/ValidationViolationChecker.java
|
ValidationViolationChecker.checkExpectedValidationViolations
|
public static void checkExpectedValidationViolations(
ConstraintViolationException exception,
List<String> expectedValidationViolations) {
if (exception != null && expectedValidationViolations != null) {
List<String> givenViolations = new ArrayList<String>();
for (ConstraintViolation<?> violation : exception
.getConstraintViolations()) {
givenViolations.add(violation.getMessageTemplate());
}
checkViolations(givenViolations, expectedValidationViolations);
}
}
|
java
|
public static void checkExpectedValidationViolations(
ConstraintViolationException exception,
List<String> expectedValidationViolations) {
if (exception != null && expectedValidationViolations != null) {
List<String> givenViolations = new ArrayList<String>();
for (ConstraintViolation<?> violation : exception
.getConstraintViolations()) {
givenViolations.add(violation.getMessageTemplate());
}
checkViolations(givenViolations, expectedValidationViolations);
}
}
|
[
"public",
"static",
"void",
"checkExpectedValidationViolations",
"(",
"ConstraintViolationException",
"exception",
",",
"List",
"<",
"String",
">",
"expectedValidationViolations",
")",
"{",
"if",
"(",
"exception",
"!=",
"null",
"&&",
"expectedValidationViolations",
"!=",
"null",
")",
"{",
"List",
"<",
"String",
">",
"givenViolations",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"ConstraintViolation",
"<",
"?",
">",
"violation",
":",
"exception",
".",
"getConstraintViolations",
"(",
")",
")",
"{",
"givenViolations",
".",
"add",
"(",
"violation",
".",
"getMessageTemplate",
"(",
")",
")",
";",
"}",
"checkViolations",
"(",
"givenViolations",
",",
"expectedValidationViolations",
")",
";",
"}",
"}"
] |
This method checks if the validation violations matches the violations
given in a ViolationException.
@param exception
the {@link ConstraintViolationException} containig all
violations
@param expectedValidationViolations
list of expected validation violation message templates
|
[
"This",
"method",
"checks",
"if",
"the",
"validation",
"violations",
"matches",
"the",
"violations",
"given",
"in",
"a",
"ViolationException",
"."
] |
6005adfaedd9a23cf3821b91ce5e43c6a498bb8d
|
https://github.com/flexguse/validation-violation-checker/blob/6005adfaedd9a23cf3821b91ce5e43c6a498bb8d/src/main/java/de/flexguse/util/junit/ValidationViolationChecker.java#L83-L99
|
9,903
|
flexguse/validation-violation-checker
|
src/main/java/de/flexguse/util/junit/ValidationViolationChecker.java
|
ValidationViolationChecker.checkViolations
|
private static void checkViolations(List<String> givenViolations,
List<String> expectedValidationViolations) {
/*
* check if number of expected violations matches the given violations
*/
Assert.assertEquals(
String.format(
"number of expected validation violations (%s) does not match the number of given violations (%s)",
StringUtils.join(expectedValidationViolations,
LIST_DELIMITER), StringUtils.join(
givenViolations, LIST_DELIMITER)),
expectedValidationViolations.size(), givenViolations.size());
/*
* check if the set of given violations matches the expected violations
*/
boolean listsAreCongruent = true;
List<String> givenButNotExpected = new ArrayList<String>();
for (String givenViolation : givenViolations) {
if (!expectedValidationViolations.contains(givenViolation)) {
listsAreCongruent = false;
givenButNotExpected.add(givenViolation);
}
}
Assert.assertTrue(
String.format(
"the violations (%s) where given but not expected: all given violations (%s), all expected violations (%s)",
StringUtils.join(givenButNotExpected, LIST_DELIMITER),
StringUtils.join(givenViolations, LIST_DELIMITER),
StringUtils.join(expectedValidationViolations,
LIST_DELIMITER)), listsAreCongruent);
}
|
java
|
private static void checkViolations(List<String> givenViolations,
List<String> expectedValidationViolations) {
/*
* check if number of expected violations matches the given violations
*/
Assert.assertEquals(
String.format(
"number of expected validation violations (%s) does not match the number of given violations (%s)",
StringUtils.join(expectedValidationViolations,
LIST_DELIMITER), StringUtils.join(
givenViolations, LIST_DELIMITER)),
expectedValidationViolations.size(), givenViolations.size());
/*
* check if the set of given violations matches the expected violations
*/
boolean listsAreCongruent = true;
List<String> givenButNotExpected = new ArrayList<String>();
for (String givenViolation : givenViolations) {
if (!expectedValidationViolations.contains(givenViolation)) {
listsAreCongruent = false;
givenButNotExpected.add(givenViolation);
}
}
Assert.assertTrue(
String.format(
"the violations (%s) where given but not expected: all given violations (%s), all expected violations (%s)",
StringUtils.join(givenButNotExpected, LIST_DELIMITER),
StringUtils.join(givenViolations, LIST_DELIMITER),
StringUtils.join(expectedValidationViolations,
LIST_DELIMITER)), listsAreCongruent);
}
|
[
"private",
"static",
"void",
"checkViolations",
"(",
"List",
"<",
"String",
">",
"givenViolations",
",",
"List",
"<",
"String",
">",
"expectedValidationViolations",
")",
"{",
"/*\n\t\t * check if number of expected violations matches the given violations\n\t\t */",
"Assert",
".",
"assertEquals",
"(",
"String",
".",
"format",
"(",
"\"number of expected validation violations (%s) does not match the number of given violations (%s)\"",
",",
"StringUtils",
".",
"join",
"(",
"expectedValidationViolations",
",",
"LIST_DELIMITER",
")",
",",
"StringUtils",
".",
"join",
"(",
"givenViolations",
",",
"LIST_DELIMITER",
")",
")",
",",
"expectedValidationViolations",
".",
"size",
"(",
")",
",",
"givenViolations",
".",
"size",
"(",
")",
")",
";",
"/*\n\t\t * check if the set of given violations matches the expected violations\n\t\t */",
"boolean",
"listsAreCongruent",
"=",
"true",
";",
"List",
"<",
"String",
">",
"givenButNotExpected",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"givenViolation",
":",
"givenViolations",
")",
"{",
"if",
"(",
"!",
"expectedValidationViolations",
".",
"contains",
"(",
"givenViolation",
")",
")",
"{",
"listsAreCongruent",
"=",
"false",
";",
"givenButNotExpected",
".",
"add",
"(",
"givenViolation",
")",
";",
"}",
"}",
"Assert",
".",
"assertTrue",
"(",
"String",
".",
"format",
"(",
"\"the violations (%s) where given but not expected: all given violations (%s), all expected violations (%s)\"",
",",
"StringUtils",
".",
"join",
"(",
"givenButNotExpected",
",",
"LIST_DELIMITER",
")",
",",
"StringUtils",
".",
"join",
"(",
"givenViolations",
",",
"LIST_DELIMITER",
")",
",",
"StringUtils",
".",
"join",
"(",
"expectedValidationViolations",
",",
"LIST_DELIMITER",
")",
")",
",",
"listsAreCongruent",
")",
";",
"}"
] |
Helper method doing the checking work.
@param givenViolations
@param expectedValidationViolations
|
[
"Helper",
"method",
"doing",
"the",
"checking",
"work",
"."
] |
6005adfaedd9a23cf3821b91ce5e43c6a498bb8d
|
https://github.com/flexguse/validation-violation-checker/blob/6005adfaedd9a23cf3821b91ce5e43c6a498bb8d/src/main/java/de/flexguse/util/junit/ValidationViolationChecker.java#L107-L143
|
9,904
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/JsonMapper.java
|
JsonMapper.toJson
|
public synchronized String toJson(Object input)
throws JsonException {
try {
// depth = 0;
return recurse(input);
} catch (IOException e) {
throw new JsonException(e);
}
}
|
java
|
public synchronized String toJson(Object input)
throws JsonException {
try {
// depth = 0;
return recurse(input);
} catch (IOException e) {
throw new JsonException(e);
}
}
|
[
"public",
"synchronized",
"String",
"toJson",
"(",
"Object",
"input",
")",
"throws",
"JsonException",
"{",
"try",
"{",
"// depth = 0;",
"return",
"recurse",
"(",
"input",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"JsonException",
"(",
"e",
")",
";",
"}",
"}"
] |
Converts a given object into a JSON String
@param input the object to convert into json
@return the JSON string corresponding to the given object.
@throws JsonException If the object can not be converted to a JSON string.
|
[
"Converts",
"a",
"given",
"object",
"into",
"a",
"JSON",
"String"
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/JsonMapper.java#L130-L138
|
9,905
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/JsonMapper.java
|
JsonMapper.fromJson
|
public synchronized <T> T fromJson(String jsonString, Class<T> clazz)
throws JsonException {
if (jsonString == null) {
return null;
}
Reader reader = new StringReader(jsonString);
try {
return mapper.readValue(reader, clazz);
} catch (JsonParseException e) {
throw new JsonException(e.getMessage(), e);
} catch (JsonMappingException e) {
throw new JsonException(e.getMessage(), e);
} catch (IOException e) {
throw new JsonException(e.getMessage(), e);
}
}
|
java
|
public synchronized <T> T fromJson(String jsonString, Class<T> clazz)
throws JsonException {
if (jsonString == null) {
return null;
}
Reader reader = new StringReader(jsonString);
try {
return mapper.readValue(reader, clazz);
} catch (JsonParseException e) {
throw new JsonException(e.getMessage(), e);
} catch (JsonMappingException e) {
throw new JsonException(e.getMessage(), e);
} catch (IOException e) {
throw new JsonException(e.getMessage(), e);
}
}
|
[
"public",
"synchronized",
"<",
"T",
">",
"T",
"fromJson",
"(",
"String",
"jsonString",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"throws",
"JsonException",
"{",
"if",
"(",
"jsonString",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Reader",
"reader",
"=",
"new",
"StringReader",
"(",
"jsonString",
")",
";",
"try",
"{",
"return",
"mapper",
".",
"readValue",
"(",
"reader",
",",
"clazz",
")",
";",
"}",
"catch",
"(",
"JsonParseException",
"e",
")",
"{",
"throw",
"new",
"JsonException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"catch",
"(",
"JsonMappingException",
"e",
")",
"{",
"throw",
"new",
"JsonException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"JsonException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Converts a given string into an object of the given class.
@param clazz The class to which the returned object should belong
@param jsonString the jsonstring representing the object to be parsed
@param <T> the type of the returned object
@return an instantiated object of class T corresponding to the given jsonstring
@throws JsonException If deserialization failed or if the object of class T could for some reason not be
constructed.
|
[
"Converts",
"a",
"given",
"string",
"into",
"an",
"object",
"of",
"the",
"given",
"class",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/JsonMapper.java#L150-L165
|
9,906
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/JsonMapper.java
|
JsonMapper.collectionFromJson
|
public <T> List<T> collectionFromJson(String json, Class<T> clazz) throws JsonException {
if (json == null) {
return null;
}
try {
List<T> result = new ArrayList<T>();
List tempParseResult = (List) mapper.readValue(json, new TypeReference<List<T>>() {
});
for (Object temp : tempParseResult) {
result.add(fromJson(toJson(temp), clazz));
}
return result;
} catch (JsonParseException e) {
throw new JsonException(e.getMessage(), e);
} catch (JsonMappingException e) {
throw new JsonException(e.getMessage(), e);
} catch (IOException e) {
throw new JsonException(e.getMessage(), e);
}
}
|
java
|
public <T> List<T> collectionFromJson(String json, Class<T> clazz) throws JsonException {
if (json == null) {
return null;
}
try {
List<T> result = new ArrayList<T>();
List tempParseResult = (List) mapper.readValue(json, new TypeReference<List<T>>() {
});
for (Object temp : tempParseResult) {
result.add(fromJson(toJson(temp), clazz));
}
return result;
} catch (JsonParseException e) {
throw new JsonException(e.getMessage(), e);
} catch (JsonMappingException e) {
throw new JsonException(e.getMessage(), e);
} catch (IOException e) {
throw new JsonException(e.getMessage(), e);
}
}
|
[
"public",
"<",
"T",
">",
"List",
"<",
"T",
">",
"collectionFromJson",
"(",
"String",
"json",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"throws",
"JsonException",
"{",
"if",
"(",
"json",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"List",
"<",
"T",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"List",
"tempParseResult",
"=",
"(",
"List",
")",
"mapper",
".",
"readValue",
"(",
"json",
",",
"new",
"TypeReference",
"<",
"List",
"<",
"T",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"for",
"(",
"Object",
"temp",
":",
"tempParseResult",
")",
"{",
"result",
".",
"add",
"(",
"fromJson",
"(",
"toJson",
"(",
"temp",
")",
",",
"clazz",
")",
")",
";",
"}",
"return",
"result",
";",
"}",
"catch",
"(",
"JsonParseException",
"e",
")",
"{",
"throw",
"new",
"JsonException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"catch",
"(",
"JsonMappingException",
"e",
")",
"{",
"throw",
"new",
"JsonException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"JsonException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Converts a JsonString into a corresponding javaobject of the requested type.
@param json the inputstring to be converted to a javaobject
@param clazz the class to which the resulting object should belong to
@param <T> the type of the result elements
@return An object of type T that corresponds with the given json string.
@throws JsonException If something went wrong converting the jsonstring into an object
|
[
"Converts",
"a",
"JsonString",
"into",
"a",
"corresponding",
"javaobject",
"of",
"the",
"requested",
"type",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/JsonMapper.java#L176-L196
|
9,907
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/JsonMapper.java
|
JsonMapper.recurse
|
protected String recurse(Object input)
throws IOException {
increaseDepth();
if (depth > MAXIMUMDEPTH) {
decreaseDepth();
return "{ \"error\": \"maximum serialization-depth reached.\" }";
}
StringWriter writer = new StringWriter();
mapper.writeValue(writer, input);
writer.close();
decreaseDepth();
return writer.getBuffer().toString();
}
|
java
|
protected String recurse(Object input)
throws IOException {
increaseDepth();
if (depth > MAXIMUMDEPTH) {
decreaseDepth();
return "{ \"error\": \"maximum serialization-depth reached.\" }";
}
StringWriter writer = new StringWriter();
mapper.writeValue(writer, input);
writer.close();
decreaseDepth();
return writer.getBuffer().toString();
}
|
[
"protected",
"String",
"recurse",
"(",
"Object",
"input",
")",
"throws",
"IOException",
"{",
"increaseDepth",
"(",
")",
";",
"if",
"(",
"depth",
">",
"MAXIMUMDEPTH",
")",
"{",
"decreaseDepth",
"(",
")",
";",
"return",
"\"{ \\\"error\\\": \\\"maximum serialization-depth reached.\\\" }\"",
";",
"}",
"StringWriter",
"writer",
"=",
"new",
"StringWriter",
"(",
")",
";",
"mapper",
".",
"writeValue",
"(",
"writer",
",",
"input",
")",
";",
"writer",
".",
"close",
"(",
")",
";",
"decreaseDepth",
"(",
")",
";",
"return",
"writer",
".",
"getBuffer",
"(",
")",
".",
"toString",
"(",
")",
";",
"}"
] |
This method should only be used by serializers who need recursive calls. It prevents overflow due to circular
references and ensures that the maximum depth of different sub-parts is limited
@param input the object to serialize
@return the jsonserialization of the given object
@throws java.io.IOException If serialisation of the object failed.
|
[
"This",
"method",
"should",
"only",
"be",
"used",
"by",
"serializers",
"who",
"need",
"recursive",
"calls",
".",
"It",
"prevents",
"overflow",
"due",
"to",
"circular",
"references",
"and",
"ensures",
"that",
"the",
"maximum",
"depth",
"of",
"different",
"sub",
"-",
"parts",
"is",
"limited"
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/JsonMapper.java#L213-L225
|
9,908
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/JsonMapper.java
|
JsonMapper.addClassSerializer
|
public <T> void addClassSerializer(Class<? extends T> classToMap, JsonSerializer<T> classSerializer) {
setNewObjectMapper(); // Is this right, setting a new object mapper on each add operation?
SimpleModule mod = new SimpleModule("GeolatteCommonModule-" + classSerializer.getClass().getSimpleName());
mod.addSerializer(classToMap, classSerializer);
mapper.registerModule(mod);
}
|
java
|
public <T> void addClassSerializer(Class<? extends T> classToMap, JsonSerializer<T> classSerializer) {
setNewObjectMapper(); // Is this right, setting a new object mapper on each add operation?
SimpleModule mod = new SimpleModule("GeolatteCommonModule-" + classSerializer.getClass().getSimpleName());
mod.addSerializer(classToMap, classSerializer);
mapper.registerModule(mod);
}
|
[
"public",
"<",
"T",
">",
"void",
"addClassSerializer",
"(",
"Class",
"<",
"?",
"extends",
"T",
">",
"classToMap",
",",
"JsonSerializer",
"<",
"T",
">",
"classSerializer",
")",
"{",
"setNewObjectMapper",
"(",
")",
";",
"// Is this right, setting a new object mapper on each add operation?",
"SimpleModule",
"mod",
"=",
"new",
"SimpleModule",
"(",
"\"GeolatteCommonModule-\"",
"+",
"classSerializer",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"mod",
".",
"addSerializer",
"(",
"classToMap",
",",
"classSerializer",
")",
";",
"mapper",
".",
"registerModule",
"(",
"mod",
")",
";",
"}"
] |
Adds a serializer to this mapper. Allows a user to alter the serialization behavior for a certain type.
@param classToMap the class to map
@param classSerializer the serializer
@param <T> the type of objects that will be serialized by the given serializer
|
[
"Adds",
"a",
"serializer",
"to",
"this",
"mapper",
".",
"Allows",
"a",
"user",
"to",
"alter",
"the",
"serialization",
"behavior",
"for",
"a",
"certain",
"type",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/JsonMapper.java#L234-L239
|
9,909
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/JsonMapper.java
|
JsonMapper.addClassDeserializer
|
public <T> void addClassDeserializer(Class<T> classToMap, JsonDeserializer<? extends T> classDeserializer) {
setNewObjectMapper(); // Is this right, setting a new object mapper on each add operation?
SimpleModule mod = new SimpleModule("GeolatteCommonModule-" + classDeserializer.getClass().getSimpleName());
mod.addDeserializer(classToMap, classDeserializer);
mapper.registerModule(mod);
}
|
java
|
public <T> void addClassDeserializer(Class<T> classToMap, JsonDeserializer<? extends T> classDeserializer) {
setNewObjectMapper(); // Is this right, setting a new object mapper on each add operation?
SimpleModule mod = new SimpleModule("GeolatteCommonModule-" + classDeserializer.getClass().getSimpleName());
mod.addDeserializer(classToMap, classDeserializer);
mapper.registerModule(mod);
}
|
[
"public",
"<",
"T",
">",
"void",
"addClassDeserializer",
"(",
"Class",
"<",
"T",
">",
"classToMap",
",",
"JsonDeserializer",
"<",
"?",
"extends",
"T",
">",
"classDeserializer",
")",
"{",
"setNewObjectMapper",
"(",
")",
";",
"// Is this right, setting a new object mapper on each add operation?",
"SimpleModule",
"mod",
"=",
"new",
"SimpleModule",
"(",
"\"GeolatteCommonModule-\"",
"+",
"classDeserializer",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"mod",
".",
"addDeserializer",
"(",
"classToMap",
",",
"classDeserializer",
")",
";",
"mapper",
".",
"registerModule",
"(",
"mod",
")",
";",
"}"
] |
Adds a deserializer to this mapper. Allows a user to alter the deserialization behavior for a certain type.
@param classToMap the class for which the given serializer is meant
@param classDeserializer the serializer
@param <T> the type of objects that will be serialized by the given serializer
|
[
"Adds",
"a",
"deserializer",
"to",
"this",
"mapper",
".",
"Allows",
"a",
"user",
"to",
"alter",
"the",
"deserialization",
"behavior",
"for",
"a",
"certain",
"type",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/JsonMapper.java#L248-L253
|
9,910
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/JsonMapper.java
|
JsonMapper.setNewObjectMapper
|
private void setNewObjectMapper() {
mapper = new ObjectMapper();
if (!serializeNullValues) {
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
if (ignoreUnknownProperties) {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
}
}
|
java
|
private void setNewObjectMapper() {
mapper = new ObjectMapper();
if (!serializeNullValues) {
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
if (ignoreUnknownProperties) {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
}
}
|
[
"private",
"void",
"setNewObjectMapper",
"(",
")",
"{",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
")",
";",
"if",
"(",
"!",
"serializeNullValues",
")",
"{",
"mapper",
".",
"setSerializationInclusion",
"(",
"JsonInclude",
".",
"Include",
".",
"NON_NULL",
")",
";",
"if",
"(",
"ignoreUnknownProperties",
")",
"{",
"mapper",
".",
"configure",
"(",
"DeserializationFeature",
".",
"FAIL_ON_UNKNOWN_PROPERTIES",
",",
"false",
")",
";",
"}",
"}",
"}"
] |
Sets a new object mapper, taking into account the original configuration parameters.
|
[
"Sets",
"a",
"new",
"object",
"mapper",
"taking",
"into",
"account",
"the",
"original",
"configuration",
"parameters",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/JsonMapper.java#L301-L309
|
9,911
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/to/GeoJsonTo.java
|
GeoJsonTo.createCrsTo
|
public static CrsTo createCrsTo(String crsName) {
String nameToUse = crsName == null ? "EPSG:4326" : crsName;
CrsTo result = new CrsTo();
NamedCrsPropertyTo property = new NamedCrsPropertyTo();
property.setName(nameToUse);
result.setProperties(property);
return result;
}
|
java
|
public static CrsTo createCrsTo(String crsName) {
String nameToUse = crsName == null ? "EPSG:4326" : crsName;
CrsTo result = new CrsTo();
NamedCrsPropertyTo property = new NamedCrsPropertyTo();
property.setName(nameToUse);
result.setProperties(property);
return result;
}
|
[
"public",
"static",
"CrsTo",
"createCrsTo",
"(",
"String",
"crsName",
")",
"{",
"String",
"nameToUse",
"=",
"crsName",
"==",
"null",
"?",
"\"EPSG:4326\"",
":",
"crsName",
";",
"CrsTo",
"result",
"=",
"new",
"CrsTo",
"(",
")",
";",
"NamedCrsPropertyTo",
"property",
"=",
"new",
"NamedCrsPropertyTo",
"(",
")",
";",
"property",
".",
"setName",
"(",
"nameToUse",
")",
";",
"result",
".",
"setProperties",
"(",
"property",
")",
";",
"return",
"result",
";",
"}"
] |
Convenience method to create a named crs to.
@param crsName the name of the crs to use, if null, the default crs for geojson is used.
@return the transfer object that corresponds with the default Crs. According to the GeoJson spec
The default CRS is a geographic coordinate reference system, using the WGS84 datum, and with longitude
and latitude units of decimal degrees.
|
[
"Convenience",
"method",
"to",
"create",
"a",
"named",
"crs",
"to",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/to/GeoJsonTo.java#L146-L153
|
9,912
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/to/GeoJsonTo.java
|
GeoJsonTo.createBoundingBox
|
public static double[] createBoundingBox(double[] coordinates) {
int maxActualCoords = Math.min(coordinates.length,3);// ignore potential M values, so 4 dimension (X Y Z M) becomes X Y Z
double[] result = new double[maxActualCoords * 2];
for (int i = 0; i < maxActualCoords; i++) {
result[i] = coordinates[i];
result[maxActualCoords + i] = coordinates[i];
}
return result;
}
|
java
|
public static double[] createBoundingBox(double[] coordinates) {
int maxActualCoords = Math.min(coordinates.length,3);// ignore potential M values, so 4 dimension (X Y Z M) becomes X Y Z
double[] result = new double[maxActualCoords * 2];
for (int i = 0; i < maxActualCoords; i++) {
result[i] = coordinates[i];
result[maxActualCoords + i] = coordinates[i];
}
return result;
}
|
[
"public",
"static",
"double",
"[",
"]",
"createBoundingBox",
"(",
"double",
"[",
"]",
"coordinates",
")",
"{",
"int",
"maxActualCoords",
"=",
"Math",
".",
"min",
"(",
"coordinates",
".",
"length",
",",
"3",
")",
";",
"// ignore potential M values, so 4 dimension (X Y Z M) becomes X Y Z",
"double",
"[",
"]",
"result",
"=",
"new",
"double",
"[",
"maxActualCoords",
"*",
"2",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"maxActualCoords",
";",
"i",
"++",
")",
"{",
"result",
"[",
"i",
"]",
"=",
"coordinates",
"[",
"i",
"]",
";",
"result",
"[",
"maxActualCoords",
"+",
"i",
"]",
"=",
"coordinates",
"[",
"i",
"]",
";",
"}",
"return",
"result",
";",
"}"
] |
Creates a boundingbox for a point. In this case, both the lower and higher edges of the bbox are the point
itself
@param coordinates the coordinates of the point
@return the boundingbox, a list with doubles. the result is a 2*n array where n is the number of dimensions
represented in the input, with the lowest values for all axes followed by the highest values.
|
[
"Creates",
"a",
"boundingbox",
"for",
"a",
"point",
".",
"In",
"this",
"case",
"both",
"the",
"lower",
"and",
"higher",
"edges",
"of",
"the",
"bbox",
"are",
"the",
"point",
"itself"
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/to/GeoJsonTo.java#L164-L172
|
9,913
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/to/GeoJsonTo.java
|
GeoJsonTo.mergeInto
|
private static void mergeInto(double[] first, double[] second) {
for (int j = 0; j < first.length / 2; j++) {
first[j] = Math.min(first[j], second[j]);
first[j + first.length / 2] = Math.max(first[j + first.length / 2], second[j + first.length / 2]);
}
}
|
java
|
private static void mergeInto(double[] first, double[] second) {
for (int j = 0; j < first.length / 2; j++) {
first[j] = Math.min(first[j], second[j]);
first[j + first.length / 2] = Math.max(first[j + first.length / 2], second[j + first.length / 2]);
}
}
|
[
"private",
"static",
"void",
"mergeInto",
"(",
"double",
"[",
"]",
"first",
",",
"double",
"[",
"]",
"second",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"first",
".",
"length",
"/",
"2",
";",
"j",
"++",
")",
"{",
"first",
"[",
"j",
"]",
"=",
"Math",
".",
"min",
"(",
"first",
"[",
"j",
"]",
",",
"second",
"[",
"j",
"]",
")",
";",
"first",
"[",
"j",
"+",
"first",
".",
"length",
"/",
"2",
"]",
"=",
"Math",
".",
"max",
"(",
"first",
"[",
"j",
"+",
"first",
".",
"length",
"/",
"2",
"]",
",",
"second",
"[",
"j",
"+",
"first",
".",
"length",
"/",
"2",
"]",
")",
";",
"}",
"}"
] |
Merges the second boundingbox into the first. Basically, this extends the first boundingbox to also
encapsulate the second
@param first the first boundingbox
@param second the second boundingbox
|
[
"Merges",
"the",
"second",
"boundingbox",
"into",
"the",
"first",
".",
"Basically",
"this",
"extends",
"the",
"first",
"boundingbox",
"to",
"also",
"encapsulate",
"the",
"second"
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/to/GeoJsonTo.java#L242-L247
|
9,914
|
tdebatty/spark-kmedoids
|
spark-kmedoids/src/main/java/info/debatty/spark/kmedoids/L2Similarity.java
|
L2Similarity.distance
|
public final double distance(final double[] value1, final double[] value2) {
double agg = 0;
for (int i = 0; i < value1.length; i++) {
agg += (value1[i] - value2[i]) * (value1[i] - value2[i]);
}
return Math.sqrt(agg);
}
|
java
|
public final double distance(final double[] value1, final double[] value2) {
double agg = 0;
for (int i = 0; i < value1.length; i++) {
agg += (value1[i] - value2[i]) * (value1[i] - value2[i]);
}
return Math.sqrt(agg);
}
|
[
"public",
"final",
"double",
"distance",
"(",
"final",
"double",
"[",
"]",
"value1",
",",
"final",
"double",
"[",
"]",
"value2",
")",
"{",
"double",
"agg",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"value1",
".",
"length",
";",
"i",
"++",
")",
"{",
"agg",
"+=",
"(",
"value1",
"[",
"i",
"]",
"-",
"value2",
"[",
"i",
"]",
")",
"*",
"(",
"value1",
"[",
"i",
"]",
"-",
"value2",
"[",
"i",
"]",
")",
";",
"}",
"return",
"Math",
".",
"sqrt",
"(",
"agg",
")",
";",
"}"
] |
Compute traditional Euclidean distance.
@param value1
@param value2
@return
|
[
"Compute",
"traditional",
"Euclidean",
"distance",
"."
] |
73cc1f105d3e0baadba41329e826715b319c6181
|
https://github.com/tdebatty/spark-kmedoids/blob/73cc1f105d3e0baadba41329e826715b319c6181/spark-kmedoids/src/main/java/info/debatty/spark/kmedoids/L2Similarity.java#L39-L45
|
9,915
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/cql/CqlFilterTransformation.java
|
CqlFilterTransformation.transform
|
public Boolean transform(T input) throws TransformationException {
try {
return cqlFilter.evaluate(input);
}
catch (ParseException e) {
throw new TransformationException(e, input);
}
}
|
java
|
public Boolean transform(T input) throws TransformationException {
try {
return cqlFilter.evaluate(input);
}
catch (ParseException e) {
throw new TransformationException(e, input);
}
}
|
[
"public",
"Boolean",
"transform",
"(",
"T",
"input",
")",
"throws",
"TransformationException",
"{",
"try",
"{",
"return",
"cqlFilter",
".",
"evaluate",
"(",
"input",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"throw",
"new",
"TransformationException",
"(",
"e",
",",
"input",
")",
";",
"}",
"}"
] |
Checks whether the given input object passes the cql filter.
@param input The object to evaluate
@return True if the given object passes the cql filter, false otherwise.
|
[
"Checks",
"whether",
"the",
"given",
"input",
"object",
"passes",
"the",
"cql",
"filter",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/cql/CqlFilterTransformation.java#L62-L73
|
9,916
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/geo/EnvelopeConverter.java
|
EnvelopeConverter.createEnvelope
|
public Envelope createEnvelope(double[] coordinates)
throws TypeConversionException {
if (coordinates.length < 4) {
throw new TypeConversionException("Not enough coordinates in inputstring");
} else {
double minX = Double.MAX_VALUE;
double minY = Double.MAX_VALUE;
double maxX = Double.MIN_VALUE;
double maxY = Double.MIN_VALUE;
for (int i = 0 ; i < coordinates.length; i++){
if (i % 2 == 0) {
if (coordinates[i] < minX) minX = coordinates[i];
if (coordinates[i] > maxX) maxX = coordinates[i];
} else {
if (coordinates[i] < minY) minY = coordinates[i];
if (coordinates[i] > maxY) maxY = coordinates[i];
}
}
return new Envelope(minX, minY, maxX, maxY);
}
}
|
java
|
public Envelope createEnvelope(double[] coordinates)
throws TypeConversionException {
if (coordinates.length < 4) {
throw new TypeConversionException("Not enough coordinates in inputstring");
} else {
double minX = Double.MAX_VALUE;
double minY = Double.MAX_VALUE;
double maxX = Double.MIN_VALUE;
double maxY = Double.MIN_VALUE;
for (int i = 0 ; i < coordinates.length; i++){
if (i % 2 == 0) {
if (coordinates[i] < minX) minX = coordinates[i];
if (coordinates[i] > maxX) maxX = coordinates[i];
} else {
if (coordinates[i] < minY) minY = coordinates[i];
if (coordinates[i] > maxY) maxY = coordinates[i];
}
}
return new Envelope(minX, minY, maxX, maxY);
}
}
|
[
"public",
"Envelope",
"createEnvelope",
"(",
"double",
"[",
"]",
"coordinates",
")",
"throws",
"TypeConversionException",
"{",
"if",
"(",
"coordinates",
".",
"length",
"<",
"4",
")",
"{",
"throw",
"new",
"TypeConversionException",
"(",
"\"Not enough coordinates in inputstring\"",
")",
";",
"}",
"else",
"{",
"double",
"minX",
"=",
"Double",
".",
"MAX_VALUE",
";",
"double",
"minY",
"=",
"Double",
".",
"MAX_VALUE",
";",
"double",
"maxX",
"=",
"Double",
".",
"MIN_VALUE",
";",
"double",
"maxY",
"=",
"Double",
".",
"MIN_VALUE",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"coordinates",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"%",
"2",
"==",
"0",
")",
"{",
"if",
"(",
"coordinates",
"[",
"i",
"]",
"<",
"minX",
")",
"minX",
"=",
"coordinates",
"[",
"i",
"]",
";",
"if",
"(",
"coordinates",
"[",
"i",
"]",
">",
"maxX",
")",
"maxX",
"=",
"coordinates",
"[",
"i",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"coordinates",
"[",
"i",
"]",
"<",
"minY",
")",
"minY",
"=",
"coordinates",
"[",
"i",
"]",
";",
"if",
"(",
"coordinates",
"[",
"i",
"]",
">",
"maxY",
")",
"maxY",
"=",
"coordinates",
"[",
"i",
"]",
";",
"}",
"}",
"return",
"new",
"Envelope",
"(",
"minX",
",",
"minY",
",",
"maxX",
",",
"maxY",
")",
";",
"}",
"}"
] |
Creates an envelope based on a list of coordinates. If less than two coordinates are in the list,
a typeconversion exception is thrown. If more than two coordinates are in the list, the minimum X- and
Y-coordinates are searched.
@param coordinates A list with the coordinates of the envelope
@return An envelope with the given coordinates
@throws TypeConversionException If the creation of the envelope failed
|
[
"Creates",
"an",
"envelope",
"based",
"on",
"a",
"list",
"of",
"coordinates",
".",
"If",
"less",
"than",
"two",
"coordinates",
"are",
"in",
"the",
"list",
"a",
"typeconversion",
"exception",
"is",
"thrown",
".",
"If",
"more",
"than",
"two",
"coordinates",
"are",
"in",
"the",
"list",
"the",
"minimum",
"X",
"-",
"and",
"Y",
"-",
"coordinates",
"are",
"searched",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/geo/EnvelopeConverter.java#L68-L88
|
9,917
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/geo/EnvelopeConverter.java
|
EnvelopeConverter.getCoordinates
|
public double[] getCoordinates(String inputString)
throws TypeConversionException {
String[] cstr = inputString.split(",");
int coordLength;
if (cstr.length % 2 == 0) {
coordLength = cstr.length;
} else {
coordLength = cstr.length -1;
}
double[] coordinates = new double[coordLength];
try {
for (int index = 0; index < coordLength; index++) {
coordinates[index] = Double.parseDouble(cstr[index]);
}
return coordinates;
} catch (NumberFormatException e) {
throw new TypeConversionException("String contains non-numeric data. Impossible to create envelope", e);
}
}
|
java
|
public double[] getCoordinates(String inputString)
throws TypeConversionException {
String[] cstr = inputString.split(",");
int coordLength;
if (cstr.length % 2 == 0) {
coordLength = cstr.length;
} else {
coordLength = cstr.length -1;
}
double[] coordinates = new double[coordLength];
try {
for (int index = 0; index < coordLength; index++) {
coordinates[index] = Double.parseDouble(cstr[index]);
}
return coordinates;
} catch (NumberFormatException e) {
throw new TypeConversionException("String contains non-numeric data. Impossible to create envelope", e);
}
}
|
[
"public",
"double",
"[",
"]",
"getCoordinates",
"(",
"String",
"inputString",
")",
"throws",
"TypeConversionException",
"{",
"String",
"[",
"]",
"cstr",
"=",
"inputString",
".",
"split",
"(",
"\",\"",
")",
";",
"int",
"coordLength",
";",
"if",
"(",
"cstr",
".",
"length",
"%",
"2",
"==",
"0",
")",
"{",
"coordLength",
"=",
"cstr",
".",
"length",
";",
"}",
"else",
"{",
"coordLength",
"=",
"cstr",
".",
"length",
"-",
"1",
";",
"}",
"double",
"[",
"]",
"coordinates",
"=",
"new",
"double",
"[",
"coordLength",
"]",
";",
"try",
"{",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"coordLength",
";",
"index",
"++",
")",
"{",
"coordinates",
"[",
"index",
"]",
"=",
"Double",
".",
"parseDouble",
"(",
"cstr",
"[",
"index",
"]",
")",
";",
"}",
"return",
"coordinates",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"throw",
"new",
"TypeConversionException",
"(",
"\"String contains non-numeric data. Impossible to create envelope\"",
",",
"e",
")",
";",
"}",
"}"
] |
Retrieves a list of coordinates from the given string. If the number of numbers in the string is odd,
the last number is ignored.
@param inputString The inputstring
@return A list of coordinates
@throws TypeConversionException If the conversion failed
|
[
"Retrieves",
"a",
"list",
"of",
"coordinates",
"from",
"the",
"given",
"string",
".",
"If",
"the",
"number",
"of",
"numbers",
"in",
"the",
"string",
"is",
"odd",
"the",
"last",
"number",
"is",
"ignored",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/geo/EnvelopeConverter.java#L98-L117
|
9,918
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/transformer/SimpleTransformerSink.java
|
SimpleTransformerSink.start
|
public void start() {
collectedOutput = new ArrayList<T>();
for (T element : input) {
collectedOutput.add(element);
}
}
|
java
|
public void start() {
collectedOutput = new ArrayList<T>();
for (T element : input) {
collectedOutput.add(element);
}
}
|
[
"public",
"void",
"start",
"(",
")",
"{",
"collectedOutput",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"for",
"(",
"T",
"element",
":",
"input",
")",
"{",
"collectedOutput",
".",
"add",
"(",
"element",
")",
";",
"}",
"}"
] |
Starts iterating over its input.
|
[
"Starts",
"iterating",
"over",
"its",
"input",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/transformer/SimpleTransformerSink.java#L60-L68
|
9,919
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/cql/AbstractBuilder.java
|
AbstractBuilder.getPropertyPath
|
protected String getPropertyPath(Collection<String> parts) {
StringBuilder propertyPath = new StringBuilder();
Iterator<String> partsIterator = parts.iterator();
propertyPath.append(partsIterator.next());
while (partsIterator.hasNext())
propertyPath.append(".").append(partsIterator.next());
return propertyPath.toString();
}
|
java
|
protected String getPropertyPath(Collection<String> parts) {
StringBuilder propertyPath = new StringBuilder();
Iterator<String> partsIterator = parts.iterator();
propertyPath.append(partsIterator.next());
while (partsIterator.hasNext())
propertyPath.append(".").append(partsIterator.next());
return propertyPath.toString();
}
|
[
"protected",
"String",
"getPropertyPath",
"(",
"Collection",
"<",
"String",
">",
"parts",
")",
"{",
"StringBuilder",
"propertyPath",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Iterator",
"<",
"String",
">",
"partsIterator",
"=",
"parts",
".",
"iterator",
"(",
")",
";",
"propertyPath",
".",
"append",
"(",
"partsIterator",
".",
"next",
"(",
")",
")",
";",
"while",
"(",
"partsIterator",
".",
"hasNext",
"(",
")",
")",
"propertyPath",
".",
"append",
"(",
"\".\"",
")",
".",
"append",
"(",
"partsIterator",
".",
"next",
"(",
")",
")",
";",
"return",
"propertyPath",
".",
"toString",
"(",
")",
";",
"}"
] |
Creates a dot-separated string of the given parts.
@param parts A collections of parts.
@return a dot-separated string of the parts.
|
[
"Creates",
"a",
"dot",
"-",
"separated",
"string",
"of",
"the",
"given",
"parts",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/cql/AbstractBuilder.java#L234-L243
|
9,920
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/AbstractJsonDeserializer.java
|
AbstractJsonDeserializer.getStringParam
|
protected String getStringParam(String paramName, String errorMessage)
throws IOException {
return getStringParam(paramName, errorMessage, (Map<String, Object>) inputParams.get());
}
|
java
|
protected String getStringParam(String paramName, String errorMessage)
throws IOException {
return getStringParam(paramName, errorMessage, (Map<String, Object>) inputParams.get());
}
|
[
"protected",
"String",
"getStringParam",
"(",
"String",
"paramName",
",",
"String",
"errorMessage",
")",
"throws",
"IOException",
"{",
"return",
"getStringParam",
"(",
"paramName",
",",
"errorMessage",
",",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"inputParams",
".",
"get",
"(",
")",
")",
";",
"}"
] |
Convenience method for subclasses. Uses the default map for parameterinput
@param paramName the name of the parameter
@param errorMessage the errormessage to add to the exception if the param does not exist.
@return a stringparameter with given name. If it does not exist and the errormessage is provided,
an IOException is thrown with that message. if the errormessage is not provided, null is returned.
@throws IOException Exception if the paramname does not exist and an errormessage is provided.
|
[
"Convenience",
"method",
"for",
"subclasses",
".",
"Uses",
"the",
"default",
"map",
"for",
"parameterinput"
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/AbstractJsonDeserializer.java#L110-L113
|
9,921
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/AbstractJsonDeserializer.java
|
AbstractJsonDeserializer.getDoubleParam
|
protected Double getDoubleParam(String paramName, String errorMessage) throws IOException {
return getDoubleParam(paramName, errorMessage, (Map<String, Object>) inputParams.get());
}
|
java
|
protected Double getDoubleParam(String paramName, String errorMessage) throws IOException {
return getDoubleParam(paramName, errorMessage, (Map<String, Object>) inputParams.get());
}
|
[
"protected",
"Double",
"getDoubleParam",
"(",
"String",
"paramName",
",",
"String",
"errorMessage",
")",
"throws",
"IOException",
"{",
"return",
"getDoubleParam",
"(",
"paramName",
",",
"errorMessage",
",",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"inputParams",
".",
"get",
"(",
")",
")",
";",
"}"
] |
Convenience method for subclasses. Retrieves a double with the given parametername, even if that
parametercontent is actually a string containing a number or a long or an int or... Anything that
can be converted to a double is returned. uses the default parameterhashmap from this deserializer.
@param paramName the name of the parameter
@param errorMessage the errormessage to add to the exception if the param does not exist.
@return a stringparameter with given name. If it does not exist and the errormessage is provided,
an IOException is thrown with that message. if the errormessage is not provided, null is returned.
@throws IOException Exception if the paramname does not exist and an errormessage is provided.
|
[
"Convenience",
"method",
"for",
"subclasses",
".",
"Retrieves",
"a",
"double",
"with",
"the",
"given",
"parametername",
"even",
"if",
"that",
"parametercontent",
"is",
"actually",
"a",
"string",
"containing",
"a",
"number",
"or",
"a",
"long",
"or",
"an",
"int",
"or",
"...",
"Anything",
"that",
"can",
"be",
"converted",
"to",
"a",
"double",
"is",
"returned",
".",
"uses",
"the",
"default",
"parameterhashmap",
"from",
"this",
"deserializer",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/AbstractJsonDeserializer.java#L166-L168
|
9,922
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/AbstractJsonDeserializer.java
|
AbstractJsonDeserializer.getDoubleParam
|
protected Double getDoubleParam(String paramName, String errorMessage, Map<String, Object> mapToUse)
throws IOException {
Object o = mapToUse.get(paramName);
if (o != null) {
try {
return Double.parseDouble(o.toString());
} catch (NumberFormatException ignored) {
}
}
return getTypedParam(paramName, errorMessage, Double.class, mapToUse);
}
|
java
|
protected Double getDoubleParam(String paramName, String errorMessage, Map<String, Object> mapToUse)
throws IOException {
Object o = mapToUse.get(paramName);
if (o != null) {
try {
return Double.parseDouble(o.toString());
} catch (NumberFormatException ignored) {
}
}
return getTypedParam(paramName, errorMessage, Double.class, mapToUse);
}
|
[
"protected",
"Double",
"getDoubleParam",
"(",
"String",
"paramName",
",",
"String",
"errorMessage",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"mapToUse",
")",
"throws",
"IOException",
"{",
"Object",
"o",
"=",
"mapToUse",
".",
"get",
"(",
"paramName",
")",
";",
"if",
"(",
"o",
"!=",
"null",
")",
"{",
"try",
"{",
"return",
"Double",
".",
"parseDouble",
"(",
"o",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"ignored",
")",
"{",
"}",
"}",
"return",
"getTypedParam",
"(",
"paramName",
",",
"errorMessage",
",",
"Double",
".",
"class",
",",
"mapToUse",
")",
";",
"}"
] |
Convenience method for subclasses. Retrieves a double with the given parametername, even if that
parametercontent is actually a string containing a number or a long or an int or... Anything that
can be converted to a double is returned.
@param paramName the name of the parameter
@param errorMessage the errormessage to add to the exception if the param does not exist.
@param mapToUse an external hashmap to use as inputsource. Should not be null!
@return a stringparameter with given name. If it does not exist and the errormessage is provided,
an IOException is thrown with that message. if the errormessage is not provided, null is returned.
@throws IOException Exception if the paramname does not exist and an errormessage is provided.
|
[
"Convenience",
"method",
"for",
"subclasses",
".",
"Retrieves",
"a",
"double",
"with",
"the",
"given",
"parametername",
"even",
"if",
"that",
"parametercontent",
"is",
"actually",
"a",
"string",
"containing",
"a",
"number",
"or",
"a",
"long",
"or",
"an",
"int",
"or",
"...",
"Anything",
"that",
"can",
"be",
"converted",
"to",
"a",
"double",
"is",
"returned",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/AbstractJsonDeserializer.java#L182-L192
|
9,923
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/AbstractJsonDeserializer.java
|
AbstractJsonDeserializer.getTypedParam
|
protected <A> A getTypedParam(String paramName, String errorMessage, Class<A> clazz) throws IOException {
return getTypedParam(paramName, errorMessage, clazz, (Map<String, Object>) inputParams.get());
}
|
java
|
protected <A> A getTypedParam(String paramName, String errorMessage, Class<A> clazz) throws IOException {
return getTypedParam(paramName, errorMessage, clazz, (Map<String, Object>) inputParams.get());
}
|
[
"protected",
"<",
"A",
">",
"A",
"getTypedParam",
"(",
"String",
"paramName",
",",
"String",
"errorMessage",
",",
"Class",
"<",
"A",
">",
"clazz",
")",
"throws",
"IOException",
"{",
"return",
"getTypedParam",
"(",
"paramName",
",",
"errorMessage",
",",
"clazz",
",",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"inputParams",
".",
"get",
"(",
")",
")",
";",
"}"
] |
Convenience method for subclasses. Uses the default parametermap for this deserializer.
@param paramName the name of the parameter
@param errorMessage the errormessage to add to the exception if the param does not exist.
@param clazz the class of the parameter that should be parsed.
@param <A> the type of the parameter
@return a stringparameter with given name. If it does not exist and the errormessage is provided,
an IOException is thrown with that message. if the errormessage is not provided, null is returned.
@throws IOException Exception if the paramname does not exist and an errormessage is provided.
|
[
"Convenience",
"method",
"for",
"subclasses",
".",
"Uses",
"the",
"default",
"parametermap",
"for",
"this",
"deserializer",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/AbstractJsonDeserializer.java#L299-L301
|
9,924
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/GeometryDeserializer.java
|
GeometryDeserializer.asGeomCollection
|
private GeometryCollection asGeomCollection(CrsId crsId) throws IOException {
try {
String subJson = getSubJson("geometries", "A geometrycollection requires a geometries parameter")
.replaceAll(" ", "");
String noSpaces = subJson.replace(" ", "");
if (noSpaces.contains("\"crs\":{"))
{
throw new IOException("Specification of the crs information is forbidden in child elements. Either " +
"leave it out, or specify it at the toplevel object.");
}
// add crs to each of the json geometries, otherwise they are deserialized with an undefined crs and the
// collection will then also have an undefined crs.
subJson = setCrsIds(subJson, crsId);
List<Geometry> geometries = parent.collectionFromJson(subJson, Geometry.class);
return new GeometryCollection(geometries.toArray(new Geometry[geometries.size()]));
} catch (JsonException e) {
throw new IOException(e);
}
}
|
java
|
private GeometryCollection asGeomCollection(CrsId crsId) throws IOException {
try {
String subJson = getSubJson("geometries", "A geometrycollection requires a geometries parameter")
.replaceAll(" ", "");
String noSpaces = subJson.replace(" ", "");
if (noSpaces.contains("\"crs\":{"))
{
throw new IOException("Specification of the crs information is forbidden in child elements. Either " +
"leave it out, or specify it at the toplevel object.");
}
// add crs to each of the json geometries, otherwise they are deserialized with an undefined crs and the
// collection will then also have an undefined crs.
subJson = setCrsIds(subJson, crsId);
List<Geometry> geometries = parent.collectionFromJson(subJson, Geometry.class);
return new GeometryCollection(geometries.toArray(new Geometry[geometries.size()]));
} catch (JsonException e) {
throw new IOException(e);
}
}
|
[
"private",
"GeometryCollection",
"asGeomCollection",
"(",
"CrsId",
"crsId",
")",
"throws",
"IOException",
"{",
"try",
"{",
"String",
"subJson",
"=",
"getSubJson",
"(",
"\"geometries\"",
",",
"\"A geometrycollection requires a geometries parameter\"",
")",
".",
"replaceAll",
"(",
"\" \"",
",",
"\"\"",
")",
";",
"String",
"noSpaces",
"=",
"subJson",
".",
"replace",
"(",
"\" \"",
",",
"\"\"",
")",
";",
"if",
"(",
"noSpaces",
".",
"contains",
"(",
"\"\\\"crs\\\":{\"",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Specification of the crs information is forbidden in child elements. Either \"",
"+",
"\"leave it out, or specify it at the toplevel object.\"",
")",
";",
"}",
"// add crs to each of the json geometries, otherwise they are deserialized with an undefined crs and the",
"// collection will then also have an undefined crs.",
"subJson",
"=",
"setCrsIds",
"(",
"subJson",
",",
"crsId",
")",
";",
"List",
"<",
"Geometry",
">",
"geometries",
"=",
"parent",
".",
"collectionFromJson",
"(",
"subJson",
",",
"Geometry",
".",
"class",
")",
";",
"return",
"new",
"GeometryCollection",
"(",
"geometries",
".",
"toArray",
"(",
"new",
"Geometry",
"[",
"geometries",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}",
"catch",
"(",
"JsonException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
")",
";",
"}",
"}"
] |
Parses the JSON as a GeometryCollection.
@param crsId the crsId of this collection.
@throws IOException if the given json does not correspond to a geometrycollection or can be parsed as such
@return an instance of a geometrycollection
|
[
"Parses",
"the",
"JSON",
"as",
"a",
"GeometryCollection",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/GeometryDeserializer.java#L150-L172
|
9,925
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/GeometryDeserializer.java
|
GeometryDeserializer.asMultiPolygon
|
private MultiPolygon asMultiPolygon(List<List<List<List>>> coords, CrsId crsId) throws IOException {
if (coords == null || coords.isEmpty()) {
throw new IOException("A multipolygon should have at least one polyon.");
}
Polygon[] polygons = new Polygon[coords.size()];
for (int i = 0; i < coords.size(); i++) {
polygons[i] = asPolygon(coords.get(i), crsId);
}
return new MultiPolygon(polygons);
}
|
java
|
private MultiPolygon asMultiPolygon(List<List<List<List>>> coords, CrsId crsId) throws IOException {
if (coords == null || coords.isEmpty()) {
throw new IOException("A multipolygon should have at least one polyon.");
}
Polygon[] polygons = new Polygon[coords.size()];
for (int i = 0; i < coords.size(); i++) {
polygons[i] = asPolygon(coords.get(i), crsId);
}
return new MultiPolygon(polygons);
}
|
[
"private",
"MultiPolygon",
"asMultiPolygon",
"(",
"List",
"<",
"List",
"<",
"List",
"<",
"List",
">",
">",
">",
"coords",
",",
"CrsId",
"crsId",
")",
"throws",
"IOException",
"{",
"if",
"(",
"coords",
"==",
"null",
"||",
"coords",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"A multipolygon should have at least one polyon.\"",
")",
";",
"}",
"Polygon",
"[",
"]",
"polygons",
"=",
"new",
"Polygon",
"[",
"coords",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"coords",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"polygons",
"[",
"i",
"]",
"=",
"asPolygon",
"(",
"coords",
".",
"get",
"(",
"i",
")",
",",
"crsId",
")",
";",
"}",
"return",
"new",
"MultiPolygon",
"(",
"polygons",
")",
";",
"}"
] |
Parses the JSON as a MultiPolygon geometry
@param coords the coordinates of a multipolygon which is just a list of coordinates of polygons.
@param crsId
@return an instance of multipolygon
@throws IOException if the given json does not correspond to a multipolygon or can be parsed as such
|
[
"Parses",
"the",
"JSON",
"as",
"a",
"MultiPolygon",
"geometry"
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/GeometryDeserializer.java#L216-L225
|
9,926
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/GeometryDeserializer.java
|
GeometryDeserializer.asMultiLineString
|
private MultiLineString asMultiLineString(List<List<List>> coords, CrsId crsId) throws IOException {
if (coords == null || coords.isEmpty()) {
throw new IOException("A multilinestring requires at least one line string");
}
LineString[] lineStrings = new LineString[coords.size()];
for (int i = 0; i < lineStrings.length; i++) {
lineStrings[i] = asLineString(coords.get(i), crsId);
}
return new MultiLineString(lineStrings);
}
|
java
|
private MultiLineString asMultiLineString(List<List<List>> coords, CrsId crsId) throws IOException {
if (coords == null || coords.isEmpty()) {
throw new IOException("A multilinestring requires at least one line string");
}
LineString[] lineStrings = new LineString[coords.size()];
for (int i = 0; i < lineStrings.length; i++) {
lineStrings[i] = asLineString(coords.get(i), crsId);
}
return new MultiLineString(lineStrings);
}
|
[
"private",
"MultiLineString",
"asMultiLineString",
"(",
"List",
"<",
"List",
"<",
"List",
">",
">",
"coords",
",",
"CrsId",
"crsId",
")",
"throws",
"IOException",
"{",
"if",
"(",
"coords",
"==",
"null",
"||",
"coords",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"A multilinestring requires at least one line string\"",
")",
";",
"}",
"LineString",
"[",
"]",
"lineStrings",
"=",
"new",
"LineString",
"[",
"coords",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"lineStrings",
".",
"length",
";",
"i",
"++",
")",
"{",
"lineStrings",
"[",
"i",
"]",
"=",
"asLineString",
"(",
"coords",
".",
"get",
"(",
"i",
")",
",",
"crsId",
")",
";",
"}",
"return",
"new",
"MultiLineString",
"(",
"lineStrings",
")",
";",
"}"
] |
Parses the JSON as a MultiLineString geometry
@param coords the coordinates of a multlinestring (which is a list of coordinates of linestrings)
@param crsId
@return an instance of multilinestring
@throws IOException if the given json does not correspond to a multilinestring or can be parsed as such
|
[
"Parses",
"the",
"JSON",
"as",
"a",
"MultiLineString",
"geometry"
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/GeometryDeserializer.java#L236-L245
|
9,927
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/GeometryDeserializer.java
|
GeometryDeserializer.asPolygon
|
private Polygon asPolygon(List<List<List>> coords, CrsId crsId) throws IOException {
if (coords == null || coords.isEmpty()) {
throw new IOException("A polygon requires the specification of its outer ring");
}
List<LinearRing> rings = new ArrayList<LinearRing>();
try {
for (List<List> ring : coords) {
PointSequence ringCoords = getPointSequence(ring, crsId);
rings.add(new LinearRing(ringCoords));
}
return new Polygon(rings.toArray(new LinearRing[]{}));
} catch (IllegalArgumentException e) {
throw new IOException("Invalid Polygon: " + e.getMessage(), e);
}
}
|
java
|
private Polygon asPolygon(List<List<List>> coords, CrsId crsId) throws IOException {
if (coords == null || coords.isEmpty()) {
throw new IOException("A polygon requires the specification of its outer ring");
}
List<LinearRing> rings = new ArrayList<LinearRing>();
try {
for (List<List> ring : coords) {
PointSequence ringCoords = getPointSequence(ring, crsId);
rings.add(new LinearRing(ringCoords));
}
return new Polygon(rings.toArray(new LinearRing[]{}));
} catch (IllegalArgumentException e) {
throw new IOException("Invalid Polygon: " + e.getMessage(), e);
}
}
|
[
"private",
"Polygon",
"asPolygon",
"(",
"List",
"<",
"List",
"<",
"List",
">",
">",
"coords",
",",
"CrsId",
"crsId",
")",
"throws",
"IOException",
"{",
"if",
"(",
"coords",
"==",
"null",
"||",
"coords",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"A polygon requires the specification of its outer ring\"",
")",
";",
"}",
"List",
"<",
"LinearRing",
">",
"rings",
"=",
"new",
"ArrayList",
"<",
"LinearRing",
">",
"(",
")",
";",
"try",
"{",
"for",
"(",
"List",
"<",
"List",
">",
"ring",
":",
"coords",
")",
"{",
"PointSequence",
"ringCoords",
"=",
"getPointSequence",
"(",
"ring",
",",
"crsId",
")",
";",
"rings",
".",
"add",
"(",
"new",
"LinearRing",
"(",
"ringCoords",
")",
")",
";",
"}",
"return",
"new",
"Polygon",
"(",
"rings",
".",
"toArray",
"(",
"new",
"LinearRing",
"[",
"]",
"{",
"}",
")",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Invalid Polygon: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Parses the JSON as a polygon geometry
@param coords the coordinate array corresponding with the polygon (a list containing rings, each of which
contains a list of coordinates (which in turn are lists of numbers)).
@param crsId
@return An instance of polygon
@throws IOException if the given json does not correspond to a polygon or can be parsed as such.
|
[
"Parses",
"the",
"JSON",
"as",
"a",
"polygon",
"geometry"
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/GeometryDeserializer.java#L257-L272
|
9,928
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/GeometryDeserializer.java
|
GeometryDeserializer.asPoint
|
private Point asPoint(List coords, CrsId crsId) throws IOException {
if (coords != null && coords.size() >= 2) {
ArrayList<List> coordinates = new ArrayList<List>();
coordinates.add(coords);
return new Point(getPointSequence(coordinates, crsId));
} else {
throw new IOException("A point must has exactly one coordinate (an x, a y and possibly a z value). Additional numbers in the coordinate are permitted but ignored.");
}
}
|
java
|
private Point asPoint(List coords, CrsId crsId) throws IOException {
if (coords != null && coords.size() >= 2) {
ArrayList<List> coordinates = new ArrayList<List>();
coordinates.add(coords);
return new Point(getPointSequence(coordinates, crsId));
} else {
throw new IOException("A point must has exactly one coordinate (an x, a y and possibly a z value). Additional numbers in the coordinate are permitted but ignored.");
}
}
|
[
"private",
"Point",
"asPoint",
"(",
"List",
"coords",
",",
"CrsId",
"crsId",
")",
"throws",
"IOException",
"{",
"if",
"(",
"coords",
"!=",
"null",
"&&",
"coords",
".",
"size",
"(",
")",
">=",
"2",
")",
"{",
"ArrayList",
"<",
"List",
">",
"coordinates",
"=",
"new",
"ArrayList",
"<",
"List",
">",
"(",
")",
";",
"coordinates",
".",
"add",
"(",
"coords",
")",
";",
"return",
"new",
"Point",
"(",
"getPointSequence",
"(",
"coordinates",
",",
"crsId",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IOException",
"(",
"\"A point must has exactly one coordinate (an x, a y and possibly a z value). Additional numbers in the coordinate are permitted but ignored.\"",
")",
";",
"}",
"}"
] |
Parses the JSON as a point geometry.
@param coords the coordinates (a list with an x and y value)
@param crsId
@return An instance of point
@throws IOException if the given json does not correspond to a point or can not be parsed to a point.
|
[
"Parses",
"the",
"JSON",
"as",
"a",
"point",
"geometry",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/GeometryDeserializer.java#L283-L291
|
9,929
|
tdebatty/spark-kmedoids
|
spark-kmedoids/src/main/java/info/debatty/spark/kmedoids/Clusterer.java
|
Clusterer.cluster
|
public final Solution<T> cluster(final JavaRDD<T> input_data) {
if (k <= 0) {
throw new IllegalStateException("k must be > 0!");
}
if (similarity == null) {
throw new IllegalStateException("Similarity is not defined!");
}
if (budget == null) {
throw new IllegalStateException("No budget is defined!");
}
JavaRDD<T> data = input_data.cache();
// Keep track of best solution
Solution<T> solution = new Solution<>(data.count());
logger.debug("Dataset contains {} objects", solution.getDatasetSize());
neighbor_generator.init(k);
points_supplier = new RandomPointsSupplier<>(
data, solution.getDatasetSize());
// Select random initial solution and evaluate
ArrayList<T> random_medoids = points_supplier.pick(k);
solution.setNewMedoids(random_medoids, evaluate(data, random_medoids));
solution.incComputedSimilarities(k * solution.getDatasetSize());
while (true) {
logger.trace("Trial {}", solution.getTrials());
// Select neighbor solution
CountingSimilarity<T> counting_sim =
new CountingSimilarity<>(similarity);
ArrayList<T> candidate;
try {
candidate = neighbor_generator.getNeighbor(
new NeighborGeneratorHelper<>(this),
solution,
counting_sim);
} catch (NoNeighborFoundException ex) {
solution.incComputedSimilarities(counting_sim.getCount());
break;
}
solution.incComputedSimilarities(counting_sim.getCount());
// Evaluate
double candidate_similarity = evaluate(data, candidate);
solution.incComputedSimilarities(k * solution.getDatasetSize());
neighbor_generator.notifyCandidateSolutionCost(
candidate, candidate_similarity);
if (candidate_similarity > solution.getTotalSimilarity()) {
solution.setNewMedoids(candidate, candidate_similarity);
solution.incIterations();
neighbor_generator.notifyNewSolution(
candidate, candidate_similarity);
}
solution.incTrials();
if (budget.isExhausted(solution)) {
break;
}
}
solution.end();
logger.debug("Found solution {}", solution);
return solution;
}
|
java
|
public final Solution<T> cluster(final JavaRDD<T> input_data) {
if (k <= 0) {
throw new IllegalStateException("k must be > 0!");
}
if (similarity == null) {
throw new IllegalStateException("Similarity is not defined!");
}
if (budget == null) {
throw new IllegalStateException("No budget is defined!");
}
JavaRDD<T> data = input_data.cache();
// Keep track of best solution
Solution<T> solution = new Solution<>(data.count());
logger.debug("Dataset contains {} objects", solution.getDatasetSize());
neighbor_generator.init(k);
points_supplier = new RandomPointsSupplier<>(
data, solution.getDatasetSize());
// Select random initial solution and evaluate
ArrayList<T> random_medoids = points_supplier.pick(k);
solution.setNewMedoids(random_medoids, evaluate(data, random_medoids));
solution.incComputedSimilarities(k * solution.getDatasetSize());
while (true) {
logger.trace("Trial {}", solution.getTrials());
// Select neighbor solution
CountingSimilarity<T> counting_sim =
new CountingSimilarity<>(similarity);
ArrayList<T> candidate;
try {
candidate = neighbor_generator.getNeighbor(
new NeighborGeneratorHelper<>(this),
solution,
counting_sim);
} catch (NoNeighborFoundException ex) {
solution.incComputedSimilarities(counting_sim.getCount());
break;
}
solution.incComputedSimilarities(counting_sim.getCount());
// Evaluate
double candidate_similarity = evaluate(data, candidate);
solution.incComputedSimilarities(k * solution.getDatasetSize());
neighbor_generator.notifyCandidateSolutionCost(
candidate, candidate_similarity);
if (candidate_similarity > solution.getTotalSimilarity()) {
solution.setNewMedoids(candidate, candidate_similarity);
solution.incIterations();
neighbor_generator.notifyNewSolution(
candidate, candidate_similarity);
}
solution.incTrials();
if (budget.isExhausted(solution)) {
break;
}
}
solution.end();
logger.debug("Found solution {}", solution);
return solution;
}
|
[
"public",
"final",
"Solution",
"<",
"T",
">",
"cluster",
"(",
"final",
"JavaRDD",
"<",
"T",
">",
"input_data",
")",
"{",
"if",
"(",
"k",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"k must be > 0!\"",
")",
";",
"}",
"if",
"(",
"similarity",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Similarity is not defined!\"",
")",
";",
"}",
"if",
"(",
"budget",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"No budget is defined!\"",
")",
";",
"}",
"JavaRDD",
"<",
"T",
">",
"data",
"=",
"input_data",
".",
"cache",
"(",
")",
";",
"// Keep track of best solution",
"Solution",
"<",
"T",
">",
"solution",
"=",
"new",
"Solution",
"<>",
"(",
"data",
".",
"count",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Dataset contains {} objects\"",
",",
"solution",
".",
"getDatasetSize",
"(",
")",
")",
";",
"neighbor_generator",
".",
"init",
"(",
"k",
")",
";",
"points_supplier",
"=",
"new",
"RandomPointsSupplier",
"<>",
"(",
"data",
",",
"solution",
".",
"getDatasetSize",
"(",
")",
")",
";",
"// Select random initial solution and evaluate",
"ArrayList",
"<",
"T",
">",
"random_medoids",
"=",
"points_supplier",
".",
"pick",
"(",
"k",
")",
";",
"solution",
".",
"setNewMedoids",
"(",
"random_medoids",
",",
"evaluate",
"(",
"data",
",",
"random_medoids",
")",
")",
";",
"solution",
".",
"incComputedSimilarities",
"(",
"k",
"*",
"solution",
".",
"getDatasetSize",
"(",
")",
")",
";",
"while",
"(",
"true",
")",
"{",
"logger",
".",
"trace",
"(",
"\"Trial {}\"",
",",
"solution",
".",
"getTrials",
"(",
")",
")",
";",
"// Select neighbor solution",
"CountingSimilarity",
"<",
"T",
">",
"counting_sim",
"=",
"new",
"CountingSimilarity",
"<>",
"(",
"similarity",
")",
";",
"ArrayList",
"<",
"T",
">",
"candidate",
";",
"try",
"{",
"candidate",
"=",
"neighbor_generator",
".",
"getNeighbor",
"(",
"new",
"NeighborGeneratorHelper",
"<>",
"(",
"this",
")",
",",
"solution",
",",
"counting_sim",
")",
";",
"}",
"catch",
"(",
"NoNeighborFoundException",
"ex",
")",
"{",
"solution",
".",
"incComputedSimilarities",
"(",
"counting_sim",
".",
"getCount",
"(",
")",
")",
";",
"break",
";",
"}",
"solution",
".",
"incComputedSimilarities",
"(",
"counting_sim",
".",
"getCount",
"(",
")",
")",
";",
"// Evaluate",
"double",
"candidate_similarity",
"=",
"evaluate",
"(",
"data",
",",
"candidate",
")",
";",
"solution",
".",
"incComputedSimilarities",
"(",
"k",
"*",
"solution",
".",
"getDatasetSize",
"(",
")",
")",
";",
"neighbor_generator",
".",
"notifyCandidateSolutionCost",
"(",
"candidate",
",",
"candidate_similarity",
")",
";",
"if",
"(",
"candidate_similarity",
">",
"solution",
".",
"getTotalSimilarity",
"(",
")",
")",
"{",
"solution",
".",
"setNewMedoids",
"(",
"candidate",
",",
"candidate_similarity",
")",
";",
"solution",
".",
"incIterations",
"(",
")",
";",
"neighbor_generator",
".",
"notifyNewSolution",
"(",
"candidate",
",",
"candidate_similarity",
")",
";",
"}",
"solution",
".",
"incTrials",
"(",
")",
";",
"if",
"(",
"budget",
".",
"isExhausted",
"(",
"solution",
")",
")",
"{",
"break",
";",
"}",
"}",
"solution",
".",
"end",
"(",
")",
";",
"logger",
".",
"debug",
"(",
"\"Found solution {}\"",
",",
"solution",
")",
";",
"return",
"solution",
";",
"}"
] |
Cluster the data according to defined parameters.
@param input_data
@return
|
[
"Cluster",
"the",
"data",
"according",
"to",
"defined",
"parameters",
"."
] |
73cc1f105d3e0baadba41329e826715b319c6181
|
https://github.com/tdebatty/spark-kmedoids/blob/73cc1f105d3e0baadba41329e826715b319c6181/spark-kmedoids/src/main/java/info/debatty/spark/kmedoids/Clusterer.java#L112-L183
|
9,930
|
tdebatty/spark-kmedoids
|
spark-kmedoids/src/main/java/info/debatty/spark/kmedoids/Clusterer.java
|
AssignToMedoid.argmax
|
private static int argmax(final double[] values) {
double max = -Double.MAX_VALUE;
int max_index = -1;
for (int i = 0; i < values.length; i++) {
if (values[i] > max) {
max = values[i];
max_index = i;
}
}
return max_index;
}
|
java
|
private static int argmax(final double[] values) {
double max = -Double.MAX_VALUE;
int max_index = -1;
for (int i = 0; i < values.length; i++) {
if (values[i] > max) {
max = values[i];
max_index = i;
}
}
return max_index;
}
|
[
"private",
"static",
"int",
"argmax",
"(",
"final",
"double",
"[",
"]",
"values",
")",
"{",
"double",
"max",
"=",
"-",
"Double",
".",
"MAX_VALUE",
";",
"int",
"max_index",
"=",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"values",
"[",
"i",
"]",
">",
"max",
")",
"{",
"max",
"=",
"values",
"[",
"i",
"]",
";",
"max_index",
"=",
"i",
";",
"}",
"}",
"return",
"max_index",
";",
"}"
] |
Return the index of the highest value in the array.
@param values
|
[
"Return",
"the",
"index",
"of",
"the",
"highest",
"value",
"in",
"the",
"array",
"."
] |
73cc1f105d3e0baadba41329e826715b319c6181
|
https://github.com/tdebatty/spark-kmedoids/blob/73cc1f105d3e0baadba41329e826715b319c6181/spark-kmedoids/src/main/java/info/debatty/spark/kmedoids/Clusterer.java#L302-L313
|
9,931
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isEqual
|
public static BooleanIsEqual isEqual(ComparableExpression<Boolean> left, Boolean constant) {
return new BooleanIsEqual(left, constant(constant));
}
|
java
|
public static BooleanIsEqual isEqual(ComparableExpression<Boolean> left, Boolean constant) {
return new BooleanIsEqual(left, constant(constant));
}
|
[
"public",
"static",
"BooleanIsEqual",
"isEqual",
"(",
"ComparableExpression",
"<",
"Boolean",
">",
"left",
",",
"Boolean",
"constant",
")",
"{",
"return",
"new",
"BooleanIsEqual",
"(",
"left",
",",
"constant",
"(",
"constant",
")",
")",
";",
"}"
] |
Creates a BooleanIsEqual expression from the given expression and constant.
@param left The left expression.
@param constant The constant to compare to.
@return A new BooleanIsEqual binary expression.
|
[
"Creates",
"a",
"BooleanIsEqual",
"expression",
"from",
"the",
"given",
"expression",
"and",
"constant",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L186-L188
|
9,932
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isGreaterThan
|
public static IsGreaterThan isGreaterThan(ComparableExpression<Number> left, ComparableExpression<Number> right) {
return new IsGreaterThan(left, right);
}
|
java
|
public static IsGreaterThan isGreaterThan(ComparableExpression<Number> left, ComparableExpression<Number> right) {
return new IsGreaterThan(left, right);
}
|
[
"public",
"static",
"IsGreaterThan",
"isGreaterThan",
"(",
"ComparableExpression",
"<",
"Number",
">",
"left",
",",
"ComparableExpression",
"<",
"Number",
">",
"right",
")",
"{",
"return",
"new",
"IsGreaterThan",
"(",
"left",
",",
"right",
")",
";",
"}"
] |
Creates an IsGreaterThan expression from the given expressions.
@param left The left expression.
@param right The right expression.
@return A new IsGreaterThan binary expression.
|
[
"Creates",
"an",
"IsGreaterThan",
"expression",
"from",
"the",
"given",
"expressions",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L241-L243
|
9,933
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isGreaterThanOrEqual
|
public static IsGreaterThanOrEqual isGreaterThanOrEqual(ComparableExpression<Number> left, ComparableExpression<Number> right) {
return new IsGreaterThanOrEqual(left, right);
}
|
java
|
public static IsGreaterThanOrEqual isGreaterThanOrEqual(ComparableExpression<Number> left, ComparableExpression<Number> right) {
return new IsGreaterThanOrEqual(left, right);
}
|
[
"public",
"static",
"IsGreaterThanOrEqual",
"isGreaterThanOrEqual",
"(",
"ComparableExpression",
"<",
"Number",
">",
"left",
",",
"ComparableExpression",
"<",
"Number",
">",
"right",
")",
"{",
"return",
"new",
"IsGreaterThanOrEqual",
"(",
"left",
",",
"right",
")",
";",
"}"
] |
Creates an IsGreaterThanOrEqual expression from the given expressions.
@param left The left expression.
@param right The right expression.
@return A new IsGreaterThanOrEqual binary expression.
|
[
"Creates",
"an",
"IsGreaterThanOrEqual",
"expression",
"from",
"the",
"given",
"expressions",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L274-L276
|
9,934
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isLessThanOrEqual
|
public static BooleanIsLessThanOrEqual isLessThanOrEqual(ComparableExpression<Boolean> left, Object constant) {
if (!(constant instanceof Boolean))
throw new IllegalArgumentException("constant is not a Boolean");
return new BooleanIsLessThanOrEqual(left, constant((Boolean)constant));
}
|
java
|
public static BooleanIsLessThanOrEqual isLessThanOrEqual(ComparableExpression<Boolean> left, Object constant) {
if (!(constant instanceof Boolean))
throw new IllegalArgumentException("constant is not a Boolean");
return new BooleanIsLessThanOrEqual(left, constant((Boolean)constant));
}
|
[
"public",
"static",
"BooleanIsLessThanOrEqual",
"isLessThanOrEqual",
"(",
"ComparableExpression",
"<",
"Boolean",
">",
"left",
",",
"Object",
"constant",
")",
"{",
"if",
"(",
"!",
"(",
"constant",
"instanceof",
"Boolean",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"constant is not a Boolean\"",
")",
";",
"return",
"new",
"BooleanIsLessThanOrEqual",
"(",
"left",
",",
"constant",
"(",
"(",
"Boolean",
")",
"constant",
")",
")",
";",
"}"
] |
Creates an BooleanIsGreaterThanOrEqual expression from the given expression and constant.
@param left The left expression.
@param constant The constant to compare to (must be a Boolean).
@throws IllegalArgumentException If the constant is not a Boolean or a {@link org.geolatte.common.expressions.ComparableExpression}
@return A new is less than binary expression.
|
[
"Creates",
"an",
"BooleanIsGreaterThanOrEqual",
"expression",
"from",
"the",
"given",
"expression",
"and",
"constant",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L297-L303
|
9,935
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isLessThan
|
public static IsLessThan isLessThan(ComparableExpression<Number> left, ComparableExpression<Number> right) {
return new IsLessThan(left, right);
}
|
java
|
public static IsLessThan isLessThan(ComparableExpression<Number> left, ComparableExpression<Number> right) {
return new IsLessThan(left, right);
}
|
[
"public",
"static",
"IsLessThan",
"isLessThan",
"(",
"ComparableExpression",
"<",
"Number",
">",
"left",
",",
"ComparableExpression",
"<",
"Number",
">",
"right",
")",
"{",
"return",
"new",
"IsLessThan",
"(",
"left",
",",
"right",
")",
";",
"}"
] |
Creates an IsLessThan expression from the given expressions.
@param left The left expression.
@param right The right expression.
@return A new is less than binary expression.
|
[
"Creates",
"an",
"IsLessThan",
"expression",
"from",
"the",
"given",
"expressions",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L323-L325
|
9,936
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isLessThan
|
public static IsLessThan isLessThan(ComparableExpression<Number> left, Object constant) {
if (!(constant instanceof Number))
throw new IllegalArgumentException("constant is not a Number");
return new IsLessThan(left, constant((Number)constant));
}
|
java
|
public static IsLessThan isLessThan(ComparableExpression<Number> left, Object constant) {
if (!(constant instanceof Number))
throw new IllegalArgumentException("constant is not a Number");
return new IsLessThan(left, constant((Number)constant));
}
|
[
"public",
"static",
"IsLessThan",
"isLessThan",
"(",
"ComparableExpression",
"<",
"Number",
">",
"left",
",",
"Object",
"constant",
")",
"{",
"if",
"(",
"!",
"(",
"constant",
"instanceof",
"Number",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"constant is not a Number\"",
")",
";",
"return",
"new",
"IsLessThan",
"(",
"left",
",",
"constant",
"(",
"(",
"Number",
")",
"constant",
")",
")",
";",
"}"
] |
Creates an IsLessThan expression from the given expression and constant.
@param left The left expression.
@param constant The constant to compare to (must be a Number).
@throws IllegalArgumentException If the constant is not a Number
@return A new is less than binary expression.
|
[
"Creates",
"an",
"IsLessThan",
"expression",
"from",
"the",
"given",
"expression",
"and",
"constant",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L335-L341
|
9,937
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isLessThan
|
public static BooleanIsLessThan isLessThan(BooleanExpression left, Object constant) {
if (!(constant instanceof Boolean))
throw new IllegalArgumentException("constant is not a Boolean");
return new BooleanIsLessThan(left, constant((Boolean)constant));
}
|
java
|
public static BooleanIsLessThan isLessThan(BooleanExpression left, Object constant) {
if (!(constant instanceof Boolean))
throw new IllegalArgumentException("constant is not a Boolean");
return new BooleanIsLessThan(left, constant((Boolean)constant));
}
|
[
"public",
"static",
"BooleanIsLessThan",
"isLessThan",
"(",
"BooleanExpression",
"left",
",",
"Object",
"constant",
")",
"{",
"if",
"(",
"!",
"(",
"constant",
"instanceof",
"Boolean",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"constant is not a Boolean\"",
")",
";",
"return",
"new",
"BooleanIsLessThan",
"(",
"left",
",",
"constant",
"(",
"(",
"Boolean",
")",
"constant",
")",
")",
";",
"}"
] |
Creates an BooleanIsLessThan expression from the given expression and constant.
@param left The left expression.
@param constant The constant to compare to (must be a Number).
@throws IllegalArgumentException If the constant is not a Number
@return A new is less than binary expression.
|
[
"Creates",
"an",
"BooleanIsLessThan",
"expression",
"from",
"the",
"given",
"expression",
"and",
"constant",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L362-L368
|
9,938
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isLessThan
|
public static StringIsLessThan isLessThan(StringExpression left, Object constant) {
if (!(constant instanceof String))
throw new IllegalArgumentException("constant is not a String");
return new StringIsLessThan(left, constant((String)constant));
}
|
java
|
public static StringIsLessThan isLessThan(StringExpression left, Object constant) {
if (!(constant instanceof String))
throw new IllegalArgumentException("constant is not a String");
return new StringIsLessThan(left, constant((String)constant));
}
|
[
"public",
"static",
"StringIsLessThan",
"isLessThan",
"(",
"StringExpression",
"left",
",",
"Object",
"constant",
")",
"{",
"if",
"(",
"!",
"(",
"constant",
"instanceof",
"String",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"constant is not a String\"",
")",
";",
"return",
"new",
"StringIsLessThan",
"(",
"left",
",",
"constant",
"(",
"(",
"String",
")",
"constant",
")",
")",
";",
"}"
] |
Creates an StringIsLessThan expression from the given expression and constant.
@param left The left expression.
@param constant The constant to compare to (must be a String).
@throws IllegalArgumentException If the constant is not a String
@return A new is less than binary expression.
|
[
"Creates",
"an",
"StringIsLessThan",
"expression",
"from",
"the",
"given",
"expression",
"and",
"constant",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L389-L395
|
9,939
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isLessThanOrEqual
|
public static IsLessThanOrEqual isLessThanOrEqual(NumberExpression left, Object constant) {
if (!(constant instanceof Number))
throw new IllegalArgumentException("constant is not a Number");
return new IsLessThanOrEqual(left, constant((Number)constant));
}
|
java
|
public static IsLessThanOrEqual isLessThanOrEqual(NumberExpression left, Object constant) {
if (!(constant instanceof Number))
throw new IllegalArgumentException("constant is not a Number");
return new IsLessThanOrEqual(left, constant((Number)constant));
}
|
[
"public",
"static",
"IsLessThanOrEqual",
"isLessThanOrEqual",
"(",
"NumberExpression",
"left",
",",
"Object",
"constant",
")",
"{",
"if",
"(",
"!",
"(",
"constant",
"instanceof",
"Number",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"constant is not a Number\"",
")",
";",
"return",
"new",
"IsLessThanOrEqual",
"(",
"left",
",",
"constant",
"(",
"(",
"Number",
")",
"constant",
")",
")",
";",
"}"
] |
Creates an IsLessThanOrEqual expression from the given expression and constant.
@param left The left expression.
@param constant The constant to compare to (must be a Number).
@throws IllegalArgumentException If the constant is not a Number
@return A new is less than binary expression.
|
[
"Creates",
"an",
"IsLessThanOrEqual",
"expression",
"from",
"the",
"given",
"expression",
"and",
"constant",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L416-L422
|
9,940
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isLessThanOrEqual
|
public static StringIsLessThanOrEqual isLessThanOrEqual(StringExpression left, Object constant) {
if (!(constant instanceof String))
throw new IllegalArgumentException("constant is not a String");
return new StringIsLessThanOrEqual(left, constant((String)constant));
}
|
java
|
public static StringIsLessThanOrEqual isLessThanOrEqual(StringExpression left, Object constant) {
if (!(constant instanceof String))
throw new IllegalArgumentException("constant is not a String");
return new StringIsLessThanOrEqual(left, constant((String)constant));
}
|
[
"public",
"static",
"StringIsLessThanOrEqual",
"isLessThanOrEqual",
"(",
"StringExpression",
"left",
",",
"Object",
"constant",
")",
"{",
"if",
"(",
"!",
"(",
"constant",
"instanceof",
"String",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"constant is not a String\"",
")",
";",
"return",
"new",
"StringIsLessThanOrEqual",
"(",
"left",
",",
"constant",
"(",
"(",
"String",
")",
"constant",
")",
")",
";",
"}"
] |
Creates an StringIsLessThanOrEqual expression from the given expression and constant.
@param left The left expression.
@param constant The constant to compare to (must be a String).
@throws IllegalArgumentException If the constant is not a String
@return A new is less than binary expression.
|
[
"Creates",
"an",
"StringIsLessThanOrEqual",
"expression",
"from",
"the",
"given",
"expression",
"and",
"constant",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L445-L451
|
9,941
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isNotEqual
|
public static IsNotEqual isNotEqual(ComparableExpression<Number> left, Object constant) {
if (!(constant instanceof Number))
throw new IllegalArgumentException("constant is not a Number");
return new IsNotEqual(left, constant((Number)constant));
}
|
java
|
public static IsNotEqual isNotEqual(ComparableExpression<Number> left, Object constant) {
if (!(constant instanceof Number))
throw new IllegalArgumentException("constant is not a Number");
return new IsNotEqual(left, constant((Number)constant));
}
|
[
"public",
"static",
"IsNotEqual",
"isNotEqual",
"(",
"ComparableExpression",
"<",
"Number",
">",
"left",
",",
"Object",
"constant",
")",
"{",
"if",
"(",
"!",
"(",
"constant",
"instanceof",
"Number",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"constant is not a Number\"",
")",
";",
"return",
"new",
"IsNotEqual",
"(",
"left",
",",
"constant",
"(",
"(",
"Number",
")",
"constant",
")",
")",
";",
"}"
] |
Creates an IsNotEqual expression from the given expression and constant.
@param left The left expression.
@param constant The constant to compare to (must be a Number).
@throws IllegalArgumentException If the constant is not a Number
@return A new is less than binary expression.
|
[
"Creates",
"an",
"IsNotEqual",
"expression",
"from",
"the",
"given",
"expression",
"and",
"constant",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L472-L478
|
9,942
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isNotEqual
|
public static BooleanIsNotEqual isNotEqual(ComparableExpression<Boolean> left, ComparableExpression<Boolean> right) {
return new BooleanIsNotEqual(left, right);
}
|
java
|
public static BooleanIsNotEqual isNotEqual(ComparableExpression<Boolean> left, ComparableExpression<Boolean> right) {
return new BooleanIsNotEqual(left, right);
}
|
[
"public",
"static",
"BooleanIsNotEqual",
"isNotEqual",
"(",
"ComparableExpression",
"<",
"Boolean",
">",
"left",
",",
"ComparableExpression",
"<",
"Boolean",
">",
"right",
")",
"{",
"return",
"new",
"BooleanIsNotEqual",
"(",
"left",
",",
"right",
")",
";",
"}"
] |
Creates an BooleanIsNotEqual expression from the given expressions.
@param left The left expression.
@param right The right expression.
@return A new BooleanIsNotEqual binary expression.
|
[
"Creates",
"an",
"BooleanIsNotEqual",
"expression",
"from",
"the",
"given",
"expressions",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L487-L489
|
9,943
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.add
|
public static Add add(Expression<Number> left, Expression<Number> right) {
return new Add(left, right);
}
|
java
|
public static Add add(Expression<Number> left, Expression<Number> right) {
return new Add(left, right);
}
|
[
"public",
"static",
"Add",
"add",
"(",
"Expression",
"<",
"Number",
">",
"left",
",",
"Expression",
"<",
"Number",
">",
"right",
")",
"{",
"return",
"new",
"Add",
"(",
"left",
",",
"right",
")",
";",
"}"
] |
Creates an Add expression from the given expressions.
@param left The left expression.
@param right The right expression.
@return An Add expression.
|
[
"Creates",
"an",
"Add",
"expression",
"from",
"the",
"given",
"expressions",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L509-L511
|
9,944
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.notLike
|
public static NotLike notLike(Expression<String> left, String constant, boolean caseInsensitive) {
return new NotLike(left, constant(constant), caseInsensitive);
}
|
java
|
public static NotLike notLike(Expression<String> left, String constant, boolean caseInsensitive) {
return new NotLike(left, constant(constant), caseInsensitive);
}
|
[
"public",
"static",
"NotLike",
"notLike",
"(",
"Expression",
"<",
"String",
">",
"left",
",",
"String",
"constant",
",",
"boolean",
"caseInsensitive",
")",
"{",
"return",
"new",
"NotLike",
"(",
"left",
",",
"constant",
"(",
"constant",
")",
",",
"caseInsensitive",
")",
";",
"}"
] |
Creates a NotLike expression from the given expressions with % as the wildcard character
@param left The left expression.
@param constant The constant.
@param caseInsensitive Indicates whether comparison should be case insensitive.
@return A NotLike expression.
|
[
"Creates",
"a",
"NotLike",
"expression",
"from",
"the",
"given",
"expressions",
"with",
"%",
"as",
"the",
"wildcard",
"character"
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L601-L603
|
9,945
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.notLike
|
public static NotLike notLike(Expression<String> left, Expression<String> right, char wildCardCharacter) {
return new NotLike(left, right, wildCardCharacter);
}
|
java
|
public static NotLike notLike(Expression<String> left, Expression<String> right, char wildCardCharacter) {
return new NotLike(left, right, wildCardCharacter);
}
|
[
"public",
"static",
"NotLike",
"notLike",
"(",
"Expression",
"<",
"String",
">",
"left",
",",
"Expression",
"<",
"String",
">",
"right",
",",
"char",
"wildCardCharacter",
")",
"{",
"return",
"new",
"NotLike",
"(",
"left",
",",
"right",
",",
"wildCardCharacter",
")",
";",
"}"
] |
Creates a NotLike expression from the given expressions.
@param left The left expression.
@param right The right expression.
@param wildCardCharacter The character to use as a wildcardCharacter
@return A NotLike expression.
|
[
"Creates",
"a",
"NotLike",
"expression",
"from",
"the",
"given",
"expressions",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L663-L665
|
9,946
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.and
|
public static And and(Expression<Boolean> left, Expression<Boolean> right) {
return new And(left, right);
}
|
java
|
public static And and(Expression<Boolean> left, Expression<Boolean> right) {
return new And(left, right);
}
|
[
"public",
"static",
"And",
"and",
"(",
"Expression",
"<",
"Boolean",
">",
"left",
",",
"Expression",
"<",
"Boolean",
">",
"right",
")",
"{",
"return",
"new",
"And",
"(",
"left",
",",
"right",
")",
";",
"}"
] |
Creates an And expression from the given expressions.
@param left The left expression.
@param right The right expression.
@return An And expression.
|
[
"Creates",
"an",
"And",
"expression",
"from",
"the",
"given",
"expressions",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L712-L714
|
9,947
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.or
|
public static Or or(Expression<Boolean> left, Expression<Boolean> right) {
return new Or(left, right);
}
|
java
|
public static Or or(Expression<Boolean> left, Expression<Boolean> right) {
return new Or(left, right);
}
|
[
"public",
"static",
"Or",
"or",
"(",
"Expression",
"<",
"Boolean",
">",
"left",
",",
"Expression",
"<",
"Boolean",
">",
"right",
")",
"{",
"return",
"new",
"Or",
"(",
"left",
",",
"right",
")",
";",
"}"
] |
Creates an Or expression from the given expressions.
@param left The left expression.
@param right The right expression.
@return An Or expression.
|
[
"Creates",
"an",
"Or",
"expression",
"from",
"the",
"given",
"expressions",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L723-L725
|
9,948
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isBefore
|
public static IsBefore isBefore(Expression<Date> left, Expression<Date> right) {
return new IsBefore(left, right);
}
|
java
|
public static IsBefore isBefore(Expression<Date> left, Expression<Date> right) {
return new IsBefore(left, right);
}
|
[
"public",
"static",
"IsBefore",
"isBefore",
"(",
"Expression",
"<",
"Date",
">",
"left",
",",
"Expression",
"<",
"Date",
">",
"right",
")",
"{",
"return",
"new",
"IsBefore",
"(",
"left",
",",
"right",
")",
";",
"}"
] |
Creates an IsBefore expression from the given expressions.
@param left The left hand side of the comparison
@param right The right hand side of the comparison.
@return An IsBefore expression.
|
[
"Creates",
"an",
"IsBefore",
"expression",
"from",
"the",
"given",
"expressions",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L744-L746
|
9,949
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isAfter
|
public static IsAfter isAfter(Expression<Date> left, Expression<Date> right) {
return new IsAfter(left, right);
}
|
java
|
public static IsAfter isAfter(Expression<Date> left, Expression<Date> right) {
return new IsAfter(left, right);
}
|
[
"public",
"static",
"IsAfter",
"isAfter",
"(",
"Expression",
"<",
"Date",
">",
"left",
",",
"Expression",
"<",
"Date",
">",
"right",
")",
"{",
"return",
"new",
"IsAfter",
"(",
"left",
",",
"right",
")",
";",
"}"
] |
Creates an IsAfter expression from the given expressions.
@param left The left hand side of the comparison
@param right The right hand side of the comparison.
@return An IsBefore expression.
|
[
"Creates",
"an",
"IsAfter",
"expression",
"from",
"the",
"given",
"expressions",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L755-L757
|
9,950
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isBetween
|
public static DateIsBetween isBetween(ComparableExpression<Date> date, ComparableExpression<Date> lowDate, ComparableExpression<Date> highDate) {
return new DateIsBetween(date, lowDate, highDate);
}
|
java
|
public static DateIsBetween isBetween(ComparableExpression<Date> date, ComparableExpression<Date> lowDate, ComparableExpression<Date> highDate) {
return new DateIsBetween(date, lowDate, highDate);
}
|
[
"public",
"static",
"DateIsBetween",
"isBetween",
"(",
"ComparableExpression",
"<",
"Date",
">",
"date",
",",
"ComparableExpression",
"<",
"Date",
">",
"lowDate",
",",
"ComparableExpression",
"<",
"Date",
">",
"highDate",
")",
"{",
"return",
"new",
"DateIsBetween",
"(",
"date",
",",
"lowDate",
",",
"highDate",
")",
";",
"}"
] |
Creates an IsBetween expression from the given expressions.
@param date The date to compare.
@param lowDate The low date to compare to.
@param highDate The high date to compare to
@return A DateIsBetween expression.
|
[
"Creates",
"an",
"IsBetween",
"expression",
"from",
"the",
"given",
"expressions",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L767-L769
|
9,951
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.geoEquals
|
public static GeoEquals geoEquals(Expression<Geometry> left, Expression<Geometry> right) {
return new GeoEquals(left, right);
}
|
java
|
public static GeoEquals geoEquals(Expression<Geometry> left, Expression<Geometry> right) {
return new GeoEquals(left, right);
}
|
[
"public",
"static",
"GeoEquals",
"geoEquals",
"(",
"Expression",
"<",
"Geometry",
">",
"left",
",",
"Expression",
"<",
"Geometry",
">",
"right",
")",
"{",
"return",
"new",
"GeoEquals",
"(",
"left",
",",
"right",
")",
";",
"}"
] |
Creates a GeoEquals expression from the left and right expressions.
@param left The left expression.
@param right The right expression.
@return A GeoEquals expression.
|
[
"Creates",
"a",
"GeoEquals",
"expression",
"from",
"the",
"left",
"and",
"right",
"expressions",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L795-L797
|
9,952
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/DefaultFeature.java
|
DefaultFeature.setGeometry
|
public void setGeometry(String name, Geometry value)
{
if (name == null)
{
geomPropertyName = null;
geomValue = null;
}
else
{
geomPropertyName= name;
geomValue = value;
}
}
|
java
|
public void setGeometry(String name, Geometry value)
{
if (name == null)
{
geomPropertyName = null;
geomValue = null;
}
else
{
geomPropertyName= name;
geomValue = value;
}
}
|
[
"public",
"void",
"setGeometry",
"(",
"String",
"name",
",",
"Geometry",
"value",
")",
"{",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"geomPropertyName",
"=",
"null",
";",
"geomValue",
"=",
"null",
";",
"}",
"else",
"{",
"geomPropertyName",
"=",
"name",
";",
"geomValue",
"=",
"value",
";",
"}",
"}"
] |
Sets the geometry property of the feature. This method also allows wiping the current geometry
by setting the name of the property to null. The value will in that case be ignored.
@param name the name of the geometry property, or null if the geometry property is to be wiped
@param value the value of the geometry property of this feature
|
[
"Sets",
"the",
"geometry",
"property",
"of",
"the",
"feature",
".",
"This",
"method",
"also",
"allows",
"wiping",
"the",
"current",
"geometry",
"by",
"setting",
"the",
"name",
"of",
"the",
"property",
"to",
"null",
".",
"The",
"value",
"will",
"in",
"that",
"case",
"be",
"ignored",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/DefaultFeature.java#L79-L91
|
9,953
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/DefaultFeature.java
|
DefaultFeature.setId
|
public void setId(String name, Object value)
{
if (name == null)
{
idPropertyName = null;
idValue = null;
}
else
{
idPropertyName= name;
idValue = value;
}
}
|
java
|
public void setId(String name, Object value)
{
if (name == null)
{
idPropertyName = null;
idValue = null;
}
else
{
idPropertyName= name;
idValue = value;
}
}
|
[
"public",
"void",
"setId",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"idPropertyName",
"=",
"null",
";",
"idValue",
"=",
"null",
";",
"}",
"else",
"{",
"idPropertyName",
"=",
"name",
";",
"idValue",
"=",
"value",
";",
"}",
"}"
] |
Sets the id property of the feature. This method also allows wiping the current id
by setting the name of the id to null. The value will in that case be ignored.
@param name the name of the id property, or null if the geometry property is to be wiped
@param value the value of the id property of this feature
|
[
"Sets",
"the",
"id",
"property",
"of",
"the",
"feature",
".",
"This",
"method",
"also",
"allows",
"wiping",
"the",
"current",
"id",
"by",
"setting",
"the",
"name",
"of",
"the",
"id",
"to",
"null",
".",
"The",
"value",
"will",
"in",
"that",
"case",
"be",
"ignored",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/DefaultFeature.java#L99-L111
|
9,954
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/DefaultFeature.java
|
DefaultFeature.addProperty
|
public void addProperty(String propertyName, Object value)
{
if (propertyName != null)
{
propertyNames.add(propertyName);
if (value == null)
{
properties.remove(propertyName);
}
else
{
properties.put(propertyName, value);
}
}
}
|
java
|
public void addProperty(String propertyName, Object value)
{
if (propertyName != null)
{
propertyNames.add(propertyName);
if (value == null)
{
properties.remove(propertyName);
}
else
{
properties.put(propertyName, value);
}
}
}
|
[
"public",
"void",
"addProperty",
"(",
"String",
"propertyName",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"propertyName",
"!=",
"null",
")",
"{",
"propertyNames",
".",
"add",
"(",
"propertyName",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"properties",
".",
"remove",
"(",
"propertyName",
")",
";",
"}",
"else",
"{",
"properties",
".",
"put",
"(",
"propertyName",
",",
"value",
")",
";",
"}",
"}",
"}"
] |
The name of the property to add. if it already exists, the value is updated. If the propertyname is null,
the property addition is ignored.
@param propertyName the name of the property to add
@param value the value to assign to the given property.
|
[
"The",
"name",
"of",
"the",
"property",
"to",
"add",
".",
"if",
"it",
"already",
"exists",
"the",
"value",
"is",
"updated",
".",
"If",
"the",
"propertyname",
"is",
"null",
"the",
"property",
"addition",
"is",
"ignored",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/DefaultFeature.java#L119-L133
|
9,955
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/dataformats/json/jackson/DefaultFeature.java
|
DefaultFeature.wipeProperty
|
public void wipeProperty(String propertyName)
{
if (propertyName != null)
{
propertyNames.remove(propertyName);
if (properties.containsKey(propertyName))
{
properties.remove(propertyName);
}
}
}
|
java
|
public void wipeProperty(String propertyName)
{
if (propertyName != null)
{
propertyNames.remove(propertyName);
if (properties.containsKey(propertyName))
{
properties.remove(propertyName);
}
}
}
|
[
"public",
"void",
"wipeProperty",
"(",
"String",
"propertyName",
")",
"{",
"if",
"(",
"propertyName",
"!=",
"null",
")",
"{",
"propertyNames",
".",
"remove",
"(",
"propertyName",
")",
";",
"if",
"(",
"properties",
".",
"containsKey",
"(",
"propertyName",
")",
")",
"{",
"properties",
".",
"remove",
"(",
"propertyName",
")",
";",
"}",
"}",
"}"
] |
If a property with the specified name exists, it is removed from this feature. if the given propertyname
is null, the call is ignored. Note that this method has no effect whatsoever regarding the geometry or id property.
@param propertyName the name of the property to wipe.
|
[
"If",
"a",
"property",
"with",
"the",
"specified",
"name",
"exists",
"it",
"is",
"removed",
"from",
"this",
"feature",
".",
"if",
"the",
"given",
"propertyname",
"is",
"null",
"the",
"call",
"is",
"ignored",
".",
"Note",
"that",
"this",
"method",
"has",
"no",
"effect",
"whatsoever",
"regarding",
"the",
"geometry",
"or",
"id",
"property",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/DefaultFeature.java#L141-L151
|
9,956
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/cql/Cql.java
|
Cql.toStaticFilter
|
public static Filter toStaticFilter(String cqlExpression, Class clazz) throws ParseException {
try {
Parser p = new Parser( new Lexer( new PushbackReader(new StringReader(cqlExpression), 1024)));
// Parse the input.
Start tree = p.parse();
// Build the filter expression
FilterExpressionBuilder builder = new FilterExpressionBuilder();
tree.apply(builder);
// Wrap in a filter
return new Filter(builder.getExp());
}
catch(ParserException e) {
ParseException parseException = new ParseException(e.getMessage(), e.getToken().getPos());
parseException.initCause(e);
throw parseException;
}
catch (LexerException e) {
ParseException parseException = new ParseException(e.getMessage(), 0);
parseException.initCause(e);
throw parseException;
}
catch (IOException e) {
ParseException parseException = new ParseException(e.getMessage(), 0);
parseException.initCause(e);
throw parseException;
}
}
|
java
|
public static Filter toStaticFilter(String cqlExpression, Class clazz) throws ParseException {
try {
Parser p = new Parser( new Lexer( new PushbackReader(new StringReader(cqlExpression), 1024)));
// Parse the input.
Start tree = p.parse();
// Build the filter expression
FilterExpressionBuilder builder = new FilterExpressionBuilder();
tree.apply(builder);
// Wrap in a filter
return new Filter(builder.getExp());
}
catch(ParserException e) {
ParseException parseException = new ParseException(e.getMessage(), e.getToken().getPos());
parseException.initCause(e);
throw parseException;
}
catch (LexerException e) {
ParseException parseException = new ParseException(e.getMessage(), 0);
parseException.initCause(e);
throw parseException;
}
catch (IOException e) {
ParseException parseException = new ParseException(e.getMessage(), 0);
parseException.initCause(e);
throw parseException;
}
}
|
[
"public",
"static",
"Filter",
"toStaticFilter",
"(",
"String",
"cqlExpression",
",",
"Class",
"clazz",
")",
"throws",
"ParseException",
"{",
"try",
"{",
"Parser",
"p",
"=",
"new",
"Parser",
"(",
"new",
"Lexer",
"(",
"new",
"PushbackReader",
"(",
"new",
"StringReader",
"(",
"cqlExpression",
")",
",",
"1024",
")",
")",
")",
";",
"// Parse the input.",
"Start",
"tree",
"=",
"p",
".",
"parse",
"(",
")",
";",
"// Build the filter expression",
"FilterExpressionBuilder",
"builder",
"=",
"new",
"FilterExpressionBuilder",
"(",
")",
";",
"tree",
".",
"apply",
"(",
"builder",
")",
";",
"// Wrap in a filter",
"return",
"new",
"Filter",
"(",
"builder",
".",
"getExp",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ParserException",
"e",
")",
"{",
"ParseException",
"parseException",
"=",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
".",
"getToken",
"(",
")",
".",
"getPos",
"(",
")",
")",
";",
"parseException",
".",
"initCause",
"(",
"e",
")",
";",
"throw",
"parseException",
";",
"}",
"catch",
"(",
"LexerException",
"e",
")",
"{",
"ParseException",
"parseException",
"=",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"0",
")",
";",
"parseException",
".",
"initCause",
"(",
"e",
")",
";",
"throw",
"parseException",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"ParseException",
"parseException",
"=",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"0",
")",
";",
"parseException",
".",
"initCause",
"(",
"e",
")",
";",
"throw",
"parseException",
";",
"}",
"}"
] |
Creates an executable object filter based on the given CQL expression.
This filter is only applicable for the given class.
@param cqlExpression The CQL expression.
@param clazz The type for which to construct the filter.
@return An object filter that behaves according to the given CQL expression.
@throws java.text.ParseException When parsing fails for any reason (parser, lexer, IO)
|
[
"Creates",
"an",
"executable",
"object",
"filter",
"based",
"on",
"the",
"given",
"CQL",
"expression",
".",
"This",
"filter",
"is",
"only",
"applicable",
"for",
"the",
"given",
"class",
"."
] |
dc7f92b04d8c6cb706e78cb95e746d8f12089d95
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/cql/Cql.java#L72-L104
|
9,957
|
chocoteam/choco-graph
|
src/main/java/org/chocosolver/graphsolver/cstrs/cost/tsp/heap/BinarySimpleHeap.java
|
BinarySimpleHeap.swap
|
private void swap(int n, int m) {
int eM = elements[m];
int eN = elements[n];
elements[m] = eN;
elements[n] = eM;
positions[eM] = n;
positions[eN] = m;
}
|
java
|
private void swap(int n, int m) {
int eM = elements[m];
int eN = elements[n];
elements[m] = eN;
elements[n] = eM;
positions[eM] = n;
positions[eN] = m;
}
|
[
"private",
"void",
"swap",
"(",
"int",
"n",
",",
"int",
"m",
")",
"{",
"int",
"eM",
"=",
"elements",
"[",
"m",
"]",
";",
"int",
"eN",
"=",
"elements",
"[",
"n",
"]",
";",
"elements",
"[",
"m",
"]",
"=",
"eN",
";",
"elements",
"[",
"n",
"]",
"=",
"eM",
";",
"positions",
"[",
"eM",
"]",
"=",
"n",
";",
"positions",
"[",
"eN",
"]",
"=",
"m",
";",
"}"
] |
swap data in node n with data in node m
@param n index of the node containing a data
@param m index of the node containing a data
|
[
"swap",
"data",
"in",
"node",
"n",
"with",
"data",
"in",
"node",
"m"
] |
0a03b0aafc86601977728c7e3fcb5ed376f1fae9
|
https://github.com/chocoteam/choco-graph/blob/0a03b0aafc86601977728c7e3fcb5ed376f1fae9/src/main/java/org/chocosolver/graphsolver/cstrs/cost/tsp/heap/BinarySimpleHeap.java#L172-L179
|
9,958
|
chocoteam/choco-graph
|
src/main/java/org/chocosolver/graphsolver/cstrs/cost/tsp/heap/BinarySimpleHeap.java
|
BinarySimpleHeap.moveAtFirst
|
private void moveAtFirst(int n_from) {
int eT = elements[0];
int eF = elements[n_from];
positions[eT] = -1;
positions[eF] = 0;
elements[0] = eF;
elements[n_from] = -1;
}
|
java
|
private void moveAtFirst(int n_from) {
int eT = elements[0];
int eF = elements[n_from];
positions[eT] = -1;
positions[eF] = 0;
elements[0] = eF;
elements[n_from] = -1;
}
|
[
"private",
"void",
"moveAtFirst",
"(",
"int",
"n_from",
")",
"{",
"int",
"eT",
"=",
"elements",
"[",
"0",
"]",
";",
"int",
"eF",
"=",
"elements",
"[",
"n_from",
"]",
";",
"positions",
"[",
"eT",
"]",
"=",
"-",
"1",
";",
"positions",
"[",
"eF",
"]",
"=",
"0",
";",
"elements",
"[",
"0",
"]",
"=",
"eF",
";",
"elements",
"[",
"n_from",
"]",
"=",
"-",
"1",
";",
"}"
] |
moveAtFirst data in node n_from to node 0
Erase previous information of node 0
@param n_from index of the node of the source data
|
[
"moveAtFirst",
"data",
"in",
"node",
"n_from",
"to",
"node",
"0",
"Erase",
"previous",
"information",
"of",
"node",
"0"
] |
0a03b0aafc86601977728c7e3fcb5ed376f1fae9
|
https://github.com/chocoteam/choco-graph/blob/0a03b0aafc86601977728c7e3fcb5ed376f1fae9/src/main/java/org/chocosolver/graphsolver/cstrs/cost/tsp/heap/BinarySimpleHeap.java#L187-L194
|
9,959
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/Frame.java
|
Frame.registerConfiguration
|
public boolean registerConfiguration(EncodingConfiguration ec) {
boolean changed = false;
if(sc.getChannelCount() != 2)
ec.setChannelConfig(EncodingConfiguration.ChannelConfig.INDEPENDENT);
this.ec = new EncodingConfiguration(ec);
verbatimSubframe.registerConfiguration(this.ec);
fixedSubframe.registerConfiguration(this.ec);
lpcSubframe.registerConfiguration(this.ec);
constantSubframe.registerConfiguration(this.ec);
changed = true;
return changed;
}
|
java
|
public boolean registerConfiguration(EncodingConfiguration ec) {
boolean changed = false;
if(sc.getChannelCount() != 2)
ec.setChannelConfig(EncodingConfiguration.ChannelConfig.INDEPENDENT);
this.ec = new EncodingConfiguration(ec);
verbatimSubframe.registerConfiguration(this.ec);
fixedSubframe.registerConfiguration(this.ec);
lpcSubframe.registerConfiguration(this.ec);
constantSubframe.registerConfiguration(this.ec);
changed = true;
return changed;
}
|
[
"public",
"boolean",
"registerConfiguration",
"(",
"EncodingConfiguration",
"ec",
")",
"{",
"boolean",
"changed",
"=",
"false",
";",
"if",
"(",
"sc",
".",
"getChannelCount",
"(",
")",
"!=",
"2",
")",
"ec",
".",
"setChannelConfig",
"(",
"EncodingConfiguration",
".",
"ChannelConfig",
".",
"INDEPENDENT",
")",
";",
"this",
".",
"ec",
"=",
"new",
"EncodingConfiguration",
"(",
"ec",
")",
";",
"verbatimSubframe",
".",
"registerConfiguration",
"(",
"this",
".",
"ec",
")",
";",
"fixedSubframe",
".",
"registerConfiguration",
"(",
"this",
".",
"ec",
")",
";",
"lpcSubframe",
".",
"registerConfiguration",
"(",
"this",
".",
"ec",
")",
";",
"constantSubframe",
".",
"registerConfiguration",
"(",
"this",
".",
"ec",
")",
";",
"changed",
"=",
"true",
";",
"return",
"changed",
";",
"}"
] |
This method is used to set the encoding configuration. This
configuration can be altered throughout the stream, but cannot be called while an
encoding process is active.
@param ec encoding configuration to use.
@return <code>true</code> if configuration was changed.
<code>false</code> otherwise(i.e, and encoding process was active
at the time of change)
|
[
"This",
"method",
"is",
"used",
"to",
"set",
"the",
"encoding",
"configuration",
".",
"This",
"configuration",
"can",
"be",
"altered",
"throughout",
"the",
"stream",
"but",
"cannot",
"be",
"called",
"while",
"an",
"encoding",
"process",
"is",
"active",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/Frame.java#L108-L119
|
9,960
|
chocoteam/choco-graph
|
src/main/java/org/chocosolver/graphsolver/variables/GraphVar.java
|
GraphVar.removeNode
|
public boolean removeNode(int x, ICause cause) throws ContradictionException {
assert cause != null;
assert (x >= 0 && x < n);
if (LB.getNodes().contains(x)) {
this.contradiction(cause, "remove mandatory node");
return true;
} else if (!UB.getNodes().contains(x)) {
return false;
}
ISet nei = UB.getSuccOrNeighOf(x);
for (int i : nei) {
removeArc(x, i, cause);
}
nei = UB.getPredOrNeighOf(x);
for (int i : nei) {
removeArc(i, x, cause);
}
if (UB.removeNode(x)) {
if (reactOnModification) {
delta.add(x, GraphDelta.NR, cause);
}
GraphEventType e = GraphEventType.REMOVE_NODE;
notifyPropagators(e, cause);
return true;
}
return false;
}
|
java
|
public boolean removeNode(int x, ICause cause) throws ContradictionException {
assert cause != null;
assert (x >= 0 && x < n);
if (LB.getNodes().contains(x)) {
this.contradiction(cause, "remove mandatory node");
return true;
} else if (!UB.getNodes().contains(x)) {
return false;
}
ISet nei = UB.getSuccOrNeighOf(x);
for (int i : nei) {
removeArc(x, i, cause);
}
nei = UB.getPredOrNeighOf(x);
for (int i : nei) {
removeArc(i, x, cause);
}
if (UB.removeNode(x)) {
if (reactOnModification) {
delta.add(x, GraphDelta.NR, cause);
}
GraphEventType e = GraphEventType.REMOVE_NODE;
notifyPropagators(e, cause);
return true;
}
return false;
}
|
[
"public",
"boolean",
"removeNode",
"(",
"int",
"x",
",",
"ICause",
"cause",
")",
"throws",
"ContradictionException",
"{",
"assert",
"cause",
"!=",
"null",
";",
"assert",
"(",
"x",
">=",
"0",
"&&",
"x",
"<",
"n",
")",
";",
"if",
"(",
"LB",
".",
"getNodes",
"(",
")",
".",
"contains",
"(",
"x",
")",
")",
"{",
"this",
".",
"contradiction",
"(",
"cause",
",",
"\"remove mandatory node\"",
")",
";",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"!",
"UB",
".",
"getNodes",
"(",
")",
".",
"contains",
"(",
"x",
")",
")",
"{",
"return",
"false",
";",
"}",
"ISet",
"nei",
"=",
"UB",
".",
"getSuccOrNeighOf",
"(",
"x",
")",
";",
"for",
"(",
"int",
"i",
":",
"nei",
")",
"{",
"removeArc",
"(",
"x",
",",
"i",
",",
"cause",
")",
";",
"}",
"nei",
"=",
"UB",
".",
"getPredOrNeighOf",
"(",
"x",
")",
";",
"for",
"(",
"int",
"i",
":",
"nei",
")",
"{",
"removeArc",
"(",
"i",
",",
"x",
",",
"cause",
")",
";",
"}",
"if",
"(",
"UB",
".",
"removeNode",
"(",
"x",
")",
")",
"{",
"if",
"(",
"reactOnModification",
")",
"{",
"delta",
".",
"add",
"(",
"x",
",",
"GraphDelta",
".",
"NR",
",",
"cause",
")",
";",
"}",
"GraphEventType",
"e",
"=",
"GraphEventType",
".",
"REMOVE_NODE",
";",
"notifyPropagators",
"(",
"e",
",",
"cause",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Remove node x from the domain
Removes x from the upper bound graph
@param x node's index
@param cause algorithm which is related to the removal
@return true iff the removal has an effect
|
[
"Remove",
"node",
"x",
"from",
"the",
"domain",
"Removes",
"x",
"from",
"the",
"upper",
"bound",
"graph"
] |
0a03b0aafc86601977728c7e3fcb5ed376f1fae9
|
https://github.com/chocoteam/choco-graph/blob/0a03b0aafc86601977728c7e3fcb5ed376f1fae9/src/main/java/org/chocosolver/graphsolver/variables/GraphVar.java#L111-L137
|
9,961
|
chocoteam/choco-graph
|
src/main/java/org/chocosolver/graphsolver/variables/GraphVar.java
|
GraphVar.enforceNode
|
public boolean enforceNode(int x, ICause cause) throws ContradictionException {
assert cause != null;
assert (x >= 0 && x < n);
if (UB.getNodes().contains(x)) {
if (LB.addNode(x)) {
if (reactOnModification) {
delta.add(x, GraphDelta.NE, cause);
}
GraphEventType e = GraphEventType.ADD_NODE;
notifyPropagators(e, cause);
return true;
}
return false;
}
this.contradiction(cause, "enforce node which is not in the domain");
return true;
}
|
java
|
public boolean enforceNode(int x, ICause cause) throws ContradictionException {
assert cause != null;
assert (x >= 0 && x < n);
if (UB.getNodes().contains(x)) {
if (LB.addNode(x)) {
if (reactOnModification) {
delta.add(x, GraphDelta.NE, cause);
}
GraphEventType e = GraphEventType.ADD_NODE;
notifyPropagators(e, cause);
return true;
}
return false;
}
this.contradiction(cause, "enforce node which is not in the domain");
return true;
}
|
[
"public",
"boolean",
"enforceNode",
"(",
"int",
"x",
",",
"ICause",
"cause",
")",
"throws",
"ContradictionException",
"{",
"assert",
"cause",
"!=",
"null",
";",
"assert",
"(",
"x",
">=",
"0",
"&&",
"x",
"<",
"n",
")",
";",
"if",
"(",
"UB",
".",
"getNodes",
"(",
")",
".",
"contains",
"(",
"x",
")",
")",
"{",
"if",
"(",
"LB",
".",
"addNode",
"(",
"x",
")",
")",
"{",
"if",
"(",
"reactOnModification",
")",
"{",
"delta",
".",
"add",
"(",
"x",
",",
"GraphDelta",
".",
"NE",
",",
"cause",
")",
";",
"}",
"GraphEventType",
"e",
"=",
"GraphEventType",
".",
"ADD_NODE",
";",
"notifyPropagators",
"(",
"e",
",",
"cause",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"this",
".",
"contradiction",
"(",
"cause",
",",
"\"enforce node which is not in the domain\"",
")",
";",
"return",
"true",
";",
"}"
] |
Enforce the node x to belong to any solution
Adds x to the lower bound graph
@param x node's index
@param cause algorithm which is related to the modification
@return true iff the enforcing has an effect
|
[
"Enforce",
"the",
"node",
"x",
"to",
"belong",
"to",
"any",
"solution",
"Adds",
"x",
"to",
"the",
"lower",
"bound",
"graph"
] |
0a03b0aafc86601977728c7e3fcb5ed376f1fae9
|
https://github.com/chocoteam/choco-graph/blob/0a03b0aafc86601977728c7e3fcb5ed376f1fae9/src/main/java/org/chocosolver/graphsolver/variables/GraphVar.java#L147-L163
|
9,962
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java
|
EncodedElement.clear
|
public void clear(int size, int off) {
if (size%4 != 4) size = (size/4+1)*4;
next = null;
previous = null;
data = new byte[size];
offset = off;
for(int i = 0; i < data.length; i++)
data[i] = 0;
usableBits = off;
}
|
java
|
public void clear(int size, int off) {
if (size%4 != 4) size = (size/4+1)*4;
next = null;
previous = null;
data = new byte[size];
offset = off;
for(int i = 0; i < data.length; i++)
data[i] = 0;
usableBits = off;
}
|
[
"public",
"void",
"clear",
"(",
"int",
"size",
",",
"int",
"off",
")",
"{",
"if",
"(",
"size",
"%",
"4",
"!=",
"4",
")",
"size",
"=",
"(",
"size",
"/",
"4",
"+",
"1",
")",
"*",
"4",
";",
"next",
"=",
"null",
";",
"previous",
"=",
"null",
";",
"data",
"=",
"new",
"byte",
"[",
"size",
"]",
";",
"offset",
"=",
"off",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
";",
"i",
"++",
")",
"data",
"[",
"i",
"]",
"=",
"0",
";",
"usableBits",
"=",
"off",
";",
"}"
] |
Completely clear this element and use the given size and offset for the
new data array.
@param size Size of data array to use(in bytes)
@param off Offset to use for this element. Usablebits will also be set to
this value.
|
[
"Completely",
"clear",
"this",
"element",
"and",
"use",
"the",
"given",
"size",
"and",
"offset",
"for",
"the",
"new",
"data",
"array",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java#L115-L124
|
9,963
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java
|
EncodedElement.getEnd_S
|
protected static EncodedElement getEnd_S(EncodedElement e) {
if(e == null)
return null;
EncodedElement temp = e.next;
EncodedElement end = e;
while(temp != null) {
end = temp;
temp = temp.next;
}
return end;
}
|
java
|
protected static EncodedElement getEnd_S(EncodedElement e) {
if(e == null)
return null;
EncodedElement temp = e.next;
EncodedElement end = e;
while(temp != null) {
end = temp;
temp = temp.next;
}
return end;
}
|
[
"protected",
"static",
"EncodedElement",
"getEnd_S",
"(",
"EncodedElement",
"e",
")",
"{",
"if",
"(",
"e",
"==",
"null",
")",
"return",
"null",
";",
"EncodedElement",
"temp",
"=",
"e",
".",
"next",
";",
"EncodedElement",
"end",
"=",
"e",
";",
"while",
"(",
"temp",
"!=",
"null",
")",
"{",
"end",
"=",
"temp",
";",
"temp",
"=",
"temp",
".",
"next",
";",
"}",
"return",
"end",
";",
"}"
] |
Return the last element of the list given. This is a static funtion to
provide minor speed improvement. Loops through all elements' "next"
pointers, till the last is found.
@param e EncodedElement list to find end of.
@return Final element in list.
|
[
"Return",
"the",
"last",
"element",
"of",
"the",
"list",
"given",
".",
"This",
"is",
"a",
"static",
"funtion",
"to",
"provide",
"minor",
"speed",
"improvement",
".",
"Loops",
"through",
"all",
"elements",
"next",
"pointers",
"till",
"the",
"last",
"is",
"found",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java#L236-L246
|
9,964
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java
|
EncodedElement.getEnd
|
public EncodedElement getEnd() {
EncodedElement temp = next;
EncodedElement end = this;
while(temp != null) {
end = temp;
temp = temp.next;
}
return end;
}
|
java
|
public EncodedElement getEnd() {
EncodedElement temp = next;
EncodedElement end = this;
while(temp != null) {
end = temp;
temp = temp.next;
}
return end;
}
|
[
"public",
"EncodedElement",
"getEnd",
"(",
")",
"{",
"EncodedElement",
"temp",
"=",
"next",
";",
"EncodedElement",
"end",
"=",
"this",
";",
"while",
"(",
"temp",
"!=",
"null",
")",
"{",
"end",
"=",
"temp",
";",
"temp",
"=",
"temp",
".",
"next",
";",
"}",
"return",
"end",
";",
"}"
] |
Return the last element of the list given. Loops through all elements'
"next" pointers, till the last is found.
@return last element in this list
|
[
"Return",
"the",
"last",
"element",
"of",
"the",
"list",
"given",
".",
"Loops",
"through",
"all",
"elements",
"next",
"pointers",
"till",
"the",
"last",
"is",
"found",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java#L253-L261
|
9,965
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java
|
EncodedElement.attachEnd
|
public boolean attachEnd(EncodedElement e) {
if(DEBUG_LEV > 0)
System.err.println("EncodedElement::attachEnd : Begin");
boolean attached = true;
EncodedElement current = this;
while(current.getNext() != null) {
current = current.getNext();
}
current.setNext(e);
e.setPrevious(current);
if(DEBUG_LEV > 0)
System.err.println("EncodedElement::attachEnd : End");
return attached;
}
|
java
|
public boolean attachEnd(EncodedElement e) {
if(DEBUG_LEV > 0)
System.err.println("EncodedElement::attachEnd : Begin");
boolean attached = true;
EncodedElement current = this;
while(current.getNext() != null) {
current = current.getNext();
}
current.setNext(e);
e.setPrevious(current);
if(DEBUG_LEV > 0)
System.err.println("EncodedElement::attachEnd : End");
return attached;
}
|
[
"public",
"boolean",
"attachEnd",
"(",
"EncodedElement",
"e",
")",
"{",
"if",
"(",
"DEBUG_LEV",
">",
"0",
")",
"System",
".",
"err",
".",
"println",
"(",
"\"EncodedElement::attachEnd : Begin\"",
")",
";",
"boolean",
"attached",
"=",
"true",
";",
"EncodedElement",
"current",
"=",
"this",
";",
"while",
"(",
"current",
".",
"getNext",
"(",
")",
"!=",
"null",
")",
"{",
"current",
"=",
"current",
".",
"getNext",
"(",
")",
";",
"}",
"current",
".",
"setNext",
"(",
"e",
")",
";",
"e",
".",
"setPrevious",
"(",
"current",
")",
";",
"if",
"(",
"DEBUG_LEV",
">",
"0",
")",
"System",
".",
"err",
".",
"println",
"(",
"\"EncodedElement::attachEnd : End\"",
")",
";",
"return",
"attached",
";",
"}"
] |
Attach an element to the end of this list.
@param e Element to attach.
@return True if element was attached, false otherwise.
|
[
"Attach",
"an",
"element",
"to",
"the",
"end",
"of",
"this",
"list",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java#L269-L282
|
9,966
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java
|
EncodedElement.addLong
|
public EncodedElement addLong(long input, int bitCount) {
if(next != null) {
EncodedElement end = EncodedElement.getEnd_S(next);
return end.addLong(input, bitCount);
}
else if(data.length*8 <= usableBits+bitCount) {
//create child and attach to next.
//Set child's offset appropriately(i.e, manually set usable bits)
int tOff = usableBits %8;
int size = data.length/2+1;
//guarantee that our new element can store our given value
if(size < bitCount) size = bitCount*10;
next = new EncodedElement(size, tOff);
//add int to child
return next.addLong(input, bitCount);
}
//At this point, we have the space, and we are the end of the chain.
int startPos = this.usableBits;
byte[] dest = this.data;
EncodedElement.addLong(input, bitCount, startPos, dest);
usableBits += bitCount;
return this;
}
|
java
|
public EncodedElement addLong(long input, int bitCount) {
if(next != null) {
EncodedElement end = EncodedElement.getEnd_S(next);
return end.addLong(input, bitCount);
}
else if(data.length*8 <= usableBits+bitCount) {
//create child and attach to next.
//Set child's offset appropriately(i.e, manually set usable bits)
int tOff = usableBits %8;
int size = data.length/2+1;
//guarantee that our new element can store our given value
if(size < bitCount) size = bitCount*10;
next = new EncodedElement(size, tOff);
//add int to child
return next.addLong(input, bitCount);
}
//At this point, we have the space, and we are the end of the chain.
int startPos = this.usableBits;
byte[] dest = this.data;
EncodedElement.addLong(input, bitCount, startPos, dest);
usableBits += bitCount;
return this;
}
|
[
"public",
"EncodedElement",
"addLong",
"(",
"long",
"input",
",",
"int",
"bitCount",
")",
"{",
"if",
"(",
"next",
"!=",
"null",
")",
"{",
"EncodedElement",
"end",
"=",
"EncodedElement",
".",
"getEnd_S",
"(",
"next",
")",
";",
"return",
"end",
".",
"addLong",
"(",
"input",
",",
"bitCount",
")",
";",
"}",
"else",
"if",
"(",
"data",
".",
"length",
"*",
"8",
"<=",
"usableBits",
"+",
"bitCount",
")",
"{",
"//create child and attach to next.",
"//Set child's offset appropriately(i.e, manually set usable bits)",
"int",
"tOff",
"=",
"usableBits",
"%",
"8",
";",
"int",
"size",
"=",
"data",
".",
"length",
"/",
"2",
"+",
"1",
";",
"//guarantee that our new element can store our given value",
"if",
"(",
"size",
"<",
"bitCount",
")",
"size",
"=",
"bitCount",
"*",
"10",
";",
"next",
"=",
"new",
"EncodedElement",
"(",
"size",
",",
"tOff",
")",
";",
"//add int to child",
"return",
"next",
".",
"addLong",
"(",
"input",
",",
"bitCount",
")",
";",
"}",
"//At this point, we have the space, and we are the end of the chain.",
"int",
"startPos",
"=",
"this",
".",
"usableBits",
";",
"byte",
"[",
"]",
"dest",
"=",
"this",
".",
"data",
";",
"EncodedElement",
".",
"addLong",
"(",
"input",
",",
"bitCount",
",",
"startPos",
",",
"dest",
")",
";",
"usableBits",
"+=",
"bitCount",
";",
"return",
"this",
";",
"}"
] |
Add a number of bits from a long to the end of this list's data. Will
add a new element if necessary. The bits stored are taken from the lower-
order of input.
@param input Long containing bits to append to end.
@param bitCount Number of bits to append.
@return EncodedElement which actually contains the appended value.
|
[
"Add",
"a",
"number",
"of",
"bits",
"from",
"a",
"long",
"to",
"the",
"end",
"of",
"this",
"list",
"s",
"data",
".",
"Will",
"add",
"a",
"new",
"element",
"if",
"necessary",
".",
"The",
"bits",
"stored",
"are",
"taken",
"from",
"the",
"lower",
"-",
"order",
"of",
"input",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java#L293-L315
|
9,967
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java
|
EncodedElement.packInt
|
public EncodedElement packInt(int[] inputArray, int bitSize,
int start, int skip, int countA) {
//go to end if we're not there.
if(next != null) {
EncodedElement end = EncodedElement.getEnd_S(next);
return end.packInt(inputArray, bitSize, start, skip, countA);
}
//calculate how many we can pack into current.
int writeCount = (data.length*8 - usableBits) / bitSize;
if(writeCount > countA) writeCount = countA;
//pack them and update usable bits.
EncodedElement.packInt(inputArray, bitSize, usableBits, start, skip, countA, data);
usableBits += writeCount * bitSize;
//if more remain, create child object and add there
countA -= writeCount;
if(countA > 0) {
int tOff = usableBits %8;
int size = data.length/2+1;
//guarantee that our new element can store our given value
if(size < bitSize*countA) size = bitSize*countA+10;
next = new EncodedElement(size, tOff);
//add int to child
return next.packInt(inputArray, bitSize, start+writeCount*(skip+1), skip, countA);
}
else {
//return last object we write to.
return this;
}
}
|
java
|
public EncodedElement packInt(int[] inputArray, int bitSize,
int start, int skip, int countA) {
//go to end if we're not there.
if(next != null) {
EncodedElement end = EncodedElement.getEnd_S(next);
return end.packInt(inputArray, bitSize, start, skip, countA);
}
//calculate how many we can pack into current.
int writeCount = (data.length*8 - usableBits) / bitSize;
if(writeCount > countA) writeCount = countA;
//pack them and update usable bits.
EncodedElement.packInt(inputArray, bitSize, usableBits, start, skip, countA, data);
usableBits += writeCount * bitSize;
//if more remain, create child object and add there
countA -= writeCount;
if(countA > 0) {
int tOff = usableBits %8;
int size = data.length/2+1;
//guarantee that our new element can store our given value
if(size < bitSize*countA) size = bitSize*countA+10;
next = new EncodedElement(size, tOff);
//add int to child
return next.packInt(inputArray, bitSize, start+writeCount*(skip+1), skip, countA);
}
else {
//return last object we write to.
return this;
}
}
|
[
"public",
"EncodedElement",
"packInt",
"(",
"int",
"[",
"]",
"inputArray",
",",
"int",
"bitSize",
",",
"int",
"start",
",",
"int",
"skip",
",",
"int",
"countA",
")",
"{",
"//go to end if we're not there.",
"if",
"(",
"next",
"!=",
"null",
")",
"{",
"EncodedElement",
"end",
"=",
"EncodedElement",
".",
"getEnd_S",
"(",
"next",
")",
";",
"return",
"end",
".",
"packInt",
"(",
"inputArray",
",",
"bitSize",
",",
"start",
",",
"skip",
",",
"countA",
")",
";",
"}",
"//calculate how many we can pack into current.",
"int",
"writeCount",
"=",
"(",
"data",
".",
"length",
"*",
"8",
"-",
"usableBits",
")",
"/",
"bitSize",
";",
"if",
"(",
"writeCount",
">",
"countA",
")",
"writeCount",
"=",
"countA",
";",
"//pack them and update usable bits.",
"EncodedElement",
".",
"packInt",
"(",
"inputArray",
",",
"bitSize",
",",
"usableBits",
",",
"start",
",",
"skip",
",",
"countA",
",",
"data",
")",
";",
"usableBits",
"+=",
"writeCount",
"*",
"bitSize",
";",
"//if more remain, create child object and add there",
"countA",
"-=",
"writeCount",
";",
"if",
"(",
"countA",
">",
"0",
")",
"{",
"int",
"tOff",
"=",
"usableBits",
"%",
"8",
";",
"int",
"size",
"=",
"data",
".",
"length",
"/",
"2",
"+",
"1",
";",
"//guarantee that our new element can store our given value",
"if",
"(",
"size",
"<",
"bitSize",
"*",
"countA",
")",
"size",
"=",
"bitSize",
"*",
"countA",
"+",
"10",
";",
"next",
"=",
"new",
"EncodedElement",
"(",
"size",
",",
"tOff",
")",
";",
"//add int to child",
"return",
"next",
".",
"packInt",
"(",
"inputArray",
",",
"bitSize",
",",
"start",
"+",
"writeCount",
"*",
"(",
"skip",
"+",
"1",
")",
",",
"skip",
",",
"countA",
")",
";",
"}",
"else",
"{",
"//return last object we write to.",
"return",
"this",
";",
"}",
"}"
] |
Append an equal number of bits from each int in an array within given
limits to the end of this list.
@param inputArray Array storing input values.
@param bitSize number of bits to store from each value.
@param start index of first usable index.
@param skip number of indices to skip between values(in case input data
is interleaved with non-desirable data).
@param countA Number of total indices to store from.
@return EncodedElement containing end of packed data. Data may flow
between multiple EncodedElement's, if an existing element was not large
enough for all values.
|
[
"Append",
"an",
"equal",
"number",
"of",
"bits",
"from",
"each",
"int",
"in",
"an",
"array",
"within",
"given",
"limits",
"to",
"the",
"end",
"of",
"this",
"list",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java#L376-L404
|
9,968
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java
|
EncodedElement.getTotalBits
|
public int getTotalBits() {
//this total calculates and removes the bits reserved for "offset"
// between the different children.
int total = 0;
EncodedElement iter = this;
while(iter != null) {
total += iter.usableBits - iter.offset;
iter = iter.next;
}
return total;
}
|
java
|
public int getTotalBits() {
//this total calculates and removes the bits reserved for "offset"
// between the different children.
int total = 0;
EncodedElement iter = this;
while(iter != null) {
total += iter.usableBits - iter.offset;
iter = iter.next;
}
return total;
}
|
[
"public",
"int",
"getTotalBits",
"(",
")",
"{",
"//this total calculates and removes the bits reserved for \"offset\"",
"// between the different children.",
"int",
"total",
"=",
"0",
";",
"EncodedElement",
"iter",
"=",
"this",
";",
"while",
"(",
"iter",
"!=",
"null",
")",
"{",
"total",
"+=",
"iter",
".",
"usableBits",
"-",
"iter",
".",
"offset",
";",
"iter",
"=",
"iter",
".",
"next",
";",
"}",
"return",
"total",
";",
"}"
] |
Total number of usable bits stored by this entire list. This sums the
difference of each list element's "usableBits" and "offset".
@return Total valid bits in this list.
|
[
"Total",
"number",
"of",
"usable",
"bits",
"stored",
"by",
"this",
"entire",
"list",
".",
"This",
"sums",
"the",
"difference",
"of",
"each",
"list",
"element",
"s",
"usableBits",
"and",
"offset",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java#L479-L489
|
9,969
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java
|
EncodedElement.addLong
|
private static void addLong(long input, int count, int startPos, byte[] dest) {
if(DEBUG_LEV > 30)
System.err.println("EncodedElement::addLong : Begin");
int currentByte = startPos/8;
int currentOffset = startPos%8;
int bitRoom;//how many bits can be placed in current byte
long upMask;//to clear upper bits(lower bits auto-cleared by L-shift
int downShift;//bits to shift down, isolating top bits of input
int upShift;//bits to shift up, packing byte from top.
while(count > 0) {
//find how many bits can be placed in current byte
bitRoom = 8-currentOffset;
//get those bits
//i.e, take upper 'bitsNeeded' of input, put to lower part of byte.
downShift = count-bitRoom;
upMask = 255 >>> currentOffset;
upShift = 0;
if(downShift < 0) {
//upMask = 255 >>> bitRoom-count;
upShift = bitRoom - count;
upMask = 255 >>> (currentOffset+upShift);
downShift = 0;
}
if(DEBUG_LEV > 30) {
System.err.println("count:offset:bitRoom:downShift:upShift:" +
count+":"+currentOffset+":"+bitRoom+":"+downShift+":"+upShift);
}
long currentBits = (input >>> downShift) & (upMask);
//shift bits back up to match offset
currentBits = currentBits << upShift;
upMask = (byte)upMask << upShift;
dest[currentByte] = (byte)(dest[currentByte] & (~upMask));
//merge bytes~
dest[currentByte] = (byte)(dest[currentByte] | currentBits);
//System.out.println("new currentByte: " + dest[currentByte]);
count -= bitRoom;
currentOffset = 0;
currentByte++;
}
if(DEBUG_LEV > 30)
System.err.println("EncodedElement::addLong : End");
}
|
java
|
private static void addLong(long input, int count, int startPos, byte[] dest) {
if(DEBUG_LEV > 30)
System.err.println("EncodedElement::addLong : Begin");
int currentByte = startPos/8;
int currentOffset = startPos%8;
int bitRoom;//how many bits can be placed in current byte
long upMask;//to clear upper bits(lower bits auto-cleared by L-shift
int downShift;//bits to shift down, isolating top bits of input
int upShift;//bits to shift up, packing byte from top.
while(count > 0) {
//find how many bits can be placed in current byte
bitRoom = 8-currentOffset;
//get those bits
//i.e, take upper 'bitsNeeded' of input, put to lower part of byte.
downShift = count-bitRoom;
upMask = 255 >>> currentOffset;
upShift = 0;
if(downShift < 0) {
//upMask = 255 >>> bitRoom-count;
upShift = bitRoom - count;
upMask = 255 >>> (currentOffset+upShift);
downShift = 0;
}
if(DEBUG_LEV > 30) {
System.err.println("count:offset:bitRoom:downShift:upShift:" +
count+":"+currentOffset+":"+bitRoom+":"+downShift+":"+upShift);
}
long currentBits = (input >>> downShift) & (upMask);
//shift bits back up to match offset
currentBits = currentBits << upShift;
upMask = (byte)upMask << upShift;
dest[currentByte] = (byte)(dest[currentByte] & (~upMask));
//merge bytes~
dest[currentByte] = (byte)(dest[currentByte] | currentBits);
//System.out.println("new currentByte: " + dest[currentByte]);
count -= bitRoom;
currentOffset = 0;
currentByte++;
}
if(DEBUG_LEV > 30)
System.err.println("EncodedElement::addLong : End");
}
|
[
"private",
"static",
"void",
"addLong",
"(",
"long",
"input",
",",
"int",
"count",
",",
"int",
"startPos",
",",
"byte",
"[",
"]",
"dest",
")",
"{",
"if",
"(",
"DEBUG_LEV",
">",
"30",
")",
"System",
".",
"err",
".",
"println",
"(",
"\"EncodedElement::addLong : Begin\"",
")",
";",
"int",
"currentByte",
"=",
"startPos",
"/",
"8",
";",
"int",
"currentOffset",
"=",
"startPos",
"%",
"8",
";",
"int",
"bitRoom",
";",
"//how many bits can be placed in current byte",
"long",
"upMask",
";",
"//to clear upper bits(lower bits auto-cleared by L-shift",
"int",
"downShift",
";",
"//bits to shift down, isolating top bits of input",
"int",
"upShift",
";",
"//bits to shift up, packing byte from top.",
"while",
"(",
"count",
">",
"0",
")",
"{",
"//find how many bits can be placed in current byte",
"bitRoom",
"=",
"8",
"-",
"currentOffset",
";",
"//get those bits",
"//i.e, take upper 'bitsNeeded' of input, put to lower part of byte.",
"downShift",
"=",
"count",
"-",
"bitRoom",
";",
"upMask",
"=",
"255",
">>>",
"currentOffset",
";",
"upShift",
"=",
"0",
";",
"if",
"(",
"downShift",
"<",
"0",
")",
"{",
"//upMask = 255 >>> bitRoom-count;",
"upShift",
"=",
"bitRoom",
"-",
"count",
";",
"upMask",
"=",
"255",
">>>",
"(",
"currentOffset",
"+",
"upShift",
")",
";",
"downShift",
"=",
"0",
";",
"}",
"if",
"(",
"DEBUG_LEV",
">",
"30",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"count:offset:bitRoom:downShift:upShift:\"",
"+",
"count",
"+",
"\":\"",
"+",
"currentOffset",
"+",
"\":\"",
"+",
"bitRoom",
"+",
"\":\"",
"+",
"downShift",
"+",
"\":\"",
"+",
"upShift",
")",
";",
"}",
"long",
"currentBits",
"=",
"(",
"input",
">>>",
"downShift",
")",
"&",
"(",
"upMask",
")",
";",
"//shift bits back up to match offset",
"currentBits",
"=",
"currentBits",
"<<",
"upShift",
";",
"upMask",
"=",
"(",
"byte",
")",
"upMask",
"<<",
"upShift",
";",
"dest",
"[",
"currentByte",
"]",
"=",
"(",
"byte",
")",
"(",
"dest",
"[",
"currentByte",
"]",
"&",
"(",
"~",
"upMask",
")",
")",
";",
"//merge bytes~",
"dest",
"[",
"currentByte",
"]",
"=",
"(",
"byte",
")",
"(",
"dest",
"[",
"currentByte",
"]",
"|",
"currentBits",
")",
";",
"//System.out.println(\"new currentByte: \" + dest[currentByte]);",
"count",
"-=",
"bitRoom",
";",
"currentOffset",
"=",
"0",
";",
"currentByte",
"++",
";",
"}",
"if",
"(",
"DEBUG_LEV",
">",
"30",
")",
"System",
".",
"err",
".",
"println",
"(",
"\"EncodedElement::addLong : End\"",
")",
";",
"}"
] |
This method adds a given number of bits of a long to a byte array.
@param input long to store bits from
@param count number of low-order bits to store
@param startPos start bit location in array to begin writing
@param dest array to store bits in. dest MUST have enough space to store
the given data, or this function will fail.
|
[
"This",
"method",
"adds",
"a",
"given",
"number",
"of",
"bits",
"of",
"a",
"long",
"to",
"a",
"byte",
"array",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java#L616-L658
|
9,970
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java
|
EncodedElement.packInt
|
private static void packInt(int[] inputArray, int bitSize, int startPosIn,
int start, int skip, int countA, byte[] dest) {
if(DEBUG_LEV > 30)
System.err.println("EncodedElement::packInt : Begin");
for(int valI = 0; valI < countA; valI++) {
//int input = inputArray[valI];
int input = inputArray[valI*(skip+1)+start];
int count = bitSize;
int startPos = startPosIn+valI*bitSize;
int currentByte = startPos/8;
int currentOffset = startPos%8;
int bitRoom;//how many bits can be placed in current byte
int upMask;//to clear upper bits(lower bits auto-cleared by L-shift
int downShift;//bits to shift down, isolating top bits of input
int upShift;//bits to shift up, packing byte from top.
while(count > 0) {
//find how many bits can be placed in current byte
bitRoom = 8-currentOffset;
//get those bits
//i.e, take upper 'bitsNeeded' of input, put to lower part of byte.
downShift = count-bitRoom;
//upMask = uRSHFT(255 ,currentOffset);
upMask = (currentOffset >= 32) ? 0: 255>>>currentOffset;
upShift = 0;
if(downShift < 0) {
//upMask = 255 >>> bitRoom-count;
upShift = bitRoom - count;
//upMask = uRSHFT(255,(currentOffset+upShift));
upMask = ((currentOffset+upShift) >= 32) ? 0:255>>>(currentOffset+upShift);
downShift = 0;
}
if(DEBUG_LEV > 30) {
System.err.println("count:offset:bitRoom:downShift:upShift:" +
count+":"+currentOffset+":"+bitRoom+":"+downShift+":"+upShift);
}
//int currentBits = uRSHFT(input, downShift) & (upMask);
int currentBits = (downShift >= 32) ? 0:(input>>>downShift)&upMask;
//shift bits back up to match offset
//currentBits = lSHFT(currentBits, upShift);
currentBits = (upShift >= 32) ? 0:currentBits << upShift;
//upMask = lSHFT((byte)upMask, upShift);
upMask = (upShift >= 32) ? 0:((byte)upMask)<<upShift;
dest[currentByte] = (byte)(dest[currentByte] & (~upMask));
//merge bytes~
dest[currentByte] = (byte)(dest[currentByte] | currentBits);
//System.out.println("new currentByte: " + dest[currentByte]);
count -= bitRoom;
currentOffset = 0;
currentByte++;
}
}
if(DEBUG_LEV > 30)
System.err.println("EncodedElement::packInt: End");
}
|
java
|
private static void packInt(int[] inputArray, int bitSize, int startPosIn,
int start, int skip, int countA, byte[] dest) {
if(DEBUG_LEV > 30)
System.err.println("EncodedElement::packInt : Begin");
for(int valI = 0; valI < countA; valI++) {
//int input = inputArray[valI];
int input = inputArray[valI*(skip+1)+start];
int count = bitSize;
int startPos = startPosIn+valI*bitSize;
int currentByte = startPos/8;
int currentOffset = startPos%8;
int bitRoom;//how many bits can be placed in current byte
int upMask;//to clear upper bits(lower bits auto-cleared by L-shift
int downShift;//bits to shift down, isolating top bits of input
int upShift;//bits to shift up, packing byte from top.
while(count > 0) {
//find how many bits can be placed in current byte
bitRoom = 8-currentOffset;
//get those bits
//i.e, take upper 'bitsNeeded' of input, put to lower part of byte.
downShift = count-bitRoom;
//upMask = uRSHFT(255 ,currentOffset);
upMask = (currentOffset >= 32) ? 0: 255>>>currentOffset;
upShift = 0;
if(downShift < 0) {
//upMask = 255 >>> bitRoom-count;
upShift = bitRoom - count;
//upMask = uRSHFT(255,(currentOffset+upShift));
upMask = ((currentOffset+upShift) >= 32) ? 0:255>>>(currentOffset+upShift);
downShift = 0;
}
if(DEBUG_LEV > 30) {
System.err.println("count:offset:bitRoom:downShift:upShift:" +
count+":"+currentOffset+":"+bitRoom+":"+downShift+":"+upShift);
}
//int currentBits = uRSHFT(input, downShift) & (upMask);
int currentBits = (downShift >= 32) ? 0:(input>>>downShift)&upMask;
//shift bits back up to match offset
//currentBits = lSHFT(currentBits, upShift);
currentBits = (upShift >= 32) ? 0:currentBits << upShift;
//upMask = lSHFT((byte)upMask, upShift);
upMask = (upShift >= 32) ? 0:((byte)upMask)<<upShift;
dest[currentByte] = (byte)(dest[currentByte] & (~upMask));
//merge bytes~
dest[currentByte] = (byte)(dest[currentByte] | currentBits);
//System.out.println("new currentByte: " + dest[currentByte]);
count -= bitRoom;
currentOffset = 0;
currentByte++;
}
}
if(DEBUG_LEV > 30)
System.err.println("EncodedElement::packInt: End");
}
|
[
"private",
"static",
"void",
"packInt",
"(",
"int",
"[",
"]",
"inputArray",
",",
"int",
"bitSize",
",",
"int",
"startPosIn",
",",
"int",
"start",
",",
"int",
"skip",
",",
"int",
"countA",
",",
"byte",
"[",
"]",
"dest",
")",
"{",
"if",
"(",
"DEBUG_LEV",
">",
"30",
")",
"System",
".",
"err",
".",
"println",
"(",
"\"EncodedElement::packInt : Begin\"",
")",
";",
"for",
"(",
"int",
"valI",
"=",
"0",
";",
"valI",
"<",
"countA",
";",
"valI",
"++",
")",
"{",
"//int input = inputArray[valI];",
"int",
"input",
"=",
"inputArray",
"[",
"valI",
"*",
"(",
"skip",
"+",
"1",
")",
"+",
"start",
"]",
";",
"int",
"count",
"=",
"bitSize",
";",
"int",
"startPos",
"=",
"startPosIn",
"+",
"valI",
"*",
"bitSize",
";",
"int",
"currentByte",
"=",
"startPos",
"/",
"8",
";",
"int",
"currentOffset",
"=",
"startPos",
"%",
"8",
";",
"int",
"bitRoom",
";",
"//how many bits can be placed in current byte",
"int",
"upMask",
";",
"//to clear upper bits(lower bits auto-cleared by L-shift",
"int",
"downShift",
";",
"//bits to shift down, isolating top bits of input",
"int",
"upShift",
";",
"//bits to shift up, packing byte from top.",
"while",
"(",
"count",
">",
"0",
")",
"{",
"//find how many bits can be placed in current byte",
"bitRoom",
"=",
"8",
"-",
"currentOffset",
";",
"//get those bits",
"//i.e, take upper 'bitsNeeded' of input, put to lower part of byte.",
"downShift",
"=",
"count",
"-",
"bitRoom",
";",
"//upMask = uRSHFT(255 ,currentOffset);",
"upMask",
"=",
"(",
"currentOffset",
">=",
"32",
")",
"?",
"0",
":",
"255",
">>>",
"currentOffset",
";",
"upShift",
"=",
"0",
";",
"if",
"(",
"downShift",
"<",
"0",
")",
"{",
"//upMask = 255 >>> bitRoom-count;",
"upShift",
"=",
"bitRoom",
"-",
"count",
";",
"//upMask = uRSHFT(255,(currentOffset+upShift));",
"upMask",
"=",
"(",
"(",
"currentOffset",
"+",
"upShift",
")",
">=",
"32",
")",
"?",
"0",
":",
"255",
">>>",
"(",
"currentOffset",
"+",
"upShift",
")",
";",
"downShift",
"=",
"0",
";",
"}",
"if",
"(",
"DEBUG_LEV",
">",
"30",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"count:offset:bitRoom:downShift:upShift:\"",
"+",
"count",
"+",
"\":\"",
"+",
"currentOffset",
"+",
"\":\"",
"+",
"bitRoom",
"+",
"\":\"",
"+",
"downShift",
"+",
"\":\"",
"+",
"upShift",
")",
";",
"}",
"//int currentBits = uRSHFT(input, downShift) & (upMask);",
"int",
"currentBits",
"=",
"(",
"downShift",
">=",
"32",
")",
"?",
"0",
":",
"(",
"input",
">>>",
"downShift",
")",
"&",
"upMask",
";",
"//shift bits back up to match offset",
"//currentBits = lSHFT(currentBits, upShift);",
"currentBits",
"=",
"(",
"upShift",
">=",
"32",
")",
"?",
"0",
":",
"currentBits",
"<<",
"upShift",
";",
"//upMask = lSHFT((byte)upMask, upShift);",
"upMask",
"=",
"(",
"upShift",
">=",
"32",
")",
"?",
"0",
":",
"(",
"(",
"byte",
")",
"upMask",
")",
"<<",
"upShift",
";",
"dest",
"[",
"currentByte",
"]",
"=",
"(",
"byte",
")",
"(",
"dest",
"[",
"currentByte",
"]",
"&",
"(",
"~",
"upMask",
")",
")",
";",
"//merge bytes~",
"dest",
"[",
"currentByte",
"]",
"=",
"(",
"byte",
")",
"(",
"dest",
"[",
"currentByte",
"]",
"|",
"currentBits",
")",
";",
"//System.out.println(\"new currentByte: \" + dest[currentByte]);",
"count",
"-=",
"bitRoom",
";",
"currentOffset",
"=",
"0",
";",
"currentByte",
"++",
";",
"}",
"}",
"if",
"(",
"DEBUG_LEV",
">",
"30",
")",
"System",
".",
"err",
".",
"println",
"(",
"\"EncodedElement::packInt: End\"",
")",
";",
"}"
] |
Append an equal number of bits from each int in an array within given
limits to the given byte array.
@param inputArray Array storing input values.
@param bitSize number of bits to store from each value.
@param start index of first usable index.
@param skip number of indices to skip between values(in case input data
is interleaved with non-desirable data).
@param countA Number of total indices to store from.
@param startPosIn First usable index in destination array(byte
index = startPosIn/8, bit within that byte = startPosIn%8)
@param dest Destination array to store input values in. This array *must*
be large enough to store all values or this method will fail in an
undefined manner.
|
[
"Append",
"an",
"equal",
"number",
"of",
"bits",
"from",
"each",
"int",
"in",
"an",
"array",
"within",
"given",
"limits",
"to",
"the",
"given",
"byte",
"array",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java#L689-L744
|
9,971
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java
|
EncodedElement.padToByte
|
public boolean padToByte() {
boolean padded = false;
EncodedElement end = EncodedElement.getEnd_S(this);
int tempVal = end.usableBits;
if(tempVal % 8 != 0) {
int toWrite = 8-(tempVal%8);
end.addInt(0, toWrite);
/* Assert FOR DEVEL ONLY: */
assert((this.getTotalBits()+offset) % 8 == 0);
padded = true;
}
return padded;
}
|
java
|
public boolean padToByte() {
boolean padded = false;
EncodedElement end = EncodedElement.getEnd_S(this);
int tempVal = end.usableBits;
if(tempVal % 8 != 0) {
int toWrite = 8-(tempVal%8);
end.addInt(0, toWrite);
/* Assert FOR DEVEL ONLY: */
assert((this.getTotalBits()+offset) % 8 == 0);
padded = true;
}
return padded;
}
|
[
"public",
"boolean",
"padToByte",
"(",
")",
"{",
"boolean",
"padded",
"=",
"false",
";",
"EncodedElement",
"end",
"=",
"EncodedElement",
".",
"getEnd_S",
"(",
"this",
")",
";",
"int",
"tempVal",
"=",
"end",
".",
"usableBits",
";",
"if",
"(",
"tempVal",
"%",
"8",
"!=",
"0",
")",
"{",
"int",
"toWrite",
"=",
"8",
"-",
"(",
"tempVal",
"%",
"8",
")",
";",
"end",
".",
"addInt",
"(",
"0",
",",
"toWrite",
")",
";",
"/* Assert FOR DEVEL ONLY: */",
"assert",
"(",
"(",
"this",
".",
"getTotalBits",
"(",
")",
"+",
"offset",
")",
"%",
"8",
"==",
"0",
")",
";",
"padded",
"=",
"true",
";",
"}",
"return",
"padded",
";",
"}"
] |
Force the usable data stored in this list ends on a a byte boundary, by
padding to the end with zeros.
@return true if the data was padded, false if it already ended on a byte
boundary.
|
[
"Force",
"the",
"usable",
"data",
"stored",
"in",
"this",
"list",
"ends",
"on",
"a",
"a",
"byte",
"boundary",
"by",
"padding",
"to",
"the",
"end",
"with",
"zeros",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java#L753-L766
|
9,972
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/AudioStreamEncoder.java
|
AudioStreamEncoder.getDataFormatSupport
|
public static int getDataFormatSupport(AudioFormat format) {
int result = SUPPORTED;
float sampleRate = format.getSampleRate();
AudioFormat.Encoding encoding = format.getEncoding();
if(format.getChannels() > 8 || format.getChannels() < 1)
result |= UNSUPPORTED_CHANNELCOUNT;
if(format.getSampleSizeInBits() > 24 || format.getSampleSizeInBits()%8 != 0)
result |= UNSUPPORTED_SAMPLESIZE;
if(sampleRate <= 0 || sampleRate > 655350 || sampleRate == AudioSystem.NOT_SPECIFIED)
result |= UNSUPPORTED_SAMPLERATE;
if ( !(AudioFormat.Encoding.ALAW.equals(encoding) ||
AudioFormat.Encoding.ULAW.equals(encoding) ||
AudioFormat.Encoding.PCM_SIGNED.equals(encoding) ||
AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding) ) )
result |= UNSUPPORTED_ENCODINGTYPE;
return result;
}
|
java
|
public static int getDataFormatSupport(AudioFormat format) {
int result = SUPPORTED;
float sampleRate = format.getSampleRate();
AudioFormat.Encoding encoding = format.getEncoding();
if(format.getChannels() > 8 || format.getChannels() < 1)
result |= UNSUPPORTED_CHANNELCOUNT;
if(format.getSampleSizeInBits() > 24 || format.getSampleSizeInBits()%8 != 0)
result |= UNSUPPORTED_SAMPLESIZE;
if(sampleRate <= 0 || sampleRate > 655350 || sampleRate == AudioSystem.NOT_SPECIFIED)
result |= UNSUPPORTED_SAMPLERATE;
if ( !(AudioFormat.Encoding.ALAW.equals(encoding) ||
AudioFormat.Encoding.ULAW.equals(encoding) ||
AudioFormat.Encoding.PCM_SIGNED.equals(encoding) ||
AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding) ) )
result |= UNSUPPORTED_ENCODINGTYPE;
return result;
}
|
[
"public",
"static",
"int",
"getDataFormatSupport",
"(",
"AudioFormat",
"format",
")",
"{",
"int",
"result",
"=",
"SUPPORTED",
";",
"float",
"sampleRate",
"=",
"format",
".",
"getSampleRate",
"(",
")",
";",
"AudioFormat",
".",
"Encoding",
"encoding",
"=",
"format",
".",
"getEncoding",
"(",
")",
";",
"if",
"(",
"format",
".",
"getChannels",
"(",
")",
">",
"8",
"||",
"format",
".",
"getChannels",
"(",
")",
"<",
"1",
")",
"result",
"|=",
"UNSUPPORTED_CHANNELCOUNT",
";",
"if",
"(",
"format",
".",
"getSampleSizeInBits",
"(",
")",
">",
"24",
"||",
"format",
".",
"getSampleSizeInBits",
"(",
")",
"%",
"8",
"!=",
"0",
")",
"result",
"|=",
"UNSUPPORTED_SAMPLESIZE",
";",
"if",
"(",
"sampleRate",
"<=",
"0",
"||",
"sampleRate",
">",
"655350",
"||",
"sampleRate",
"==",
"AudioSystem",
".",
"NOT_SPECIFIED",
")",
"result",
"|=",
"UNSUPPORTED_SAMPLERATE",
";",
"if",
"(",
"!",
"(",
"AudioFormat",
".",
"Encoding",
".",
"ALAW",
".",
"equals",
"(",
"encoding",
")",
"||",
"AudioFormat",
".",
"Encoding",
".",
"ULAW",
".",
"equals",
"(",
"encoding",
")",
"||",
"AudioFormat",
".",
"Encoding",
".",
"PCM_SIGNED",
".",
"equals",
"(",
"encoding",
")",
"||",
"AudioFormat",
".",
"Encoding",
".",
"PCM_UNSIGNED",
".",
"equals",
"(",
"encoding",
")",
")",
")",
"result",
"|=",
"UNSUPPORTED_ENCODINGTYPE",
";",
"return",
"result",
";",
"}"
] |
Checks whether the given AudioFormat can be properly encoded by this
FLAC library.
@param format AudioFormat to test for support.
@return Bit positions set according to issue:
Bit Position : Problem-area
0 : Channel count unsupported
1 : Sample size unsupported
2 : Sample Rate unsupported
3 : Encoding Type Unsupported
4-7: unused, always zero.
return value of 0 means supported
|
[
"Checks",
"whether",
"the",
"given",
"AudioFormat",
"can",
"be",
"properly",
"encoded",
"by",
"this",
"FLAC",
"library",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/AudioStreamEncoder.java#L144-L160
|
9,973
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/FrameHeader.java
|
FrameHeader.encodeBlockSize
|
private static byte encodeBlockSize(int blockSize) {
if(DEBUG_LEV > 0 )
System.err.println("FrameHeader::encodeBlockSize : Begin");
byte value = 0;
int i;
for(i = 0; i < definedBlockSizes.length; i++) {
if(blockSize == definedBlockSizes[i]) {
value = (byte)i;
break;
}
}
if(i >= definedBlockSizes.length) {
if(blockSize <= 255)
value = 0x6;
else
value = 0x7;
}
if(DEBUG_LEV > 0 )
System.err.println("FrameHeader::encodeBlockSize : End");
return value;
}
|
java
|
private static byte encodeBlockSize(int blockSize) {
if(DEBUG_LEV > 0 )
System.err.println("FrameHeader::encodeBlockSize : Begin");
byte value = 0;
int i;
for(i = 0; i < definedBlockSizes.length; i++) {
if(blockSize == definedBlockSizes[i]) {
value = (byte)i;
break;
}
}
if(i >= definedBlockSizes.length) {
if(blockSize <= 255)
value = 0x6;
else
value = 0x7;
}
if(DEBUG_LEV > 0 )
System.err.println("FrameHeader::encodeBlockSize : End");
return value;
}
|
[
"private",
"static",
"byte",
"encodeBlockSize",
"(",
"int",
"blockSize",
")",
"{",
"if",
"(",
"DEBUG_LEV",
">",
"0",
")",
"System",
".",
"err",
".",
"println",
"(",
"\"FrameHeader::encodeBlockSize : Begin\"",
")",
";",
"byte",
"value",
"=",
"0",
";",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"definedBlockSizes",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"blockSize",
"==",
"definedBlockSizes",
"[",
"i",
"]",
")",
"{",
"value",
"=",
"(",
"byte",
")",
"i",
";",
"break",
";",
"}",
"}",
"if",
"(",
"i",
">=",
"definedBlockSizes",
".",
"length",
")",
"{",
"if",
"(",
"blockSize",
"<=",
"255",
")",
"value",
"=",
"0x6",
";",
"else",
"value",
"=",
"0x7",
";",
"}",
"if",
"(",
"DEBUG_LEV",
">",
"0",
")",
"System",
".",
"err",
".",
"println",
"(",
"\"FrameHeader::encodeBlockSize : End\"",
")",
";",
"return",
"value",
";",
"}"
] |
Given a block size, select the proper bit settings to use according to
the FLAC stream.
@param blockSize
@return
|
[
"Given",
"a",
"block",
"size",
"select",
"the",
"proper",
"bit",
"settings",
"to",
"use",
"according",
"to",
"the",
"FLAC",
"stream",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/FrameHeader.java#L223-L245
|
9,974
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/BlockThreadManager.java
|
BlockThreadManager.blockWhileQueueExceeds
|
public void blockWhileQueueExceeds(int count) {
boolean loop = true;
boolean interrupted = false;
try {
do {
synchronized(outstandingCountLock) {
if(outstandingCount > count) {
try {
outstandingCountLock.wait();
}catch(InterruptedException e) {
//ignore interruption, loop again.
interrupted = true;
}
}
else
loop = false;
}
}while(loop);
}finally {
if(interrupted)
Thread.currentThread().interrupt();
}
}
|
java
|
public void blockWhileQueueExceeds(int count) {
boolean loop = true;
boolean interrupted = false;
try {
do {
synchronized(outstandingCountLock) {
if(outstandingCount > count) {
try {
outstandingCountLock.wait();
}catch(InterruptedException e) {
//ignore interruption, loop again.
interrupted = true;
}
}
else
loop = false;
}
}while(loop);
}finally {
if(interrupted)
Thread.currentThread().interrupt();
}
}
|
[
"public",
"void",
"blockWhileQueueExceeds",
"(",
"int",
"count",
")",
"{",
"boolean",
"loop",
"=",
"true",
";",
"boolean",
"interrupted",
"=",
"false",
";",
"try",
"{",
"do",
"{",
"synchronized",
"(",
"outstandingCountLock",
")",
"{",
"if",
"(",
"outstandingCount",
">",
"count",
")",
"{",
"try",
"{",
"outstandingCountLock",
".",
"wait",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"//ignore interruption, loop again.",
"interrupted",
"=",
"true",
";",
"}",
"}",
"else",
"loop",
"=",
"false",
";",
"}",
"}",
"while",
"(",
"loop",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"interrupted",
")",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"}"
] |
This function is used to help control flow of BlockEncodeRequests into
this manager. It will block so long as their is at least as many
unprocessed blocks waiting to be encoded as the value given.
@param count Maximum number of outstanding requests that may exist before
this method may return.
|
[
"This",
"function",
"is",
"used",
"to",
"help",
"control",
"flow",
"of",
"BlockEncodeRequests",
"into",
"this",
"manager",
".",
"It",
"will",
"block",
"so",
"long",
"as",
"their",
"is",
"at",
"least",
"as",
"many",
"unprocessed",
"blocks",
"waiting",
"to",
"be",
"encoded",
"as",
"the",
"value",
"given",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/BlockThreadManager.java#L135-L157
|
9,975
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/BlockThreadManager.java
|
BlockThreadManager.addFrameThread
|
synchronized public boolean addFrameThread(Frame frame) {
FrameThread ft = new FrameThread(frame, this);
inactiveFrameThreads.add(ft);
boolean r = true;
startFrameThreads();
return r;
}
|
java
|
synchronized public boolean addFrameThread(Frame frame) {
FrameThread ft = new FrameThread(frame, this);
inactiveFrameThreads.add(ft);
boolean r = true;
startFrameThreads();
return r;
}
|
[
"synchronized",
"public",
"boolean",
"addFrameThread",
"(",
"Frame",
"frame",
")",
"{",
"FrameThread",
"ft",
"=",
"new",
"FrameThread",
"(",
"frame",
",",
"this",
")",
";",
"inactiveFrameThreads",
".",
"add",
"(",
"ft",
")",
";",
"boolean",
"r",
"=",
"true",
";",
"startFrameThreads",
"(",
")",
";",
"return",
"r",
";",
"}"
] |
Add a Frame to this manager, which it will use to encode a block. Each
Frame added allows one more thread to be used for encoding. At least one
Frame must be added for this manager to encode.
@param frame Frame to use for encoding.
@return boolean false if there was an error adding the frame, true
otherwise.
|
[
"Add",
"a",
"Frame",
"to",
"this",
"manager",
"which",
"it",
"will",
"use",
"to",
"encode",
"a",
"block",
".",
"Each",
"Frame",
"added",
"allows",
"one",
"more",
"thread",
"to",
"be",
"used",
"for",
"encoding",
".",
"At",
"least",
"one",
"Frame",
"must",
"be",
"added",
"for",
"this",
"manager",
"to",
"encode",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/BlockThreadManager.java#L167-L173
|
9,976
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/BlockThreadManager.java
|
BlockThreadManager.startFrameThreads
|
synchronized private void startFrameThreads() {
if(!process)
return;
int requests = unassignedEncodeRequests.size();
int frames = inactiveFrameThreads.size();
frames = (requests <= frames) ? requests:frames;
for(int i = 0; i < frames; i++) {
FrameThread ft = inactiveFrameThreads.remove(0);
Thread thread = new Thread(ft);
frameThreadMap.put(ft, thread);
thread.start();
}
}
|
java
|
synchronized private void startFrameThreads() {
if(!process)
return;
int requests = unassignedEncodeRequests.size();
int frames = inactiveFrameThreads.size();
frames = (requests <= frames) ? requests:frames;
for(int i = 0; i < frames; i++) {
FrameThread ft = inactiveFrameThreads.remove(0);
Thread thread = new Thread(ft);
frameThreadMap.put(ft, thread);
thread.start();
}
}
|
[
"synchronized",
"private",
"void",
"startFrameThreads",
"(",
")",
"{",
"if",
"(",
"!",
"process",
")",
"return",
";",
"int",
"requests",
"=",
"unassignedEncodeRequests",
".",
"size",
"(",
")",
";",
"int",
"frames",
"=",
"inactiveFrameThreads",
".",
"size",
"(",
")",
";",
"frames",
"=",
"(",
"requests",
"<=",
"frames",
")",
"?",
"requests",
":",
"frames",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"frames",
";",
"i",
"++",
")",
"{",
"FrameThread",
"ft",
"=",
"inactiveFrameThreads",
".",
"remove",
"(",
"0",
")",
";",
"Thread",
"thread",
"=",
"new",
"Thread",
"(",
"ft",
")",
";",
"frameThreadMap",
".",
"put",
"(",
"ft",
",",
"thread",
")",
";",
"thread",
".",
"start",
"(",
")",
";",
"}",
"}"
] |
Start any available FrameThread objects encoding, so long as there are
waiting BlockEncodeRequest objects.
|
[
"Start",
"any",
"available",
"FrameThread",
"objects",
"encoding",
"so",
"long",
"as",
"there",
"are",
"waiting",
"BlockEncodeRequest",
"objects",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/BlockThreadManager.java#L180-L192
|
9,977
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/BlockThreadManager.java
|
BlockThreadManager.run
|
public void run () {
//wait for finished item
//send finished item to encoder
//loop to top
boolean loop = true;
boolean interrupted = false;
try {
while(loop) {
try {
if(nextTarget == null)
nextTarget = orderedEncodeRequests.poll(500,TimeUnit.MILLISECONDS);
if(nextTarget == null) {
loop = false;
}
else if(nextTarget.frameNumber < 0) {
loop = false;
nextTarget = null;
orderedEncodeRequests.clear();
}
else if(finishedRequestStore.remove(nextTarget)) {
encoder.blockFinished(nextTarget);
nextTarget = null;
synchronized(outstandingCountLock) {
outstandingCount--;
outstandingCountLock.notifyAll();
}
}
else {
BlockEncodeRequest ber = finishedEncodeRequests.poll(500, TimeUnit.MILLISECONDS);
if(ber == null) {//nothing to process yet, let this thread end.
loop = false;
}
else if(nextTarget == ber) {
encoder.blockFinished(ber);
nextTarget = null;
synchronized(outstandingCountLock) {
outstandingCount--;
outstandingCountLock.notifyAll();
}
}
else {
finishedRequestStore.add(ber);
}
}
}catch(InterruptedException e) {
interrupted = true;
}
}
}finally {
if(interrupted)
Thread.currentThread().interrupt();
}
synchronized(this) {
managerThread = null;
restartManager();
}
}
|
java
|
public void run () {
//wait for finished item
//send finished item to encoder
//loop to top
boolean loop = true;
boolean interrupted = false;
try {
while(loop) {
try {
if(nextTarget == null)
nextTarget = orderedEncodeRequests.poll(500,TimeUnit.MILLISECONDS);
if(nextTarget == null) {
loop = false;
}
else if(nextTarget.frameNumber < 0) {
loop = false;
nextTarget = null;
orderedEncodeRequests.clear();
}
else if(finishedRequestStore.remove(nextTarget)) {
encoder.blockFinished(nextTarget);
nextTarget = null;
synchronized(outstandingCountLock) {
outstandingCount--;
outstandingCountLock.notifyAll();
}
}
else {
BlockEncodeRequest ber = finishedEncodeRequests.poll(500, TimeUnit.MILLISECONDS);
if(ber == null) {//nothing to process yet, let this thread end.
loop = false;
}
else if(nextTarget == ber) {
encoder.blockFinished(ber);
nextTarget = null;
synchronized(outstandingCountLock) {
outstandingCount--;
outstandingCountLock.notifyAll();
}
}
else {
finishedRequestStore.add(ber);
}
}
}catch(InterruptedException e) {
interrupted = true;
}
}
}finally {
if(interrupted)
Thread.currentThread().interrupt();
}
synchronized(this) {
managerThread = null;
restartManager();
}
}
|
[
"public",
"void",
"run",
"(",
")",
"{",
"//wait for finished item",
"//send finished item to encoder",
"//loop to top",
"boolean",
"loop",
"=",
"true",
";",
"boolean",
"interrupted",
"=",
"false",
";",
"try",
"{",
"while",
"(",
"loop",
")",
"{",
"try",
"{",
"if",
"(",
"nextTarget",
"==",
"null",
")",
"nextTarget",
"=",
"orderedEncodeRequests",
".",
"poll",
"(",
"500",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"if",
"(",
"nextTarget",
"==",
"null",
")",
"{",
"loop",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"nextTarget",
".",
"frameNumber",
"<",
"0",
")",
"{",
"loop",
"=",
"false",
";",
"nextTarget",
"=",
"null",
";",
"orderedEncodeRequests",
".",
"clear",
"(",
")",
";",
"}",
"else",
"if",
"(",
"finishedRequestStore",
".",
"remove",
"(",
"nextTarget",
")",
")",
"{",
"encoder",
".",
"blockFinished",
"(",
"nextTarget",
")",
";",
"nextTarget",
"=",
"null",
";",
"synchronized",
"(",
"outstandingCountLock",
")",
"{",
"outstandingCount",
"--",
";",
"outstandingCountLock",
".",
"notifyAll",
"(",
")",
";",
"}",
"}",
"else",
"{",
"BlockEncodeRequest",
"ber",
"=",
"finishedEncodeRequests",
".",
"poll",
"(",
"500",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"if",
"(",
"ber",
"==",
"null",
")",
"{",
"//nothing to process yet, let this thread end.",
"loop",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"nextTarget",
"==",
"ber",
")",
"{",
"encoder",
".",
"blockFinished",
"(",
"ber",
")",
";",
"nextTarget",
"=",
"null",
";",
"synchronized",
"(",
"outstandingCountLock",
")",
"{",
"outstandingCount",
"--",
";",
"outstandingCountLock",
".",
"notifyAll",
"(",
")",
";",
"}",
"}",
"else",
"{",
"finishedRequestStore",
".",
"add",
"(",
"ber",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"interrupted",
"=",
"true",
";",
"}",
"}",
"}",
"finally",
"{",
"if",
"(",
"interrupted",
")",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"synchronized",
"(",
"this",
")",
"{",
"managerThread",
"=",
"null",
";",
"restartManager",
"(",
")",
";",
"}",
"}"
] |
Waits for the next BlockEncodeRequest that needs to be sent back to the
FLACEncoder for finalizing. If no request is finished, or currently
assigned to an encoding thread, will timeout after 0.5 seconds and end.
|
[
"Waits",
"for",
"the",
"next",
"BlockEncodeRequest",
"that",
"needs",
"to",
"be",
"sent",
"back",
"to",
"the",
"FLACEncoder",
"for",
"finalizing",
".",
"If",
"no",
"request",
"is",
"finished",
"or",
"currently",
"assigned",
"to",
"an",
"encoding",
"thread",
"will",
"timeout",
"after",
"0",
".",
"5",
"seconds",
"and",
"end",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/BlockThreadManager.java#L276-L332
|
9,978
|
chocoteam/choco-graph
|
src/main/java/org/chocosolver/graphsolver/util/LCAGraphManager.java
|
LCAGraphManager.proceedFirstDFS
|
private void proceedFirstDFS() {
for (int i = 0; i < nbNodes; i++) {
iterator[i] = successors[i].iterator();
}
int i = root;
int k = 0;
father[k] = k;
dfsNumberOfNode[root] = k;
nodeOfDfsNumber[k] = root;
int j;
k++;
while (true) {
if (iterator[i].hasNext()) {
j = iterator[i].next();
if (dfsNumberOfNode[j] == -1) {
father[k] = dfsNumberOfNode[i];
dfsNumberOfNode[j] = k;
nodeOfDfsNumber[k] = j;
i = j;
k++;
}
} else {
if (i == root) {
break;
} else {
i = nodeOfDfsNumber[father[dfsNumberOfNode[i]]];
}
}
}
if (k != nbActives) {
throw new UnsupportedOperationException("LCApreprocess did not reach all nodes");
}
for (; k < nbNodes; k++) {
father[k] = -1;
}
}
|
java
|
private void proceedFirstDFS() {
for (int i = 0; i < nbNodes; i++) {
iterator[i] = successors[i].iterator();
}
int i = root;
int k = 0;
father[k] = k;
dfsNumberOfNode[root] = k;
nodeOfDfsNumber[k] = root;
int j;
k++;
while (true) {
if (iterator[i].hasNext()) {
j = iterator[i].next();
if (dfsNumberOfNode[j] == -1) {
father[k] = dfsNumberOfNode[i];
dfsNumberOfNode[j] = k;
nodeOfDfsNumber[k] = j;
i = j;
k++;
}
} else {
if (i == root) {
break;
} else {
i = nodeOfDfsNumber[father[dfsNumberOfNode[i]]];
}
}
}
if (k != nbActives) {
throw new UnsupportedOperationException("LCApreprocess did not reach all nodes");
}
for (; k < nbNodes; k++) {
father[k] = -1;
}
}
|
[
"private",
"void",
"proceedFirstDFS",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nbNodes",
";",
"i",
"++",
")",
"{",
"iterator",
"[",
"i",
"]",
"=",
"successors",
"[",
"i",
"]",
".",
"iterator",
"(",
")",
";",
"}",
"int",
"i",
"=",
"root",
";",
"int",
"k",
"=",
"0",
";",
"father",
"[",
"k",
"]",
"=",
"k",
";",
"dfsNumberOfNode",
"[",
"root",
"]",
"=",
"k",
";",
"nodeOfDfsNumber",
"[",
"k",
"]",
"=",
"root",
";",
"int",
"j",
";",
"k",
"++",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"iterator",
"[",
"i",
"]",
".",
"hasNext",
"(",
")",
")",
"{",
"j",
"=",
"iterator",
"[",
"i",
"]",
".",
"next",
"(",
")",
";",
"if",
"(",
"dfsNumberOfNode",
"[",
"j",
"]",
"==",
"-",
"1",
")",
"{",
"father",
"[",
"k",
"]",
"=",
"dfsNumberOfNode",
"[",
"i",
"]",
";",
"dfsNumberOfNode",
"[",
"j",
"]",
"=",
"k",
";",
"nodeOfDfsNumber",
"[",
"k",
"]",
"=",
"j",
";",
"i",
"=",
"j",
";",
"k",
"++",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"i",
"==",
"root",
")",
"{",
"break",
";",
"}",
"else",
"{",
"i",
"=",
"nodeOfDfsNumber",
"[",
"father",
"[",
"dfsNumberOfNode",
"[",
"i",
"]",
"]",
"]",
";",
"}",
"}",
"}",
"if",
"(",
"k",
"!=",
"nbActives",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"LCApreprocess did not reach all nodes\"",
")",
";",
"}",
"for",
"(",
";",
"k",
"<",
"nbNodes",
";",
"k",
"++",
")",
"{",
"father",
"[",
"k",
"]",
"=",
"-",
"1",
";",
"}",
"}"
] |
perform a dfs in graph to label nodes
|
[
"perform",
"a",
"dfs",
"in",
"graph",
"to",
"label",
"nodes"
] |
0a03b0aafc86601977728c7e3fcb5ed376f1fae9
|
https://github.com/chocoteam/choco-graph/blob/0a03b0aafc86601977728c7e3fcb5ed376f1fae9/src/main/java/org/chocosolver/graphsolver/util/LCAGraphManager.java#L113-L148
|
9,979
|
chocoteam/choco-graph
|
src/main/java/org/chocosolver/graphsolver/search/strategy/GraphSearch.java
|
GraphSearch.configure
|
public GraphSearch configure(int policy, boolean enforce) {
if (enforce) {
decisionType = GraphAssignment.graph_enforcer;
} else {
decisionType = GraphAssignment.graph_remover;
}
mode = policy;
return this;
}
|
java
|
public GraphSearch configure(int policy, boolean enforce) {
if (enforce) {
decisionType = GraphAssignment.graph_enforcer;
} else {
decisionType = GraphAssignment.graph_remover;
}
mode = policy;
return this;
}
|
[
"public",
"GraphSearch",
"configure",
"(",
"int",
"policy",
",",
"boolean",
"enforce",
")",
"{",
"if",
"(",
"enforce",
")",
"{",
"decisionType",
"=",
"GraphAssignment",
".",
"graph_enforcer",
";",
"}",
"else",
"{",
"decisionType",
"=",
"GraphAssignment",
".",
"graph_remover",
";",
"}",
"mode",
"=",
"policy",
";",
"return",
"this",
";",
"}"
] |
Configures the search
@param policy way to select arcs
@param enforce true if a decision is an arc enforcing
false if a decision is an arc removal
|
[
"Configures",
"the",
"search"
] |
0a03b0aafc86601977728c7e3fcb5ed376f1fae9
|
https://github.com/chocoteam/choco-graph/blob/0a03b0aafc86601977728c7e3fcb5ed376f1fae9/src/main/java/org/chocosolver/graphsolver/search/strategy/GraphSearch.java#L107-L115
|
9,980
|
mojohaus/clirr-maven-plugin
|
src/main/java/org/codehaus/mojo/clirr/ClirrReport.java
|
ClirrReport.generate
|
public void generate( org.codehaus.doxia.sink.Sink sink, Locale locale )
throws MavenReportException
{
generate( (Sink) sink, locale );
}
|
java
|
public void generate( org.codehaus.doxia.sink.Sink sink, Locale locale )
throws MavenReportException
{
generate( (Sink) sink, locale );
}
|
[
"public",
"void",
"generate",
"(",
"org",
".",
"codehaus",
".",
"doxia",
".",
"sink",
".",
"Sink",
"sink",
",",
"Locale",
"locale",
")",
"throws",
"MavenReportException",
"{",
"generate",
"(",
"(",
"Sink",
")",
"sink",
",",
"locale",
")",
";",
"}"
] |
eventually, we must replace this with the o.a.m.d.s.Sink class as a parameter
|
[
"eventually",
"we",
"must",
"replace",
"this",
"with",
"the",
"o",
".",
"a",
".",
"m",
".",
"d",
".",
"s",
".",
"Sink",
"class",
"as",
"a",
"parameter"
] |
4348dc31ee003097fa352b1cc3a607dda502bb4c
|
https://github.com/mojohaus/clirr-maven-plugin/blob/4348dc31ee003097fa352b1cc3a607dda502bb4c/src/main/java/org/codehaus/mojo/clirr/ClirrReport.java#L370-L375
|
9,981
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/StreamConfiguration.java
|
StreamConfiguration.setSampleRate
|
public boolean setSampleRate(int rate) {
boolean result = (rate <= MAX_SAMPLE_RATE && rate >= MIN_SAMPLE_RATE);
sampleRate = rate;
return result;
}
|
java
|
public boolean setSampleRate(int rate) {
boolean result = (rate <= MAX_SAMPLE_RATE && rate >= MIN_SAMPLE_RATE);
sampleRate = rate;
return result;
}
|
[
"public",
"boolean",
"setSampleRate",
"(",
"int",
"rate",
")",
"{",
"boolean",
"result",
"=",
"(",
"rate",
"<=",
"MAX_SAMPLE_RATE",
"&&",
"rate",
">=",
"MIN_SAMPLE_RATE",
")",
";",
"sampleRate",
"=",
"rate",
";",
"return",
"result",
";",
"}"
] |
Set the sample rate. Because this is not a value that may be
guessed and corrected, the value will be set to that given even if it is
not valid.
@param rate sample rate(in Hz)
@return true if given rate was within the valid range, false otherwise.
|
[
"Set",
"the",
"sample",
"rate",
".",
"Because",
"this",
"is",
"not",
"a",
"value",
"that",
"may",
"be",
"guessed",
"and",
"corrected",
"the",
"value",
"will",
"be",
"set",
"to",
"that",
"given",
"even",
"if",
"it",
"is",
"not",
"valid",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/StreamConfiguration.java#L189-L193
|
9,982
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/StreamConfiguration.java
|
StreamConfiguration.setBitsPerSample
|
public boolean setBitsPerSample(int bitsPerSample) {
boolean result = ((bitsPerSample <= MAX_BITS_PER_SAMPLE) &&
(bitsPerSample >= MIN_BITS_PER_SAMPLE) );
this.bitsPerSample = bitsPerSample;
return result;
}
|
java
|
public boolean setBitsPerSample(int bitsPerSample) {
boolean result = ((bitsPerSample <= MAX_BITS_PER_SAMPLE) &&
(bitsPerSample >= MIN_BITS_PER_SAMPLE) );
this.bitsPerSample = bitsPerSample;
return result;
}
|
[
"public",
"boolean",
"setBitsPerSample",
"(",
"int",
"bitsPerSample",
")",
"{",
"boolean",
"result",
"=",
"(",
"(",
"bitsPerSample",
"<=",
"MAX_BITS_PER_SAMPLE",
")",
"&&",
"(",
"bitsPerSample",
">=",
"MIN_BITS_PER_SAMPLE",
")",
")",
";",
"this",
".",
"bitsPerSample",
"=",
"bitsPerSample",
";",
"return",
"result",
";",
"}"
] |
Set the bits per sample. Because this is not a value that may be
guessed and corrected, the value will be set to that given even if it is
not valid.
@param bitsPerSample number of bits per sample
@return true if value given is within the valid range, false otherwise.
|
[
"Set",
"the",
"bits",
"per",
"sample",
".",
"Because",
"this",
"is",
"not",
"a",
"value",
"that",
"may",
"be",
"guessed",
"and",
"corrected",
"the",
"value",
"will",
"be",
"set",
"to",
"that",
"given",
"even",
"if",
"it",
"is",
"not",
"valid",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/StreamConfiguration.java#L210-L215
|
9,983
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/StreamConfiguration.java
|
StreamConfiguration.setMaxBlockSize
|
public int setMaxBlockSize(int size) {
maxBlockSize = (size <= MAX_BLOCK_SIZE) ? size:MAX_BLOCK_SIZE;
maxBlockSize = (maxBlockSize >= MIN_BLOCK_SIZE) ? maxBlockSize:MIN_BLOCK_SIZE;
return maxBlockSize;
}
|
java
|
public int setMaxBlockSize(int size) {
maxBlockSize = (size <= MAX_BLOCK_SIZE) ? size:MAX_BLOCK_SIZE;
maxBlockSize = (maxBlockSize >= MIN_BLOCK_SIZE) ? maxBlockSize:MIN_BLOCK_SIZE;
return maxBlockSize;
}
|
[
"public",
"int",
"setMaxBlockSize",
"(",
"int",
"size",
")",
"{",
"maxBlockSize",
"=",
"(",
"size",
"<=",
"MAX_BLOCK_SIZE",
")",
"?",
"size",
":",
"MAX_BLOCK_SIZE",
";",
"maxBlockSize",
"=",
"(",
"maxBlockSize",
">=",
"MIN_BLOCK_SIZE",
")",
"?",
"maxBlockSize",
":",
"MIN_BLOCK_SIZE",
";",
"return",
"maxBlockSize",
";",
"}"
] |
Set the maximum block size to use. If this value is out of a valid range,
it will be set to the closest valid value. User must ensure that this
value is set above or equal to the minimum block size.
@param size maximum block size to use.
@return actual size set
|
[
"Set",
"the",
"maximum",
"block",
"size",
"to",
"use",
".",
"If",
"this",
"value",
"is",
"out",
"of",
"a",
"valid",
"range",
"it",
"will",
"be",
"set",
"to",
"the",
"closest",
"valid",
"value",
".",
"User",
"must",
"ensure",
"that",
"this",
"value",
"is",
"set",
"above",
"or",
"equal",
"to",
"the",
"minimum",
"block",
"size",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/StreamConfiguration.java#L224-L228
|
9,984
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/StreamConfiguration.java
|
StreamConfiguration.setMinBlockSize
|
public int setMinBlockSize(int size) {
minBlockSize = (size <= MAX_BLOCK_SIZE) ? size:MAX_BLOCK_SIZE;
minBlockSize = (minBlockSize >= MIN_BLOCK_SIZE) ? maxBlockSize:MIN_BLOCK_SIZE;
return minBlockSize;
}
|
java
|
public int setMinBlockSize(int size) {
minBlockSize = (size <= MAX_BLOCK_SIZE) ? size:MAX_BLOCK_SIZE;
minBlockSize = (minBlockSize >= MIN_BLOCK_SIZE) ? maxBlockSize:MIN_BLOCK_SIZE;
return minBlockSize;
}
|
[
"public",
"int",
"setMinBlockSize",
"(",
"int",
"size",
")",
"{",
"minBlockSize",
"=",
"(",
"size",
"<=",
"MAX_BLOCK_SIZE",
")",
"?",
"size",
":",
"MAX_BLOCK_SIZE",
";",
"minBlockSize",
"=",
"(",
"minBlockSize",
">=",
"MIN_BLOCK_SIZE",
")",
"?",
"maxBlockSize",
":",
"MIN_BLOCK_SIZE",
";",
"return",
"minBlockSize",
";",
"}"
] |
Set the minimum block size to use. If this value is out of a valid range,
it will be set to the closest valid value. User must ensure that this
value is set below or equal to the maximum block size.
@param size minimum block size to use.
@return actual size set
|
[
"Set",
"the",
"minimum",
"block",
"size",
"to",
"use",
".",
"If",
"this",
"value",
"is",
"out",
"of",
"a",
"valid",
"range",
"it",
"will",
"be",
"set",
"to",
"the",
"closest",
"valid",
"value",
".",
"User",
"must",
"ensure",
"that",
"this",
"value",
"is",
"set",
"below",
"or",
"equal",
"to",
"the",
"maximum",
"block",
"size",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/StreamConfiguration.java#L237-L241
|
9,985
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/StreamConfiguration.java
|
StreamConfiguration.isEncodingSubsetCompliant
|
public boolean isEncodingSubsetCompliant(EncodingConfiguration ec) {
boolean result = true;
result = isStreamSubsetCompliant();
if(this.sampleRate <= 48000) {
result &= ec.maximumLPCOrder <= 12;
result &= ec.maximumRicePartitionOrder <= 8;
}
return result;
}
|
java
|
public boolean isEncodingSubsetCompliant(EncodingConfiguration ec) {
boolean result = true;
result = isStreamSubsetCompliant();
if(this.sampleRate <= 48000) {
result &= ec.maximumLPCOrder <= 12;
result &= ec.maximumRicePartitionOrder <= 8;
}
return result;
}
|
[
"public",
"boolean",
"isEncodingSubsetCompliant",
"(",
"EncodingConfiguration",
"ec",
")",
"{",
"boolean",
"result",
"=",
"true",
";",
"result",
"=",
"isStreamSubsetCompliant",
"(",
")",
";",
"if",
"(",
"this",
".",
"sampleRate",
"<=",
"48000",
")",
"{",
"result",
"&=",
"ec",
".",
"maximumLPCOrder",
"<=",
"12",
";",
"result",
"&=",
"ec",
".",
"maximumRicePartitionOrder",
"<=",
"8",
";",
"}",
"return",
"result",
";",
"}"
] |
Test if this StreamConfiguration and a paired EncodingConfiguration define
a Subset compliant stream. FLAC defines a subset of options to
ensure resulting FLAC streams are streamable.
@param ec EncodingConfiguration object to check against
@return true if these configurations are Subset compliant, false otherwise.
|
[
"Test",
"if",
"this",
"StreamConfiguration",
"and",
"a",
"paired",
"EncodingConfiguration",
"define",
"a",
"Subset",
"compliant",
"stream",
".",
"FLAC",
"defines",
"a",
"subset",
"of",
"options",
"to",
"ensure",
"resulting",
"FLAC",
"streams",
"are",
"streamable",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/StreamConfiguration.java#L277-L285
|
9,986
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/MetadataBlockStreamInfo.java
|
MetadataBlockStreamInfo.getStreamInfo
|
public static EncodedElement getStreamInfo(StreamConfiguration sc,
int minFrameSize, int maxFrameSize, long samplesInStream, byte[] md5Hash) {
int bytes = getByteSize();
EncodedElement ele = new EncodedElement(bytes, 0);
int encodedBitsPerSample = sc.getBitsPerSample()-1;
ele.addInt(sc.getMinBlockSize(), 16);
ele.addInt(sc.getMaxBlockSize(), 16);
ele.addInt(minFrameSize, 24);
ele.addInt(maxFrameSize, 24);
ele.addInt(sc.getSampleRate(), 20);
ele.addInt(sc.getChannelCount()-1, 3);
ele.addInt(encodedBitsPerSample, 5);
ele.addLong(samplesInStream, 36);
for(int i = 0; i < 16; i++) {
ele.addInt(md5Hash[i], 8);
}
return ele;
}
|
java
|
public static EncodedElement getStreamInfo(StreamConfiguration sc,
int minFrameSize, int maxFrameSize, long samplesInStream, byte[] md5Hash) {
int bytes = getByteSize();
EncodedElement ele = new EncodedElement(bytes, 0);
int encodedBitsPerSample = sc.getBitsPerSample()-1;
ele.addInt(sc.getMinBlockSize(), 16);
ele.addInt(sc.getMaxBlockSize(), 16);
ele.addInt(minFrameSize, 24);
ele.addInt(maxFrameSize, 24);
ele.addInt(sc.getSampleRate(), 20);
ele.addInt(sc.getChannelCount()-1, 3);
ele.addInt(encodedBitsPerSample, 5);
ele.addLong(samplesInStream, 36);
for(int i = 0; i < 16; i++) {
ele.addInt(md5Hash[i], 8);
}
return ele;
}
|
[
"public",
"static",
"EncodedElement",
"getStreamInfo",
"(",
"StreamConfiguration",
"sc",
",",
"int",
"minFrameSize",
",",
"int",
"maxFrameSize",
",",
"long",
"samplesInStream",
",",
"byte",
"[",
"]",
"md5Hash",
")",
"{",
"int",
"bytes",
"=",
"getByteSize",
"(",
")",
";",
"EncodedElement",
"ele",
"=",
"new",
"EncodedElement",
"(",
"bytes",
",",
"0",
")",
";",
"int",
"encodedBitsPerSample",
"=",
"sc",
".",
"getBitsPerSample",
"(",
")",
"-",
"1",
";",
"ele",
".",
"addInt",
"(",
"sc",
".",
"getMinBlockSize",
"(",
")",
",",
"16",
")",
";",
"ele",
".",
"addInt",
"(",
"sc",
".",
"getMaxBlockSize",
"(",
")",
",",
"16",
")",
";",
"ele",
".",
"addInt",
"(",
"minFrameSize",
",",
"24",
")",
";",
"ele",
".",
"addInt",
"(",
"maxFrameSize",
",",
"24",
")",
";",
"ele",
".",
"addInt",
"(",
"sc",
".",
"getSampleRate",
"(",
")",
",",
"20",
")",
";",
"ele",
".",
"addInt",
"(",
"sc",
".",
"getChannelCount",
"(",
")",
"-",
"1",
",",
"3",
")",
";",
"ele",
".",
"addInt",
"(",
"encodedBitsPerSample",
",",
"5",
")",
";",
"ele",
".",
"addLong",
"(",
"samplesInStream",
",",
"36",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"16",
";",
"i",
"++",
")",
"{",
"ele",
".",
"addInt",
"(",
"md5Hash",
"[",
"i",
"]",
",",
"8",
")",
";",
"}",
"return",
"ele",
";",
"}"
] |
Create a FLAC StreamInfo metadata block with the given parameters. Because
of the data stored in a StreamInfo block, this should generally be created
only after all encoding is done.
@param sc StreamConfiguration used in this FLAC stream.
@param minFrameSize Size of smallest frame in FLAC stream.
@param maxFrameSize Size of largest frame in FLAC stream.
@param samplesInStream Total number of inter-channel audio samples in
FLAC stream.
@param md5Hash MD5 hash of the raw audio samples.
@return EncodedElement containing created StreamInfo block.
|
[
"Create",
"a",
"FLAC",
"StreamInfo",
"metadata",
"block",
"with",
"the",
"given",
"parameters",
".",
"Because",
"of",
"the",
"data",
"stored",
"in",
"a",
"StreamInfo",
"block",
"this",
"should",
"generally",
"be",
"created",
"only",
"after",
"all",
"encoding",
"is",
"done",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/MetadataBlockStreamInfo.java#L65-L82
|
9,987
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/MetadataBlockStreamInfo.java
|
MetadataBlockStreamInfo.getByteSize
|
static public int getByteSize() {
int size = 0;
size += 16;
size += 16;
size += 24;
size += 24;
size += 20;
size += 3;
size += 5;
size += 36;
size += 64;
size += 64;
size = size/8;
return size;
}
|
java
|
static public int getByteSize() {
int size = 0;
size += 16;
size += 16;
size += 24;
size += 24;
size += 20;
size += 3;
size += 5;
size += 36;
size += 64;
size += 64;
size = size/8;
return size;
}
|
[
"static",
"public",
"int",
"getByteSize",
"(",
")",
"{",
"int",
"size",
"=",
"0",
";",
"size",
"+=",
"16",
";",
"size",
"+=",
"16",
";",
"size",
"+=",
"24",
";",
"size",
"+=",
"24",
";",
"size",
"+=",
"20",
";",
"size",
"+=",
"3",
";",
"size",
"+=",
"5",
";",
"size",
"+=",
"36",
";",
"size",
"+=",
"64",
";",
"size",
"+=",
"64",
";",
"size",
"=",
"size",
"/",
"8",
";",
"return",
"size",
";",
"}"
] |
Get the expected size of a properly formed STREAMINFO metadata block.
@return size of properly formed FLAC STREAMINFO metadata block.
|
[
"Get",
"the",
"expected",
"size",
"of",
"a",
"properly",
"formed",
"STREAMINFO",
"metadata",
"block",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/MetadataBlockStreamInfo.java#L89-L103
|
9,988
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/LPC.java
|
LPC.calculate
|
public static void calculate(LPC lpc, long[] R) {
int coeffCount = lpc.order;
//calculate first iteration directly
double[] A = lpc.rawCoefficients;
for(int i = 0; i < coeffCount+1; i++) A[i] = 0.0;
A[0] = 1;
double E = R[0];
//calculate remaining iterations
if(R[0] == 0) {
for(int i = 0; i < coeffCount+1; i++)
A[i] = 0.0;
}
else {
double[] ATemp = lpc.tempCoefficients;
for(int i = 0; i < coeffCount+1; i++) ATemp[i] = 0.0;
for(int k = 0; k < coeffCount; k++) {
double lambda = 0.0;
double temp = 0;
for(int j = 0; j <= k; j++) {
temp += A[j]*R[k+1-j];
}
lambda = -temp/E;
for(int i = 0; i <= k+1; i++) {
ATemp[i] = A[i]+lambda*A[k+1-i];
}
System.arraycopy(ATemp, 0, A, 0, coeffCount+1);
E = (1-lambda*lambda)*E;
}
}
lpc.rawError = E;
}
|
java
|
public static void calculate(LPC lpc, long[] R) {
int coeffCount = lpc.order;
//calculate first iteration directly
double[] A = lpc.rawCoefficients;
for(int i = 0; i < coeffCount+1; i++) A[i] = 0.0;
A[0] = 1;
double E = R[0];
//calculate remaining iterations
if(R[0] == 0) {
for(int i = 0; i < coeffCount+1; i++)
A[i] = 0.0;
}
else {
double[] ATemp = lpc.tempCoefficients;
for(int i = 0; i < coeffCount+1; i++) ATemp[i] = 0.0;
for(int k = 0; k < coeffCount; k++) {
double lambda = 0.0;
double temp = 0;
for(int j = 0; j <= k; j++) {
temp += A[j]*R[k+1-j];
}
lambda = -temp/E;
for(int i = 0; i <= k+1; i++) {
ATemp[i] = A[i]+lambda*A[k+1-i];
}
System.arraycopy(ATemp, 0, A, 0, coeffCount+1);
E = (1-lambda*lambda)*E;
}
}
lpc.rawError = E;
}
|
[
"public",
"static",
"void",
"calculate",
"(",
"LPC",
"lpc",
",",
"long",
"[",
"]",
"R",
")",
"{",
"int",
"coeffCount",
"=",
"lpc",
".",
"order",
";",
"//calculate first iteration directly",
"double",
"[",
"]",
"A",
"=",
"lpc",
".",
"rawCoefficients",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"coeffCount",
"+",
"1",
";",
"i",
"++",
")",
"A",
"[",
"i",
"]",
"=",
"0.0",
";",
"A",
"[",
"0",
"]",
"=",
"1",
";",
"double",
"E",
"=",
"R",
"[",
"0",
"]",
";",
"//calculate remaining iterations",
"if",
"(",
"R",
"[",
"0",
"]",
"==",
"0",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"coeffCount",
"+",
"1",
";",
"i",
"++",
")",
"A",
"[",
"i",
"]",
"=",
"0.0",
";",
"}",
"else",
"{",
"double",
"[",
"]",
"ATemp",
"=",
"lpc",
".",
"tempCoefficients",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"coeffCount",
"+",
"1",
";",
"i",
"++",
")",
"ATemp",
"[",
"i",
"]",
"=",
"0.0",
";",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"coeffCount",
";",
"k",
"++",
")",
"{",
"double",
"lambda",
"=",
"0.0",
";",
"double",
"temp",
"=",
"0",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<=",
"k",
";",
"j",
"++",
")",
"{",
"temp",
"+=",
"A",
"[",
"j",
"]",
"*",
"R",
"[",
"k",
"+",
"1",
"-",
"j",
"]",
";",
"}",
"lambda",
"=",
"-",
"temp",
"/",
"E",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"k",
"+",
"1",
";",
"i",
"++",
")",
"{",
"ATemp",
"[",
"i",
"]",
"=",
"A",
"[",
"i",
"]",
"+",
"lambda",
"*",
"A",
"[",
"k",
"+",
"1",
"-",
"i",
"]",
";",
"}",
"System",
".",
"arraycopy",
"(",
"ATemp",
",",
"0",
",",
"A",
",",
"0",
",",
"coeffCount",
"+",
"1",
")",
";",
"E",
"=",
"(",
"1",
"-",
"lambda",
"*",
"lambda",
")",
"*",
"E",
";",
"}",
"}",
"lpc",
".",
"rawError",
"=",
"E",
";",
"}"
] |
Calculate an LPC using the given Auto-correlation data. Static method
used since this is slightly faster than a more strictly object-oriented
approach.
@param lpc LPC to calculate
@param R Autocorrelation data to use
|
[
"Calculate",
"an",
"LPC",
"using",
"the",
"given",
"Auto",
"-",
"correlation",
"data",
".",
"Static",
"method",
"used",
"since",
"this",
"is",
"slightly",
"faster",
"than",
"a",
"more",
"strictly",
"object",
"-",
"oriented",
"approach",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/LPC.java#L71-L106
|
9,989
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/LPC.java
|
LPC.calculateFromPrior
|
public static void calculateFromPrior(LPC lpc, long[] R, LPC priorLPC) {
int coeffCount = lpc.order;
//calculate first iteration directly
double[] A = lpc.rawCoefficients;
for(int i = 0; i < coeffCount+1; i++) A[i] = 0.0;
A[0] = 1;
double E = R[0];
int startIter = 0;
if(priorLPC != null && priorLPC.order < lpc.order) {
startIter = priorLPC.order;
E = priorLPC.rawError;
System.arraycopy(priorLPC.rawCoefficients, 0, A, 0, startIter+1);
}
//calculate remaining iterations
if(R[0] == 0) {
for(int i = 0; i < coeffCount+1; i++)
A[i] = 0.0;
}
else {
double[] ATemp = lpc.tempCoefficients;
for(int i = 0; i < coeffCount+1; i++) ATemp[i] = 0.0;
for(int k = startIter; k < coeffCount; k++) {
double lambda = 0.0;
double temp = 0.0;
for(int j = 0; j <= k; j++) {
temp -= A[j]*R[k-j+1];
}
lambda = temp/E;
for(int i = 0; i <= k+1; i++) {
ATemp[i] = A[i]+lambda*A[k+1-i];
}
System.arraycopy(ATemp, 0, A, 0, coeffCount+1);
E = (1-lambda*lambda)*E;
}
}
lpc.rawError = E;
}
|
java
|
public static void calculateFromPrior(LPC lpc, long[] R, LPC priorLPC) {
int coeffCount = lpc.order;
//calculate first iteration directly
double[] A = lpc.rawCoefficients;
for(int i = 0; i < coeffCount+1; i++) A[i] = 0.0;
A[0] = 1;
double E = R[0];
int startIter = 0;
if(priorLPC != null && priorLPC.order < lpc.order) {
startIter = priorLPC.order;
E = priorLPC.rawError;
System.arraycopy(priorLPC.rawCoefficients, 0, A, 0, startIter+1);
}
//calculate remaining iterations
if(R[0] == 0) {
for(int i = 0; i < coeffCount+1; i++)
A[i] = 0.0;
}
else {
double[] ATemp = lpc.tempCoefficients;
for(int i = 0; i < coeffCount+1; i++) ATemp[i] = 0.0;
for(int k = startIter; k < coeffCount; k++) {
double lambda = 0.0;
double temp = 0.0;
for(int j = 0; j <= k; j++) {
temp -= A[j]*R[k-j+1];
}
lambda = temp/E;
for(int i = 0; i <= k+1; i++) {
ATemp[i] = A[i]+lambda*A[k+1-i];
}
System.arraycopy(ATemp, 0, A, 0, coeffCount+1);
E = (1-lambda*lambda)*E;
}
}
lpc.rawError = E;
}
|
[
"public",
"static",
"void",
"calculateFromPrior",
"(",
"LPC",
"lpc",
",",
"long",
"[",
"]",
"R",
",",
"LPC",
"priorLPC",
")",
"{",
"int",
"coeffCount",
"=",
"lpc",
".",
"order",
";",
"//calculate first iteration directly",
"double",
"[",
"]",
"A",
"=",
"lpc",
".",
"rawCoefficients",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"coeffCount",
"+",
"1",
";",
"i",
"++",
")",
"A",
"[",
"i",
"]",
"=",
"0.0",
";",
"A",
"[",
"0",
"]",
"=",
"1",
";",
"double",
"E",
"=",
"R",
"[",
"0",
"]",
";",
"int",
"startIter",
"=",
"0",
";",
"if",
"(",
"priorLPC",
"!=",
"null",
"&&",
"priorLPC",
".",
"order",
"<",
"lpc",
".",
"order",
")",
"{",
"startIter",
"=",
"priorLPC",
".",
"order",
";",
"E",
"=",
"priorLPC",
".",
"rawError",
";",
"System",
".",
"arraycopy",
"(",
"priorLPC",
".",
"rawCoefficients",
",",
"0",
",",
"A",
",",
"0",
",",
"startIter",
"+",
"1",
")",
";",
"}",
"//calculate remaining iterations",
"if",
"(",
"R",
"[",
"0",
"]",
"==",
"0",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"coeffCount",
"+",
"1",
";",
"i",
"++",
")",
"A",
"[",
"i",
"]",
"=",
"0.0",
";",
"}",
"else",
"{",
"double",
"[",
"]",
"ATemp",
"=",
"lpc",
".",
"tempCoefficients",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"coeffCount",
"+",
"1",
";",
"i",
"++",
")",
"ATemp",
"[",
"i",
"]",
"=",
"0.0",
";",
"for",
"(",
"int",
"k",
"=",
"startIter",
";",
"k",
"<",
"coeffCount",
";",
"k",
"++",
")",
"{",
"double",
"lambda",
"=",
"0.0",
";",
"double",
"temp",
"=",
"0.0",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<=",
"k",
";",
"j",
"++",
")",
"{",
"temp",
"-=",
"A",
"[",
"j",
"]",
"*",
"R",
"[",
"k",
"-",
"j",
"+",
"1",
"]",
";",
"}",
"lambda",
"=",
"temp",
"/",
"E",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"k",
"+",
"1",
";",
"i",
"++",
")",
"{",
"ATemp",
"[",
"i",
"]",
"=",
"A",
"[",
"i",
"]",
"+",
"lambda",
"*",
"A",
"[",
"k",
"+",
"1",
"-",
"i",
"]",
";",
"}",
"System",
".",
"arraycopy",
"(",
"ATemp",
",",
"0",
",",
"A",
",",
"0",
",",
"coeffCount",
"+",
"1",
")",
";",
"E",
"=",
"(",
"1",
"-",
"lambda",
"*",
"lambda",
")",
"*",
"E",
";",
"}",
"}",
"lpc",
".",
"rawError",
"=",
"E",
";",
"}"
] |
Calculate an LPC using a prior order LPC's values to save calculations.
@param lpc LPC to calculate
@param R Auto-correlation data to use.
@param priorLPC Prior order LPC to use(may be any order lower than our
target LPC)
|
[
"Calculate",
"an",
"LPC",
"using",
"a",
"prior",
"order",
"LPC",
"s",
"values",
"to",
"save",
"calculations",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/LPC.java#L117-L156
|
9,990
|
chocoteam/choco-graph
|
src/main/java/org/chocosolver/graphsolver/util/BitOperations.java
|
BitOperations.binaryLCA
|
public static int binaryLCA(int x, int y) {
if (x == y) {
return x;
}
int xor = x ^ y;
int idx = getMaxExp(xor);
if (idx == -1) {
throw new UnsupportedOperationException();
}
return replaceBy1and0sFrom(x, idx);
}
|
java
|
public static int binaryLCA(int x, int y) {
if (x == y) {
return x;
}
int xor = x ^ y;
int idx = getMaxExp(xor);
if (idx == -1) {
throw new UnsupportedOperationException();
}
return replaceBy1and0sFrom(x, idx);
}
|
[
"public",
"static",
"int",
"binaryLCA",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"if",
"(",
"x",
"==",
"y",
")",
"{",
"return",
"x",
";",
"}",
"int",
"xor",
"=",
"x",
"^",
"y",
";",
"int",
"idx",
"=",
"getMaxExp",
"(",
"xor",
")",
";",
"if",
"(",
"idx",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"return",
"replaceBy1and0sFrom",
"(",
"x",
",",
"idx",
")",
";",
"}"
] |
Get the lowest common ancestor of x and y in a complete binary tree
@param x a node
@param y a node
@return the lowest common ancestor of x and y in a complete binary tree
|
[
"Get",
"the",
"lowest",
"common",
"ancestor",
"of",
"x",
"and",
"y",
"in",
"a",
"complete",
"binary",
"tree"
] |
0a03b0aafc86601977728c7e3fcb5ed376f1fae9
|
https://github.com/chocoteam/choco-graph/blob/0a03b0aafc86601977728c7e3fcb5ed376f1fae9/src/main/java/org/chocosolver/graphsolver/util/BitOperations.java#L52-L62
|
9,991
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/BlockEncodeRequest.java
|
BlockEncodeRequest.setAll
|
public void setAll(int[] samples, int count, int start, int skip,
long frameNumber, EncodedElement result) {
// assert(start == 0);
this.samples = samples;
this.count = count;
this.start = start;
this.skip = skip;
this.frameNumber = frameNumber;
this.result = result;
valid = false;
this.encodedSamples = 0;
}
|
java
|
public void setAll(int[] samples, int count, int start, int skip,
long frameNumber, EncodedElement result) {
// assert(start == 0);
this.samples = samples;
this.count = count;
this.start = start;
this.skip = skip;
this.frameNumber = frameNumber;
this.result = result;
valid = false;
this.encodedSamples = 0;
}
|
[
"public",
"void",
"setAll",
"(",
"int",
"[",
"]",
"samples",
",",
"int",
"count",
",",
"int",
"start",
",",
"int",
"skip",
",",
"long",
"frameNumber",
",",
"EncodedElement",
"result",
")",
"{",
"// assert(start == 0);",
"this",
".",
"samples",
"=",
"samples",
";",
"this",
".",
"count",
"=",
"count",
";",
"this",
".",
"start",
"=",
"start",
";",
"this",
".",
"skip",
"=",
"skip",
";",
"this",
".",
"frameNumber",
"=",
"frameNumber",
";",
"this",
".",
"result",
"=",
"result",
";",
"valid",
"=",
"false",
";",
"this",
".",
"encodedSamples",
"=",
"0",
";",
"}"
] |
Set all values, preparing this object to be sent to an encoder. Member
variable "valid" is set to false by this call.
@param samples Sample data, interleaved if multiple channels are used
@param count Number of valid samples
@param start Index of first valid sample
@param skip Number of samples to skip between samples(this should be
equal to number-of-channels minus 1.
@param frameNumber Framenumber assigned to this block.
@param result Location to store result of encode.
|
[
"Set",
"all",
"values",
"preparing",
"this",
"object",
"to",
"be",
"sent",
"to",
"an",
"encoder",
".",
"Member",
"variable",
"valid",
"is",
"set",
"to",
"false",
"by",
"this",
"call",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/BlockEncodeRequest.java#L58-L69
|
9,992
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/FLAC_ConsoleFileEncoder.java
|
FLAC_ConsoleFileEncoder.getInt
|
int getInt(String[] args, int index) {
int result = -1;
if(index >= 0 && index < args.length) {
try {
result = Integer.parseInt(args[index]);
}catch(NumberFormatException e) {
result = -1;
}
}
return result;
}
|
java
|
int getInt(String[] args, int index) {
int result = -1;
if(index >= 0 && index < args.length) {
try {
result = Integer.parseInt(args[index]);
}catch(NumberFormatException e) {
result = -1;
}
}
return result;
}
|
[
"int",
"getInt",
"(",
"String",
"[",
"]",
"args",
",",
"int",
"index",
")",
"{",
"int",
"result",
"=",
"-",
"1",
";",
"if",
"(",
"index",
">=",
"0",
"&&",
"index",
"<",
"args",
".",
"length",
")",
"{",
"try",
"{",
"result",
"=",
"Integer",
".",
"parseInt",
"(",
"args",
"[",
"index",
"]",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"result",
"=",
"-",
"1",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Utility function to parse a positive integer argument out of a String
array at the given index.
@param args String array containing element to find.
@param index Index of array element to parse integer from.
@return Integer parsed, or -1 if error.
|
[
"Utility",
"function",
"to",
"parse",
"a",
"positive",
"integer",
"argument",
"out",
"of",
"a",
"String",
"array",
"at",
"the",
"given",
"index",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/FLAC_ConsoleFileEncoder.java#L328-L338
|
9,993
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/FLACFileWriter.java
|
FLACFileWriter.adjustConfigurations
|
private StreamConfiguration adjustConfigurations(AudioFormat format) {
int sampleRate = (int) format.getSampleRate();
int sampleSize = format.getSampleSizeInBits();
int channels = format.getChannels();
StreamConfiguration streamConfiguration = new StreamConfiguration();
streamConfiguration.setSampleRate(sampleRate);
streamConfiguration.setBitsPerSample(sampleSize);
streamConfiguration.setChannelCount(channels);
return streamConfiguration;
}
|
java
|
private StreamConfiguration adjustConfigurations(AudioFormat format) {
int sampleRate = (int) format.getSampleRate();
int sampleSize = format.getSampleSizeInBits();
int channels = format.getChannels();
StreamConfiguration streamConfiguration = new StreamConfiguration();
streamConfiguration.setSampleRate(sampleRate);
streamConfiguration.setBitsPerSample(sampleSize);
streamConfiguration.setChannelCount(channels);
return streamConfiguration;
}
|
[
"private",
"StreamConfiguration",
"adjustConfigurations",
"(",
"AudioFormat",
"format",
")",
"{",
"int",
"sampleRate",
"=",
"(",
"int",
")",
"format",
".",
"getSampleRate",
"(",
")",
";",
"int",
"sampleSize",
"=",
"format",
".",
"getSampleSizeInBits",
"(",
")",
";",
"int",
"channels",
"=",
"format",
".",
"getChannels",
"(",
")",
";",
"StreamConfiguration",
"streamConfiguration",
"=",
"new",
"StreamConfiguration",
"(",
")",
";",
"streamConfiguration",
".",
"setSampleRate",
"(",
"sampleRate",
")",
";",
"streamConfiguration",
".",
"setBitsPerSample",
"(",
"sampleSize",
")",
";",
"streamConfiguration",
".",
"setChannelCount",
"(",
"channels",
")",
";",
"return",
"streamConfiguration",
";",
"}"
] |
Method sets input stream configuration for encoder.
@param format input format
@return stream configuration for encoder.
|
[
"Method",
"sets",
"input",
"stream",
"configuration",
"for",
"encoder",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/FLACFileWriter.java#L184-L195
|
9,994
|
aerogear/aerogear-android-push
|
library/src/main/java/org/jboss/aerogear/android/unifiedpush/fcm/UnifiedPushConfig.java
|
UnifiedPushConfig.validateCategories
|
private static void validateCategories(String... categories) {
for (String category : categories) {
if (!category.matches(FCM_TOPIC_PATTERN)) {
throw new IllegalArgumentException(String.format("%s does not match %s", category, FCM_TOPIC_PATTERN));
}
}
}
|
java
|
private static void validateCategories(String... categories) {
for (String category : categories) {
if (!category.matches(FCM_TOPIC_PATTERN)) {
throw new IllegalArgumentException(String.format("%s does not match %s", category, FCM_TOPIC_PATTERN));
}
}
}
|
[
"private",
"static",
"void",
"validateCategories",
"(",
"String",
"...",
"categories",
")",
"{",
"for",
"(",
"String",
"category",
":",
"categories",
")",
"{",
"if",
"(",
"!",
"category",
".",
"matches",
"(",
"FCM_TOPIC_PATTERN",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"%s does not match %s\"",
",",
"category",
",",
"FCM_TOPIC_PATTERN",
")",
")",
";",
"}",
"}",
"}"
] |
Validates categories against Google's pattern.
@param categories a group of Strings each will be validated.
@throws IllegalArgumentException if a category fails to match [a-zA-Z0-9-_.~%]+
|
[
"Validates",
"categories",
"against",
"Google",
"s",
"pattern",
"."
] |
f21f93393a9f4590e9a8d6d045ab9aabca3d211f
|
https://github.com/aerogear/aerogear-android-push/blob/f21f93393a9f4590e9a8d6d045ab9aabca3d211f/library/src/main/java/org/jboss/aerogear/android/unifiedpush/fcm/UnifiedPushConfig.java#L310-L317
|
9,995
|
chocoteam/choco-graph
|
src/main/java/org/chocosolver/graphsolver/variables/delta/GraphDeltaMonitor.java
|
GraphDeltaMonitor.forEachNode
|
public void forEachNode(IntProcedure proc, GraphEventType evt) throws ContradictionException {
int type;
if (evt == GraphEventType.REMOVE_NODE) {
type = GraphDelta.NR;
for (int i = frozenFirst[type]; i < frozenLast[type]; i++) {
if (delta.getCause(i, type) != propagator) {
proc.execute(delta.get(i, type));
}
}
} else if (evt == GraphEventType.ADD_NODE) {
type = GraphDelta.NE;
for (int i = frozenFirst[type]; i < frozenLast[type]; i++) {
if (delta.getCause(i, type) != propagator) {
proc.execute(delta.get(i, type));
}
}
} else {
throw new UnsupportedOperationException();
}
}
|
java
|
public void forEachNode(IntProcedure proc, GraphEventType evt) throws ContradictionException {
int type;
if (evt == GraphEventType.REMOVE_NODE) {
type = GraphDelta.NR;
for (int i = frozenFirst[type]; i < frozenLast[type]; i++) {
if (delta.getCause(i, type) != propagator) {
proc.execute(delta.get(i, type));
}
}
} else if (evt == GraphEventType.ADD_NODE) {
type = GraphDelta.NE;
for (int i = frozenFirst[type]; i < frozenLast[type]; i++) {
if (delta.getCause(i, type) != propagator) {
proc.execute(delta.get(i, type));
}
}
} else {
throw new UnsupportedOperationException();
}
}
|
[
"public",
"void",
"forEachNode",
"(",
"IntProcedure",
"proc",
",",
"GraphEventType",
"evt",
")",
"throws",
"ContradictionException",
"{",
"int",
"type",
";",
"if",
"(",
"evt",
"==",
"GraphEventType",
".",
"REMOVE_NODE",
")",
"{",
"type",
"=",
"GraphDelta",
".",
"NR",
";",
"for",
"(",
"int",
"i",
"=",
"frozenFirst",
"[",
"type",
"]",
";",
"i",
"<",
"frozenLast",
"[",
"type",
"]",
";",
"i",
"++",
")",
"{",
"if",
"(",
"delta",
".",
"getCause",
"(",
"i",
",",
"type",
")",
"!=",
"propagator",
")",
"{",
"proc",
".",
"execute",
"(",
"delta",
".",
"get",
"(",
"i",
",",
"type",
")",
")",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"evt",
"==",
"GraphEventType",
".",
"ADD_NODE",
")",
"{",
"type",
"=",
"GraphDelta",
".",
"NE",
";",
"for",
"(",
"int",
"i",
"=",
"frozenFirst",
"[",
"type",
"]",
";",
"i",
"<",
"frozenLast",
"[",
"type",
"]",
";",
"i",
"++",
")",
"{",
"if",
"(",
"delta",
".",
"getCause",
"(",
"i",
",",
"type",
")",
"!=",
"propagator",
")",
"{",
"proc",
".",
"execute",
"(",
"delta",
".",
"get",
"(",
"i",
",",
"type",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"}"
] |
Applies proc to every vertex which has just been removed or enforced, depending on evt.
@param proc an incremental procedure over vertices
@param evt either ENFORCENODE or REMOVENODE
@throws ContradictionException if a failure occurs
|
[
"Applies",
"proc",
"to",
"every",
"vertex",
"which",
"has",
"just",
"been",
"removed",
"or",
"enforced",
"depending",
"on",
"evt",
"."
] |
0a03b0aafc86601977728c7e3fcb5ed376f1fae9
|
https://github.com/chocoteam/choco-graph/blob/0a03b0aafc86601977728c7e3fcb5ed376f1fae9/src/main/java/org/chocosolver/graphsolver/variables/delta/GraphDeltaMonitor.java#L91-L110
|
9,996
|
chocoteam/choco-graph
|
src/main/java/org/chocosolver/graphsolver/variables/delta/GraphDeltaMonitor.java
|
GraphDeltaMonitor.forEachArc
|
public void forEachArc(PairProcedure proc, GraphEventType evt) throws ContradictionException {
if (evt == GraphEventType.REMOVE_ARC) {
for (int i = frozenFirst[2]; i < frozenLast[2]; i++) {
if (delta.getCause(i, GraphDelta.AR_TAIL) != propagator) {
proc.execute(delta.get(i, GraphDelta.AR_TAIL), delta.get(i, GraphDelta.AR_HEAD));
}
}
} else if (evt == GraphEventType.ADD_ARC) {
for (int i = frozenFirst[3]; i < frozenLast[3]; i++) {
if (delta.getCause(i, GraphDelta.AE_TAIL) != propagator) {
proc.execute(delta.get(i, GraphDelta.AE_TAIL), delta.get(i, GraphDelta.AE_HEAD));
}
}
} else {
throw new UnsupportedOperationException();
}
}
|
java
|
public void forEachArc(PairProcedure proc, GraphEventType evt) throws ContradictionException {
if (evt == GraphEventType.REMOVE_ARC) {
for (int i = frozenFirst[2]; i < frozenLast[2]; i++) {
if (delta.getCause(i, GraphDelta.AR_TAIL) != propagator) {
proc.execute(delta.get(i, GraphDelta.AR_TAIL), delta.get(i, GraphDelta.AR_HEAD));
}
}
} else if (evt == GraphEventType.ADD_ARC) {
for (int i = frozenFirst[3]; i < frozenLast[3]; i++) {
if (delta.getCause(i, GraphDelta.AE_TAIL) != propagator) {
proc.execute(delta.get(i, GraphDelta.AE_TAIL), delta.get(i, GraphDelta.AE_HEAD));
}
}
} else {
throw new UnsupportedOperationException();
}
}
|
[
"public",
"void",
"forEachArc",
"(",
"PairProcedure",
"proc",
",",
"GraphEventType",
"evt",
")",
"throws",
"ContradictionException",
"{",
"if",
"(",
"evt",
"==",
"GraphEventType",
".",
"REMOVE_ARC",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"frozenFirst",
"[",
"2",
"]",
";",
"i",
"<",
"frozenLast",
"[",
"2",
"]",
";",
"i",
"++",
")",
"{",
"if",
"(",
"delta",
".",
"getCause",
"(",
"i",
",",
"GraphDelta",
".",
"AR_TAIL",
")",
"!=",
"propagator",
")",
"{",
"proc",
".",
"execute",
"(",
"delta",
".",
"get",
"(",
"i",
",",
"GraphDelta",
".",
"AR_TAIL",
")",
",",
"delta",
".",
"get",
"(",
"i",
",",
"GraphDelta",
".",
"AR_HEAD",
")",
")",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"evt",
"==",
"GraphEventType",
".",
"ADD_ARC",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"frozenFirst",
"[",
"3",
"]",
";",
"i",
"<",
"frozenLast",
"[",
"3",
"]",
";",
"i",
"++",
")",
"{",
"if",
"(",
"delta",
".",
"getCause",
"(",
"i",
",",
"GraphDelta",
".",
"AE_TAIL",
")",
"!=",
"propagator",
")",
"{",
"proc",
".",
"execute",
"(",
"delta",
".",
"get",
"(",
"i",
",",
"GraphDelta",
".",
"AE_TAIL",
")",
",",
"delta",
".",
"get",
"(",
"i",
",",
"GraphDelta",
".",
"AE_HEAD",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"}"
] |
Applies proc to every arc which has just been removed or enforced, depending on evt.
@param proc an incremental procedure over arcs
@param evt either ENFORCEARC or REMOVEARC
@throws ContradictionException if a failure occurs
|
[
"Applies",
"proc",
"to",
"every",
"arc",
"which",
"has",
"just",
"been",
"removed",
"or",
"enforced",
"depending",
"on",
"evt",
"."
] |
0a03b0aafc86601977728c7e3fcb5ed376f1fae9
|
https://github.com/chocoteam/choco-graph/blob/0a03b0aafc86601977728c7e3fcb5ed376f1fae9/src/main/java/org/chocosolver/graphsolver/variables/delta/GraphDeltaMonitor.java#L118-L134
|
9,997
|
chocoteam/choco-graph
|
src/main/java/org/chocosolver/graphsolver/cstrs/connectivity/PropSizeMaxCC.java
|
PropSizeMaxCC.getGLBCCNodes
|
private Set<Integer> getGLBCCNodes(int cc) {
Set<Integer> ccNodes = new HashSet<>();
for (int i = GLBCCFinder.getCCFirstNode()[cc]; i >= 0; i = GLBCCFinder.getCCNextNode()[i]) {
ccNodes.add(i);
}
return ccNodes;
}
|
java
|
private Set<Integer> getGLBCCNodes(int cc) {
Set<Integer> ccNodes = new HashSet<>();
for (int i = GLBCCFinder.getCCFirstNode()[cc]; i >= 0; i = GLBCCFinder.getCCNextNode()[i]) {
ccNodes.add(i);
}
return ccNodes;
}
|
[
"private",
"Set",
"<",
"Integer",
">",
"getGLBCCNodes",
"(",
"int",
"cc",
")",
"{",
"Set",
"<",
"Integer",
">",
"ccNodes",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"GLBCCFinder",
".",
"getCCFirstNode",
"(",
")",
"[",
"cc",
"]",
";",
"i",
">=",
"0",
";",
"i",
"=",
"GLBCCFinder",
".",
"getCCNextNode",
"(",
")",
"[",
"i",
"]",
")",
"{",
"ccNodes",
".",
"add",
"(",
"i",
")",
";",
"}",
"return",
"ccNodes",
";",
"}"
] |
Retrieve the nodes of a GLB CC.
@param cc The GLB CC index.
@return The set of nodes of the GLB CC cc.
|
[
"Retrieve",
"the",
"nodes",
"of",
"a",
"GLB",
"CC",
"."
] |
0a03b0aafc86601977728c7e3fcb5ed376f1fae9
|
https://github.com/chocoteam/choco-graph/blob/0a03b0aafc86601977728c7e3fcb5ed376f1fae9/src/main/java/org/chocosolver/graphsolver/cstrs/connectivity/PropSizeMaxCC.java#L166-L172
|
9,998
|
amplexus/java-flac-encoder
|
src/main/java/net/sourceforge/javaflacencoder/Subframe_LPC.java
|
Subframe_LPC.quantizeCoefficients
|
private static int quantizeCoefficients(double[] coefficients, int[] dest,
int order, int precision) {
assert(precision >= 2 && precision <= 15);
assert(coefficients.length >= order+1);
assert(dest.length >= order+1);
if(precision < 2 || precision > 15)
throw new IllegalArgumentException("Error! precision must be between 2 and 15, inclusive.");
int shiftApplied = 0;
int maxValAllowed = (1<<(precision-2))-1;//minus an extra bit for sign.
int minValAllowed = -1*maxValAllowed-1;
double maxVal = 0;
for(int i = 1; i <= order; i++) {
double temp = coefficients[i];
if(temp < 0) temp*= -1;
if(temp > maxVal)
maxVal = temp;
}
//find shift to use(by max value)
for(shiftApplied = 15; shiftApplied > 0; shiftApplied--) {
int temp = (int)(maxVal * (1<<shiftApplied));
if(temp <= maxValAllowed)
break;
}
if(maxVal > maxValAllowed) {//no shift should have been applied
//ensure max value is not too large, cap all necessary //
for(int i = 1; i <= order; i++) {
double temp = coefficients[i];
if(temp < 0)
temp = temp * -1;
if(temp > maxValAllowed) {
if(coefficients[i] < 0)
dest[i] = minValAllowed;
else
dest[i] = maxValAllowed;
}
else
dest[i] = (int)coefficients[i];
}
}
else {
//shift and quantize all values by found shift
for(int i = 1; i <= order; i++) {
double temp = coefficients[i]*(1<<shiftApplied);
temp = (temp > 0) ? temp+0.5:temp-0.5;
dest[i] = (int)temp;
}
}
return shiftApplied;
}
|
java
|
private static int quantizeCoefficients(double[] coefficients, int[] dest,
int order, int precision) {
assert(precision >= 2 && precision <= 15);
assert(coefficients.length >= order+1);
assert(dest.length >= order+1);
if(precision < 2 || precision > 15)
throw new IllegalArgumentException("Error! precision must be between 2 and 15, inclusive.");
int shiftApplied = 0;
int maxValAllowed = (1<<(precision-2))-1;//minus an extra bit for sign.
int minValAllowed = -1*maxValAllowed-1;
double maxVal = 0;
for(int i = 1; i <= order; i++) {
double temp = coefficients[i];
if(temp < 0) temp*= -1;
if(temp > maxVal)
maxVal = temp;
}
//find shift to use(by max value)
for(shiftApplied = 15; shiftApplied > 0; shiftApplied--) {
int temp = (int)(maxVal * (1<<shiftApplied));
if(temp <= maxValAllowed)
break;
}
if(maxVal > maxValAllowed) {//no shift should have been applied
//ensure max value is not too large, cap all necessary //
for(int i = 1; i <= order; i++) {
double temp = coefficients[i];
if(temp < 0)
temp = temp * -1;
if(temp > maxValAllowed) {
if(coefficients[i] < 0)
dest[i] = minValAllowed;
else
dest[i] = maxValAllowed;
}
else
dest[i] = (int)coefficients[i];
}
}
else {
//shift and quantize all values by found shift
for(int i = 1; i <= order; i++) {
double temp = coefficients[i]*(1<<shiftApplied);
temp = (temp > 0) ? temp+0.5:temp-0.5;
dest[i] = (int)temp;
}
}
return shiftApplied;
}
|
[
"private",
"static",
"int",
"quantizeCoefficients",
"(",
"double",
"[",
"]",
"coefficients",
",",
"int",
"[",
"]",
"dest",
",",
"int",
"order",
",",
"int",
"precision",
")",
"{",
"assert",
"(",
"precision",
">=",
"2",
"&&",
"precision",
"<=",
"15",
")",
";",
"assert",
"(",
"coefficients",
".",
"length",
">=",
"order",
"+",
"1",
")",
";",
"assert",
"(",
"dest",
".",
"length",
">=",
"order",
"+",
"1",
")",
";",
"if",
"(",
"precision",
"<",
"2",
"||",
"precision",
">",
"15",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Error! precision must be between 2 and 15, inclusive.\"",
")",
";",
"int",
"shiftApplied",
"=",
"0",
";",
"int",
"maxValAllowed",
"=",
"(",
"1",
"<<",
"(",
"precision",
"-",
"2",
")",
")",
"-",
"1",
";",
"//minus an extra bit for sign.",
"int",
"minValAllowed",
"=",
"-",
"1",
"*",
"maxValAllowed",
"-",
"1",
";",
"double",
"maxVal",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"order",
";",
"i",
"++",
")",
"{",
"double",
"temp",
"=",
"coefficients",
"[",
"i",
"]",
";",
"if",
"(",
"temp",
"<",
"0",
")",
"temp",
"*=",
"-",
"1",
";",
"if",
"(",
"temp",
">",
"maxVal",
")",
"maxVal",
"=",
"temp",
";",
"}",
"//find shift to use(by max value)",
"for",
"(",
"shiftApplied",
"=",
"15",
";",
"shiftApplied",
">",
"0",
";",
"shiftApplied",
"--",
")",
"{",
"int",
"temp",
"=",
"(",
"int",
")",
"(",
"maxVal",
"*",
"(",
"1",
"<<",
"shiftApplied",
")",
")",
";",
"if",
"(",
"temp",
"<=",
"maxValAllowed",
")",
"break",
";",
"}",
"if",
"(",
"maxVal",
">",
"maxValAllowed",
")",
"{",
"//no shift should have been applied",
"//ensure max value is not too large, cap all necessary //",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"order",
";",
"i",
"++",
")",
"{",
"double",
"temp",
"=",
"coefficients",
"[",
"i",
"]",
";",
"if",
"(",
"temp",
"<",
"0",
")",
"temp",
"=",
"temp",
"*",
"-",
"1",
";",
"if",
"(",
"temp",
">",
"maxValAllowed",
")",
"{",
"if",
"(",
"coefficients",
"[",
"i",
"]",
"<",
"0",
")",
"dest",
"[",
"i",
"]",
"=",
"minValAllowed",
";",
"else",
"dest",
"[",
"i",
"]",
"=",
"maxValAllowed",
";",
"}",
"else",
"dest",
"[",
"i",
"]",
"=",
"(",
"int",
")",
"coefficients",
"[",
"i",
"]",
";",
"}",
"}",
"else",
"{",
"//shift and quantize all values by found shift",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"order",
";",
"i",
"++",
")",
"{",
"double",
"temp",
"=",
"coefficients",
"[",
"i",
"]",
"*",
"(",
"1",
"<<",
"shiftApplied",
")",
";",
"temp",
"=",
"(",
"temp",
">",
"0",
")",
"?",
"temp",
"+",
"0.5",
":",
"temp",
"-",
"0.5",
";",
"dest",
"[",
"i",
"]",
"=",
"(",
"int",
")",
"temp",
";",
"}",
"}",
"return",
"shiftApplied",
";",
"}"
] |
Quantize coefficients to integer values of the given precision, and
calculate the shift needed.
@param coefficients values to quantize. These values will not be changed.
@param dest destination for quantized values.
@param order number of values to quantize. First value skipped, coefficients
array must be at least order+1 in length.
@param precision number of signed bits to use for coefficients(must be in range 2-15, inclusive).
@return
|
[
"Quantize",
"coefficients",
"to",
"integer",
"values",
"of",
"the",
"given",
"precision",
"and",
"calculate",
"the",
"shift",
"needed",
"."
] |
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
|
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/Subframe_LPC.java#L259-L308
|
9,999
|
aerogear/aerogear-android-push
|
library/src/main/java/org/jboss/aerogear/android/unifiedpush/fcm/AeroGearFCMPushRegistrar.java
|
AeroGearFCMPushRegistrar.unregister
|
@Override
public void unregister(final Context context, final Callback<Void> callback) {
new AsyncTask<Void, Void, Exception>() {
@Override
protected Exception doInBackground(Void... params) {
try {
if ((deviceToken == null) || (deviceToken.trim().equals(""))) {
throw new IllegalStateException(DEVICE_ALREADY_UNREGISTERED);
}
if (instanceId == null) {
instanceId = firebaseInstanceIdProvider.get(context);
}
String token = Tasks.await(instanceId.getInstanceId(), 30, TimeUnit.SECONDS).getToken();
FirebaseMessaging firebaseMessaging = firebaseMessagingProvider.get(context);
for (String catgory : categories) {
firebaseMessaging.unsubscribeFromTopic(catgory);
}
//Unsubscribe to generic topic
firebaseMessaging.unsubscribeFromTopic(variantId);
instanceId.deleteInstanceId();
HttpProvider provider = httpProviderProvider.get(deviceRegistryURL, TIMEOUT);
setPasswordAuthentication(variantId, secret, provider);
try {
provider.delete(deviceToken);
deviceToken = "";
removeSavedPostData(context.getApplicationContext());
return null;
} catch (HttpException ex) {
return ex;
}
} catch (Exception ex) {
return ex;
}
}
@SuppressWarnings("unchecked")
@Override
protected void onPostExecute(Exception result) {
if (result == null) {
callback.onSuccess(null);
} else {
callback.onFailure(result);
}
}
}.execute((Void) null);
}
|
java
|
@Override
public void unregister(final Context context, final Callback<Void> callback) {
new AsyncTask<Void, Void, Exception>() {
@Override
protected Exception doInBackground(Void... params) {
try {
if ((deviceToken == null) || (deviceToken.trim().equals(""))) {
throw new IllegalStateException(DEVICE_ALREADY_UNREGISTERED);
}
if (instanceId == null) {
instanceId = firebaseInstanceIdProvider.get(context);
}
String token = Tasks.await(instanceId.getInstanceId(), 30, TimeUnit.SECONDS).getToken();
FirebaseMessaging firebaseMessaging = firebaseMessagingProvider.get(context);
for (String catgory : categories) {
firebaseMessaging.unsubscribeFromTopic(catgory);
}
//Unsubscribe to generic topic
firebaseMessaging.unsubscribeFromTopic(variantId);
instanceId.deleteInstanceId();
HttpProvider provider = httpProviderProvider.get(deviceRegistryURL, TIMEOUT);
setPasswordAuthentication(variantId, secret, provider);
try {
provider.delete(deviceToken);
deviceToken = "";
removeSavedPostData(context.getApplicationContext());
return null;
} catch (HttpException ex) {
return ex;
}
} catch (Exception ex) {
return ex;
}
}
@SuppressWarnings("unchecked")
@Override
protected void onPostExecute(Exception result) {
if (result == null) {
callback.onSuccess(null);
} else {
callback.onFailure(result);
}
}
}.execute((Void) null);
}
|
[
"@",
"Override",
"public",
"void",
"unregister",
"(",
"final",
"Context",
"context",
",",
"final",
"Callback",
"<",
"Void",
">",
"callback",
")",
"{",
"new",
"AsyncTask",
"<",
"Void",
",",
"Void",
",",
"Exception",
">",
"(",
")",
"{",
"@",
"Override",
"protected",
"Exception",
"doInBackground",
"(",
"Void",
"...",
"params",
")",
"{",
"try",
"{",
"if",
"(",
"(",
"deviceToken",
"==",
"null",
")",
"||",
"(",
"deviceToken",
".",
"trim",
"(",
")",
".",
"equals",
"(",
"\"\"",
")",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"DEVICE_ALREADY_UNREGISTERED",
")",
";",
"}",
"if",
"(",
"instanceId",
"==",
"null",
")",
"{",
"instanceId",
"=",
"firebaseInstanceIdProvider",
".",
"get",
"(",
"context",
")",
";",
"}",
"String",
"token",
"=",
"Tasks",
".",
"await",
"(",
"instanceId",
".",
"getInstanceId",
"(",
")",
",",
"30",
",",
"TimeUnit",
".",
"SECONDS",
")",
".",
"getToken",
"(",
")",
";",
"FirebaseMessaging",
"firebaseMessaging",
"=",
"firebaseMessagingProvider",
".",
"get",
"(",
"context",
")",
";",
"for",
"(",
"String",
"catgory",
":",
"categories",
")",
"{",
"firebaseMessaging",
".",
"unsubscribeFromTopic",
"(",
"catgory",
")",
";",
"}",
"//Unsubscribe to generic topic",
"firebaseMessaging",
".",
"unsubscribeFromTopic",
"(",
"variantId",
")",
";",
"instanceId",
".",
"deleteInstanceId",
"(",
")",
";",
"HttpProvider",
"provider",
"=",
"httpProviderProvider",
".",
"get",
"(",
"deviceRegistryURL",
",",
"TIMEOUT",
")",
";",
"setPasswordAuthentication",
"(",
"variantId",
",",
"secret",
",",
"provider",
")",
";",
"try",
"{",
"provider",
".",
"delete",
"(",
"deviceToken",
")",
";",
"deviceToken",
"=",
"\"\"",
";",
"removeSavedPostData",
"(",
"context",
".",
"getApplicationContext",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"catch",
"(",
"HttpException",
"ex",
")",
"{",
"return",
"ex",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"return",
"ex",
";",
"}",
"}",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Override",
"protected",
"void",
"onPostExecute",
"(",
"Exception",
"result",
")",
"{",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"callback",
".",
"onSuccess",
"(",
"null",
")",
";",
"}",
"else",
"{",
"callback",
".",
"onFailure",
"(",
"result",
")",
";",
"}",
"}",
"}",
".",
"execute",
"(",
"(",
"Void",
")",
"null",
")",
";",
"}"
] |
Unregister device from Unified Push Server.
if the device isn't registered onFailure will be called
@param context Android application context
@param callback a callback.
|
[
"Unregister",
"device",
"from",
"Unified",
"Push",
"Server",
"."
] |
f21f93393a9f4590e9a8d6d045ab9aabca3d211f
|
https://github.com/aerogear/aerogear-android-push/blob/f21f93393a9f4590e9a8d6d045ab9aabca3d211f/library/src/main/java/org/jboss/aerogear/android/unifiedpush/fcm/AeroGearFCMPushRegistrar.java#L246-L303
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.