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
|
---|---|---|---|---|---|---|---|---|---|---|---|
6,000 |
GistLabs/mechanize
|
src/main/java/com/gistlabs/mechanize/document/json/hypermedia/JsonLink.java
|
JsonLink.linkRel
|
public String linkRel() {
if (this.linkRel!=null) return this.linkRel;
if (node.hasAttribute("rel")) return node.getAttribute("rel");
//else
return node.getName();
}
|
java
|
public String linkRel() {
if (this.linkRel!=null) return this.linkRel;
if (node.hasAttribute("rel")) return node.getAttribute("rel");
//else
return node.getName();
}
|
[
"public",
"String",
"linkRel",
"(",
")",
"{",
"if",
"(",
"this",
".",
"linkRel",
"!=",
"null",
")",
"return",
"this",
".",
"linkRel",
";",
"if",
"(",
"node",
".",
"hasAttribute",
"(",
"\"rel\"",
")",
")",
"return",
"node",
".",
"getAttribute",
"(",
"\"rel\"",
")",
";",
"//else ",
"return",
"node",
".",
"getName",
"(",
")",
";",
"}"
] |
the String name of the link relationship from this resource to the resource identified by the link
@return Either the linkRel arg at construction, the value of the "rel" attribute, or the name of the node itself.
|
[
"the",
"String",
"name",
"of",
"the",
"link",
"relationship",
"from",
"this",
"resource",
"to",
"the",
"resource",
"identified",
"by",
"the",
"link"
] |
32ddd0774439a4c08513c05d7ac7416a3899efed
|
https://github.com/GistLabs/mechanize/blob/32ddd0774439a4c08513c05d7ac7416a3899efed/src/main/java/com/gistlabs/mechanize/document/json/hypermedia/JsonLink.java#L61-L68
|
6,001 |
GistLabs/mechanize
|
src/main/java/com/gistlabs/mechanize/document/html/form/Form.java
|
Form.submit
|
@SuppressWarnings("unchecked")
private <T extends Resource> T submit(Form form, Parameters parameters) {
RequestBuilder<Resource> request = doRequest(form.getUri()).set(parameters);
boolean doPost = form.isDoPost();
boolean multiPart = form.isMultiPart();
if(doPost && multiPart) {
request.multiPart();
addFiles(request, form);
}
return (T) (doPost ? request.post() : request.get());
}
|
java
|
@SuppressWarnings("unchecked")
private <T extends Resource> T submit(Form form, Parameters parameters) {
RequestBuilder<Resource> request = doRequest(form.getUri()).set(parameters);
boolean doPost = form.isDoPost();
boolean multiPart = form.isMultiPart();
if(doPost && multiPart) {
request.multiPart();
addFiles(request, form);
}
return (T) (doPost ? request.post() : request.get());
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"<",
"T",
"extends",
"Resource",
">",
"T",
"submit",
"(",
"Form",
"form",
",",
"Parameters",
"parameters",
")",
"{",
"RequestBuilder",
"<",
"Resource",
">",
"request",
"=",
"doRequest",
"(",
"form",
".",
"getUri",
"(",
")",
")",
".",
"set",
"(",
"parameters",
")",
";",
"boolean",
"doPost",
"=",
"form",
".",
"isDoPost",
"(",
")",
";",
"boolean",
"multiPart",
"=",
"form",
".",
"isMultiPart",
"(",
")",
";",
"if",
"(",
"doPost",
"&&",
"multiPart",
")",
"{",
"request",
".",
"multiPart",
"(",
")",
";",
"addFiles",
"(",
"request",
",",
"form",
")",
";",
"}",
"return",
"(",
"T",
")",
"(",
"doPost",
"?",
"request",
".",
"post",
"(",
")",
":",
"request",
".",
"get",
"(",
")",
")",
";",
"}"
] |
Returns the page object received as response to the form submit action.
|
[
"Returns",
"the",
"page",
"object",
"received",
"as",
"response",
"to",
"the",
"form",
"submit",
"action",
"."
] |
32ddd0774439a4c08513c05d7ac7416a3899efed
|
https://github.com/GistLabs/mechanize/blob/32ddd0774439a4c08513c05d7ac7416a3899efed/src/main/java/com/gistlabs/mechanize/document/html/form/Form.java#L246-L256
|
6,002 |
GistLabs/mechanize
|
src/main/java/com/gistlabs/mechanize/document/html/form/Form.java
|
Form.composeParameters
|
private Parameters composeParameters(SubmitButton button, SubmitImage image, int x, int y) {
Parameters params = new Parameters();
for(FormElement element : this) {
String name = element.getName();
String value = element.getValue();
if(element instanceof Checkable) {
if(((Checkable)element).isChecked())
params.add(name, value != null ? value : "");
}
else if(element instanceof Select) {
Select select = (Select)element;
for(Select.Option option : select.getOptions())
if(option.isSelected())
params.add(select.getName(), option.getValue() != null ? option.getValue() : "");
}
else if(!(element instanceof SubmitButton) && !(element instanceof SubmitImage) && !(element instanceof Upload)) {
if(name != null)
params.add(name, value != null ? value : "");
}
}
if(button != null && button.getName() != null)
params.add(button.getName(), button.getValue() != null ? button.getValue() : "");
if(image != null) {
if(image.getValue() != null && image.getValue().length() > 1)
params.add(image.getName(), image.getValue());
params.add(image.getName() + ".x", "" + x);
params.add(image.getName() + ".y", "" + y);
}
return params;
}
|
java
|
private Parameters composeParameters(SubmitButton button, SubmitImage image, int x, int y) {
Parameters params = new Parameters();
for(FormElement element : this) {
String name = element.getName();
String value = element.getValue();
if(element instanceof Checkable) {
if(((Checkable)element).isChecked())
params.add(name, value != null ? value : "");
}
else if(element instanceof Select) {
Select select = (Select)element;
for(Select.Option option : select.getOptions())
if(option.isSelected())
params.add(select.getName(), option.getValue() != null ? option.getValue() : "");
}
else if(!(element instanceof SubmitButton) && !(element instanceof SubmitImage) && !(element instanceof Upload)) {
if(name != null)
params.add(name, value != null ? value : "");
}
}
if(button != null && button.getName() != null)
params.add(button.getName(), button.getValue() != null ? button.getValue() : "");
if(image != null) {
if(image.getValue() != null && image.getValue().length() > 1)
params.add(image.getName(), image.getValue());
params.add(image.getName() + ".x", "" + x);
params.add(image.getName() + ".y", "" + y);
}
return params;
}
|
[
"private",
"Parameters",
"composeParameters",
"(",
"SubmitButton",
"button",
",",
"SubmitImage",
"image",
",",
"int",
"x",
",",
"int",
"y",
")",
"{",
"Parameters",
"params",
"=",
"new",
"Parameters",
"(",
")",
";",
"for",
"(",
"FormElement",
"element",
":",
"this",
")",
"{",
"String",
"name",
"=",
"element",
".",
"getName",
"(",
")",
";",
"String",
"value",
"=",
"element",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"element",
"instanceof",
"Checkable",
")",
"{",
"if",
"(",
"(",
"(",
"Checkable",
")",
"element",
")",
".",
"isChecked",
"(",
")",
")",
"params",
".",
"add",
"(",
"name",
",",
"value",
"!=",
"null",
"?",
"value",
":",
"\"\"",
")",
";",
"}",
"else",
"if",
"(",
"element",
"instanceof",
"Select",
")",
"{",
"Select",
"select",
"=",
"(",
"Select",
")",
"element",
";",
"for",
"(",
"Select",
".",
"Option",
"option",
":",
"select",
".",
"getOptions",
"(",
")",
")",
"if",
"(",
"option",
".",
"isSelected",
"(",
")",
")",
"params",
".",
"add",
"(",
"select",
".",
"getName",
"(",
")",
",",
"option",
".",
"getValue",
"(",
")",
"!=",
"null",
"?",
"option",
".",
"getValue",
"(",
")",
":",
"\"\"",
")",
";",
"}",
"else",
"if",
"(",
"!",
"(",
"element",
"instanceof",
"SubmitButton",
")",
"&&",
"!",
"(",
"element",
"instanceof",
"SubmitImage",
")",
"&&",
"!",
"(",
"element",
"instanceof",
"Upload",
")",
")",
"{",
"if",
"(",
"name",
"!=",
"null",
")",
"params",
".",
"add",
"(",
"name",
",",
"value",
"!=",
"null",
"?",
"value",
":",
"\"\"",
")",
";",
"}",
"}",
"if",
"(",
"button",
"!=",
"null",
"&&",
"button",
".",
"getName",
"(",
")",
"!=",
"null",
")",
"params",
".",
"add",
"(",
"button",
".",
"getName",
"(",
")",
",",
"button",
".",
"getValue",
"(",
")",
"!=",
"null",
"?",
"button",
".",
"getValue",
"(",
")",
":",
"\"\"",
")",
";",
"if",
"(",
"image",
"!=",
"null",
")",
"{",
"if",
"(",
"image",
".",
"getValue",
"(",
")",
"!=",
"null",
"&&",
"image",
".",
"getValue",
"(",
")",
".",
"length",
"(",
")",
">",
"1",
")",
"params",
".",
"add",
"(",
"image",
".",
"getName",
"(",
")",
",",
"image",
".",
"getValue",
"(",
")",
")",
";",
"params",
".",
"add",
"(",
"image",
".",
"getName",
"(",
")",
"+",
"\".x\"",
",",
"\"\"",
"+",
"x",
")",
";",
"params",
".",
"add",
"(",
"image",
".",
"getName",
"(",
")",
"+",
"\".y\"",
",",
"\"\"",
"+",
"y",
")",
";",
"}",
"return",
"params",
";",
"}"
] |
Returns the parameters containing all name value params beside submit button, image button, unchecked radio
buttons and checkboxes and without Upload information.
|
[
"Returns",
"the",
"parameters",
"containing",
"all",
"name",
"value",
"params",
"beside",
"submit",
"button",
"image",
"button",
"unchecked",
"radio",
"buttons",
"and",
"checkboxes",
"and",
"without",
"Upload",
"information",
"."
] |
32ddd0774439a4c08513c05d7ac7416a3899efed
|
https://github.com/GistLabs/mechanize/blob/32ddd0774439a4c08513c05d7ac7416a3899efed/src/main/java/com/gistlabs/mechanize/document/html/form/Form.java#L272-L301
|
6,003 |
wirecardBrasil/moip-sdk-java
|
src/main/java/br/com/moip/api/request/RequestTools.java
|
RequestTools.getBody
|
String getBody(Object object, ContentType contentType) {
if (contentType == ContentType.APPLICATION_FORM_URLENCODED) {
return jsonToUrlEncodedString((JsonObject) new JsonParser().parse(gson.toJson(object)));
}
return gson.toJson(object);
}
|
java
|
String getBody(Object object, ContentType contentType) {
if (contentType == ContentType.APPLICATION_FORM_URLENCODED) {
return jsonToUrlEncodedString((JsonObject) new JsonParser().parse(gson.toJson(object)));
}
return gson.toJson(object);
}
|
[
"String",
"getBody",
"(",
"Object",
"object",
",",
"ContentType",
"contentType",
")",
"{",
"if",
"(",
"contentType",
"==",
"ContentType",
".",
"APPLICATION_FORM_URLENCODED",
")",
"{",
"return",
"jsonToUrlEncodedString",
"(",
"(",
"JsonObject",
")",
"new",
"JsonParser",
"(",
")",
".",
"parse",
"(",
"gson",
".",
"toJson",
"(",
"object",
")",
")",
")",
";",
"}",
"return",
"gson",
".",
"toJson",
"(",
"object",
")",
";",
"}"
] |
This method is used to get a serialized object into its equivalent JSON representation.
@param object
{@code Object} the body object.
@param contentType
{@ContentType} the content type header.
@return {@code String}
|
[
"This",
"method",
"is",
"used",
"to",
"get",
"a",
"serialized",
"object",
"into",
"its",
"equivalent",
"JSON",
"representation",
"."
] |
5bee84fa9457d7becfd18954bf5105037f49829c
|
https://github.com/wirecardBrasil/moip-sdk-java/blob/5bee84fa9457d7becfd18954bf5105037f49829c/src/main/java/br/com/moip/api/request/RequestTools.java#L62-L68
|
6,004 |
wirecardBrasil/moip-sdk-java
|
src/main/java/br/com/moip/api/response/Response.java
|
Response.jsonToMap
|
public Map<String, Object> jsonToMap(String json) {
/*
* This if block treats the /v2/accounts/exists response. Currently the endpoint returns the status
* code on its response body, breaking the JSON conversion.
*/
if ("200".equals(json)) {
this.responseBody.put("code", 200);
return this.responseBody;
}
if ("400".equals(json)) {
this.responseBody.put("code", 400);
return this.responseBody;
}
if ("404".equals(json)) {
this.responseBody.put("code", 404);
return this.responseBody;
}
if (!json.equals("")) {
ObjectMapper mapper = new ObjectMapper();
try {
this.responseBody = mapper.readValue(json, new TypeReference<Map<String, Object>>(){});
} catch (IOException e) {
e.printStackTrace();
}
}
return this.responseBody;
}
|
java
|
public Map<String, Object> jsonToMap(String json) {
/*
* This if block treats the /v2/accounts/exists response. Currently the endpoint returns the status
* code on its response body, breaking the JSON conversion.
*/
if ("200".equals(json)) {
this.responseBody.put("code", 200);
return this.responseBody;
}
if ("400".equals(json)) {
this.responseBody.put("code", 400);
return this.responseBody;
}
if ("404".equals(json)) {
this.responseBody.put("code", 404);
return this.responseBody;
}
if (!json.equals("")) {
ObjectMapper mapper = new ObjectMapper();
try {
this.responseBody = mapper.readValue(json, new TypeReference<Map<String, Object>>(){});
} catch (IOException e) {
e.printStackTrace();
}
}
return this.responseBody;
}
|
[
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"jsonToMap",
"(",
"String",
"json",
")",
"{",
"/*\n * This if block treats the /v2/accounts/exists response. Currently the endpoint returns the status\n * code on its response body, breaking the JSON conversion.\n */",
"if",
"(",
"\"200\"",
".",
"equals",
"(",
"json",
")",
")",
"{",
"this",
".",
"responseBody",
".",
"put",
"(",
"\"code\"",
",",
"200",
")",
";",
"return",
"this",
".",
"responseBody",
";",
"}",
"if",
"(",
"\"400\"",
".",
"equals",
"(",
"json",
")",
")",
"{",
"this",
".",
"responseBody",
".",
"put",
"(",
"\"code\"",
",",
"400",
")",
";",
"return",
"this",
".",
"responseBody",
";",
"}",
"if",
"(",
"\"404\"",
".",
"equals",
"(",
"json",
")",
")",
"{",
"this",
".",
"responseBody",
".",
"put",
"(",
"\"code\"",
",",
"404",
")",
";",
"return",
"this",
".",
"responseBody",
";",
"}",
"if",
"(",
"!",
"json",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"ObjectMapper",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
")",
";",
"try",
"{",
"this",
".",
"responseBody",
"=",
"mapper",
".",
"readValue",
"(",
"json",
",",
"new",
"TypeReference",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"return",
"this",
".",
"responseBody",
";",
"}"
] |
This method is used to receive the JSON returned from API and cast it to a Map.
@param json
{@code String} the JSON returned from API, by {@code InputStream}.
@return {@code Map}
|
[
"This",
"method",
"is",
"used",
"to",
"receive",
"the",
"JSON",
"returned",
"from",
"API",
"and",
"cast",
"it",
"to",
"a",
"Map",
"."
] |
5bee84fa9457d7becfd18954bf5105037f49829c
|
https://github.com/wirecardBrasil/moip-sdk-java/blob/5bee84fa9457d7becfd18954bf5105037f49829c/src/main/java/br/com/moip/api/response/Response.java#L25-L55
|
6,005 |
wirecardBrasil/moip-sdk-java
|
src/main/java/br/com/moip/models/Customers.java
|
Customers.deleteCreditCard
|
public Map<String, Object> deleteCreditCard(String creditCardId, Setup setup) {
this.requestMaker = new RequestMaker(setup);
RequestProperties props = new RequestPropertiesBuilder()
.method("DELETE")
.endpoint(String.format("/v2/fundinginstruments/%s", creditCardId))
.type(Customers.class)
.contentType(CONTENT_TYPE)
.build();
return this.requestMaker.doRequest(props);
}
|
java
|
public Map<String, Object> deleteCreditCard(String creditCardId, Setup setup) {
this.requestMaker = new RequestMaker(setup);
RequestProperties props = new RequestPropertiesBuilder()
.method("DELETE")
.endpoint(String.format("/v2/fundinginstruments/%s", creditCardId))
.type(Customers.class)
.contentType(CONTENT_TYPE)
.build();
return this.requestMaker.doRequest(props);
}
|
[
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"deleteCreditCard",
"(",
"String",
"creditCardId",
",",
"Setup",
"setup",
")",
"{",
"this",
".",
"requestMaker",
"=",
"new",
"RequestMaker",
"(",
"setup",
")",
";",
"RequestProperties",
"props",
"=",
"new",
"RequestPropertiesBuilder",
"(",
")",
".",
"method",
"(",
"\"DELETE\"",
")",
".",
"endpoint",
"(",
"String",
".",
"format",
"(",
"\"/v2/fundinginstruments/%s\"",
",",
"creditCardId",
")",
")",
".",
"type",
"(",
"Customers",
".",
"class",
")",
".",
"contentType",
"(",
"CONTENT_TYPE",
")",
".",
"build",
"(",
")",
";",
"return",
"this",
".",
"requestMaker",
".",
"doRequest",
"(",
"props",
")",
";",
"}"
] |
This method is used to delete a saved credit card of an customer.
@param creditCardId
{@code String} the Moip credit card external ID.
@param setup
{@code Setup} the setup object.
@return {@code Map<String, Object>}
|
[
"This",
"method",
"is",
"used",
"to",
"delete",
"a",
"saved",
"credit",
"card",
"of",
"an",
"customer",
"."
] |
5bee84fa9457d7becfd18954bf5105037f49829c
|
https://github.com/wirecardBrasil/moip-sdk-java/blob/5bee84fa9457d7becfd18954bf5105037f49829c/src/main/java/br/com/moip/models/Customers.java#L78-L88
|
6,006 |
wirecardBrasil/moip-sdk-java
|
src/main/java/br/com/moip/models/Accounts.java
|
Accounts.isTaxDocument
|
private boolean isTaxDocument(String argument) {
try {
Integer.parseInt(argument.substring(0,1));
} catch (Exception ex) {
return false;
}
return true;
}
|
java
|
private boolean isTaxDocument(String argument) {
try {
Integer.parseInt(argument.substring(0,1));
} catch (Exception ex) {
return false;
}
return true;
}
|
[
"private",
"boolean",
"isTaxDocument",
"(",
"String",
"argument",
")",
"{",
"try",
"{",
"Integer",
".",
"parseInt",
"(",
"argument",
".",
"substring",
"(",
"0",
",",
"1",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
This method is used to validate the argument of bellow method, if probably it's a tax document or not.
@param argument
{@code String} the received argument.
@return {@code boolean}
|
[
"This",
"method",
"is",
"used",
"to",
"validate",
"the",
"argument",
"of",
"bellow",
"method",
"if",
"probably",
"it",
"s",
"a",
"tax",
"document",
"or",
"not",
"."
] |
5bee84fa9457d7becfd18954bf5105037f49829c
|
https://github.com/wirecardBrasil/moip-sdk-java/blob/5bee84fa9457d7becfd18954bf5105037f49829c/src/main/java/br/com/moip/models/Accounts.java#L25-L32
|
6,007 |
wirecardBrasil/moip-sdk-java
|
src/main/java/br/com/moip/models/Accounts.java
|
Accounts.listBankAccounts
|
public List<Map<String, Object>> listBankAccounts(String moipAccountId, Setup setup) {
this.requestMaker = new RequestMaker(setup);
RequestProperties props = new RequestPropertiesBuilder()
.method("GET")
.endpoint(String.format("%s/%s/bankaccounts", ENDPOINT, moipAccountId))
.type(BankAccounts.class)
.contentType(CONTENT_TYPE)
.build();
return this.requestMaker.getList(props);
}
|
java
|
public List<Map<String, Object>> listBankAccounts(String moipAccountId, Setup setup) {
this.requestMaker = new RequestMaker(setup);
RequestProperties props = new RequestPropertiesBuilder()
.method("GET")
.endpoint(String.format("%s/%s/bankaccounts", ENDPOINT, moipAccountId))
.type(BankAccounts.class)
.contentType(CONTENT_TYPE)
.build();
return this.requestMaker.getList(props);
}
|
[
"public",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"listBankAccounts",
"(",
"String",
"moipAccountId",
",",
"Setup",
"setup",
")",
"{",
"this",
".",
"requestMaker",
"=",
"new",
"RequestMaker",
"(",
"setup",
")",
";",
"RequestProperties",
"props",
"=",
"new",
"RequestPropertiesBuilder",
"(",
")",
".",
"method",
"(",
"\"GET\"",
")",
".",
"endpoint",
"(",
"String",
".",
"format",
"(",
"\"%s/%s/bankaccounts\"",
",",
"ENDPOINT",
",",
"moipAccountId",
")",
")",
".",
"type",
"(",
"BankAccounts",
".",
"class",
")",
".",
"contentType",
"(",
"CONTENT_TYPE",
")",
".",
"build",
"(",
")",
";",
"return",
"this",
".",
"requestMaker",
".",
"getList",
"(",
"props",
")",
";",
"}"
] |
This method allows you to list all bank account of a Moip account.
@param moipAccountId
{@code String} the Moip account external ID.
@param setup
{@code Setup} the setup object.
@return {@code Map<String, Object>}
|
[
"This",
"method",
"allows",
"you",
"to",
"list",
"all",
"bank",
"account",
"of",
"a",
"Moip",
"account",
"."
] |
5bee84fa9457d7becfd18954bf5105037f49829c
|
https://github.com/wirecardBrasil/moip-sdk-java/blob/5bee84fa9457d7becfd18954bf5105037f49829c/src/main/java/br/com/moip/models/Accounts.java#L172-L182
|
6,008 |
PomepuyN/discreet-app-rate
|
DiscreetAppRate/src/main/java/fr/nicolaspomepuy/discreetapprate/AppRate.java
|
AppRate.reset
|
public void reset() {
if (debug) LogD("Count reset");
editor.putInt(KEY_COUNT, 0);
editor.putBoolean(KEY_CLICKED, false);
editor.putLong(KEY_LAST_CRASH, 0L);
commitEditor();
}
|
java
|
public void reset() {
if (debug) LogD("Count reset");
editor.putInt(KEY_COUNT, 0);
editor.putBoolean(KEY_CLICKED, false);
editor.putLong(KEY_LAST_CRASH, 0L);
commitEditor();
}
|
[
"public",
"void",
"reset",
"(",
")",
"{",
"if",
"(",
"debug",
")",
"LogD",
"(",
"\"Count reset\"",
")",
";",
"editor",
".",
"putInt",
"(",
"KEY_COUNT",
",",
"0",
")",
";",
"editor",
".",
"putBoolean",
"(",
"KEY_CLICKED",
",",
"false",
")",
";",
"editor",
".",
"putLong",
"(",
"KEY_LAST_CRASH",
",",
"0L",
")",
";",
"commitEditor",
"(",
")",
";",
"}"
] |
Reset the count to start over
|
[
"Reset",
"the",
"count",
"to",
"start",
"over"
] |
d9e007907d98191145f2b31057f0813e18bb320a
|
https://github.com/PomepuyN/discreet-app-rate/blob/d9e007907d98191145f2b31057f0813e18bb320a/DiscreetAppRate/src/main/java/fr/nicolaspomepuy/discreetapprate/AppRate.java#L420-L426
|
6,009 |
wirecardBrasil/moip-sdk-java
|
src/main/java/br/com/moip/models/NotificationPreferences.java
|
NotificationPreferences.list
|
public List<Map<String, Object>> list(Setup setup) {
this.requestMaker = new RequestMaker(setup);
RequestProperties props = new RequestPropertiesBuilder()
.method("GET")
.endpoint(ENDPOINT)
.type(NotificationPreferences.class)
.contentType(CONTENT_TYPE)
.build();
return this.requestMaker.getList(props);
}
|
java
|
public List<Map<String, Object>> list(Setup setup) {
this.requestMaker = new RequestMaker(setup);
RequestProperties props = new RequestPropertiesBuilder()
.method("GET")
.endpoint(ENDPOINT)
.type(NotificationPreferences.class)
.contentType(CONTENT_TYPE)
.build();
return this.requestMaker.getList(props);
}
|
[
"public",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"list",
"(",
"Setup",
"setup",
")",
"{",
"this",
".",
"requestMaker",
"=",
"new",
"RequestMaker",
"(",
"setup",
")",
";",
"RequestProperties",
"props",
"=",
"new",
"RequestPropertiesBuilder",
"(",
")",
".",
"method",
"(",
"\"GET\"",
")",
".",
"endpoint",
"(",
"ENDPOINT",
")",
".",
"type",
"(",
"NotificationPreferences",
".",
"class",
")",
".",
"contentType",
"(",
"CONTENT_TYPE",
")",
".",
"build",
"(",
")",
";",
"return",
"this",
".",
"requestMaker",
".",
"getList",
"(",
"props",
")",
";",
"}"
] |
This method is used to get all created notification preferences.
@param setup
{@code Setup} the setup object.
@return {@code List<Map<String, Object>>}
|
[
"This",
"method",
"is",
"used",
"to",
"get",
"all",
"created",
"notification",
"preferences",
"."
] |
5bee84fa9457d7becfd18954bf5105037f49829c
|
https://github.com/wirecardBrasil/moip-sdk-java/blob/5bee84fa9457d7becfd18954bf5105037f49829c/src/main/java/br/com/moip/models/NotificationPreferences.java#L72-L82
|
6,010 |
wirecardBrasil/moip-sdk-java
|
src/main/java/br/com/moip/api/request/RequestPropertiesBuilder.java
|
RequestPropertiesBuilder.acceptBuilder
|
private String acceptBuilder(String version) {
String acceptValue = "application/json";
if(version == "2.1") acceptValue += ";version=" + version;
return acceptValue;
}
|
java
|
private String acceptBuilder(String version) {
String acceptValue = "application/json";
if(version == "2.1") acceptValue += ";version=" + version;
return acceptValue;
}
|
[
"private",
"String",
"acceptBuilder",
"(",
"String",
"version",
")",
"{",
"String",
"acceptValue",
"=",
"\"application/json\"",
";",
"if",
"(",
"version",
"==",
"\"2.1\"",
")",
"acceptValue",
"+=",
"\";version=\"",
"+",
"version",
";",
"return",
"acceptValue",
";",
"}"
] |
This method is used to validate and build the accept JSON version.
@param version
{@code String} version
@return {@code String} the mounted header value
|
[
"This",
"method",
"is",
"used",
"to",
"validate",
"and",
"build",
"the",
"accept",
"JSON",
"version",
"."
] |
5bee84fa9457d7becfd18954bf5105037f49829c
|
https://github.com/wirecardBrasil/moip-sdk-java/blob/5bee84fa9457d7becfd18954bf5105037f49829c/src/main/java/br/com/moip/api/request/RequestPropertiesBuilder.java#L122-L127
|
6,011 |
wirecardBrasil/moip-sdk-java
|
src/main/java/br/com/moip/models/Escrows.java
|
Escrows.release
|
public Map<String, Object> release(String escrowId, Setup setup) {
this.requestMaker = new RequestMaker(setup);
RequestProperties props = new RequestPropertiesBuilder()
.method("POST")
.endpoint(String.format("%s/%s/release", ENDPOINT, escrowId))
.type(Escrows.class)
.contentType(CONTENT_TYPE)
.build();
return this.requestMaker.doRequest(props);
}
|
java
|
public Map<String, Object> release(String escrowId, Setup setup) {
this.requestMaker = new RequestMaker(setup);
RequestProperties props = new RequestPropertiesBuilder()
.method("POST")
.endpoint(String.format("%s/%s/release", ENDPOINT, escrowId))
.type(Escrows.class)
.contentType(CONTENT_TYPE)
.build();
return this.requestMaker.doRequest(props);
}
|
[
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"release",
"(",
"String",
"escrowId",
",",
"Setup",
"setup",
")",
"{",
"this",
".",
"requestMaker",
"=",
"new",
"RequestMaker",
"(",
"setup",
")",
";",
"RequestProperties",
"props",
"=",
"new",
"RequestPropertiesBuilder",
"(",
")",
".",
"method",
"(",
"\"POST\"",
")",
".",
"endpoint",
"(",
"String",
".",
"format",
"(",
"\"%s/%s/release\"",
",",
"ENDPOINT",
",",
"escrowId",
")",
")",
".",
"type",
"(",
"Escrows",
".",
"class",
")",
".",
"contentType",
"(",
"CONTENT_TYPE",
")",
".",
"build",
"(",
")",
";",
"return",
"this",
".",
"requestMaker",
".",
"doRequest",
"(",
"props",
")",
";",
"}"
] |
This method allows you to release a payment with escrow.
@param escrowId
{@code String} the Moip escrow external ID.
@param setup
{@code Setup} the setup object.
@return {@code Map<String, Object>}
|
[
"This",
"method",
"allows",
"you",
"to",
"release",
"a",
"payment",
"with",
"escrow",
"."
] |
5bee84fa9457d7becfd18954bf5105037f49829c
|
https://github.com/wirecardBrasil/moip-sdk-java/blob/5bee84fa9457d7becfd18954bf5105037f49829c/src/main/java/br/com/moip/models/Escrows.java#L27-L37
|
6,012 |
wirecardBrasil/moip-sdk-java
|
src/main/java/br/com/moip/models/Connect.java
|
Connect.buildUrl
|
public String buildUrl(String clientId, String redirectUri, String[] scope, Setup setup) {
String url = setup.getEnvironment() + "/oauth/authorize";
url += String.format("?response_type=code&client_id=%s&redirect_uri=%s&scope=", clientId, redirectUri);
for (Integer index = 0; index < scope.length; ++index) {
url += scope[index];
if ((index + 1) < scope.length) url += ',';
}
return url;
}
|
java
|
public String buildUrl(String clientId, String redirectUri, String[] scope, Setup setup) {
String url = setup.getEnvironment() + "/oauth/authorize";
url += String.format("?response_type=code&client_id=%s&redirect_uri=%s&scope=", clientId, redirectUri);
for (Integer index = 0; index < scope.length; ++index) {
url += scope[index];
if ((index + 1) < scope.length) url += ',';
}
return url;
}
|
[
"public",
"String",
"buildUrl",
"(",
"String",
"clientId",
",",
"String",
"redirectUri",
",",
"String",
"[",
"]",
"scope",
",",
"Setup",
"setup",
")",
"{",
"String",
"url",
"=",
"setup",
".",
"getEnvironment",
"(",
")",
"+",
"\"/oauth/authorize\"",
";",
"url",
"+=",
"String",
".",
"format",
"(",
"\"?response_type=code&client_id=%s&redirect_uri=%s&scope=\"",
",",
"clientId",
",",
"redirectUri",
")",
";",
"for",
"(",
"Integer",
"index",
"=",
"0",
";",
"index",
"<",
"scope",
".",
"length",
";",
"++",
"index",
")",
"{",
"url",
"+=",
"scope",
"[",
"index",
"]",
";",
"if",
"(",
"(",
"index",
"+",
"1",
")",
"<",
"scope",
".",
"length",
")",
"url",
"+=",
"'",
"'",
";",
"}",
"return",
"url",
";",
"}"
] |
This method is used to build the URL to request access permission for your seller.
@param clientId
{@code String} the APP ID.
@param redirectUri
{@code String} the address that you want to redirect your user after they grant the permission.
@param scope
{@code String array} the array of permissions that you want to request.
Ex: RECEIVE_FUNDS, MANAGE_ACCOUNT_INFO, TRANSFER_FUNDS...
@param setup
{@code Setup} the setup object.
@return {@code String}
|
[
"This",
"method",
"is",
"used",
"to",
"build",
"the",
"URL",
"to",
"request",
"access",
"permission",
"for",
"your",
"seller",
"."
] |
5bee84fa9457d7becfd18954bf5105037f49829c
|
https://github.com/wirecardBrasil/moip-sdk-java/blob/5bee84fa9457d7becfd18954bf5105037f49829c/src/main/java/br/com/moip/models/Connect.java#L34-L47
|
6,013 |
PomepuyN/discreet-app-rate
|
DiscreetAppRate/src/main/java/fr/nicolaspomepuy/discreetapprate/Utils.java
|
Utils.convertDPItoPixels
|
public static int convertDPItoPixels(Context context, int dpi) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpi * scale + 0.5f);
}
|
java
|
public static int convertDPItoPixels(Context context, int dpi) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpi * scale + 0.5f);
}
|
[
"public",
"static",
"int",
"convertDPItoPixels",
"(",
"Context",
"context",
",",
"int",
"dpi",
")",
"{",
"final",
"float",
"scale",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"getDisplayMetrics",
"(",
")",
".",
"density",
";",
"return",
"(",
"int",
")",
"(",
"dpi",
"*",
"scale",
"+",
"0.5f",
")",
";",
"}"
] |
Convert a size in dp to a size in pixels
@param context the {@link android.content.Context} to be used
@param dpi size in dp
@return the size in pixels
|
[
"Convert",
"a",
"size",
"in",
"dp",
"to",
"a",
"size",
"in",
"pixels"
] |
d9e007907d98191145f2b31057f0813e18bb320a
|
https://github.com/PomepuyN/discreet-app-rate/blob/d9e007907d98191145f2b31057f0813e18bb320a/DiscreetAppRate/src/main/java/fr/nicolaspomepuy/discreetapprate/Utils.java#L36-L39
|
6,014 |
wirecardBrasil/moip-sdk-java
|
src/main/java/br/com/moip/models/Payments.java
|
Payments.authorize
|
public Map<String, Object> authorize(String paymentId, int amount, Setup setup) {
if (setup.getEnvironment() == SANDBOX_URL) {
this.requestMaker = new RequestMaker(setup);
RequestProperties props = new RequestPropertiesBuilder()
.method("GET")
.endpoint(String.format("%s?payment_id=%s&amount=%s", ENDPOINT_TO_AUTHORIZE, paymentId, amount))
.type(Payments.class)
.contentType(CONTENT_TYPE)
.build();
return this.requestMaker.doRequest(props);
}
else {
ErrorBuilder error = new ErrorBuilder()
.code("404")
.path("")
.description("Wrong environment! Only payments created on Sandbox environment can be manually authorized.");
Errors errors = new Errors();
errors.setError(error);
throw new ValidationException(404, "Not Found", errors);
}
}
|
java
|
public Map<String, Object> authorize(String paymentId, int amount, Setup setup) {
if (setup.getEnvironment() == SANDBOX_URL) {
this.requestMaker = new RequestMaker(setup);
RequestProperties props = new RequestPropertiesBuilder()
.method("GET")
.endpoint(String.format("%s?payment_id=%s&amount=%s", ENDPOINT_TO_AUTHORIZE, paymentId, amount))
.type(Payments.class)
.contentType(CONTENT_TYPE)
.build();
return this.requestMaker.doRequest(props);
}
else {
ErrorBuilder error = new ErrorBuilder()
.code("404")
.path("")
.description("Wrong environment! Only payments created on Sandbox environment can be manually authorized.");
Errors errors = new Errors();
errors.setError(error);
throw new ValidationException(404, "Not Found", errors);
}
}
|
[
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"authorize",
"(",
"String",
"paymentId",
",",
"int",
"amount",
",",
"Setup",
"setup",
")",
"{",
"if",
"(",
"setup",
".",
"getEnvironment",
"(",
")",
"==",
"SANDBOX_URL",
")",
"{",
"this",
".",
"requestMaker",
"=",
"new",
"RequestMaker",
"(",
"setup",
")",
";",
"RequestProperties",
"props",
"=",
"new",
"RequestPropertiesBuilder",
"(",
")",
".",
"method",
"(",
"\"GET\"",
")",
".",
"endpoint",
"(",
"String",
".",
"format",
"(",
"\"%s?payment_id=%s&amount=%s\"",
",",
"ENDPOINT_TO_AUTHORIZE",
",",
"paymentId",
",",
"amount",
")",
")",
".",
"type",
"(",
"Payments",
".",
"class",
")",
".",
"contentType",
"(",
"CONTENT_TYPE",
")",
".",
"build",
"(",
")",
";",
"return",
"this",
".",
"requestMaker",
".",
"doRequest",
"(",
"props",
")",
";",
"}",
"else",
"{",
"ErrorBuilder",
"error",
"=",
"new",
"ErrorBuilder",
"(",
")",
".",
"code",
"(",
"\"404\"",
")",
".",
"path",
"(",
"\"\"",
")",
".",
"description",
"(",
"\"Wrong environment! Only payments created on Sandbox environment can be manually authorized.\"",
")",
";",
"Errors",
"errors",
"=",
"new",
"Errors",
"(",
")",
";",
"errors",
".",
"setError",
"(",
"error",
")",
";",
"throw",
"new",
"ValidationException",
"(",
"404",
",",
"\"Not Found\"",
",",
"errors",
")",
";",
"}",
"}"
] |
This method is used to simulate the payment authorization. To make it, its necessary
send the Moip payment external ID and the amount value.
WARNING: This method can be used to request only Sandbox environment.
@param paymentId
{@code String} the Moip payment external ID.
@param amount
{@code int} the amount value that will be authorized.
@param setup
{@code Setup} the setup obeject.
@return {@code Map<String, Object>}
|
[
"This",
"method",
"is",
"used",
"to",
"simulate",
"the",
"payment",
"authorization",
".",
"To",
"make",
"it",
"its",
"necessary",
"send",
"the",
"Moip",
"payment",
"external",
"ID",
"and",
"the",
"amount",
"value",
"."
] |
5bee84fa9457d7becfd18954bf5105037f49829c
|
https://github.com/wirecardBrasil/moip-sdk-java/blob/5bee84fa9457d7becfd18954bf5105037f49829c/src/main/java/br/com/moip/models/Payments.java#L137-L160
|
6,015 |
wirecardBrasil/moip-sdk-java
|
src/main/java/br/com/moip/helpers/PayloadFactory.java
|
PayloadFactory.payloadFactory
|
@SafeVarargs
public static Map<String, Object> payloadFactory(Map.Entry<String, Object>... entries) {
Map<String, Object> map = new HashMap<>();
for (Map.Entry<String, Object> entry : entries)
map.put(entry.getKey(), entry.getValue());
return Collections.unmodifiableMap(map);
}
|
java
|
@SafeVarargs
public static Map<String, Object> payloadFactory(Map.Entry<String, Object>... entries) {
Map<String, Object> map = new HashMap<>();
for (Map.Entry<String, Object> entry : entries)
map.put(entry.getKey(), entry.getValue());
return Collections.unmodifiableMap(map);
}
|
[
"@",
"SafeVarargs",
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"payloadFactory",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"...",
"entries",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"entries",
")",
"map",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"return",
"Collections",
".",
"unmodifiableMap",
"(",
"map",
")",
";",
"}"
] |
This method was created to simplify the construction of request payloads. However, the use of this method
shouldn't be compulsory and you can also use plain old Maps.
@param entries
{@code Map.Entry<String, Object>} the entries that will describe the request payload.
@return {@code Map<String, Object>}
|
[
"This",
"method",
"was",
"created",
"to",
"simplify",
"the",
"construction",
"of",
"request",
"payloads",
".",
"However",
"the",
"use",
"of",
"this",
"method",
"shouldn",
"t",
"be",
"compulsory",
"and",
"you",
"can",
"also",
"use",
"plain",
"old",
"Maps",
"."
] |
5bee84fa9457d7becfd18954bf5105037f49829c
|
https://github.com/wirecardBrasil/moip-sdk-java/blob/5bee84fa9457d7becfd18954bf5105037f49829c/src/main/java/br/com/moip/helpers/PayloadFactory.java#L19-L27
|
6,016 |
sdl/Testy
|
src/main/java/com/sdl/selenium/extjs3/panel/Panel.java
|
Panel.clickOnTool
|
public boolean clickOnTool(String id) {
ExtJsComponent toolElement = getToolElement(id).setVisibility(true);
return toolElement.click();
}
|
java
|
public boolean clickOnTool(String id) {
ExtJsComponent toolElement = getToolElement(id).setVisibility(true);
return toolElement.click();
}
|
[
"public",
"boolean",
"clickOnTool",
"(",
"String",
"id",
")",
"{",
"ExtJsComponent",
"toolElement",
"=",
"getToolElement",
"(",
"id",
")",
".",
"setVisibility",
"(",
"true",
")",
";",
"return",
"toolElement",
".",
"click",
"(",
")",
";",
"}"
] |
click on element with class "x-tool-" + id
@param id element
@return true | false
|
[
"click",
"on",
"element",
"with",
"class",
"x",
"-",
"tool",
"-",
"+",
"id"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/panel/Panel.java#L60-L63
|
6,017 |
sdl/Testy
|
src/main/java/com/sdl/selenium/WebLocatorSuggestions.java
|
WebLocatorSuggestions.proposeSolutions
|
private static void proposeSolutions(String[] dataSet, int k, int startPosition, String[] result, WebLocator webLocator) throws SolutionFoundException {
if (k == 0) {
validateSolution(webLocator, differences(dataSet, result));
return;
}
for (int i = startPosition; i <= dataSet.length - k; i++) {
result[result.length - k] = dataSet[i];
proposeSolutions(dataSet, k - 1, i + 1, result, webLocator);
}
}
|
java
|
private static void proposeSolutions(String[] dataSet, int k, int startPosition, String[] result, WebLocator webLocator) throws SolutionFoundException {
if (k == 0) {
validateSolution(webLocator, differences(dataSet, result));
return;
}
for (int i = startPosition; i <= dataSet.length - k; i++) {
result[result.length - k] = dataSet[i];
proposeSolutions(dataSet, k - 1, i + 1, result, webLocator);
}
}
|
[
"private",
"static",
"void",
"proposeSolutions",
"(",
"String",
"[",
"]",
"dataSet",
",",
"int",
"k",
",",
"int",
"startPosition",
",",
"String",
"[",
"]",
"result",
",",
"WebLocator",
"webLocator",
")",
"throws",
"SolutionFoundException",
"{",
"if",
"(",
"k",
"==",
"0",
")",
"{",
"validateSolution",
"(",
"webLocator",
",",
"differences",
"(",
"dataSet",
",",
"result",
")",
")",
";",
"return",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"startPosition",
";",
"i",
"<=",
"dataSet",
".",
"length",
"-",
"k",
";",
"i",
"++",
")",
"{",
"result",
"[",
"result",
".",
"length",
"-",
"k",
"]",
"=",
"dataSet",
"[",
"i",
"]",
";",
"proposeSolutions",
"(",
"dataSet",
",",
"k",
"-",
"1",
",",
"i",
"+",
"1",
",",
"result",
",",
"webLocator",
")",
";",
"}",
"}"
] |
Generates combinations of all objects from the dataSet taken k at a time.
Each combination is a possible solution that must be validated.
|
[
"Generates",
"combinations",
"of",
"all",
"objects",
"from",
"the",
"dataSet",
"taken",
"k",
"at",
"a",
"time",
".",
"Each",
"combination",
"is",
"a",
"possible",
"solution",
"that",
"must",
"be",
"validated",
"."
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/WebLocatorSuggestions.java#L357-L368
|
6,018 |
sdl/Testy
|
src/main/java/com/sdl/selenium/WebLocatorSuggestions.java
|
WebLocatorSuggestions.validateSolution
|
private static void validateSolution(WebLocator webLocator, String[] differences) throws SolutionFoundException {
//all changes will be recorded here in a human readable form
StringBuilder sb = new StringBuilder();
//all changes will be kept here and restored after the xPath is generated.
Map<String, Object> backup = new HashMap<>();
XPathBuilder builder = webLocator.getPathBuilder();
for (String fieldName : differences) {
try {
Field field = XPathBuilder.class.getDeclaredField(fieldName);
field.setAccessible(true);
Object fieldValue = field.get(builder);
switch (fieldName) {
case "root":
field.set(builder, "//");
break;
case "tag":
field.set(builder, "*");
break;
case "visibility":
field.set(builder, false);
break;
case "labelTag":
field.set(builder, "label");
break;
case "labelPosition":
field.set(builder, WebLocatorConfig.getDefaultLabelPosition());
break;
case "position":
field.set(builder, -1);
break;
case "resultIdx":
field.set(builder, -1);
break;
default:
field.set(builder, null);
}
backup.put(fieldName, fieldValue);
sb.append(String.format("set%s(\"%s\") and ", capitalize(fieldName), fieldValue));
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
//this is not a valid solution. nothing to do here.
}
}
int matches = webLocator.size();
if (matches > 0) {
//remove last 'and' from the message
if (sb.lastIndexOf("and") > 0) {
sb.replace(sb.lastIndexOf("and"), sb.length(), "");
}
LOGGER.warn("Found {} matches by removing {}: \n{}", matches, sb.toString(), getMatchedElementsHtml(webLocator));
throw new SolutionFoundException();
}
//restore the original builder from the backup
for (String fieldName : differences) {
try {
Field field = XPathBuilder.class.getDeclaredField(fieldName);
field.setAccessible(true);
field.set(builder, backup.get(fieldName));
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
}
}
|
java
|
private static void validateSolution(WebLocator webLocator, String[] differences) throws SolutionFoundException {
//all changes will be recorded here in a human readable form
StringBuilder sb = new StringBuilder();
//all changes will be kept here and restored after the xPath is generated.
Map<String, Object> backup = new HashMap<>();
XPathBuilder builder = webLocator.getPathBuilder();
for (String fieldName : differences) {
try {
Field field = XPathBuilder.class.getDeclaredField(fieldName);
field.setAccessible(true);
Object fieldValue = field.get(builder);
switch (fieldName) {
case "root":
field.set(builder, "//");
break;
case "tag":
field.set(builder, "*");
break;
case "visibility":
field.set(builder, false);
break;
case "labelTag":
field.set(builder, "label");
break;
case "labelPosition":
field.set(builder, WebLocatorConfig.getDefaultLabelPosition());
break;
case "position":
field.set(builder, -1);
break;
case "resultIdx":
field.set(builder, -1);
break;
default:
field.set(builder, null);
}
backup.put(fieldName, fieldValue);
sb.append(String.format("set%s(\"%s\") and ", capitalize(fieldName), fieldValue));
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
//this is not a valid solution. nothing to do here.
}
}
int matches = webLocator.size();
if (matches > 0) {
//remove last 'and' from the message
if (sb.lastIndexOf("and") > 0) {
sb.replace(sb.lastIndexOf("and"), sb.length(), "");
}
LOGGER.warn("Found {} matches by removing {}: \n{}", matches, sb.toString(), getMatchedElementsHtml(webLocator));
throw new SolutionFoundException();
}
//restore the original builder from the backup
for (String fieldName : differences) {
try {
Field field = XPathBuilder.class.getDeclaredField(fieldName);
field.setAccessible(true);
field.set(builder, backup.get(fieldName));
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
}
}
|
[
"private",
"static",
"void",
"validateSolution",
"(",
"WebLocator",
"webLocator",
",",
"String",
"[",
"]",
"differences",
")",
"throws",
"SolutionFoundException",
"{",
"//all changes will be recorded here in a human readable form",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"//all changes will be kept here and restored after the xPath is generated.",
"Map",
"<",
"String",
",",
"Object",
">",
"backup",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"XPathBuilder",
"builder",
"=",
"webLocator",
".",
"getPathBuilder",
"(",
")",
";",
"for",
"(",
"String",
"fieldName",
":",
"differences",
")",
"{",
"try",
"{",
"Field",
"field",
"=",
"XPathBuilder",
".",
"class",
".",
"getDeclaredField",
"(",
"fieldName",
")",
";",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"Object",
"fieldValue",
"=",
"field",
".",
"get",
"(",
"builder",
")",
";",
"switch",
"(",
"fieldName",
")",
"{",
"case",
"\"root\"",
":",
"field",
".",
"set",
"(",
"builder",
",",
"\"//\"",
")",
";",
"break",
";",
"case",
"\"tag\"",
":",
"field",
".",
"set",
"(",
"builder",
",",
"\"*\"",
")",
";",
"break",
";",
"case",
"\"visibility\"",
":",
"field",
".",
"set",
"(",
"builder",
",",
"false",
")",
";",
"break",
";",
"case",
"\"labelTag\"",
":",
"field",
".",
"set",
"(",
"builder",
",",
"\"label\"",
")",
";",
"break",
";",
"case",
"\"labelPosition\"",
":",
"field",
".",
"set",
"(",
"builder",
",",
"WebLocatorConfig",
".",
"getDefaultLabelPosition",
"(",
")",
")",
";",
"break",
";",
"case",
"\"position\"",
":",
"field",
".",
"set",
"(",
"builder",
",",
"-",
"1",
")",
";",
"break",
";",
"case",
"\"resultIdx\"",
":",
"field",
".",
"set",
"(",
"builder",
",",
"-",
"1",
")",
";",
"break",
";",
"default",
":",
"field",
".",
"set",
"(",
"builder",
",",
"null",
")",
";",
"}",
"backup",
".",
"put",
"(",
"fieldName",
",",
"fieldValue",
")",
";",
"sb",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"set%s(\\\"%s\\\") and \"",
",",
"capitalize",
"(",
"fieldName",
")",
",",
"fieldValue",
")",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"NoSuchFieldException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"//this is not a valid solution. nothing to do here.",
"}",
"}",
"int",
"matches",
"=",
"webLocator",
".",
"size",
"(",
")",
";",
"if",
"(",
"matches",
">",
"0",
")",
"{",
"//remove last 'and' from the message",
"if",
"(",
"sb",
".",
"lastIndexOf",
"(",
"\"and\"",
")",
">",
"0",
")",
"{",
"sb",
".",
"replace",
"(",
"sb",
".",
"lastIndexOf",
"(",
"\"and\"",
")",
",",
"sb",
".",
"length",
"(",
")",
",",
"\"\"",
")",
";",
"}",
"LOGGER",
".",
"warn",
"(",
"\"Found {} matches by removing {}: \\n{}\"",
",",
"matches",
",",
"sb",
".",
"toString",
"(",
")",
",",
"getMatchedElementsHtml",
"(",
"webLocator",
")",
")",
";",
"throw",
"new",
"SolutionFoundException",
"(",
")",
";",
"}",
"//restore the original builder from the backup",
"for",
"(",
"String",
"fieldName",
":",
"differences",
")",
"{",
"try",
"{",
"Field",
"field",
"=",
"XPathBuilder",
".",
"class",
".",
"getDeclaredField",
"(",
"fieldName",
")",
";",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"field",
".",
"set",
"(",
"builder",
",",
"backup",
".",
"get",
"(",
"fieldName",
")",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"NoSuchFieldException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}"
] |
Nullifies all fields of the builder that are not part of the proposed solution and validates the new xPath.
|
[
"Nullifies",
"all",
"fields",
"of",
"the",
"builder",
"that",
"are",
"not",
"part",
"of",
"the",
"proposed",
"solution",
"and",
"validates",
"the",
"new",
"xPath",
"."
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/WebLocatorSuggestions.java#L373-L451
|
6,019 |
sdl/Testy
|
src/main/java/com/sdl/selenium/WebLocatorSuggestions.java
|
WebLocatorSuggestions.differences
|
private static String[] differences(String[] first, String[] second) {
String[] sortedFirst = Arrays.copyOf(first, first.length); // O(n)
String[] sortedSecond = Arrays.copyOf(second, second.length); // O(m)
Arrays.sort(sortedFirst); // O(n log n)
Arrays.sort(sortedSecond); // O(m log m)
int firstIndex = 0;
int secondIndex = 0;
LinkedList<String> diffs = new LinkedList<>();
while (firstIndex < sortedFirst.length && secondIndex < sortedSecond.length) {
int compare = (int) Math.signum(sortedFirst[firstIndex].compareTo(sortedSecond[secondIndex]));
switch (compare) {
case -1:
diffs.add(sortedFirst[firstIndex]);
firstIndex++;
break;
case 1:
diffs.add(sortedSecond[secondIndex]);
secondIndex++;
break;
default:
firstIndex++;
secondIndex++;
}
}
String[] strDups = new String[diffs.size()];
return diffs.toArray(strDups);
}
|
java
|
private static String[] differences(String[] first, String[] second) {
String[] sortedFirst = Arrays.copyOf(first, first.length); // O(n)
String[] sortedSecond = Arrays.copyOf(second, second.length); // O(m)
Arrays.sort(sortedFirst); // O(n log n)
Arrays.sort(sortedSecond); // O(m log m)
int firstIndex = 0;
int secondIndex = 0;
LinkedList<String> diffs = new LinkedList<>();
while (firstIndex < sortedFirst.length && secondIndex < sortedSecond.length) {
int compare = (int) Math.signum(sortedFirst[firstIndex].compareTo(sortedSecond[secondIndex]));
switch (compare) {
case -1:
diffs.add(sortedFirst[firstIndex]);
firstIndex++;
break;
case 1:
diffs.add(sortedSecond[secondIndex]);
secondIndex++;
break;
default:
firstIndex++;
secondIndex++;
}
}
String[] strDups = new String[diffs.size()];
return diffs.toArray(strDups);
}
|
[
"private",
"static",
"String",
"[",
"]",
"differences",
"(",
"String",
"[",
"]",
"first",
",",
"String",
"[",
"]",
"second",
")",
"{",
"String",
"[",
"]",
"sortedFirst",
"=",
"Arrays",
".",
"copyOf",
"(",
"first",
",",
"first",
".",
"length",
")",
";",
"// O(n)",
"String",
"[",
"]",
"sortedSecond",
"=",
"Arrays",
".",
"copyOf",
"(",
"second",
",",
"second",
".",
"length",
")",
";",
"// O(m)",
"Arrays",
".",
"sort",
"(",
"sortedFirst",
")",
";",
"// O(n log n)",
"Arrays",
".",
"sort",
"(",
"sortedSecond",
")",
";",
"// O(m log m)",
"int",
"firstIndex",
"=",
"0",
";",
"int",
"secondIndex",
"=",
"0",
";",
"LinkedList",
"<",
"String",
">",
"diffs",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"while",
"(",
"firstIndex",
"<",
"sortedFirst",
".",
"length",
"&&",
"secondIndex",
"<",
"sortedSecond",
".",
"length",
")",
"{",
"int",
"compare",
"=",
"(",
"int",
")",
"Math",
".",
"signum",
"(",
"sortedFirst",
"[",
"firstIndex",
"]",
".",
"compareTo",
"(",
"sortedSecond",
"[",
"secondIndex",
"]",
")",
")",
";",
"switch",
"(",
"compare",
")",
"{",
"case",
"-",
"1",
":",
"diffs",
".",
"add",
"(",
"sortedFirst",
"[",
"firstIndex",
"]",
")",
";",
"firstIndex",
"++",
";",
"break",
";",
"case",
"1",
":",
"diffs",
".",
"add",
"(",
"sortedSecond",
"[",
"secondIndex",
"]",
")",
";",
"secondIndex",
"++",
";",
"break",
";",
"default",
":",
"firstIndex",
"++",
";",
"secondIndex",
"++",
";",
"}",
"}",
"String",
"[",
"]",
"strDups",
"=",
"new",
"String",
"[",
"diffs",
".",
"size",
"(",
")",
"]",
";",
"return",
"diffs",
".",
"toArray",
"(",
"strDups",
")",
";",
"}"
] |
Returns an array that contains all differences between first and second.
|
[
"Returns",
"an",
"array",
"that",
"contains",
"all",
"differences",
"between",
"first",
"and",
"second",
"."
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/WebLocatorSuggestions.java#L458-L491
|
6,020 |
sdl/Testy
|
src/main/java/com/sdl/selenium/web/XPathBuilder.java
|
XPathBuilder.getBasePathSelector
|
protected String getBasePathSelector() {
// TODO use disabled
// TODO verify what need to be equal OR contains
List<String> selector = new ArrayList<>();
CollectionUtils.addIgnoreNull(selector, getBasePath());
if (!WebDriverConfig.isIE()) {
if (hasStyle()) {
selector.add(applyTemplate("style", getStyle()));
}
// TODO make specific for WebLocator
if (isVisibility()) {
// TODO selector.append(" and count(ancestor-or-self::*[contains(replace(@style, '\s*:\s*', ':'), 'display:none')]) = 0");
CollectionUtils.addIgnoreNull(selector, applyTemplate("visibility", isVisibility()));
}
}
return selector.isEmpty() ? "" : String.join(" and ", selector);
}
|
java
|
protected String getBasePathSelector() {
// TODO use disabled
// TODO verify what need to be equal OR contains
List<String> selector = new ArrayList<>();
CollectionUtils.addIgnoreNull(selector, getBasePath());
if (!WebDriverConfig.isIE()) {
if (hasStyle()) {
selector.add(applyTemplate("style", getStyle()));
}
// TODO make specific for WebLocator
if (isVisibility()) {
// TODO selector.append(" and count(ancestor-or-self::*[contains(replace(@style, '\s*:\s*', ':'), 'display:none')]) = 0");
CollectionUtils.addIgnoreNull(selector, applyTemplate("visibility", isVisibility()));
}
}
return selector.isEmpty() ? "" : String.join(" and ", selector);
}
|
[
"protected",
"String",
"getBasePathSelector",
"(",
")",
"{",
"// TODO use disabled",
"// TODO verify what need to be equal OR contains",
"List",
"<",
"String",
">",
"selector",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"CollectionUtils",
".",
"addIgnoreNull",
"(",
"selector",
",",
"getBasePath",
"(",
")",
")",
";",
"if",
"(",
"!",
"WebDriverConfig",
".",
"isIE",
"(",
")",
")",
"{",
"if",
"(",
"hasStyle",
"(",
")",
")",
"{",
"selector",
".",
"add",
"(",
"applyTemplate",
"(",
"\"style\"",
",",
"getStyle",
"(",
")",
")",
")",
";",
"}",
"// TODO make specific for WebLocator",
"if",
"(",
"isVisibility",
"(",
")",
")",
"{",
"// TODO selector.append(\" and count(ancestor-or-self::*[contains(replace(@style, '\\s*:\\s*', ':'), 'display:none')]) = 0\");",
"CollectionUtils",
".",
"addIgnoreNull",
"(",
"selector",
",",
"applyTemplate",
"(",
"\"visibility\"",
",",
"isVisibility",
"(",
")",
")",
")",
";",
"}",
"}",
"return",
"selector",
".",
"isEmpty",
"(",
")",
"?",
"\"\"",
":",
"String",
".",
"join",
"(",
"\" and \"",
",",
"selector",
")",
";",
"}"
] |
Containing baseCls, class, name and style
@return baseSelector
|
[
"Containing",
"baseCls",
"class",
"name",
"and",
"style"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/web/XPathBuilder.java#L766-L784
|
6,021 |
sdl/Testy
|
src/main/java/com/sdl/selenium/web/XPathBuilder.java
|
XPathBuilder.getItemPath
|
protected String getItemPath(boolean disabled) {
String selector = getBaseItemPath();
String subPath = applyTemplateValue(disabled ? "disabled" : "enabled");
if (subPath != null) {
selector += !Strings.isNullOrEmpty(selector) ? " and " + subPath : subPath;
}
Map<String, String[]> templatesValues = getTemplatesValues();
String[] tagAndPositions = templatesValues.get("tagAndPosition");
List<String> tagAndPosition = new ArrayList<>();
if (tagAndPositions != null) {
tagAndPosition.addAll(Arrays.asList(tagAndPositions));
tagAndPosition.add(0, getTag());
}
String tag;
if (!tagAndPosition.isEmpty()) {
tag = applyTemplate("tagAndPosition", tagAndPosition.toArray());
} else {
tag = getTag();
}
selector = getRoot() + tag + (!Strings.isNullOrEmpty(selector) ? "[" + selector + "]" : "");
return selector;
}
|
java
|
protected String getItemPath(boolean disabled) {
String selector = getBaseItemPath();
String subPath = applyTemplateValue(disabled ? "disabled" : "enabled");
if (subPath != null) {
selector += !Strings.isNullOrEmpty(selector) ? " and " + subPath : subPath;
}
Map<String, String[]> templatesValues = getTemplatesValues();
String[] tagAndPositions = templatesValues.get("tagAndPosition");
List<String> tagAndPosition = new ArrayList<>();
if (tagAndPositions != null) {
tagAndPosition.addAll(Arrays.asList(tagAndPositions));
tagAndPosition.add(0, getTag());
}
String tag;
if (!tagAndPosition.isEmpty()) {
tag = applyTemplate("tagAndPosition", tagAndPosition.toArray());
} else {
tag = getTag();
}
selector = getRoot() + tag + (!Strings.isNullOrEmpty(selector) ? "[" + selector + "]" : "");
return selector;
}
|
[
"protected",
"String",
"getItemPath",
"(",
"boolean",
"disabled",
")",
"{",
"String",
"selector",
"=",
"getBaseItemPath",
"(",
")",
";",
"String",
"subPath",
"=",
"applyTemplateValue",
"(",
"disabled",
"?",
"\"disabled\"",
":",
"\"enabled\"",
")",
";",
"if",
"(",
"subPath",
"!=",
"null",
")",
"{",
"selector",
"+=",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
"selector",
")",
"?",
"\" and \"",
"+",
"subPath",
":",
"subPath",
";",
"}",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"templatesValues",
"=",
"getTemplatesValues",
"(",
")",
";",
"String",
"[",
"]",
"tagAndPositions",
"=",
"templatesValues",
".",
"get",
"(",
"\"tagAndPosition\"",
")",
";",
"List",
"<",
"String",
">",
"tagAndPosition",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"tagAndPositions",
"!=",
"null",
")",
"{",
"tagAndPosition",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"tagAndPositions",
")",
")",
";",
"tagAndPosition",
".",
"add",
"(",
"0",
",",
"getTag",
"(",
")",
")",
";",
"}",
"String",
"tag",
";",
"if",
"(",
"!",
"tagAndPosition",
".",
"isEmpty",
"(",
")",
")",
"{",
"tag",
"=",
"applyTemplate",
"(",
"\"tagAndPosition\"",
",",
"tagAndPosition",
".",
"toArray",
"(",
")",
")",
";",
"}",
"else",
"{",
"tag",
"=",
"getTag",
"(",
")",
";",
"}",
"selector",
"=",
"getRoot",
"(",
")",
"+",
"tag",
"+",
"(",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
"selector",
")",
"?",
"\"[\"",
"+",
"selector",
"+",
"\"]\"",
":",
"\"\"",
")",
";",
"return",
"selector",
";",
"}"
] |
this method is meant to be overridden by each component
@param disabled disabled
@return String
|
[
"this",
"method",
"is",
"meant",
"to",
"be",
"overridden",
"by",
"each",
"component"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/web/XPathBuilder.java#L950-L971
|
6,022 |
sdl/Testy
|
src/main/java/com/sdl/selenium/extjs3/button/Button.java
|
Button.clickWithExtJS
|
public boolean clickWithExtJS() {
String id = getAttributeId();
if (hasId(id)) {
String script = "return (function(){var b = Ext.getCmp('" + id + "'); if(b) {b.onClick({preventDefault:function(){},button:0}); return true;} return false;})()";
Object object = WebLocatorUtils.doExecuteScript(script);
LOGGER.info("clickWithExtJS on {}; result: {}", toString(), object);
return (Boolean) object;
}
LOGGER.debug("id is: " + id);
return false;
}
|
java
|
public boolean clickWithExtJS() {
String id = getAttributeId();
if (hasId(id)) {
String script = "return (function(){var b = Ext.getCmp('" + id + "'); if(b) {b.onClick({preventDefault:function(){},button:0}); return true;} return false;})()";
Object object = WebLocatorUtils.doExecuteScript(script);
LOGGER.info("clickWithExtJS on {}; result: {}", toString(), object);
return (Boolean) object;
}
LOGGER.debug("id is: " + id);
return false;
}
|
[
"public",
"boolean",
"clickWithExtJS",
"(",
")",
"{",
"String",
"id",
"=",
"getAttributeId",
"(",
")",
";",
"if",
"(",
"hasId",
"(",
"id",
")",
")",
"{",
"String",
"script",
"=",
"\"return (function(){var b = Ext.getCmp('\"",
"+",
"id",
"+",
"\"'); if(b) {b.onClick({preventDefault:function(){},button:0}); return true;} return false;})()\"",
";",
"Object",
"object",
"=",
"WebLocatorUtils",
".",
"doExecuteScript",
"(",
"script",
")",
";",
"LOGGER",
".",
"info",
"(",
"\"clickWithExtJS on {}; result: {}\"",
",",
"toString",
"(",
")",
",",
"object",
")",
";",
"return",
"(",
"Boolean",
")",
"object",
";",
"}",
"LOGGER",
".",
"debug",
"(",
"\"id is: \"",
"+",
"id",
")",
";",
"return",
"false",
";",
"}"
] |
TO Be used in extreme cases when simple .click is not working
@return true or false
|
[
"TO",
"Be",
"used",
"in",
"extreme",
"cases",
"when",
"simple",
".",
"click",
"is",
"not",
"working"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/button/Button.java#L90-L100
|
6,023 |
sdl/Testy
|
src/main/java/com/sdl/selenium/extjs3/conditions/ExtjsConditionManager.java
|
ExtjsConditionManager.addFailConditions
|
public ExtjsConditionManager addFailConditions(String... messages) {
for (String message : messages) {
if (message != null && message.length() > 0) {
this.add(new MessageBoxFailCondition(message));
}
}
return this;
}
|
java
|
public ExtjsConditionManager addFailConditions(String... messages) {
for (String message : messages) {
if (message != null && message.length() > 0) {
this.add(new MessageBoxFailCondition(message));
}
}
return this;
}
|
[
"public",
"ExtjsConditionManager",
"addFailConditions",
"(",
"String",
"...",
"messages",
")",
"{",
"for",
"(",
"String",
"message",
":",
"messages",
")",
"{",
"if",
"(",
"message",
"!=",
"null",
"&&",
"message",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"this",
".",
"add",
"(",
"new",
"MessageBoxFailCondition",
"(",
"message",
")",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] |
add each message to MessageBoxFailCondition
@param messages messages
@return this
|
[
"add",
"each",
"message",
"to",
"MessageBoxFailCondition"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/conditions/ExtjsConditionManager.java#L82-L89
|
6,024 |
sdl/Testy
|
src/main/java/com/sdl/selenium/extjs3/conditions/ExtjsConditionManager.java
|
ExtjsConditionManager.addSuccessConditions
|
public ExtjsConditionManager addSuccessConditions(String... messages) {
for (String message : messages) {
if (message != null && message.length() > 0) {
this.add(new MessageBoxSuccessCondition(message));
}
}
return this;
}
|
java
|
public ExtjsConditionManager addSuccessConditions(String... messages) {
for (String message : messages) {
if (message != null && message.length() > 0) {
this.add(new MessageBoxSuccessCondition(message));
}
}
return this;
}
|
[
"public",
"ExtjsConditionManager",
"addSuccessConditions",
"(",
"String",
"...",
"messages",
")",
"{",
"for",
"(",
"String",
"message",
":",
"messages",
")",
"{",
"if",
"(",
"message",
"!=",
"null",
"&&",
"message",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"this",
".",
"add",
"(",
"new",
"MessageBoxSuccessCondition",
"(",
"message",
")",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] |
add each message to MessageBoxSuccessCondition
@param messages messages
@return this
|
[
"add",
"each",
"message",
"to",
"MessageBoxSuccessCondition"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/conditions/ExtjsConditionManager.java#L97-L104
|
6,025 |
sdl/Testy
|
src/main/java/com/sdl/selenium/extjs3/grid/GridPanel.java
|
GridPanel.getAttrId
|
protected String getAttrId() {
String id = getAttributeId();
assertThat(MessageFormat.format("{0} id is null. The path is: {1}", getPathBuilder().getClassName(), getXPath()), id, notNullValue());
return id;
}
|
java
|
protected String getAttrId() {
String id = getAttributeId();
assertThat(MessageFormat.format("{0} id is null. The path is: {1}", getPathBuilder().getClassName(), getXPath()), id, notNullValue());
return id;
}
|
[
"protected",
"String",
"getAttrId",
"(",
")",
"{",
"String",
"id",
"=",
"getAttributeId",
"(",
")",
";",
"assertThat",
"(",
"MessageFormat",
".",
"format",
"(",
"\"{0} id is null. The path is: {1}\"",
",",
"getPathBuilder",
"(",
")",
".",
"getClassName",
"(",
")",
",",
"getXPath",
"(",
")",
")",
",",
"id",
",",
"notNullValue",
"(",
")",
")",
";",
"return",
"id",
";",
"}"
] |
Will Fail if id is null
@return attribute
|
[
"Will",
"Fail",
"if",
"id",
"is",
"null"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/grid/GridPanel.java#L148-L152
|
6,026 |
sdl/Testy
|
src/main/java/com/sdl/selenium/extjs3/grid/GridPanel.java
|
GridPanel.isCellPresent
|
public boolean isCellPresent(String searchElement, int columnId, SearchType... searchTypes) {
ready();
GridCell cell = new GridCell(columnId, searchElement, searchTypes).setContainer(this);
boolean selected;
do {
selected = cell.isElementPresent();
} while (!selected && scrollPageDown());
return selected;
}
|
java
|
public boolean isCellPresent(String searchElement, int columnId, SearchType... searchTypes) {
ready();
GridCell cell = new GridCell(columnId, searchElement, searchTypes).setContainer(this);
boolean selected;
do {
selected = cell.isElementPresent();
} while (!selected && scrollPageDown());
return selected;
}
|
[
"public",
"boolean",
"isCellPresent",
"(",
"String",
"searchElement",
",",
"int",
"columnId",
",",
"SearchType",
"...",
"searchTypes",
")",
"{",
"ready",
"(",
")",
";",
"GridCell",
"cell",
"=",
"new",
"GridCell",
"(",
"columnId",
",",
"searchElement",
",",
"searchTypes",
")",
".",
"setContainer",
"(",
"this",
")",
";",
"boolean",
"selected",
";",
"do",
"{",
"selected",
"=",
"cell",
".",
"isElementPresent",
"(",
")",
";",
"}",
"while",
"(",
"!",
"selected",
"&&",
"scrollPageDown",
"(",
")",
")",
";",
"return",
"selected",
";",
"}"
] |
Scroll Page Down to find the cell. If you found it return true, if not return false.
@param searchElement searchElement
@param columnId columnId
@param searchTypes SearchType.EQUALS
@return true or false
|
[
"Scroll",
"Page",
"Down",
"to",
"find",
"the",
"cell",
".",
"If",
"you",
"found",
"it",
"return",
"true",
"if",
"not",
"return",
"false",
"."
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/grid/GridPanel.java#L267-L275
|
6,027 |
sdl/Testy
|
src/main/java/com/sdl/selenium/extjs3/grid/GridPanel.java
|
GridPanel.isRowPresent
|
public boolean isRowPresent(String searchElement) {
ready();
boolean found;
GridCell cell = getCell(searchElement);
// scrollTop(); // make sure always start from top then scroll down till the end of the page
// do {
// if the row is not in visible (need to scroll down - errors when used BufferView in grid)
found = cell.isElementPresent();
// } while(!found && scrollPageDown());
return found;
}
|
java
|
public boolean isRowPresent(String searchElement) {
ready();
boolean found;
GridCell cell = getCell(searchElement);
// scrollTop(); // make sure always start from top then scroll down till the end of the page
// do {
// if the row is not in visible (need to scroll down - errors when used BufferView in grid)
found = cell.isElementPresent();
// } while(!found && scrollPageDown());
return found;
}
|
[
"public",
"boolean",
"isRowPresent",
"(",
"String",
"searchElement",
")",
"{",
"ready",
"(",
")",
";",
"boolean",
"found",
";",
"GridCell",
"cell",
"=",
"getCell",
"(",
"searchElement",
")",
";",
"// scrollTop(); // make sure always start from top then scroll down till the end of the page",
"// do {",
"// if the row is not in visible (need to scroll down - errors when used BufferView in grid)",
"found",
"=",
"cell",
".",
"isElementPresent",
"(",
")",
";",
"// } while(!found && scrollPageDown());",
"return",
"found",
";",
"}"
] |
returns if a grid contains a certain element
@param searchElement the searchElement of the grid element on which the search is done
@return true or false
|
[
"returns",
"if",
"a",
"grid",
"contains",
"a",
"certain",
"element"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/grid/GridPanel.java#L316-L327
|
6,028 |
sdl/Testy
|
src/main/java/com/sdl/selenium/extjs3/grid/GridPanel.java
|
GridPanel.getRow
|
public String[] getRow(String searchText) {
String[] rowElements = null;
GridRow row = new GridRow(this, searchText, getSearchColumnId(), SearchType.CONTAINS);
String text = row.getText();
if (text != null) {
rowElements = text.split("\n");
}
return rowElements;
}
|
java
|
public String[] getRow(String searchText) {
String[] rowElements = null;
GridRow row = new GridRow(this, searchText, getSearchColumnId(), SearchType.CONTAINS);
String text = row.getText();
if (text != null) {
rowElements = text.split("\n");
}
return rowElements;
}
|
[
"public",
"String",
"[",
"]",
"getRow",
"(",
"String",
"searchText",
")",
"{",
"String",
"[",
"]",
"rowElements",
"=",
"null",
";",
"GridRow",
"row",
"=",
"new",
"GridRow",
"(",
"this",
",",
"searchText",
",",
"getSearchColumnId",
"(",
")",
",",
"SearchType",
".",
"CONTAINS",
")",
";",
"String",
"text",
"=",
"row",
".",
"getText",
"(",
")",
";",
"if",
"(",
"text",
"!=",
"null",
")",
"{",
"rowElements",
"=",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
";",
"}",
"return",
"rowElements",
";",
"}"
] |
returns all text elements from a grid
@param searchText searchText
@return all text elements from a grid
|
[
"returns",
"all",
"text",
"elements",
"from",
"a",
"grid"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/grid/GridPanel.java#L523-L531
|
6,029 |
sdl/Testy
|
src/main/java/com/sdl/selenium/extjs3/grid/GridPanel.java
|
GridPanel.checkboxColumnSelect
|
public boolean checkboxColumnSelect(String searchText) {
boolean selected = false;
if (ready(true)) {
String path;
int rowIndex = getRowIndex(searchText);
if (rowIndex != -1) {
path = getRow(rowIndex).getXPath() + "//div[contains(@class,'x-grid3-check-col')]";
WebLocator element = new WebLocator().setElPath(path);
if (element.ready()) {
// TODO (verify if is working) to scroll to this element (if element is not visible)
WebLocator locator = new WebLocator(this).setElPath("//*[contains(@class,'x-grid3-focus')]");
locator.sendKeys(Keys.TAB);
selected = isCheckBoxColumnSelected(searchText) || element.click();
LOGGER.info("Clicking on checkboxColumnSelect corresponding to line : " + searchText);
} else {
LOGGER.warn("Could not click on checkboxColumnSelect corresponding to line : " + searchText + "; path = " + path);
return false;
}
}
} else {
LOGGER.warn("checkboxColumnSelect: grid is not ready for use: " + toString());
selected = false;
}
return selected;
}
|
java
|
public boolean checkboxColumnSelect(String searchText) {
boolean selected = false;
if (ready(true)) {
String path;
int rowIndex = getRowIndex(searchText);
if (rowIndex != -1) {
path = getRow(rowIndex).getXPath() + "//div[contains(@class,'x-grid3-check-col')]";
WebLocator element = new WebLocator().setElPath(path);
if (element.ready()) {
// TODO (verify if is working) to scroll to this element (if element is not visible)
WebLocator locator = new WebLocator(this).setElPath("//*[contains(@class,'x-grid3-focus')]");
locator.sendKeys(Keys.TAB);
selected = isCheckBoxColumnSelected(searchText) || element.click();
LOGGER.info("Clicking on checkboxColumnSelect corresponding to line : " + searchText);
} else {
LOGGER.warn("Could not click on checkboxColumnSelect corresponding to line : " + searchText + "; path = " + path);
return false;
}
}
} else {
LOGGER.warn("checkboxColumnSelect: grid is not ready for use: " + toString());
selected = false;
}
return selected;
}
|
[
"public",
"boolean",
"checkboxColumnSelect",
"(",
"String",
"searchText",
")",
"{",
"boolean",
"selected",
"=",
"false",
";",
"if",
"(",
"ready",
"(",
"true",
")",
")",
"{",
"String",
"path",
";",
"int",
"rowIndex",
"=",
"getRowIndex",
"(",
"searchText",
")",
";",
"if",
"(",
"rowIndex",
"!=",
"-",
"1",
")",
"{",
"path",
"=",
"getRow",
"(",
"rowIndex",
")",
".",
"getXPath",
"(",
")",
"+",
"\"//div[contains(@class,'x-grid3-check-col')]\"",
";",
"WebLocator",
"element",
"=",
"new",
"WebLocator",
"(",
")",
".",
"setElPath",
"(",
"path",
")",
";",
"if",
"(",
"element",
".",
"ready",
"(",
")",
")",
"{",
"// TODO (verify if is working) to scroll to this element (if element is not visible)",
"WebLocator",
"locator",
"=",
"new",
"WebLocator",
"(",
"this",
")",
".",
"setElPath",
"(",
"\"//*[contains(@class,'x-grid3-focus')]\"",
")",
";",
"locator",
".",
"sendKeys",
"(",
"Keys",
".",
"TAB",
")",
";",
"selected",
"=",
"isCheckBoxColumnSelected",
"(",
"searchText",
")",
"||",
"element",
".",
"click",
"(",
")",
";",
"LOGGER",
".",
"info",
"(",
"\"Clicking on checkboxColumnSelect corresponding to line : \"",
"+",
"searchText",
")",
";",
"}",
"else",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Could not click on checkboxColumnSelect corresponding to line : \"",
"+",
"searchText",
"+",
"\"; path = \"",
"+",
"path",
")",
";",
"return",
"false",
";",
"}",
"}",
"}",
"else",
"{",
"LOGGER",
".",
"warn",
"(",
"\"checkboxColumnSelect: grid is not ready for use: \"",
"+",
"toString",
"(",
")",
")",
";",
"selected",
"=",
"false",
";",
"}",
"return",
"selected",
";",
"}"
] |
clicks in the checkbox found at the beginning of the grid which contains a specific element
@param searchText searchText
@return true or false
|
[
"clicks",
"in",
"the",
"checkbox",
"found",
"at",
"the",
"beginning",
"of",
"the",
"grid",
"which",
"contains",
"a",
"specific",
"element"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/grid/GridPanel.java#L737-L761
|
6,030 |
sdl/Testy
|
src/main/java/com/sdl/selenium/extjs3/form/ComboBox.java
|
ComboBox.setValueWithJs
|
private boolean setValueWithJs(final String componentId, final String value) {
boolean selected;
String script = "return (function(){var c = Ext.getCmp('" + componentId + "'); var record = c.findRecord(c.displayField, '" + value + "');" +
"if(record){c.onSelect(record, c.store.indexOf(record)); return true;} return false;})()";
log.warn("force ComboBox Value with js: " + script);
selected = (Boolean) WebLocatorUtils.doExecuteScript(script);
log.warn("force ComboBox select result: " + selected);
return selected;
}
|
java
|
private boolean setValueWithJs(final String componentId, final String value) {
boolean selected;
String script = "return (function(){var c = Ext.getCmp('" + componentId + "'); var record = c.findRecord(c.displayField, '" + value + "');" +
"if(record){c.onSelect(record, c.store.indexOf(record)); return true;} return false;})()";
log.warn("force ComboBox Value with js: " + script);
selected = (Boolean) WebLocatorUtils.doExecuteScript(script);
log.warn("force ComboBox select result: " + selected);
return selected;
}
|
[
"private",
"boolean",
"setValueWithJs",
"(",
"final",
"String",
"componentId",
",",
"final",
"String",
"value",
")",
"{",
"boolean",
"selected",
";",
"String",
"script",
"=",
"\"return (function(){var c = Ext.getCmp('\"",
"+",
"componentId",
"+",
"\"'); var record = c.findRecord(c.displayField, '\"",
"+",
"value",
"+",
"\"');\"",
"+",
"\"if(record){c.onSelect(record, c.store.indexOf(record)); return true;} return false;})()\"",
";",
"log",
".",
"warn",
"(",
"\"force ComboBox Value with js: \"",
"+",
"script",
")",
";",
"selected",
"=",
"(",
"Boolean",
")",
"WebLocatorUtils",
".",
"doExecuteScript",
"(",
"script",
")",
";",
"log",
".",
"warn",
"(",
"\"force ComboBox select result: \"",
"+",
"selected",
")",
";",
"return",
"selected",
";",
"}"
] |
this method is used in case normal flow for selection fails
@param componentId ComboBox id so we can use directly js to force selection of that value
@param value value
@return true or false
|
[
"this",
"method",
"is",
"used",
"in",
"case",
"normal",
"flow",
"for",
"selection",
"fails"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/form/ComboBox.java#L118-L126
|
6,031 |
sdl/Testy
|
src/main/java/com/sdl/selenium/extjs3/ExtJsComponent.java
|
ExtJsComponent.waitToActivate
|
public boolean waitToActivate(int seconds) {
String info = toString();
int count = 0;
boolean hasMask;
while ((hasMask = hasMask()) && (count < seconds)) {
count++;
LOGGER.info("waitToActivate:" + (seconds - count) + " seconds; " + info);
Utils.sleep(1000);
}
return !hasMask;
}
|
java
|
public boolean waitToActivate(int seconds) {
String info = toString();
int count = 0;
boolean hasMask;
while ((hasMask = hasMask()) && (count < seconds)) {
count++;
LOGGER.info("waitToActivate:" + (seconds - count) + " seconds; " + info);
Utils.sleep(1000);
}
return !hasMask;
}
|
[
"public",
"boolean",
"waitToActivate",
"(",
"int",
"seconds",
")",
"{",
"String",
"info",
"=",
"toString",
"(",
")",
";",
"int",
"count",
"=",
"0",
";",
"boolean",
"hasMask",
";",
"while",
"(",
"(",
"hasMask",
"=",
"hasMask",
"(",
")",
")",
"&&",
"(",
"count",
"<",
"seconds",
")",
")",
"{",
"count",
"++",
";",
"LOGGER",
".",
"info",
"(",
"\"waitToActivate:\"",
"+",
"(",
"seconds",
"-",
"count",
")",
"+",
"\" seconds; \"",
"+",
"info",
")",
";",
"Utils",
".",
"sleep",
"(",
"1000",
")",
";",
"}",
"return",
"!",
"hasMask",
";",
"}"
] |
Wait for the element to be activated when there is deactivation mask on top of it
@param seconds sec
|
[
"Wait",
"for",
"the",
"element",
"to",
"be",
"activated",
"when",
"there",
"is",
"deactivation",
"mask",
"on",
"top",
"of",
"it"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/ExtJsComponent.java#L94-L104
|
6,032 |
Alfresco/alfresco-indexer
|
alfresco-indexer-webscripts/src/main/java/com/github/maoo/indexer/dao/IndexingDaoImpl.java
|
IndexingDaoImpl.getLastAclChangeSetID
|
public Long getLastAclChangeSetID(){
if(logger.isDebugEnabled()){
logger.debug("[getLastAclChangeSetID]");
}
return (Long) template.selectOne(SELECT_LAST_ACL_CHANGE_SET_ID);
}
|
java
|
public Long getLastAclChangeSetID(){
if(logger.isDebugEnabled()){
logger.debug("[getLastAclChangeSetID]");
}
return (Long) template.selectOne(SELECT_LAST_ACL_CHANGE_SET_ID);
}
|
[
"public",
"Long",
"getLastAclChangeSetID",
"(",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"[getLastAclChangeSetID]\"",
")",
";",
"}",
"return",
"(",
"Long",
")",
"template",
".",
"selectOne",
"(",
"SELECT_LAST_ACL_CHANGE_SET_ID",
")",
";",
"}"
] |
Get the last acl change set id from database
@return
|
[
"Get",
"the",
"last",
"acl",
"change",
"set",
"id",
"from",
"database"
] |
1b2439d1bde9829ae2dc90a27578661c7e3d09b4
|
https://github.com/Alfresco/alfresco-indexer/blob/1b2439d1bde9829ae2dc90a27578661c7e3d09b4/alfresco-indexer-webscripts/src/main/java/com/github/maoo/indexer/dao/IndexingDaoImpl.java#L145-L152
|
6,033 |
Alfresco/alfresco-indexer
|
alfresco-indexer-webscripts/src/main/java/com/github/maoo/indexer/dao/IndexingDaoImpl.java
|
IndexingDaoImpl.getLastTransactionID
|
public Long getLastTransactionID(){
if(logger.isDebugEnabled()){
logger.debug("[getLastTransactionID]");
}
return (Long) template.selectOne(SELECT_LAST_TRANSACTION_ID);
}
|
java
|
public Long getLastTransactionID(){
if(logger.isDebugEnabled()){
logger.debug("[getLastTransactionID]");
}
return (Long) template.selectOne(SELECT_LAST_TRANSACTION_ID);
}
|
[
"public",
"Long",
"getLastTransactionID",
"(",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"[getLastTransactionID]\"",
")",
";",
"}",
"return",
"(",
"Long",
")",
"template",
".",
"selectOne",
"(",
"SELECT_LAST_TRANSACTION_ID",
")",
";",
"}"
] |
Get the last transaction id from database
@return
|
[
"Get",
"the",
"last",
"transaction",
"id",
"from",
"database"
] |
1b2439d1bde9829ae2dc90a27578661c7e3d09b4
|
https://github.com/Alfresco/alfresco-indexer/blob/1b2439d1bde9829ae2dc90a27578661c7e3d09b4/alfresco-indexer-webscripts/src/main/java/com/github/maoo/indexer/dao/IndexingDaoImpl.java#L159-L166
|
6,034 |
Alfresco/alfresco-indexer
|
alfresco-indexer-webscripts/src/main/java/com/github/maoo/indexer/dao/IndexingDaoImpl.java
|
IndexingDaoImpl.filterNodes
|
private List<NodeEntity> filterNodes(List<NodeEntity> nodes)
{
List<NodeEntity> filteredNodes= null;
//Filter by sites
Map<String,Boolean> filters=getFilters();
if(filters.values().contains(Boolean.TRUE)){
filteredNodes= new ArrayList<NodeEntity>();
for(NodeEntity node:nodes){
boolean shouldBeAdded=true;
NodeRef nodeRef= new NodeRef(node.getStore().getStoreRef(),node.getUuid());
String nodeType="{"+node.getTypeNamespace()+"}"+node.getTypeName();
if(nodeService.exists(nodeRef)){
//Filter by site
if(filters.get(SITES_FILTER)){
Path pathObj = nodeService.getPath(nodeRef);
String siteName = Utils.getSiteName(pathObj);
shouldBeAdded= siteName!=null && this.sites.contains(siteName);
}
//Filter by properties
if(filters.get(PROPERTIES_FILTER) && shouldBeAdded){
for(String prop:this.properties){
int pos=prop.lastIndexOf(":");
String qName=null;
String value=null;
if(pos!=-1 && (prop.length()-1)>pos){
qName=prop.substring(0, pos);
value= prop.substring(pos+1,prop.length());
}
if(StringUtils.isEmpty(qName) || StringUtils.isEmpty(value)){
//Invalid property
continue;
}
Serializable rawValue= nodeService.getProperty(nodeRef, QName.createQName(qName));
shouldBeAdded=shouldBeAdded && value.equals(rawValue);
}
}
}
else if(nodeType.equals(ContentModel.TYPE_DELETED.toString())){
shouldBeAdded=Boolean.TRUE;
}
if(shouldBeAdded){
filteredNodes.add(node);
}
}
}else{
filteredNodes=nodes;
}
return filteredNodes;
}
|
java
|
private List<NodeEntity> filterNodes(List<NodeEntity> nodes)
{
List<NodeEntity> filteredNodes= null;
//Filter by sites
Map<String,Boolean> filters=getFilters();
if(filters.values().contains(Boolean.TRUE)){
filteredNodes= new ArrayList<NodeEntity>();
for(NodeEntity node:nodes){
boolean shouldBeAdded=true;
NodeRef nodeRef= new NodeRef(node.getStore().getStoreRef(),node.getUuid());
String nodeType="{"+node.getTypeNamespace()+"}"+node.getTypeName();
if(nodeService.exists(nodeRef)){
//Filter by site
if(filters.get(SITES_FILTER)){
Path pathObj = nodeService.getPath(nodeRef);
String siteName = Utils.getSiteName(pathObj);
shouldBeAdded= siteName!=null && this.sites.contains(siteName);
}
//Filter by properties
if(filters.get(PROPERTIES_FILTER) && shouldBeAdded){
for(String prop:this.properties){
int pos=prop.lastIndexOf(":");
String qName=null;
String value=null;
if(pos!=-1 && (prop.length()-1)>pos){
qName=prop.substring(0, pos);
value= prop.substring(pos+1,prop.length());
}
if(StringUtils.isEmpty(qName) || StringUtils.isEmpty(value)){
//Invalid property
continue;
}
Serializable rawValue= nodeService.getProperty(nodeRef, QName.createQName(qName));
shouldBeAdded=shouldBeAdded && value.equals(rawValue);
}
}
}
else if(nodeType.equals(ContentModel.TYPE_DELETED.toString())){
shouldBeAdded=Boolean.TRUE;
}
if(shouldBeAdded){
filteredNodes.add(node);
}
}
}else{
filteredNodes=nodes;
}
return filteredNodes;
}
|
[
"private",
"List",
"<",
"NodeEntity",
">",
"filterNodes",
"(",
"List",
"<",
"NodeEntity",
">",
"nodes",
")",
"{",
"List",
"<",
"NodeEntity",
">",
"filteredNodes",
"=",
"null",
";",
"//Filter by sites",
"Map",
"<",
"String",
",",
"Boolean",
">",
"filters",
"=",
"getFilters",
"(",
")",
";",
"if",
"(",
"filters",
".",
"values",
"(",
")",
".",
"contains",
"(",
"Boolean",
".",
"TRUE",
")",
")",
"{",
"filteredNodes",
"=",
"new",
"ArrayList",
"<",
"NodeEntity",
">",
"(",
")",
";",
"for",
"(",
"NodeEntity",
"node",
":",
"nodes",
")",
"{",
"boolean",
"shouldBeAdded",
"=",
"true",
";",
"NodeRef",
"nodeRef",
"=",
"new",
"NodeRef",
"(",
"node",
".",
"getStore",
"(",
")",
".",
"getStoreRef",
"(",
")",
",",
"node",
".",
"getUuid",
"(",
")",
")",
";",
"String",
"nodeType",
"=",
"\"{\"",
"+",
"node",
".",
"getTypeNamespace",
"(",
")",
"+",
"\"}\"",
"+",
"node",
".",
"getTypeName",
"(",
")",
";",
"if",
"(",
"nodeService",
".",
"exists",
"(",
"nodeRef",
")",
")",
"{",
"//Filter by site",
"if",
"(",
"filters",
".",
"get",
"(",
"SITES_FILTER",
")",
")",
"{",
"Path",
"pathObj",
"=",
"nodeService",
".",
"getPath",
"(",
"nodeRef",
")",
";",
"String",
"siteName",
"=",
"Utils",
".",
"getSiteName",
"(",
"pathObj",
")",
";",
"shouldBeAdded",
"=",
"siteName",
"!=",
"null",
"&&",
"this",
".",
"sites",
".",
"contains",
"(",
"siteName",
")",
";",
"}",
"//Filter by properties",
"if",
"(",
"filters",
".",
"get",
"(",
"PROPERTIES_FILTER",
")",
"&&",
"shouldBeAdded",
")",
"{",
"for",
"(",
"String",
"prop",
":",
"this",
".",
"properties",
")",
"{",
"int",
"pos",
"=",
"prop",
".",
"lastIndexOf",
"(",
"\":\"",
")",
";",
"String",
"qName",
"=",
"null",
";",
"String",
"value",
"=",
"null",
";",
"if",
"(",
"pos",
"!=",
"-",
"1",
"&&",
"(",
"prop",
".",
"length",
"(",
")",
"-",
"1",
")",
">",
"pos",
")",
"{",
"qName",
"=",
"prop",
".",
"substring",
"(",
"0",
",",
"pos",
")",
";",
"value",
"=",
"prop",
".",
"substring",
"(",
"pos",
"+",
"1",
",",
"prop",
".",
"length",
"(",
")",
")",
";",
"}",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"qName",
")",
"||",
"StringUtils",
".",
"isEmpty",
"(",
"value",
")",
")",
"{",
"//Invalid property",
"continue",
";",
"}",
"Serializable",
"rawValue",
"=",
"nodeService",
".",
"getProperty",
"(",
"nodeRef",
",",
"QName",
".",
"createQName",
"(",
"qName",
")",
")",
";",
"shouldBeAdded",
"=",
"shouldBeAdded",
"&&",
"value",
".",
"equals",
"(",
"rawValue",
")",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"nodeType",
".",
"equals",
"(",
"ContentModel",
".",
"TYPE_DELETED",
".",
"toString",
"(",
")",
")",
")",
"{",
"shouldBeAdded",
"=",
"Boolean",
".",
"TRUE",
";",
"}",
"if",
"(",
"shouldBeAdded",
")",
"{",
"filteredNodes",
".",
"add",
"(",
"node",
")",
";",
"}",
"}",
"}",
"else",
"{",
"filteredNodes",
"=",
"nodes",
";",
"}",
"return",
"filteredNodes",
";",
"}"
] |
Filter the nodes based on some parameters
@param nodes
@return
|
[
"Filter",
"the",
"nodes",
"based",
"on",
"some",
"parameters"
] |
1b2439d1bde9829ae2dc90a27578661c7e3d09b4
|
https://github.com/Alfresco/alfresco-indexer/blob/1b2439d1bde9829ae2dc90a27578661c7e3d09b4/alfresco-indexer-webscripts/src/main/java/com/github/maoo/indexer/dao/IndexingDaoImpl.java#L173-L236
|
6,035 |
Alfresco/alfresco-indexer
|
alfresco-indexer-webscripts/src/main/java/com/github/maoo/indexer/dao/IndexingDaoImpl.java
|
IndexingDaoImpl.getFilters
|
private Map<String,Boolean> getFilters()
{
Map<String,Boolean> filters= new HashMap<String, Boolean>(2);
//Site filter
filters.put(SITES_FILTER, this.sites!=null && this.sites.size() > 0);
//Properties filter
filters.put(PROPERTIES_FILTER, this.properties!=null && this.properties.size() > 0);
return filters;
}
|
java
|
private Map<String,Boolean> getFilters()
{
Map<String,Boolean> filters= new HashMap<String, Boolean>(2);
//Site filter
filters.put(SITES_FILTER, this.sites!=null && this.sites.size() > 0);
//Properties filter
filters.put(PROPERTIES_FILTER, this.properties!=null && this.properties.size() > 0);
return filters;
}
|
[
"private",
"Map",
"<",
"String",
",",
"Boolean",
">",
"getFilters",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"Boolean",
">",
"filters",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Boolean",
">",
"(",
"2",
")",
";",
"//Site filter",
"filters",
".",
"put",
"(",
"SITES_FILTER",
",",
"this",
".",
"sites",
"!=",
"null",
"&&",
"this",
".",
"sites",
".",
"size",
"(",
")",
">",
"0",
")",
";",
"//Properties filter",
"filters",
".",
"put",
"(",
"PROPERTIES_FILTER",
",",
"this",
".",
"properties",
"!=",
"null",
"&&",
"this",
".",
"properties",
".",
"size",
"(",
")",
">",
"0",
")",
";",
"return",
"filters",
";",
"}"
] |
Get existing filters
@return
|
[
"Get",
"existing",
"filters"
] |
1b2439d1bde9829ae2dc90a27578661c7e3d09b4
|
https://github.com/Alfresco/alfresco-indexer/blob/1b2439d1bde9829ae2dc90a27578661c7e3d09b4/alfresco-indexer-webscripts/src/main/java/com/github/maoo/indexer/dao/IndexingDaoImpl.java#L242-L251
|
6,036 |
sdl/Testy
|
src/main/java/com/sdl/selenium/web/table/Table.java
|
Table.isRowPresent
|
public boolean isRowPresent(String searchElement) {
ready();
Cell cell = getCell(searchElement);
return cell.isElementPresent();
}
|
java
|
public boolean isRowPresent(String searchElement) {
ready();
Cell cell = getCell(searchElement);
return cell.isElementPresent();
}
|
[
"public",
"boolean",
"isRowPresent",
"(",
"String",
"searchElement",
")",
"{",
"ready",
"(",
")",
";",
"Cell",
"cell",
"=",
"getCell",
"(",
"searchElement",
")",
";",
"return",
"cell",
".",
"isElementPresent",
"(",
")",
";",
"}"
] |
returns if a table contains a certain element
@param searchElement the searchElement of the table element on which the search is done
@return if a table contains a certain element
|
[
"returns",
"if",
"a",
"table",
"contains",
"a",
"certain",
"element"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/web/table/Table.java#L69-L73
|
6,037 |
sdl/Testy
|
src/main/java/com/sdl/selenium/web/table/Table.java
|
Table.getColumnTexts
|
public String[] getColumnTexts(int columnIndex) {
int count = getCount();
if (count > 0) {
String[] texts = new String[count];
for (int i = 1; i <= count; i++) {
texts[i - 1] = getText(i, columnIndex);
}
return texts;
} else {
return null;
}
}
|
java
|
public String[] getColumnTexts(int columnIndex) {
int count = getCount();
if (count > 0) {
String[] texts = new String[count];
for (int i = 1; i <= count; i++) {
texts[i - 1] = getText(i, columnIndex);
}
return texts;
} else {
return null;
}
}
|
[
"public",
"String",
"[",
"]",
"getColumnTexts",
"(",
"int",
"columnIndex",
")",
"{",
"int",
"count",
"=",
"getCount",
"(",
")",
";",
"if",
"(",
"count",
">",
"0",
")",
"{",
"String",
"[",
"]",
"texts",
"=",
"new",
"String",
"[",
"count",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"count",
";",
"i",
"++",
")",
"{",
"texts",
"[",
"i",
"-",
"1",
"]",
"=",
"getText",
"(",
"i",
",",
"columnIndex",
")",
";",
"}",
"return",
"texts",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
get all strings as array from specified columnIndex
@param columnIndex columnIndex
@return all strings as array from specified columnIndex
|
[
"get",
"all",
"strings",
"as",
"array",
"from",
"specified",
"columnIndex"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/web/table/Table.java#L165-L176
|
6,038 |
sdl/Testy
|
src/main/java/com/sdl/selenium/utils/config/WebDriverConfig.java
|
WebDriverConfig.getWebDriver
|
public static WebDriver getWebDriver(String browserProperties, URL remoteUrl) throws IOException {
URL resource = Thread.currentThread().getContextClassLoader().getResource(browserProperties);
log.debug("File: {} " + (resource != null ? "exists" : "does not exist"), browserProperties);
if (resource != null) {
Browser browser = findBrowser(resource.openStream());
return getDriver(browser, resource.openStream(), remoteUrl);
}
return null;
}
|
java
|
public static WebDriver getWebDriver(String browserProperties, URL remoteUrl) throws IOException {
URL resource = Thread.currentThread().getContextClassLoader().getResource(browserProperties);
log.debug("File: {} " + (resource != null ? "exists" : "does not exist"), browserProperties);
if (resource != null) {
Browser browser = findBrowser(resource.openStream());
return getDriver(browser, resource.openStream(), remoteUrl);
}
return null;
}
|
[
"public",
"static",
"WebDriver",
"getWebDriver",
"(",
"String",
"browserProperties",
",",
"URL",
"remoteUrl",
")",
"throws",
"IOException",
"{",
"URL",
"resource",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
".",
"getResource",
"(",
"browserProperties",
")",
";",
"log",
".",
"debug",
"(",
"\"File: {} \"",
"+",
"(",
"resource",
"!=",
"null",
"?",
"\"exists\"",
":",
"\"does not exist\"",
")",
",",
"browserProperties",
")",
";",
"if",
"(",
"resource",
"!=",
"null",
")",
"{",
"Browser",
"browser",
"=",
"findBrowser",
"(",
"resource",
".",
"openStream",
"(",
")",
")",
";",
"return",
"getDriver",
"(",
"browser",
",",
"resource",
".",
"openStream",
"(",
")",
",",
"remoteUrl",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Create and return new WebDriver or RemoteWebDriver based on properties file
@param browserProperties path to browser.properties
@param remoteUrl url
@return WebDriver
@throws IOException exception
|
[
"Create",
"and",
"return",
"new",
"WebDriver",
"or",
"RemoteWebDriver",
"based",
"on",
"properties",
"file"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/utils/config/WebDriverConfig.java#L173-L183
|
6,039 |
sdl/Testy
|
src/main/java/com/sdl/selenium/utils/config/WebDriverConfig.java
|
WebDriverConfig.switchToLastTab
|
public static String switchToLastTab() {
int totalTabs;
int time = 0;
do {
Utils.sleep(100L);
totalTabs = getCountTabs();
time++;
} while (totalTabs <= 1 && time < 10);
return switchToTab(totalTabs - 1);
}
|
java
|
public static String switchToLastTab() {
int totalTabs;
int time = 0;
do {
Utils.sleep(100L);
totalTabs = getCountTabs();
time++;
} while (totalTabs <= 1 && time < 10);
return switchToTab(totalTabs - 1);
}
|
[
"public",
"static",
"String",
"switchToLastTab",
"(",
")",
"{",
"int",
"totalTabs",
";",
"int",
"time",
"=",
"0",
";",
"do",
"{",
"Utils",
".",
"sleep",
"(",
"100L",
")",
";",
"totalTabs",
"=",
"getCountTabs",
"(",
")",
";",
"time",
"++",
";",
"}",
"while",
"(",
"totalTabs",
"<=",
"1",
"&&",
"time",
"<",
"10",
")",
";",
"return",
"switchToTab",
"(",
"totalTabs",
"-",
"1",
")",
";",
"}"
] |
Switch driver to last browser tab
@return oldTabName
|
[
"Switch",
"driver",
"to",
"last",
"browser",
"tab"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/utils/config/WebDriverConfig.java#L261-L270
|
6,040 |
sdl/Testy
|
src/main/java/com/sdl/selenium/web/WebLocator.java
|
WebLocator.click
|
public boolean click() {
boolean click = waitToRender();
assertThat("Element was not rendered " + toString(), click);
click = executor.click(this);
assertThat("Could not click " + toString(), click);
LOGGER.info("click on {}", toString());
return click;
}
|
java
|
public boolean click() {
boolean click = waitToRender();
assertThat("Element was not rendered " + toString(), click);
click = executor.click(this);
assertThat("Could not click " + toString(), click);
LOGGER.info("click on {}", toString());
return click;
}
|
[
"public",
"boolean",
"click",
"(",
")",
"{",
"boolean",
"click",
"=",
"waitToRender",
"(",
")",
";",
"assertThat",
"(",
"\"Element was not rendered \"",
"+",
"toString",
"(",
")",
",",
"click",
")",
";",
"click",
"=",
"executor",
".",
"click",
"(",
"this",
")",
";",
"assertThat",
"(",
"\"Could not click \"",
"+",
"toString",
"(",
")",
",",
"click",
")",
";",
"LOGGER",
".",
"info",
"(",
"\"click on {}\"",
",",
"toString",
"(",
")",
")",
";",
"return",
"click",
";",
"}"
] |
Click once do you catch exceptions StaleElementReferenceException.
@return true | false
|
[
"Click",
"once",
"do",
"you",
"catch",
"exceptions",
"StaleElementReferenceException",
"."
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/web/WebLocator.java#L169-L176
|
6,041 |
sdl/Testy
|
src/main/java/com/sdl/selenium/web/WebLocator.java
|
WebLocator.focus
|
public WebLocator focus() {
boolean focus = waitToRender();
assertThat("Element was not rendered " + toString(), focus);
focus = executor.focus(this);
assertThat("Could not focus " + toString(), focus);
LOGGER.info("focus on {}", toString());
return this;
}
|
java
|
public WebLocator focus() {
boolean focus = waitToRender();
assertThat("Element was not rendered " + toString(), focus);
focus = executor.focus(this);
assertThat("Could not focus " + toString(), focus);
LOGGER.info("focus on {}", toString());
return this;
}
|
[
"public",
"WebLocator",
"focus",
"(",
")",
"{",
"boolean",
"focus",
"=",
"waitToRender",
"(",
")",
";",
"assertThat",
"(",
"\"Element was not rendered \"",
"+",
"toString",
"(",
")",
",",
"focus",
")",
";",
"focus",
"=",
"executor",
".",
"focus",
"(",
"this",
")",
";",
"assertThat",
"(",
"\"Could not focus \"",
"+",
"toString",
"(",
")",
",",
"focus",
")",
";",
"LOGGER",
".",
"info",
"(",
"\"focus on {}\"",
",",
"toString",
"(",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Using XPath only
@return true | false
|
[
"Using",
"XPath",
"only"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/web/WebLocator.java#L312-L319
|
6,042 |
sdl/Testy
|
src/main/java/com/sdl/selenium/web/WebLocator.java
|
WebLocator.waitTextToRender
|
public String waitTextToRender(int seconds, String excludeText) {
String text = null;
if (seconds == 0 && ((text = getText(true)) != null && text.length() > 0 && !text.equals(excludeText))) {
return text;
}
for (int i = 0, count = 5 * seconds; i < count; i++) {
text = getText(true);
if (text != null && text.length() > 0 && !text.equals(excludeText)) {
return text;
}
if (i == 0) {
// log only fist time
LOGGER.debug("waitTextToRender");
}
Utils.sleep(200);
}
LOGGER.warn("No text was found for Element after " + seconds + " sec; " + this);
return excludeText.equals(text) ? null : text;
}
|
java
|
public String waitTextToRender(int seconds, String excludeText) {
String text = null;
if (seconds == 0 && ((text = getText(true)) != null && text.length() > 0 && !text.equals(excludeText))) {
return text;
}
for (int i = 0, count = 5 * seconds; i < count; i++) {
text = getText(true);
if (text != null && text.length() > 0 && !text.equals(excludeText)) {
return text;
}
if (i == 0) {
// log only fist time
LOGGER.debug("waitTextToRender");
}
Utils.sleep(200);
}
LOGGER.warn("No text was found for Element after " + seconds + " sec; " + this);
return excludeText.equals(text) ? null : text;
}
|
[
"public",
"String",
"waitTextToRender",
"(",
"int",
"seconds",
",",
"String",
"excludeText",
")",
"{",
"String",
"text",
"=",
"null",
";",
"if",
"(",
"seconds",
"==",
"0",
"&&",
"(",
"(",
"text",
"=",
"getText",
"(",
"true",
")",
")",
"!=",
"null",
"&&",
"text",
".",
"length",
"(",
")",
">",
"0",
"&&",
"!",
"text",
".",
"equals",
"(",
"excludeText",
")",
")",
")",
"{",
"return",
"text",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"count",
"=",
"5",
"*",
"seconds",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"text",
"=",
"getText",
"(",
"true",
")",
";",
"if",
"(",
"text",
"!=",
"null",
"&&",
"text",
".",
"length",
"(",
")",
">",
"0",
"&&",
"!",
"text",
".",
"equals",
"(",
"excludeText",
")",
")",
"{",
"return",
"text",
";",
"}",
"if",
"(",
"i",
"==",
"0",
")",
"{",
"// log only fist time",
"LOGGER",
".",
"debug",
"(",
"\"waitTextToRender\"",
")",
";",
"}",
"Utils",
".",
"sleep",
"(",
"200",
")",
";",
"}",
"LOGGER",
".",
"warn",
"(",
"\"No text was found for Element after \"",
"+",
"seconds",
"+",
"\" sec; \"",
"+",
"this",
")",
";",
"return",
"excludeText",
".",
"equals",
"(",
"text",
")",
"?",
"null",
":",
"text",
";",
"}"
] |
Waits for the text to be loaded by looking at the content and not take in consideration the excludeText
text or what ever text is given as parameter
@param seconds time in seconds
@param excludeText exclude text
@return string
|
[
"Waits",
"for",
"the",
"text",
"to",
"be",
"loaded",
"by",
"looking",
"at",
"the",
"content",
"and",
"not",
"take",
"in",
"consideration",
"the",
"excludeText",
"text",
"or",
"what",
"ever",
"text",
"is",
"given",
"as",
"parameter"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/web/WebLocator.java#L459-L477
|
6,043 |
sdl/Testy
|
src/main/java/com/sdl/selenium/extjs3/tab/TabPanel.java
|
TabPanel.setActive
|
public boolean setActive() {
String baseTabPath = "//*[" + getPathBuilder().getBasePath() + "]";
String titlePath = baseTabPath + getTitlePath();
WebLocator titleElement = new WebLocator(getPathBuilder().getContainer()).setElPath(titlePath).setInfoMessage(getPathBuilder().getText() + " Tab");
LOGGER.info("setActive : " + toString());
boolean activated;
try {
activated = titleElement.click();
} catch (ElementNotVisibleException e) {
LOGGER.error("setActive Exception: " + e.getMessage());
activated = setActiveWithExtJS();
}
if (activated) {
Utils.sleep(300); // need to make sure this tab is rendered
}
return activated;
}
|
java
|
public boolean setActive() {
String baseTabPath = "//*[" + getPathBuilder().getBasePath() + "]";
String titlePath = baseTabPath + getTitlePath();
WebLocator titleElement = new WebLocator(getPathBuilder().getContainer()).setElPath(titlePath).setInfoMessage(getPathBuilder().getText() + " Tab");
LOGGER.info("setActive : " + toString());
boolean activated;
try {
activated = titleElement.click();
} catch (ElementNotVisibleException e) {
LOGGER.error("setActive Exception: " + e.getMessage());
activated = setActiveWithExtJS();
}
if (activated) {
Utils.sleep(300); // need to make sure this tab is rendered
}
return activated;
}
|
[
"public",
"boolean",
"setActive",
"(",
")",
"{",
"String",
"baseTabPath",
"=",
"\"//*[\"",
"+",
"getPathBuilder",
"(",
")",
".",
"getBasePath",
"(",
")",
"+",
"\"]\"",
";",
"String",
"titlePath",
"=",
"baseTabPath",
"+",
"getTitlePath",
"(",
")",
";",
"WebLocator",
"titleElement",
"=",
"new",
"WebLocator",
"(",
"getPathBuilder",
"(",
")",
".",
"getContainer",
"(",
")",
")",
".",
"setElPath",
"(",
"titlePath",
")",
".",
"setInfoMessage",
"(",
"getPathBuilder",
"(",
")",
".",
"getText",
"(",
")",
"+",
"\" Tab\"",
")",
";",
"LOGGER",
".",
"info",
"(",
"\"setActive : \"",
"+",
"toString",
"(",
")",
")",
";",
"boolean",
"activated",
";",
"try",
"{",
"activated",
"=",
"titleElement",
".",
"click",
"(",
")",
";",
"}",
"catch",
"(",
"ElementNotVisibleException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"setActive Exception: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"activated",
"=",
"setActiveWithExtJS",
"(",
")",
";",
"}",
"if",
"(",
"activated",
")",
"{",
"Utils",
".",
"sleep",
"(",
"300",
")",
";",
"// need to make sure this tab is rendered\r",
"}",
"return",
"activated",
";",
"}"
] |
After the tab is set to active will wait 300ms to make sure tab is rendered
@return true or false
|
[
"After",
"the",
"tab",
"is",
"set",
"to",
"active",
"will",
"wait",
"300ms",
"to",
"make",
"sure",
"tab",
"is",
"rendered"
] |
b3ae061554016f926f04694a39ff00dab7576609
|
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/tab/TabPanel.java#L82-L98
|
6,044 |
twitter/joauth
|
src/main/java/com/twitter/joauth/Signer.java
|
Signer.getString
|
public String getString(String str, String tokenSecret, String consumerSecret)
throws InvalidKeyException, NoSuchAlgorithmException {
return getString(str, OAuthParams.HMAC_SHA1, tokenSecret, consumerSecret);
}
|
java
|
public String getString(String str, String tokenSecret, String consumerSecret)
throws InvalidKeyException, NoSuchAlgorithmException {
return getString(str, OAuthParams.HMAC_SHA1, tokenSecret, consumerSecret);
}
|
[
"public",
"String",
"getString",
"(",
"String",
"str",
",",
"String",
"tokenSecret",
",",
"String",
"consumerSecret",
")",
"throws",
"InvalidKeyException",
",",
"NoSuchAlgorithmException",
"{",
"return",
"getString",
"(",
"str",
",",
"OAuthParams",
".",
"HMAC_SHA1",
",",
"tokenSecret",
",",
"consumerSecret",
")",
";",
"}"
] |
produce an encoded signature string
|
[
"produce",
"an",
"encoded",
"signature",
"string"
] |
b4f6afb6be79ecb0bb8d04c76b17cfa51de4ffab
|
https://github.com/twitter/joauth/blob/b4f6afb6be79ecb0bb8d04c76b17cfa51de4ffab/src/main/java/com/twitter/joauth/Signer.java#L32-L35
|
6,045 |
thombergs/diffparser
|
src/main/java/io/reflectoring/diffparser/unified/ResizingParseWindow.java
|
ResizingParseWindow.resizeWindowIfNecessary
|
private void resizeWindowIfNecessary(int newSize) {
try {
int numberOfLinesToLoad = newSize - this.lineQueue.size();
for (int i = 0; i < numberOfLinesToLoad; i++) {
String nextLine = getNextLine();
if (nextLine != null) {
lineQueue.addLast(nextLine);
} else {
throw new IndexOutOfBoundsException("End of stream has been reached!");
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
private void resizeWindowIfNecessary(int newSize) {
try {
int numberOfLinesToLoad = newSize - this.lineQueue.size();
for (int i = 0; i < numberOfLinesToLoad; i++) {
String nextLine = getNextLine();
if (nextLine != null) {
lineQueue.addLast(nextLine);
} else {
throw new IndexOutOfBoundsException("End of stream has been reached!");
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
[
"private",
"void",
"resizeWindowIfNecessary",
"(",
"int",
"newSize",
")",
"{",
"try",
"{",
"int",
"numberOfLinesToLoad",
"=",
"newSize",
"-",
"this",
".",
"lineQueue",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numberOfLinesToLoad",
";",
"i",
"++",
")",
"{",
"String",
"nextLine",
"=",
"getNextLine",
"(",
")",
";",
"if",
"(",
"nextLine",
"!=",
"null",
")",
"{",
"lineQueue",
".",
"addLast",
"(",
"nextLine",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"End of stream has been reached!\"",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Resizes the sliding window to the given size, if necessary.
@param newSize the new size of the window (i.e. the number of lines in the
window).
|
[
"Resizes",
"the",
"sliding",
"window",
"to",
"the",
"given",
"size",
"if",
"necessary",
"."
] |
699921a49bfe96bac5be4d460edf450741fdb225
|
https://github.com/thombergs/diffparser/blob/699921a49bfe96bac5be4d460edf450741fdb225/src/main/java/io/reflectoring/diffparser/unified/ResizingParseWindow.java#L75-L89
|
6,046 |
thombergs/diffparser
|
src/main/java/io/reflectoring/diffparser/api/UnifiedDiffParser.java
|
UnifiedDiffParser.cutAfterTab
|
private String cutAfterTab(String line) {
Pattern p = Pattern.compile("^(.*)\\t.*$");
Matcher matcher = p.matcher(line);
if (matcher.matches()) {
return matcher.group(1);
} else {
return line;
}
}
|
java
|
private String cutAfterTab(String line) {
Pattern p = Pattern.compile("^(.*)\\t.*$");
Matcher matcher = p.matcher(line);
if (matcher.matches()) {
return matcher.group(1);
} else {
return line;
}
}
|
[
"private",
"String",
"cutAfterTab",
"(",
"String",
"line",
")",
"{",
"Pattern",
"p",
"=",
"Pattern",
".",
"compile",
"(",
"\"^(.*)\\\\t.*$\"",
")",
";",
"Matcher",
"matcher",
"=",
"p",
".",
"matcher",
"(",
"line",
")",
";",
"if",
"(",
"matcher",
".",
"matches",
"(",
")",
")",
"{",
"return",
"matcher",
".",
"group",
"(",
"1",
")",
";",
"}",
"else",
"{",
"return",
"line",
";",
"}",
"}"
] |
Cuts a TAB and all following characters from a String.
|
[
"Cuts",
"a",
"TAB",
"and",
"all",
"following",
"characters",
"from",
"a",
"String",
"."
] |
699921a49bfe96bac5be4d460edf450741fdb225
|
https://github.com/thombergs/diffparser/blob/699921a49bfe96bac5be4d460edf450741fdb225/src/main/java/io/reflectoring/diffparser/api/UnifiedDiffParser.java#L150-L158
|
6,047 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/tiles/matrix/TileMatrix.java
|
TileMatrix.validateValues
|
private void validateValues(String column, long value, boolean allowZero) {
if (value < 0 || (value == 0 && !allowZero)) {
throw new GeoPackageException(column
+ " value must be greater than "
+ (allowZero ? "or equal to " : "") + "0: " + value);
}
}
|
java
|
private void validateValues(String column, long value, boolean allowZero) {
if (value < 0 || (value == 0 && !allowZero)) {
throw new GeoPackageException(column
+ " value must be greater than "
+ (allowZero ? "or equal to " : "") + "0: " + value);
}
}
|
[
"private",
"void",
"validateValues",
"(",
"String",
"column",
",",
"long",
"value",
",",
"boolean",
"allowZero",
")",
"{",
"if",
"(",
"value",
"<",
"0",
"||",
"(",
"value",
"==",
"0",
"&&",
"!",
"allowZero",
")",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"column",
"+",
"\" value must be greater than \"",
"+",
"(",
"allowZero",
"?",
"\"or equal to \"",
":",
"\"\"",
")",
"+",
"\"0: \"",
"+",
"value",
")",
";",
"}",
"}"
] |
Validate the long values are greater than 0, or greater than or equal to
0 based upon the allowZero flag
@param column
@param value
@param allowZero
|
[
"Validate",
"the",
"long",
"values",
"are",
"greater",
"than",
"0",
"or",
"greater",
"than",
"or",
"equal",
"to",
"0",
"based",
"upon",
"the",
"allowZero",
"flag"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/tiles/matrix/TileMatrix.java#L279-L285
|
6,048 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/io/ResourceIOUtils.java
|
ResourceIOUtils.parseSQLStatements
|
public static List<String> parseSQLStatements(String path, String name) {
return parseSQLStatements("/" + path + "/" + name);
}
|
java
|
public static List<String> parseSQLStatements(String path, String name) {
return parseSQLStatements("/" + path + "/" + name);
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"parseSQLStatements",
"(",
"String",
"path",
",",
"String",
"name",
")",
"{",
"return",
"parseSQLStatements",
"(",
"\"/\"",
"+",
"path",
"+",
"\"/\"",
"+",
"name",
")",
";",
"}"
] |
Parse the SQL statements for the base resource path and sql file name
@param path
base resource path
@param name
sql file name
@return list of sql statements
|
[
"Parse",
"the",
"SQL",
"statements",
"for",
"the",
"base",
"resource",
"path",
"and",
"sql",
"file",
"name"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/io/ResourceIOUtils.java#L28-L30
|
6,049 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/io/ResourceIOUtils.java
|
ResourceIOUtils.parseSQLStatements
|
public static List<String> parseSQLStatements(String resourceName) {
InputStream stream = ResourceIOUtils.class
.getResourceAsStream(resourceName);
if (stream == null) {
throw new GeoPackageException("Failed to find resource: "
+ resourceName);
}
List<String> statements = parseSQLStatements(stream);
return statements;
}
|
java
|
public static List<String> parseSQLStatements(String resourceName) {
InputStream stream = ResourceIOUtils.class
.getResourceAsStream(resourceName);
if (stream == null) {
throw new GeoPackageException("Failed to find resource: "
+ resourceName);
}
List<String> statements = parseSQLStatements(stream);
return statements;
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"parseSQLStatements",
"(",
"String",
"resourceName",
")",
"{",
"InputStream",
"stream",
"=",
"ResourceIOUtils",
".",
"class",
".",
"getResourceAsStream",
"(",
"resourceName",
")",
";",
"if",
"(",
"stream",
"==",
"null",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to find resource: \"",
"+",
"resourceName",
")",
";",
"}",
"List",
"<",
"String",
">",
"statements",
"=",
"parseSQLStatements",
"(",
"stream",
")",
";",
"return",
"statements",
";",
"}"
] |
Parse the SQL statements for the resource name
@param resourceName
resource name
@return list of sql statements
|
[
"Parse",
"the",
"SQL",
"statements",
"for",
"the",
"resource",
"name"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/io/ResourceIOUtils.java#L39-L48
|
6,050 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/io/ResourceIOUtils.java
|
ResourceIOUtils.parseSQLStatements
|
public static List<String> parseSQLStatements(final InputStream stream) {
List<String> statements = new ArrayList<>();
// Use multiple newlines as the delimiter
Scanner s = new Scanner(stream);
try {
s.useDelimiter(Pattern.compile("\\n\\s*\\n"));
// Parse and add each statement
while (s.hasNext()) {
String statement = s.next().trim();
statements.add(statement);
}
} finally {
s.close();
}
return statements;
}
|
java
|
public static List<String> parseSQLStatements(final InputStream stream) {
List<String> statements = new ArrayList<>();
// Use multiple newlines as the delimiter
Scanner s = new Scanner(stream);
try {
s.useDelimiter(Pattern.compile("\\n\\s*\\n"));
// Parse and add each statement
while (s.hasNext()) {
String statement = s.next().trim();
statements.add(statement);
}
} finally {
s.close();
}
return statements;
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"parseSQLStatements",
"(",
"final",
"InputStream",
"stream",
")",
"{",
"List",
"<",
"String",
">",
"statements",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"// Use multiple newlines as the delimiter",
"Scanner",
"s",
"=",
"new",
"Scanner",
"(",
"stream",
")",
";",
"try",
"{",
"s",
".",
"useDelimiter",
"(",
"Pattern",
".",
"compile",
"(",
"\"\\\\n\\\\s*\\\\n\"",
")",
")",
";",
"// Parse and add each statement",
"while",
"(",
"s",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"statement",
"=",
"s",
".",
"next",
"(",
")",
".",
"trim",
"(",
")",
";",
"statements",
".",
"add",
"(",
"statement",
")",
";",
"}",
"}",
"finally",
"{",
"s",
".",
"close",
"(",
")",
";",
"}",
"return",
"statements",
";",
"}"
] |
Parse the SQL statements for the input stream
@param stream
input stream
@return list of sql statements
|
[
"Parse",
"the",
"SQL",
"statements",
"for",
"the",
"input",
"stream"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/io/ResourceIOUtils.java#L57-L75
|
6,051 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java
|
ContentsIdExtension.get
|
public ContentsId get(String tableName) {
ContentsId contentsId = null;
try {
if (contentsIdDao.isTableExists()) {
contentsId = contentsIdDao.queryForTableName(tableName);
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to query contents id for GeoPackage: "
+ geoPackage.getName() + ", Table Name: "
+ tableName, e);
}
return contentsId;
}
|
java
|
public ContentsId get(String tableName) {
ContentsId contentsId = null;
try {
if (contentsIdDao.isTableExists()) {
contentsId = contentsIdDao.queryForTableName(tableName);
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to query contents id for GeoPackage: "
+ geoPackage.getName() + ", Table Name: "
+ tableName, e);
}
return contentsId;
}
|
[
"public",
"ContentsId",
"get",
"(",
"String",
"tableName",
")",
"{",
"ContentsId",
"contentsId",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"contentsIdDao",
".",
"isTableExists",
"(",
")",
")",
"{",
"contentsId",
"=",
"contentsIdDao",
".",
"queryForTableName",
"(",
"tableName",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to query contents id for GeoPackage: \"",
"+",
"geoPackage",
".",
"getName",
"(",
")",
"+",
"\", Table Name: \"",
"+",
"tableName",
",",
"e",
")",
";",
"}",
"return",
"contentsId",
";",
"}"
] |
Get the contents id object
@param tableName
table name
@return contents id or null
|
[
"Get",
"the",
"contents",
"id",
"object"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java#L125-L138
|
6,052 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java
|
ContentsIdExtension.getId
|
public Long getId(String tableName) {
Long id = null;
ContentsId contentsId = get(tableName);
if (contentsId != null) {
id = contentsId.getId();
}
return id;
}
|
java
|
public Long getId(String tableName) {
Long id = null;
ContentsId contentsId = get(tableName);
if (contentsId != null) {
id = contentsId.getId();
}
return id;
}
|
[
"public",
"Long",
"getId",
"(",
"String",
"tableName",
")",
"{",
"Long",
"id",
"=",
"null",
";",
"ContentsId",
"contentsId",
"=",
"get",
"(",
"tableName",
")",
";",
"if",
"(",
"contentsId",
"!=",
"null",
")",
"{",
"id",
"=",
"contentsId",
".",
"getId",
"(",
")",
";",
"}",
"return",
"id",
";",
"}"
] |
Get the contents id
@param tableName
table name
@return contents id or null
|
[
"Get",
"the",
"contents",
"id"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java#L158-L165
|
6,053 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java
|
ContentsIdExtension.create
|
public ContentsId create(String tableName) {
if (!has()) {
getOrCreateExtension();
}
ContentsId contentsId = new ContentsId();
Contents contents = geoPackage.getTableContents(tableName);
contentsId.setContents(contents);
try {
contentsIdDao.create(contentsId);
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to create contents id for GeoPackage: "
+ geoPackage.getName() + ", Table Name: "
+ tableName, e);
}
return contentsId;
}
|
java
|
public ContentsId create(String tableName) {
if (!has()) {
getOrCreateExtension();
}
ContentsId contentsId = new ContentsId();
Contents contents = geoPackage.getTableContents(tableName);
contentsId.setContents(contents);
try {
contentsIdDao.create(contentsId);
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to create contents id for GeoPackage: "
+ geoPackage.getName() + ", Table Name: "
+ tableName, e);
}
return contentsId;
}
|
[
"public",
"ContentsId",
"create",
"(",
"String",
"tableName",
")",
"{",
"if",
"(",
"!",
"has",
"(",
")",
")",
"{",
"getOrCreateExtension",
"(",
")",
";",
"}",
"ContentsId",
"contentsId",
"=",
"new",
"ContentsId",
"(",
")",
";",
"Contents",
"contents",
"=",
"geoPackage",
".",
"getTableContents",
"(",
"tableName",
")",
";",
"contentsId",
".",
"setContents",
"(",
"contents",
")",
";",
"try",
"{",
"contentsIdDao",
".",
"create",
"(",
"contentsId",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to create contents id for GeoPackage: \"",
"+",
"geoPackage",
".",
"getName",
"(",
")",
"+",
"\", Table Name: \"",
"+",
"tableName",
",",
"e",
")",
";",
"}",
"return",
"contentsId",
";",
"}"
] |
Create a contents id
@param tableName
table name
@return new contents id
|
[
"Create",
"a",
"contents",
"id"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java#L185-L203
|
6,054 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java
|
ContentsIdExtension.getOrCreate
|
public ContentsId getOrCreate(String tableName) {
ContentsId contentsId = get(tableName);
if (contentsId == null) {
contentsId = create(tableName);
}
return contentsId;
}
|
java
|
public ContentsId getOrCreate(String tableName) {
ContentsId contentsId = get(tableName);
if (contentsId == null) {
contentsId = create(tableName);
}
return contentsId;
}
|
[
"public",
"ContentsId",
"getOrCreate",
"(",
"String",
"tableName",
")",
"{",
"ContentsId",
"contentsId",
"=",
"get",
"(",
"tableName",
")",
";",
"if",
"(",
"contentsId",
"==",
"null",
")",
"{",
"contentsId",
"=",
"create",
"(",
"tableName",
")",
";",
"}",
"return",
"contentsId",
";",
"}"
] |
Get or create a contents id
@param tableName
table name
@return new or existing contents id
|
[
"Get",
"or",
"create",
"a",
"contents",
"id"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java#L246-L252
|
6,055 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java
|
ContentsIdExtension.delete
|
public boolean delete(String tableName) {
boolean deleted = false;
try {
if (contentsIdDao.isTableExists()) {
deleted = contentsIdDao.deleteByTableName(tableName) > 0;
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to delete Contents Id extension table. GeoPackage: "
+ geoPackage.getName() + ", Table Name: "
+ tableName, e);
}
return deleted;
}
|
java
|
public boolean delete(String tableName) {
boolean deleted = false;
try {
if (contentsIdDao.isTableExists()) {
deleted = contentsIdDao.deleteByTableName(tableName) > 0;
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to delete Contents Id extension table. GeoPackage: "
+ geoPackage.getName() + ", Table Name: "
+ tableName, e);
}
return deleted;
}
|
[
"public",
"boolean",
"delete",
"(",
"String",
"tableName",
")",
"{",
"boolean",
"deleted",
"=",
"false",
";",
"try",
"{",
"if",
"(",
"contentsIdDao",
".",
"isTableExists",
"(",
")",
")",
"{",
"deleted",
"=",
"contentsIdDao",
".",
"deleteByTableName",
"(",
"tableName",
")",
">",
"0",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to delete Contents Id extension table. GeoPackage: \"",
"+",
"geoPackage",
".",
"getName",
"(",
")",
"+",
"\", Table Name: \"",
"+",
"tableName",
",",
"e",
")",
";",
"}",
"return",
"deleted",
";",
"}"
] |
Delete the contents id for the table
@param tableName
table name
@return true if deleted
|
[
"Delete",
"the",
"contents",
"id",
"for",
"the",
"table"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java#L297-L310
|
6,056 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java
|
ContentsIdExtension.createIds
|
public int createIds(String type) {
List<String> tables = getMissing(type);
for (String tableName : tables) {
getOrCreate(tableName);
}
return tables.size();
}
|
java
|
public int createIds(String type) {
List<String> tables = getMissing(type);
for (String tableName : tables) {
getOrCreate(tableName);
}
return tables.size();
}
|
[
"public",
"int",
"createIds",
"(",
"String",
"type",
")",
"{",
"List",
"<",
"String",
">",
"tables",
"=",
"getMissing",
"(",
"type",
")",
";",
"for",
"(",
"String",
"tableName",
":",
"tables",
")",
"{",
"getOrCreate",
"(",
"tableName",
")",
";",
"}",
"return",
"tables",
".",
"size",
"(",
")",
";",
"}"
] |
Create contents ids for contents of the data type and currently without
@param type
contents data type
@return newly created contents ids count
|
[
"Create",
"contents",
"ids",
"for",
"contents",
"of",
"the",
"data",
"type",
"and",
"currently",
"without"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java#L339-L348
|
6,057 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java
|
ContentsIdExtension.deleteIds
|
public int deleteIds() {
int deleted = 0;
try {
if (contentsIdDao.isTableExists()) {
deleted = contentsIdDao.delete(contentsIdDao.deleteBuilder()
.prepare());
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to delete all contents ids. GeoPackage: "
+ geoPackage.getName(), e);
}
return deleted;
}
|
java
|
public int deleteIds() {
int deleted = 0;
try {
if (contentsIdDao.isTableExists()) {
deleted = contentsIdDao.delete(contentsIdDao.deleteBuilder()
.prepare());
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to delete all contents ids. GeoPackage: "
+ geoPackage.getName(), e);
}
return deleted;
}
|
[
"public",
"int",
"deleteIds",
"(",
")",
"{",
"int",
"deleted",
"=",
"0",
";",
"try",
"{",
"if",
"(",
"contentsIdDao",
".",
"isTableExists",
"(",
")",
")",
"{",
"deleted",
"=",
"contentsIdDao",
".",
"delete",
"(",
"contentsIdDao",
".",
"deleteBuilder",
"(",
")",
".",
"prepare",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to delete all contents ids. GeoPackage: \"",
"+",
"geoPackage",
".",
"getName",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"deleted",
";",
"}"
] |
Delete all contents ids
@return deleted contents ids count
|
[
"Delete",
"all",
"contents",
"ids"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java#L355-L368
|
6,058 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java
|
ContentsIdExtension.deleteIds
|
public int deleteIds(String type) {
int deleted = 0;
try {
if (contentsIdDao.isTableExists()) {
List<ContentsId> contentsIds = getIds(type);
deleted = contentsIdDao.delete(contentsIds);
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to delete contents ids by type. GeoPackage: "
+ geoPackage.getName() + ", Type: " + type, e);
}
return deleted;
}
|
java
|
public int deleteIds(String type) {
int deleted = 0;
try {
if (contentsIdDao.isTableExists()) {
List<ContentsId> contentsIds = getIds(type);
deleted = contentsIdDao.delete(contentsIds);
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to delete contents ids by type. GeoPackage: "
+ geoPackage.getName() + ", Type: " + type, e);
}
return deleted;
}
|
[
"public",
"int",
"deleteIds",
"(",
"String",
"type",
")",
"{",
"int",
"deleted",
"=",
"0",
";",
"try",
"{",
"if",
"(",
"contentsIdDao",
".",
"isTableExists",
"(",
")",
")",
"{",
"List",
"<",
"ContentsId",
">",
"contentsIds",
"=",
"getIds",
"(",
"type",
")",
";",
"deleted",
"=",
"contentsIdDao",
".",
"delete",
"(",
"contentsIds",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to delete contents ids by type. GeoPackage: \"",
"+",
"geoPackage",
".",
"getName",
"(",
")",
"+",
"\", Type: \"",
"+",
"type",
",",
"e",
")",
";",
"}",
"return",
"deleted",
";",
"}"
] |
Delete contents ids for contents of the data type
@param type
contents data type
@return deleted contents ids count
|
[
"Delete",
"contents",
"ids",
"for",
"contents",
"of",
"the",
"data",
"type"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java#L388-L401
|
6,059 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java
|
ContentsIdExtension.getIds
|
public List<ContentsId> getIds() {
List<ContentsId> contentsIds = null;
try {
if (contentsIdDao.isTableExists()) {
contentsIds = contentsIdDao.queryForAll();
} else {
contentsIds = new ArrayList<>();
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to query for all contents ids. GeoPackage: "
+ geoPackage.getName(), e);
}
return contentsIds;
}
|
java
|
public List<ContentsId> getIds() {
List<ContentsId> contentsIds = null;
try {
if (contentsIdDao.isTableExists()) {
contentsIds = contentsIdDao.queryForAll();
} else {
contentsIds = new ArrayList<>();
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to query for all contents ids. GeoPackage: "
+ geoPackage.getName(), e);
}
return contentsIds;
}
|
[
"public",
"List",
"<",
"ContentsId",
">",
"getIds",
"(",
")",
"{",
"List",
"<",
"ContentsId",
">",
"contentsIds",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"contentsIdDao",
".",
"isTableExists",
"(",
")",
")",
"{",
"contentsIds",
"=",
"contentsIdDao",
".",
"queryForAll",
"(",
")",
";",
"}",
"else",
"{",
"contentsIds",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to query for all contents ids. GeoPackage: \"",
"+",
"geoPackage",
".",
"getName",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"contentsIds",
";",
"}"
] |
Get all contents ids
@return contents ids
|
[
"Get",
"all",
"contents",
"ids"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java#L408-L422
|
6,060 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java
|
ContentsIdExtension.count
|
public long count() {
long count = 0;
if (has()) {
try {
count = contentsIdDao.countOf();
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to count contents ids. GeoPackage: "
+ geoPackage.getName(), e);
}
}
return count;
}
|
java
|
public long count() {
long count = 0;
if (has()) {
try {
count = contentsIdDao.countOf();
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to count contents ids. GeoPackage: "
+ geoPackage.getName(), e);
}
}
return count;
}
|
[
"public",
"long",
"count",
"(",
")",
"{",
"long",
"count",
"=",
"0",
";",
"if",
"(",
"has",
"(",
")",
")",
"{",
"try",
"{",
"count",
"=",
"contentsIdDao",
".",
"countOf",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to count contents ids. GeoPackage: \"",
"+",
"geoPackage",
".",
"getName",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"return",
"count",
";",
"}"
] |
Get the count of contents ids
@return count
|
[
"Get",
"the",
"count",
"of",
"contents",
"ids"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java#L429-L441
|
6,061 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java
|
ContentsIdExtension.getIds
|
public List<ContentsId> getIds(String type) {
List<ContentsId> contentsIds = null;
ContentsDao contentsDao = geoPackage.getContentsDao();
try {
if (contentsIdDao.isTableExists()) {
QueryBuilder<Contents, String> contentsQueryBuilder = contentsDao
.queryBuilder();
QueryBuilder<ContentsId, Long> contentsIdQueryBuilder = contentsIdDao
.queryBuilder();
contentsQueryBuilder.where()
.eq(Contents.COLUMN_DATA_TYPE, type);
contentsIdQueryBuilder.join(contentsQueryBuilder);
contentsIds = contentsIdQueryBuilder.query();
} else {
contentsIds = new ArrayList<>();
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to query for contents id by contents data type. GeoPackage: "
+ geoPackage.getName() + ", Type: " + type, e);
}
return contentsIds;
}
|
java
|
public List<ContentsId> getIds(String type) {
List<ContentsId> contentsIds = null;
ContentsDao contentsDao = geoPackage.getContentsDao();
try {
if (contentsIdDao.isTableExists()) {
QueryBuilder<Contents, String> contentsQueryBuilder = contentsDao
.queryBuilder();
QueryBuilder<ContentsId, Long> contentsIdQueryBuilder = contentsIdDao
.queryBuilder();
contentsQueryBuilder.where()
.eq(Contents.COLUMN_DATA_TYPE, type);
contentsIdQueryBuilder.join(contentsQueryBuilder);
contentsIds = contentsIdQueryBuilder.query();
} else {
contentsIds = new ArrayList<>();
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to query for contents id by contents data type. GeoPackage: "
+ geoPackage.getName() + ", Type: " + type, e);
}
return contentsIds;
}
|
[
"public",
"List",
"<",
"ContentsId",
">",
"getIds",
"(",
"String",
"type",
")",
"{",
"List",
"<",
"ContentsId",
">",
"contentsIds",
"=",
"null",
";",
"ContentsDao",
"contentsDao",
"=",
"geoPackage",
".",
"getContentsDao",
"(",
")",
";",
"try",
"{",
"if",
"(",
"contentsIdDao",
".",
"isTableExists",
"(",
")",
")",
"{",
"QueryBuilder",
"<",
"Contents",
",",
"String",
">",
"contentsQueryBuilder",
"=",
"contentsDao",
".",
"queryBuilder",
"(",
")",
";",
"QueryBuilder",
"<",
"ContentsId",
",",
"Long",
">",
"contentsIdQueryBuilder",
"=",
"contentsIdDao",
".",
"queryBuilder",
"(",
")",
";",
"contentsQueryBuilder",
".",
"where",
"(",
")",
".",
"eq",
"(",
"Contents",
".",
"COLUMN_DATA_TYPE",
",",
"type",
")",
";",
"contentsIdQueryBuilder",
".",
"join",
"(",
"contentsQueryBuilder",
")",
";",
"contentsIds",
"=",
"contentsIdQueryBuilder",
".",
"query",
"(",
")",
";",
"}",
"else",
"{",
"contentsIds",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to query for contents id by contents data type. GeoPackage: \"",
"+",
"geoPackage",
".",
"getName",
"(",
")",
"+",
"\", Type: \"",
"+",
"type",
",",
"e",
")",
";",
"}",
"return",
"contentsIds",
";",
"}"
] |
Get by contents data type
@param type
contents data type
@return contents ids
|
[
"Get",
"by",
"contents",
"data",
"type"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java#L461-L492
|
6,062 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java
|
ContentsIdExtension.getMissing
|
public List<String> getMissing(String type) {
List<String> missing = new ArrayList<>();
ContentsDao contentsDao = geoPackage.getContentsDao();
GenericRawResults<String[]> results = null;
try {
StringBuilder query = new StringBuilder();
query.append("SELECT ");
query.append(Contents.COLUMN_TABLE_NAME);
query.append(" FROM ");
query.append(Contents.TABLE_NAME);
StringBuilder where = new StringBuilder();
String[] queryArgs;
if (type != null && !type.isEmpty()) {
where.append(Contents.COLUMN_DATA_TYPE);
where.append(" = ?");
queryArgs = new String[] { type };
} else {
queryArgs = new String[] {};
type = null;
}
if (contentsIdDao.isTableExists()) {
if (where.length() > 0) {
where.append(" AND ");
}
where.append(Contents.COLUMN_TABLE_NAME);
where.append(" NOT IN (SELECT ");
where.append(ContentsId.COLUMN_TABLE_NAME);
where.append(" FROM ");
where.append(ContentsId.TABLE_NAME);
where.append(")");
}
if (where.length() > 0) {
query.append(" WHERE ").append(where);
}
results = contentsDao.queryRaw(query.toString(), queryArgs);
for (String[] resultRow : results) {
missing.add(resultRow[0]);
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to query for missing contents ids. GeoPackage: "
+ geoPackage.getName() + ", Type: " + type, e);
} finally {
if (results != null) {
try {
results.close();
} catch (IOException e) {
logger.log(Level.WARNING,
"Failed to close generic raw results from missing contents ids query. type: "
+ type, e);
}
}
}
return missing;
}
|
java
|
public List<String> getMissing(String type) {
List<String> missing = new ArrayList<>();
ContentsDao contentsDao = geoPackage.getContentsDao();
GenericRawResults<String[]> results = null;
try {
StringBuilder query = new StringBuilder();
query.append("SELECT ");
query.append(Contents.COLUMN_TABLE_NAME);
query.append(" FROM ");
query.append(Contents.TABLE_NAME);
StringBuilder where = new StringBuilder();
String[] queryArgs;
if (type != null && !type.isEmpty()) {
where.append(Contents.COLUMN_DATA_TYPE);
where.append(" = ?");
queryArgs = new String[] { type };
} else {
queryArgs = new String[] {};
type = null;
}
if (contentsIdDao.isTableExists()) {
if (where.length() > 0) {
where.append(" AND ");
}
where.append(Contents.COLUMN_TABLE_NAME);
where.append(" NOT IN (SELECT ");
where.append(ContentsId.COLUMN_TABLE_NAME);
where.append(" FROM ");
where.append(ContentsId.TABLE_NAME);
where.append(")");
}
if (where.length() > 0) {
query.append(" WHERE ").append(where);
}
results = contentsDao.queryRaw(query.toString(), queryArgs);
for (String[] resultRow : results) {
missing.add(resultRow[0]);
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to query for missing contents ids. GeoPackage: "
+ geoPackage.getName() + ", Type: " + type, e);
} finally {
if (results != null) {
try {
results.close();
} catch (IOException e) {
logger.log(Level.WARNING,
"Failed to close generic raw results from missing contents ids query. type: "
+ type, e);
}
}
}
return missing;
}
|
[
"public",
"List",
"<",
"String",
">",
"getMissing",
"(",
"String",
"type",
")",
"{",
"List",
"<",
"String",
">",
"missing",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"ContentsDao",
"contentsDao",
"=",
"geoPackage",
".",
"getContentsDao",
"(",
")",
";",
"GenericRawResults",
"<",
"String",
"[",
"]",
">",
"results",
"=",
"null",
";",
"try",
"{",
"StringBuilder",
"query",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"query",
".",
"append",
"(",
"\"SELECT \"",
")",
";",
"query",
".",
"append",
"(",
"Contents",
".",
"COLUMN_TABLE_NAME",
")",
";",
"query",
".",
"append",
"(",
"\" FROM \"",
")",
";",
"query",
".",
"append",
"(",
"Contents",
".",
"TABLE_NAME",
")",
";",
"StringBuilder",
"where",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"[",
"]",
"queryArgs",
";",
"if",
"(",
"type",
"!=",
"null",
"&&",
"!",
"type",
".",
"isEmpty",
"(",
")",
")",
"{",
"where",
".",
"append",
"(",
"Contents",
".",
"COLUMN_DATA_TYPE",
")",
";",
"where",
".",
"append",
"(",
"\" = ?\"",
")",
";",
"queryArgs",
"=",
"new",
"String",
"[",
"]",
"{",
"type",
"}",
";",
"}",
"else",
"{",
"queryArgs",
"=",
"new",
"String",
"[",
"]",
"{",
"}",
";",
"type",
"=",
"null",
";",
"}",
"if",
"(",
"contentsIdDao",
".",
"isTableExists",
"(",
")",
")",
"{",
"if",
"(",
"where",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"where",
".",
"append",
"(",
"\" AND \"",
")",
";",
"}",
"where",
".",
"append",
"(",
"Contents",
".",
"COLUMN_TABLE_NAME",
")",
";",
"where",
".",
"append",
"(",
"\" NOT IN (SELECT \"",
")",
";",
"where",
".",
"append",
"(",
"ContentsId",
".",
"COLUMN_TABLE_NAME",
")",
";",
"where",
".",
"append",
"(",
"\" FROM \"",
")",
";",
"where",
".",
"append",
"(",
"ContentsId",
".",
"TABLE_NAME",
")",
";",
"where",
".",
"append",
"(",
"\")\"",
")",
";",
"}",
"if",
"(",
"where",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"query",
".",
"append",
"(",
"\" WHERE \"",
")",
".",
"append",
"(",
"where",
")",
";",
"}",
"results",
"=",
"contentsDao",
".",
"queryRaw",
"(",
"query",
".",
"toString",
"(",
")",
",",
"queryArgs",
")",
";",
"for",
"(",
"String",
"[",
"]",
"resultRow",
":",
"results",
")",
"{",
"missing",
".",
"add",
"(",
"resultRow",
"[",
"0",
"]",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to query for missing contents ids. GeoPackage: \"",
"+",
"geoPackage",
".",
"getName",
"(",
")",
"+",
"\", Type: \"",
"+",
"type",
",",
"e",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"results",
"!=",
"null",
")",
"{",
"try",
"{",
"results",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Failed to close generic raw results from missing contents ids query. type: \"",
"+",
"type",
",",
"e",
")",
";",
"}",
"}",
"}",
"return",
"missing",
";",
"}"
] |
Get contents by data type without contents ids
@param type
contents data type
@return table names without contents ids
|
[
"Get",
"contents",
"by",
"data",
"type",
"without",
"contents",
"ids"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java#L521-L585
|
6,063 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java
|
ContentsIdExtension.getOrCreateExtension
|
public Extensions getOrCreateExtension() {
// Create table
geoPackage.createContentsIdTable();
Extensions extension = getOrCreate(EXTENSION_NAME, null, null,
EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE);
return extension;
}
|
java
|
public Extensions getOrCreateExtension() {
// Create table
geoPackage.createContentsIdTable();
Extensions extension = getOrCreate(EXTENSION_NAME, null, null,
EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE);
return extension;
}
|
[
"public",
"Extensions",
"getOrCreateExtension",
"(",
")",
"{",
"// Create table",
"geoPackage",
".",
"createContentsIdTable",
"(",
")",
";",
"Extensions",
"extension",
"=",
"getOrCreate",
"(",
"EXTENSION_NAME",
",",
"null",
",",
"null",
",",
"EXTENSION_DEFINITION",
",",
"ExtensionScopeType",
".",
"READ_WRITE",
")",
";",
"return",
"extension",
";",
"}"
] |
Get or create if needed the extension
@return extensions object
|
[
"Get",
"or",
"create",
"if",
"needed",
"the",
"extension"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/contents/ContentsIdExtension.java#L592-L601
|
6,064 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/core/srs/SpatialReferenceSystem.java
|
SpatialReferenceSystem.getProjection
|
public Projection getProjection() {
String authority = getOrganization();
long code = getOrganizationCoordsysId();
String definition = getDefinition_12_063();
if (definition == null) {
definition = getDefinition();
}
Projection projection = ProjectionFactory.getProjection(authority,
code, null, definition);
return projection;
}
|
java
|
public Projection getProjection() {
String authority = getOrganization();
long code = getOrganizationCoordsysId();
String definition = getDefinition_12_063();
if (definition == null) {
definition = getDefinition();
}
Projection projection = ProjectionFactory.getProjection(authority,
code, null, definition);
return projection;
}
|
[
"public",
"Projection",
"getProjection",
"(",
")",
"{",
"String",
"authority",
"=",
"getOrganization",
"(",
")",
";",
"long",
"code",
"=",
"getOrganizationCoordsysId",
"(",
")",
";",
"String",
"definition",
"=",
"getDefinition_12_063",
"(",
")",
";",
"if",
"(",
"definition",
"==",
"null",
")",
"{",
"definition",
"=",
"getDefinition",
"(",
")",
";",
"}",
"Projection",
"projection",
"=",
"ProjectionFactory",
".",
"getProjection",
"(",
"authority",
",",
"code",
",",
"null",
",",
"definition",
")",
";",
"return",
"projection",
";",
"}"
] |
Get the projection for the Spatial Reference System
@return projection
@since 3.0.0
|
[
"Get",
"the",
"projection",
"for",
"the",
"Spatial",
"Reference",
"System"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/core/srs/SpatialReferenceSystem.java#L336-L349
|
6,065 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/core/srs/SpatialReferenceSystem.java
|
SpatialReferenceSystem.getTransformation
|
public ProjectionTransform getTransformation(Projection projection) {
Projection projectionTo = getProjection();
return projection.getTransformation(projectionTo);
}
|
java
|
public ProjectionTransform getTransformation(Projection projection) {
Projection projectionTo = getProjection();
return projection.getTransformation(projectionTo);
}
|
[
"public",
"ProjectionTransform",
"getTransformation",
"(",
"Projection",
"projection",
")",
"{",
"Projection",
"projectionTo",
"=",
"getProjection",
"(",
")",
";",
"return",
"projection",
".",
"getTransformation",
"(",
"projectionTo",
")",
";",
"}"
] |
Get the projection transform from the provided projection to the Spatial
Reference System projection
@param projection
from projection
@return projection transform
@since 3.0.0
|
[
"Get",
"the",
"projection",
"transform",
"from",
"the",
"provided",
"projection",
"to",
"the",
"Spatial",
"Reference",
"System",
"projection"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/core/srs/SpatialReferenceSystem.java#L360-L363
|
6,066 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/index/GeometryIndexDao.java
|
GeometryIndexDao.populate
|
public GeometryIndex populate(TableIndex tableIndex, long geomId,
GeometryEnvelope envelope) {
GeometryIndex geometryIndex = new GeometryIndex();
geometryIndex.setTableIndex(tableIndex);
geometryIndex.setGeomId(geomId);
geometryIndex.setMinX(envelope.getMinX());
geometryIndex.setMaxX(envelope.getMaxX());
geometryIndex.setMinY(envelope.getMinY());
geometryIndex.setMaxY(envelope.getMaxY());
if (envelope.hasZ()) {
geometryIndex.setMinZ(envelope.getMinZ());
geometryIndex.setMaxZ(envelope.getMaxZ());
}
if (envelope.hasM()) {
geometryIndex.setMinM(envelope.getMinM());
geometryIndex.setMaxM(envelope.getMaxM());
}
return geometryIndex;
}
|
java
|
public GeometryIndex populate(TableIndex tableIndex, long geomId,
GeometryEnvelope envelope) {
GeometryIndex geometryIndex = new GeometryIndex();
geometryIndex.setTableIndex(tableIndex);
geometryIndex.setGeomId(geomId);
geometryIndex.setMinX(envelope.getMinX());
geometryIndex.setMaxX(envelope.getMaxX());
geometryIndex.setMinY(envelope.getMinY());
geometryIndex.setMaxY(envelope.getMaxY());
if (envelope.hasZ()) {
geometryIndex.setMinZ(envelope.getMinZ());
geometryIndex.setMaxZ(envelope.getMaxZ());
}
if (envelope.hasM()) {
geometryIndex.setMinM(envelope.getMinM());
geometryIndex.setMaxM(envelope.getMaxM());
}
return geometryIndex;
}
|
[
"public",
"GeometryIndex",
"populate",
"(",
"TableIndex",
"tableIndex",
",",
"long",
"geomId",
",",
"GeometryEnvelope",
"envelope",
")",
"{",
"GeometryIndex",
"geometryIndex",
"=",
"new",
"GeometryIndex",
"(",
")",
";",
"geometryIndex",
".",
"setTableIndex",
"(",
"tableIndex",
")",
";",
"geometryIndex",
".",
"setGeomId",
"(",
"geomId",
")",
";",
"geometryIndex",
".",
"setMinX",
"(",
"envelope",
".",
"getMinX",
"(",
")",
")",
";",
"geometryIndex",
".",
"setMaxX",
"(",
"envelope",
".",
"getMaxX",
"(",
")",
")",
";",
"geometryIndex",
".",
"setMinY",
"(",
"envelope",
".",
"getMinY",
"(",
")",
")",
";",
"geometryIndex",
".",
"setMaxY",
"(",
"envelope",
".",
"getMaxY",
"(",
")",
")",
";",
"if",
"(",
"envelope",
".",
"hasZ",
"(",
")",
")",
"{",
"geometryIndex",
".",
"setMinZ",
"(",
"envelope",
".",
"getMinZ",
"(",
")",
")",
";",
"geometryIndex",
".",
"setMaxZ",
"(",
"envelope",
".",
"getMaxZ",
"(",
")",
")",
";",
"}",
"if",
"(",
"envelope",
".",
"hasM",
"(",
")",
")",
"{",
"geometryIndex",
".",
"setMinM",
"(",
"envelope",
".",
"getMinM",
"(",
")",
")",
";",
"geometryIndex",
".",
"setMaxM",
"(",
"envelope",
".",
"getMaxM",
"(",
")",
")",
";",
"}",
"return",
"geometryIndex",
";",
"}"
] |
Populate a new geometry index from an envelope
@param tableIndex
table index
@param geomId
geometry id
@param envelope
geometry envelope
@return geometry index
|
[
"Populate",
"a",
"new",
"geometry",
"index",
"from",
"an",
"envelope"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/index/GeometryIndexDao.java#L220-L239
|
6,067 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/index/GeometryIndexDao.java
|
GeometryIndexDao.deleteAll
|
public int deleteAll() throws SQLException {
int count = 0;
if (isTableExists()) {
DeleteBuilder<GeometryIndex, GeometryIndexKey> db = deleteBuilder();
PreparedDelete<GeometryIndex> deleteQuery = db.prepare();
count = delete(deleteQuery);
}
return count;
}
|
java
|
public int deleteAll() throws SQLException {
int count = 0;
if (isTableExists()) {
DeleteBuilder<GeometryIndex, GeometryIndexKey> db = deleteBuilder();
PreparedDelete<GeometryIndex> deleteQuery = db.prepare();
count = delete(deleteQuery);
}
return count;
}
|
[
"public",
"int",
"deleteAll",
"(",
")",
"throws",
"SQLException",
"{",
"int",
"count",
"=",
"0",
";",
"if",
"(",
"isTableExists",
"(",
")",
")",
"{",
"DeleteBuilder",
"<",
"GeometryIndex",
",",
"GeometryIndexKey",
">",
"db",
"=",
"deleteBuilder",
"(",
")",
";",
"PreparedDelete",
"<",
"GeometryIndex",
">",
"deleteQuery",
"=",
"db",
".",
"prepare",
"(",
")",
";",
"count",
"=",
"delete",
"(",
"deleteQuery",
")",
";",
"}",
"return",
"count",
";",
"}"
] |
Delete all geometry indices
@return rows deleted
@throws SQLException
upon deletion failure
@since 1.1.5
|
[
"Delete",
"all",
"geometry",
"indices"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/index/GeometryIndexDao.java#L249-L260
|
6,068 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/related/dublin/DublinCoreMetadata.java
|
DublinCoreMetadata.hasColumn
|
public static boolean hasColumn(UserTable<?> table, DublinCoreType type) {
boolean hasColumn = table.hasColumn(type.getName());
if (!hasColumn) {
for (String synonym : type.getSynonyms()) {
hasColumn = table.hasColumn(synonym);
if (hasColumn) {
break;
}
}
}
return hasColumn;
}
|
java
|
public static boolean hasColumn(UserTable<?> table, DublinCoreType type) {
boolean hasColumn = table.hasColumn(type.getName());
if (!hasColumn) {
for (String synonym : type.getSynonyms()) {
hasColumn = table.hasColumn(synonym);
if (hasColumn) {
break;
}
}
}
return hasColumn;
}
|
[
"public",
"static",
"boolean",
"hasColumn",
"(",
"UserTable",
"<",
"?",
">",
"table",
",",
"DublinCoreType",
"type",
")",
"{",
"boolean",
"hasColumn",
"=",
"table",
".",
"hasColumn",
"(",
"type",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"!",
"hasColumn",
")",
"{",
"for",
"(",
"String",
"synonym",
":",
"type",
".",
"getSynonyms",
"(",
")",
")",
"{",
"hasColumn",
"=",
"table",
".",
"hasColumn",
"(",
"synonym",
")",
";",
"if",
"(",
"hasColumn",
")",
"{",
"break",
";",
"}",
"}",
"}",
"return",
"hasColumn",
";",
"}"
] |
Check if the table has a column for the Dublin Core Type term
@param table
user table
@param type
Dublin Core Type
@return true if has column
|
[
"Check",
"if",
"the",
"table",
"has",
"a",
"column",
"for",
"the",
"Dublin",
"Core",
"Type",
"term"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/related/dublin/DublinCoreMetadata.java#L24-L38
|
6,069 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/related/dublin/DublinCoreMetadata.java
|
DublinCoreMetadata.getColumn
|
public static <T extends UserColumn> T getColumn(UserTable<T> table,
DublinCoreType type) {
T column = null;
if (table.hasColumn(type.getName())) {
column = table.getColumn(type.getName());
} else {
for (String synonym : type.getSynonyms()) {
if (table.hasColumn(synonym)) {
column = table.getColumn(synonym);
break;
}
}
}
return column;
}
|
java
|
public static <T extends UserColumn> T getColumn(UserTable<T> table,
DublinCoreType type) {
T column = null;
if (table.hasColumn(type.getName())) {
column = table.getColumn(type.getName());
} else {
for (String synonym : type.getSynonyms()) {
if (table.hasColumn(synonym)) {
column = table.getColumn(synonym);
break;
}
}
}
return column;
}
|
[
"public",
"static",
"<",
"T",
"extends",
"UserColumn",
">",
"T",
"getColumn",
"(",
"UserTable",
"<",
"T",
">",
"table",
",",
"DublinCoreType",
"type",
")",
"{",
"T",
"column",
"=",
"null",
";",
"if",
"(",
"table",
".",
"hasColumn",
"(",
"type",
".",
"getName",
"(",
")",
")",
")",
"{",
"column",
"=",
"table",
".",
"getColumn",
"(",
"type",
".",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"for",
"(",
"String",
"synonym",
":",
"type",
".",
"getSynonyms",
"(",
")",
")",
"{",
"if",
"(",
"table",
".",
"hasColumn",
"(",
"synonym",
")",
")",
"{",
"column",
"=",
"table",
".",
"getColumn",
"(",
"synonym",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"column",
";",
"}"
] |
Get the column from the table for the Dublin Core Type term
@param table
user table
@param type
Dublin Core Type
@param <T>
column type
@return column
|
[
"Get",
"the",
"column",
"from",
"the",
"table",
"for",
"the",
"Dublin",
"Core",
"Type",
"term"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/related/dublin/DublinCoreMetadata.java#L64-L81
|
6,070 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/related/dublin/DublinCoreMetadata.java
|
DublinCoreMetadata.getColumn
|
public static <T extends UserColumn> T getColumn(UserCoreRow<T, ?> row,
DublinCoreType type) {
return getColumn(row.getTable(), type);
}
|
java
|
public static <T extends UserColumn> T getColumn(UserCoreRow<T, ?> row,
DublinCoreType type) {
return getColumn(row.getTable(), type);
}
|
[
"public",
"static",
"<",
"T",
"extends",
"UserColumn",
">",
"T",
"getColumn",
"(",
"UserCoreRow",
"<",
"T",
",",
"?",
">",
"row",
",",
"DublinCoreType",
"type",
")",
"{",
"return",
"getColumn",
"(",
"row",
".",
"getTable",
"(",
")",
",",
"type",
")",
";",
"}"
] |
Get the column from the row for the Dublin Core Type term
@param row
user row
@param type
Dublin Core Type
@param <T>
column type
@return column
|
[
"Get",
"the",
"column",
"from",
"the",
"row",
"for",
"the",
"Dublin",
"Core",
"Type",
"term"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/related/dublin/DublinCoreMetadata.java#L94-L97
|
6,071 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/related/dublin/DublinCoreMetadata.java
|
DublinCoreMetadata.getValue
|
public static Object getValue(UserCoreRow<?, ?> row, DublinCoreType type) {
UserColumn column = getColumn(row, type);
Object value = row.getValue(column.getIndex());
return value;
}
|
java
|
public static Object getValue(UserCoreRow<?, ?> row, DublinCoreType type) {
UserColumn column = getColumn(row, type);
Object value = row.getValue(column.getIndex());
return value;
}
|
[
"public",
"static",
"Object",
"getValue",
"(",
"UserCoreRow",
"<",
"?",
",",
"?",
">",
"row",
",",
"DublinCoreType",
"type",
")",
"{",
"UserColumn",
"column",
"=",
"getColumn",
"(",
"row",
",",
"type",
")",
";",
"Object",
"value",
"=",
"row",
".",
"getValue",
"(",
"column",
".",
"getIndex",
"(",
")",
")",
";",
"return",
"value",
";",
"}"
] |
Get the value from the row for the Dublin Core Type term
@param row
user row
@param type
Dublin Core Type
@return value
|
[
"Get",
"the",
"value",
"from",
"the",
"row",
"for",
"the",
"Dublin",
"Core",
"Type",
"term"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/related/dublin/DublinCoreMetadata.java#L108-L115
|
6,072 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/coverage/CoverageDataRequest.java
|
CoverageDataRequest.overlap
|
public BoundingBox overlap(BoundingBox projectedCoverage) {
BoundingBox overlap = null;
if (point) {
overlap = projectedBoundingBox;
} else {
overlap = projectedBoundingBox.overlap(projectedCoverage);
}
return overlap;
}
|
java
|
public BoundingBox overlap(BoundingBox projectedCoverage) {
BoundingBox overlap = null;
if (point) {
overlap = projectedBoundingBox;
} else {
overlap = projectedBoundingBox.overlap(projectedCoverage);
}
return overlap;
}
|
[
"public",
"BoundingBox",
"overlap",
"(",
"BoundingBox",
"projectedCoverage",
")",
"{",
"BoundingBox",
"overlap",
"=",
"null",
";",
"if",
"(",
"point",
")",
"{",
"overlap",
"=",
"projectedBoundingBox",
";",
"}",
"else",
"{",
"overlap",
"=",
"projectedBoundingBox",
".",
"overlap",
"(",
"projectedCoverage",
")",
";",
"}",
"return",
"overlap",
";",
"}"
] |
Get the bounding box overlap between the projected bounding box and the
coverage data bounding box
@param projectedCoverage
projected coverage
@return overlap bounding box
|
[
"Get",
"the",
"bounding",
"box",
"overlap",
"between",
"the",
"projected",
"bounding",
"box",
"and",
"the",
"coverage",
"data",
"bounding",
"box"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/coverage/CoverageDataRequest.java#L97-L105
|
6,073 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java
|
FeatureTileTableCoreLinker.link
|
public void link(String featureTable, String tileTable) {
if (!isLinked(featureTable, tileTable)) {
getOrCreateExtension();
try {
if (!featureTileLinkDao.isTableExists()) {
geoPackage.createFeatureTileLinkTable();
}
FeatureTileLink link = new FeatureTileLink();
link.setFeatureTableName(featureTable);
link.setTileTableName(tileTable);
featureTileLinkDao.create(link);
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to create feature tile link for GeoPackage: "
+ geoPackage.getName() + ", Feature Table: "
+ featureTable + ", Tile Table: " + tileTable,
e);
}
}
}
|
java
|
public void link(String featureTable, String tileTable) {
if (!isLinked(featureTable, tileTable)) {
getOrCreateExtension();
try {
if (!featureTileLinkDao.isTableExists()) {
geoPackage.createFeatureTileLinkTable();
}
FeatureTileLink link = new FeatureTileLink();
link.setFeatureTableName(featureTable);
link.setTileTableName(tileTable);
featureTileLinkDao.create(link);
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to create feature tile link for GeoPackage: "
+ geoPackage.getName() + ", Feature Table: "
+ featureTable + ", Tile Table: " + tileTable,
e);
}
}
}
|
[
"public",
"void",
"link",
"(",
"String",
"featureTable",
",",
"String",
"tileTable",
")",
"{",
"if",
"(",
"!",
"isLinked",
"(",
"featureTable",
",",
"tileTable",
")",
")",
"{",
"getOrCreateExtension",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"featureTileLinkDao",
".",
"isTableExists",
"(",
")",
")",
"{",
"geoPackage",
".",
"createFeatureTileLinkTable",
"(",
")",
";",
"}",
"FeatureTileLink",
"link",
"=",
"new",
"FeatureTileLink",
"(",
")",
";",
"link",
".",
"setFeatureTableName",
"(",
"featureTable",
")",
";",
"link",
".",
"setTileTableName",
"(",
"tileTable",
")",
";",
"featureTileLinkDao",
".",
"create",
"(",
"link",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to create feature tile link for GeoPackage: \"",
"+",
"geoPackage",
".",
"getName",
"(",
")",
"+",
"\", Feature Table: \"",
"+",
"featureTable",
"+",
"\", Tile Table: \"",
"+",
"tileTable",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Link a feature and tile table together. Does nothing if already linked.
@param featureTable
feature table
@param tileTable
tile table
|
[
"Link",
"a",
"feature",
"and",
"tile",
"table",
"together",
".",
"Does",
"nothing",
"if",
"already",
"linked",
"."
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java#L88-L111
|
6,074 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java
|
FeatureTileTableCoreLinker.isLinked
|
public boolean isLinked(String featureTable, String tileTable) {
FeatureTileLink link = getLink(featureTable, tileTable);
return link != null;
}
|
java
|
public boolean isLinked(String featureTable, String tileTable) {
FeatureTileLink link = getLink(featureTable, tileTable);
return link != null;
}
|
[
"public",
"boolean",
"isLinked",
"(",
"String",
"featureTable",
",",
"String",
"tileTable",
")",
"{",
"FeatureTileLink",
"link",
"=",
"getLink",
"(",
"featureTable",
",",
"tileTable",
")",
";",
"return",
"link",
"!=",
"null",
";",
"}"
] |
Determine if the feature table is linked to the tile table
@param featureTable
feature table
@param tileTable
tile table
@return true if linked
|
[
"Determine",
"if",
"the",
"feature",
"table",
"is",
"linked",
"to",
"the",
"tile",
"table"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java#L122-L125
|
6,075 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java
|
FeatureTileTableCoreLinker.getLink
|
public FeatureTileLink getLink(String featureTable, String tileTable) {
FeatureTileLink link = null;
if (featureTileLinksActive()) {
FeatureTileLinkKey id = new FeatureTileLinkKey(featureTable,
tileTable);
try {
link = featureTileLinkDao.queryForId(id);
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to get feature tile link for GeoPackage: "
+ geoPackage.getName() + ", Feature Table: "
+ featureTable + ", Tile Table: " + tileTable,
e);
}
}
return link;
}
|
java
|
public FeatureTileLink getLink(String featureTable, String tileTable) {
FeatureTileLink link = null;
if (featureTileLinksActive()) {
FeatureTileLinkKey id = new FeatureTileLinkKey(featureTable,
tileTable);
try {
link = featureTileLinkDao.queryForId(id);
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to get feature tile link for GeoPackage: "
+ geoPackage.getName() + ", Feature Table: "
+ featureTable + ", Tile Table: " + tileTable,
e);
}
}
return link;
}
|
[
"public",
"FeatureTileLink",
"getLink",
"(",
"String",
"featureTable",
",",
"String",
"tileTable",
")",
"{",
"FeatureTileLink",
"link",
"=",
"null",
";",
"if",
"(",
"featureTileLinksActive",
"(",
")",
")",
"{",
"FeatureTileLinkKey",
"id",
"=",
"new",
"FeatureTileLinkKey",
"(",
"featureTable",
",",
"tileTable",
")",
";",
"try",
"{",
"link",
"=",
"featureTileLinkDao",
".",
"queryForId",
"(",
"id",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to get feature tile link for GeoPackage: \"",
"+",
"geoPackage",
".",
"getName",
"(",
")",
"+",
"\", Feature Table: \"",
"+",
"featureTable",
"+",
"\", Tile Table: \"",
"+",
"tileTable",
",",
"e",
")",
";",
"}",
"}",
"return",
"link",
";",
"}"
] |
Get the feature and tile table link if it exists
@param featureTable
feature table
@param tileTable
tile table
@return link or null
|
[
"Get",
"the",
"feature",
"and",
"tile",
"table",
"link",
"if",
"it",
"exists"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java#L136-L154
|
6,076 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java
|
FeatureTileTableCoreLinker.queryForFeatureTable
|
public List<FeatureTileLink> queryForFeatureTable(String featureTable) {
List<FeatureTileLink> links = null;
if (featureTileLinksActive()) {
links = featureTileLinkDao.queryForFeatureTableName(featureTable);
} else {
links = new ArrayList<FeatureTileLink>();
}
return links;
}
|
java
|
public List<FeatureTileLink> queryForFeatureTable(String featureTable) {
List<FeatureTileLink> links = null;
if (featureTileLinksActive()) {
links = featureTileLinkDao.queryForFeatureTableName(featureTable);
} else {
links = new ArrayList<FeatureTileLink>();
}
return links;
}
|
[
"public",
"List",
"<",
"FeatureTileLink",
">",
"queryForFeatureTable",
"(",
"String",
"featureTable",
")",
"{",
"List",
"<",
"FeatureTileLink",
">",
"links",
"=",
"null",
";",
"if",
"(",
"featureTileLinksActive",
"(",
")",
")",
"{",
"links",
"=",
"featureTileLinkDao",
".",
"queryForFeatureTableName",
"(",
"featureTable",
")",
";",
"}",
"else",
"{",
"links",
"=",
"new",
"ArrayList",
"<",
"FeatureTileLink",
">",
"(",
")",
";",
"}",
"return",
"links",
";",
"}"
] |
Query for feature tile links by feature table
@param featureTable
feature table
@return links
|
[
"Query",
"for",
"feature",
"tile",
"links",
"by",
"feature",
"table"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java#L163-L174
|
6,077 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java
|
FeatureTileTableCoreLinker.queryForTileTable
|
public List<FeatureTileLink> queryForTileTable(String tileTable) {
List<FeatureTileLink> links = null;
if (featureTileLinksActive()) {
links = featureTileLinkDao.queryForTileTableName(tileTable);
} else {
links = new ArrayList<FeatureTileLink>();
}
return links;
}
|
java
|
public List<FeatureTileLink> queryForTileTable(String tileTable) {
List<FeatureTileLink> links = null;
if (featureTileLinksActive()) {
links = featureTileLinkDao.queryForTileTableName(tileTable);
} else {
links = new ArrayList<FeatureTileLink>();
}
return links;
}
|
[
"public",
"List",
"<",
"FeatureTileLink",
">",
"queryForTileTable",
"(",
"String",
"tileTable",
")",
"{",
"List",
"<",
"FeatureTileLink",
">",
"links",
"=",
"null",
";",
"if",
"(",
"featureTileLinksActive",
"(",
")",
")",
"{",
"links",
"=",
"featureTileLinkDao",
".",
"queryForTileTableName",
"(",
"tileTable",
")",
";",
"}",
"else",
"{",
"links",
"=",
"new",
"ArrayList",
"<",
"FeatureTileLink",
">",
"(",
")",
";",
"}",
"return",
"links",
";",
"}"
] |
Query for feature tile links by tile table
@param tileTable
tile table
@return links
|
[
"Query",
"for",
"feature",
"tile",
"links",
"by",
"tile",
"table"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java#L183-L194
|
6,078 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java
|
FeatureTileTableCoreLinker.deleteLink
|
public boolean deleteLink(String featureTable, String tileTable) {
boolean deleted = false;
try {
if (featureTileLinkDao.isTableExists()) {
FeatureTileLinkKey id = new FeatureTileLinkKey(featureTable,
tileTable);
deleted = featureTileLinkDao.deleteById(id) > 0;
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to delete feature tile link for GeoPackage: "
+ geoPackage.getName() + ", Feature Table: "
+ featureTable + ", Tile Table: " + tileTable, e);
}
return deleted;
}
|
java
|
public boolean deleteLink(String featureTable, String tileTable) {
boolean deleted = false;
try {
if (featureTileLinkDao.isTableExists()) {
FeatureTileLinkKey id = new FeatureTileLinkKey(featureTable,
tileTable);
deleted = featureTileLinkDao.deleteById(id) > 0;
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to delete feature tile link for GeoPackage: "
+ geoPackage.getName() + ", Feature Table: "
+ featureTable + ", Tile Table: " + tileTable, e);
}
return deleted;
}
|
[
"public",
"boolean",
"deleteLink",
"(",
"String",
"featureTable",
",",
"String",
"tileTable",
")",
"{",
"boolean",
"deleted",
"=",
"false",
";",
"try",
"{",
"if",
"(",
"featureTileLinkDao",
".",
"isTableExists",
"(",
")",
")",
"{",
"FeatureTileLinkKey",
"id",
"=",
"new",
"FeatureTileLinkKey",
"(",
"featureTable",
",",
"tileTable",
")",
";",
"deleted",
"=",
"featureTileLinkDao",
".",
"deleteById",
"(",
"id",
")",
">",
"0",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to delete feature tile link for GeoPackage: \"",
"+",
"geoPackage",
".",
"getName",
"(",
")",
"+",
"\", Feature Table: \"",
"+",
"featureTable",
"+",
"\", Tile Table: \"",
"+",
"tileTable",
",",
"e",
")",
";",
"}",
"return",
"deleted",
";",
"}"
] |
Delete the feature tile table link
@param featureTable
feature table
@param tileTable
tile table
@return true if deleted
|
[
"Delete",
"the",
"feature",
"tile",
"table",
"link"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java#L205-L223
|
6,079 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java
|
FeatureTileTableCoreLinker.deleteLinks
|
public int deleteLinks(String table) {
int deleted = 0;
try {
if (featureTileLinkDao.isTableExists()) {
deleted = featureTileLinkDao.deleteByTableName(table);
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to delete feature tile links for GeoPackage: "
+ geoPackage.getName() + ", Table: " + table, e);
}
return deleted;
}
|
java
|
public int deleteLinks(String table) {
int deleted = 0;
try {
if (featureTileLinkDao.isTableExists()) {
deleted = featureTileLinkDao.deleteByTableName(table);
}
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to delete feature tile links for GeoPackage: "
+ geoPackage.getName() + ", Table: " + table, e);
}
return deleted;
}
|
[
"public",
"int",
"deleteLinks",
"(",
"String",
"table",
")",
"{",
"int",
"deleted",
"=",
"0",
";",
"try",
"{",
"if",
"(",
"featureTileLinkDao",
".",
"isTableExists",
"(",
")",
")",
"{",
"deleted",
"=",
"featureTileLinkDao",
".",
"deleteByTableName",
"(",
"table",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to delete feature tile links for GeoPackage: \"",
"+",
"geoPackage",
".",
"getName",
"(",
")",
"+",
"\", Table: \"",
"+",
"table",
",",
"e",
")",
";",
"}",
"return",
"deleted",
";",
"}"
] |
Delete the feature tile table links for the feature or tile table
@param table
table name
@return links deleted
|
[
"Delete",
"the",
"feature",
"tile",
"table",
"links",
"for",
"the",
"feature",
"or",
"tile",
"table"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java#L232-L247
|
6,080 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java
|
FeatureTileTableCoreLinker.featureTileLinksActive
|
private boolean featureTileLinksActive() {
boolean active = false;
if (has()) {
try {
active = featureTileLinkDao.isTableExists();
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to check if the feature tile link table exists for GeoPackage: "
+ geoPackage.getName(), e);
}
}
return active;
}
|
java
|
private boolean featureTileLinksActive() {
boolean active = false;
if (has()) {
try {
active = featureTileLinkDao.isTableExists();
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to check if the feature tile link table exists for GeoPackage: "
+ geoPackage.getName(), e);
}
}
return active;
}
|
[
"private",
"boolean",
"featureTileLinksActive",
"(",
")",
"{",
"boolean",
"active",
"=",
"false",
";",
"if",
"(",
"has",
"(",
")",
")",
"{",
"try",
"{",
"active",
"=",
"featureTileLinkDao",
".",
"isTableExists",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to check if the feature tile link table exists for GeoPackage: \"",
"+",
"geoPackage",
".",
"getName",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"return",
"active",
";",
"}"
] |
Determine if the feature tile link extension and table exists
@return
|
[
"Determine",
"if",
"the",
"feature",
"tile",
"link",
"extension",
"and",
"table",
"exists"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java#L289-L304
|
6,081 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java
|
FeatureTileTableCoreLinker.getTileTablesForFeatureTable
|
public List<String> getTileTablesForFeatureTable(String featureTable) {
List<String> tileTables = new ArrayList<String>();
List<FeatureTileLink> links = queryForFeatureTable(featureTable);
for (FeatureTileLink link : links) {
tileTables.add(link.getTileTableName());
}
return tileTables;
}
|
java
|
public List<String> getTileTablesForFeatureTable(String featureTable) {
List<String> tileTables = new ArrayList<String>();
List<FeatureTileLink> links = queryForFeatureTable(featureTable);
for (FeatureTileLink link : links) {
tileTables.add(link.getTileTableName());
}
return tileTables;
}
|
[
"public",
"List",
"<",
"String",
">",
"getTileTablesForFeatureTable",
"(",
"String",
"featureTable",
")",
"{",
"List",
"<",
"String",
">",
"tileTables",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"List",
"<",
"FeatureTileLink",
">",
"links",
"=",
"queryForFeatureTable",
"(",
"featureTable",
")",
";",
"for",
"(",
"FeatureTileLink",
"link",
":",
"links",
")",
"{",
"tileTables",
".",
"add",
"(",
"link",
".",
"getTileTableName",
"(",
")",
")",
";",
"}",
"return",
"tileTables",
";",
"}"
] |
Query for the tile table names linked to a feature table
@param featureTable
feature table
@return tiles tables
|
[
"Query",
"for",
"the",
"tile",
"table",
"names",
"linked",
"to",
"a",
"feature",
"table"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java#L313-L323
|
6,082 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java
|
FeatureTileTableCoreLinker.getFeatureTablesForTileTable
|
public List<String> getFeatureTablesForTileTable(String tileTable) {
List<String> featureTables = new ArrayList<String>();
List<FeatureTileLink> links = queryForTileTable(tileTable);
for (FeatureTileLink link : links) {
featureTables.add(link.getFeatureTableName());
}
return featureTables;
}
|
java
|
public List<String> getFeatureTablesForTileTable(String tileTable) {
List<String> featureTables = new ArrayList<String>();
List<FeatureTileLink> links = queryForTileTable(tileTable);
for (FeatureTileLink link : links) {
featureTables.add(link.getFeatureTableName());
}
return featureTables;
}
|
[
"public",
"List",
"<",
"String",
">",
"getFeatureTablesForTileTable",
"(",
"String",
"tileTable",
")",
"{",
"List",
"<",
"String",
">",
"featureTables",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"List",
"<",
"FeatureTileLink",
">",
"links",
"=",
"queryForTileTable",
"(",
"tileTable",
")",
";",
"for",
"(",
"FeatureTileLink",
"link",
":",
"links",
")",
"{",
"featureTables",
".",
"add",
"(",
"link",
".",
"getFeatureTableName",
"(",
")",
")",
";",
"}",
"return",
"featureTables",
";",
"}"
] |
Query for the feature table names linked to a tile table
@param tileTable
tile table
@return feature tables
|
[
"Query",
"for",
"the",
"feature",
"table",
"names",
"linked",
"to",
"a",
"tile",
"table"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/link/FeatureTileTableCoreLinker.java#L332-L342
|
6,083 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/io/GeoPackageIOUtils.java
|
GeoPackageIOUtils.getFileExtension
|
public static String getFileExtension(File file) {
String fileName = file.getName();
String extension = null;
int extensionIndex = fileName.lastIndexOf(".");
if (extensionIndex > -1) {
extension = fileName.substring(extensionIndex + 1);
}
return extension;
}
|
java
|
public static String getFileExtension(File file) {
String fileName = file.getName();
String extension = null;
int extensionIndex = fileName.lastIndexOf(".");
if (extensionIndex > -1) {
extension = fileName.substring(extensionIndex + 1);
}
return extension;
}
|
[
"public",
"static",
"String",
"getFileExtension",
"(",
"File",
"file",
")",
"{",
"String",
"fileName",
"=",
"file",
".",
"getName",
"(",
")",
";",
"String",
"extension",
"=",
"null",
";",
"int",
"extensionIndex",
"=",
"fileName",
".",
"lastIndexOf",
"(",
"\".\"",
")",
";",
"if",
"(",
"extensionIndex",
">",
"-",
"1",
")",
"{",
"extension",
"=",
"fileName",
".",
"substring",
"(",
"extensionIndex",
"+",
"1",
")",
";",
"}",
"return",
"extension",
";",
"}"
] |
Get the file extension
@param file
file
@return extension
|
[
"Get",
"the",
"file",
"extension"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/io/GeoPackageIOUtils.java#L35-L46
|
6,084 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/io/GeoPackageIOUtils.java
|
GeoPackageIOUtils.addFileExtension
|
public static File addFileExtension(File file, String extension) {
return new File(file.getAbsolutePath() + "." + extension);
}
|
java
|
public static File addFileExtension(File file, String extension) {
return new File(file.getAbsolutePath() + "." + extension);
}
|
[
"public",
"static",
"File",
"addFileExtension",
"(",
"File",
"file",
",",
"String",
"extension",
")",
"{",
"return",
"new",
"File",
"(",
"file",
".",
"getAbsolutePath",
"(",
")",
"+",
"\".\"",
"+",
"extension",
")",
";",
"}"
] |
Add a the file extension to the file
@param file
file
@param extension
file extension
@return new file with extension
@since 3.0.2
|
[
"Add",
"a",
"the",
"file",
"extension",
"to",
"the",
"file"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/io/GeoPackageIOUtils.java#L70-L72
|
6,085 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/io/GeoPackageIOUtils.java
|
GeoPackageIOUtils.getFileNameWithoutExtension
|
public static String getFileNameWithoutExtension(File file) {
String name = file.getName();
int extensionIndex = name.lastIndexOf(".");
if (extensionIndex > -1) {
name = name.substring(0, extensionIndex);
}
return name;
}
|
java
|
public static String getFileNameWithoutExtension(File file) {
String name = file.getName();
int extensionIndex = name.lastIndexOf(".");
if (extensionIndex > -1) {
name = name.substring(0, extensionIndex);
}
return name;
}
|
[
"public",
"static",
"String",
"getFileNameWithoutExtension",
"(",
"File",
"file",
")",
"{",
"String",
"name",
"=",
"file",
".",
"getName",
"(",
")",
";",
"int",
"extensionIndex",
"=",
"name",
".",
"lastIndexOf",
"(",
"\".\"",
")",
";",
"if",
"(",
"extensionIndex",
">",
"-",
"1",
")",
"{",
"name",
"=",
"name",
".",
"substring",
"(",
"0",
",",
"extensionIndex",
")",
";",
"}",
"return",
"name",
";",
"}"
] |
Get the file name with the extension removed
@param file
file
@return file name
|
[
"Get",
"the",
"file",
"name",
"with",
"the",
"extension",
"removed"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/io/GeoPackageIOUtils.java#L81-L91
|
6,086 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/io/GeoPackageIOUtils.java
|
GeoPackageIOUtils.copyFile
|
public static void copyFile(File copyFrom, File copyTo) throws IOException {
InputStream from = new FileInputStream(copyFrom);
OutputStream to = new FileOutputStream(copyTo);
copyStream(from, to);
}
|
java
|
public static void copyFile(File copyFrom, File copyTo) throws IOException {
InputStream from = new FileInputStream(copyFrom);
OutputStream to = new FileOutputStream(copyTo);
copyStream(from, to);
}
|
[
"public",
"static",
"void",
"copyFile",
"(",
"File",
"copyFrom",
",",
"File",
"copyTo",
")",
"throws",
"IOException",
"{",
"InputStream",
"from",
"=",
"new",
"FileInputStream",
"(",
"copyFrom",
")",
";",
"OutputStream",
"to",
"=",
"new",
"FileOutputStream",
"(",
"copyTo",
")",
";",
"copyStream",
"(",
"from",
",",
"to",
")",
";",
"}"
] |
Copy a file to a file location
@param copyFrom
from file
@param copyTo
to file
@throws IOException
upon failure
|
[
"Copy",
"a",
"file",
"to",
"a",
"file",
"location"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/io/GeoPackageIOUtils.java#L103-L109
|
6,087 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/io/GeoPackageIOUtils.java
|
GeoPackageIOUtils.fileBytes
|
public static byte[] fileBytes(File file) throws IOException {
FileInputStream fis = new FileInputStream(file);
return streamBytes(fis);
}
|
java
|
public static byte[] fileBytes(File file) throws IOException {
FileInputStream fis = new FileInputStream(file);
return streamBytes(fis);
}
|
[
"public",
"static",
"byte",
"[",
"]",
"fileBytes",
"(",
"File",
"file",
")",
"throws",
"IOException",
"{",
"FileInputStream",
"fis",
"=",
"new",
"FileInputStream",
"(",
"file",
")",
";",
"return",
"streamBytes",
"(",
"fis",
")",
";",
"}"
] |
Get the file bytes
@param file
input file
@return file bytes
@throws IOException
upon failure
|
[
"Get",
"the",
"file",
"bytes"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/io/GeoPackageIOUtils.java#L161-L166
|
6,088 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/io/GeoPackageIOUtils.java
|
GeoPackageIOUtils.streamBytes
|
public static byte[] streamBytes(InputStream stream) throws IOException {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
copyStream(stream, bytes);
return bytes.toByteArray();
}
|
java
|
public static byte[] streamBytes(InputStream stream) throws IOException {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
copyStream(stream, bytes);
return bytes.toByteArray();
}
|
[
"public",
"static",
"byte",
"[",
"]",
"streamBytes",
"(",
"InputStream",
"stream",
")",
"throws",
"IOException",
"{",
"ByteArrayOutputStream",
"bytes",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"copyStream",
"(",
"stream",
",",
"bytes",
")",
";",
"return",
"bytes",
".",
"toByteArray",
"(",
")",
";",
"}"
] |
Get the stream bytes
@param stream
input stream
@return stream bytes
@throws IOException
upon failure
|
[
"Get",
"the",
"stream",
"bytes"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/io/GeoPackageIOUtils.java#L177-L184
|
6,089 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/io/GeoPackageIOUtils.java
|
GeoPackageIOUtils.formatBytes
|
public static String formatBytes(long bytes) {
double value = bytes;
String unit = "B";
if (bytes >= 1024) {
int exponent = (int) (Math.log(bytes) / Math.log(1024));
exponent = Math.min(exponent, 4);
switch (exponent) {
case 1:
unit = "KB";
break;
case 2:
unit = "MB";
break;
case 3:
unit = "GB";
break;
case 4:
unit = "TB";
break;
}
value = bytes / Math.pow(1024, exponent);
}
DecimalFormat df = new DecimalFormat("#.##");
return df.format(value) + " " + unit;
}
|
java
|
public static String formatBytes(long bytes) {
double value = bytes;
String unit = "B";
if (bytes >= 1024) {
int exponent = (int) (Math.log(bytes) / Math.log(1024));
exponent = Math.min(exponent, 4);
switch (exponent) {
case 1:
unit = "KB";
break;
case 2:
unit = "MB";
break;
case 3:
unit = "GB";
break;
case 4:
unit = "TB";
break;
}
value = bytes / Math.pow(1024, exponent);
}
DecimalFormat df = new DecimalFormat("#.##");
return df.format(value) + " " + unit;
}
|
[
"public",
"static",
"String",
"formatBytes",
"(",
"long",
"bytes",
")",
"{",
"double",
"value",
"=",
"bytes",
";",
"String",
"unit",
"=",
"\"B\"",
";",
"if",
"(",
"bytes",
">=",
"1024",
")",
"{",
"int",
"exponent",
"=",
"(",
"int",
")",
"(",
"Math",
".",
"log",
"(",
"bytes",
")",
"/",
"Math",
".",
"log",
"(",
"1024",
")",
")",
";",
"exponent",
"=",
"Math",
".",
"min",
"(",
"exponent",
",",
"4",
")",
";",
"switch",
"(",
"exponent",
")",
"{",
"case",
"1",
":",
"unit",
"=",
"\"KB\"",
";",
"break",
";",
"case",
"2",
":",
"unit",
"=",
"\"MB\"",
";",
"break",
";",
"case",
"3",
":",
"unit",
"=",
"\"GB\"",
";",
"break",
";",
"case",
"4",
":",
"unit",
"=",
"\"TB\"",
";",
"break",
";",
"}",
"value",
"=",
"bytes",
"/",
"Math",
".",
"pow",
"(",
"1024",
",",
"exponent",
")",
";",
"}",
"DecimalFormat",
"df",
"=",
"new",
"DecimalFormat",
"(",
"\"#.##\"",
")",
";",
"return",
"df",
".",
"format",
"(",
"value",
")",
"+",
"\" \"",
"+",
"unit",
";",
"}"
] |
Format the bytes into readable text
@param bytes
bytes
@return bytes text
|
[
"Format",
"the",
"bytes",
"into",
"readable",
"text"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/io/GeoPackageIOUtils.java#L242-L269
|
6,090 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/link/FeatureTileLinkDao.java
|
FeatureTileLinkDao.queryForFeatureTableName
|
public List<FeatureTileLink> queryForFeatureTableName(
String featureTableName) {
List<FeatureTileLink> results = null;
try {
results = queryForEq(FeatureTileLink.COLUMN_FEATURE_TABLE_NAME,
featureTableName);
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to query for Feature Tile Link objects by Feature Table Name: "
+ featureTableName);
}
return results;
}
|
java
|
public List<FeatureTileLink> queryForFeatureTableName(
String featureTableName) {
List<FeatureTileLink> results = null;
try {
results = queryForEq(FeatureTileLink.COLUMN_FEATURE_TABLE_NAME,
featureTableName);
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to query for Feature Tile Link objects by Feature Table Name: "
+ featureTableName);
}
return results;
}
|
[
"public",
"List",
"<",
"FeatureTileLink",
">",
"queryForFeatureTableName",
"(",
"String",
"featureTableName",
")",
"{",
"List",
"<",
"FeatureTileLink",
">",
"results",
"=",
"null",
";",
"try",
"{",
"results",
"=",
"queryForEq",
"(",
"FeatureTileLink",
".",
"COLUMN_FEATURE_TABLE_NAME",
",",
"featureTableName",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to query for Feature Tile Link objects by Feature Table Name: \"",
"+",
"featureTableName",
")",
";",
"}",
"return",
"results",
";",
"}"
] |
Query by feature table name
@param featureTableName
feature table name
@return feature tile links
|
[
"Query",
"by",
"feature",
"table",
"name"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/link/FeatureTileLinkDao.java#L191-L203
|
6,091 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/link/FeatureTileLinkDao.java
|
FeatureTileLinkDao.queryForTileTableName
|
public List<FeatureTileLink> queryForTileTableName(String tileTableName) {
List<FeatureTileLink> results = null;
try {
results = queryForEq(FeatureTileLink.COLUMN_TILE_TABLE_NAME,
tileTableName);
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to query for Feature Tile Link objects by Tile Table Name: "
+ tileTableName);
}
return results;
}
|
java
|
public List<FeatureTileLink> queryForTileTableName(String tileTableName) {
List<FeatureTileLink> results = null;
try {
results = queryForEq(FeatureTileLink.COLUMN_TILE_TABLE_NAME,
tileTableName);
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to query for Feature Tile Link objects by Tile Table Name: "
+ tileTableName);
}
return results;
}
|
[
"public",
"List",
"<",
"FeatureTileLink",
">",
"queryForTileTableName",
"(",
"String",
"tileTableName",
")",
"{",
"List",
"<",
"FeatureTileLink",
">",
"results",
"=",
"null",
";",
"try",
"{",
"results",
"=",
"queryForEq",
"(",
"FeatureTileLink",
".",
"COLUMN_TILE_TABLE_NAME",
",",
"tileTableName",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to query for Feature Tile Link objects by Tile Table Name: \"",
"+",
"tileTableName",
")",
";",
"}",
"return",
"results",
";",
"}"
] |
Query by tile table name
@param tileTableName
tile table name
@return feature tile links
|
[
"Query",
"by",
"tile",
"table",
"name"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/link/FeatureTileLinkDao.java#L212-L223
|
6,092 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/link/FeatureTileLinkDao.java
|
FeatureTileLinkDao.deleteByTableName
|
public int deleteByTableName(String tableName) throws SQLException {
DeleteBuilder<FeatureTileLink, FeatureTileLinkKey> db = deleteBuilder();
db.where().eq(FeatureTileLink.COLUMN_FEATURE_TABLE_NAME, tableName)
.or().eq(FeatureTileLink.COLUMN_TILE_TABLE_NAME, tableName);
PreparedDelete<FeatureTileLink> deleteQuery = db.prepare();
int deleted = delete(deleteQuery);
return deleted;
}
|
java
|
public int deleteByTableName(String tableName) throws SQLException {
DeleteBuilder<FeatureTileLink, FeatureTileLinkKey> db = deleteBuilder();
db.where().eq(FeatureTileLink.COLUMN_FEATURE_TABLE_NAME, tableName)
.or().eq(FeatureTileLink.COLUMN_TILE_TABLE_NAME, tableName);
PreparedDelete<FeatureTileLink> deleteQuery = db.prepare();
int deleted = delete(deleteQuery);
return deleted;
}
|
[
"public",
"int",
"deleteByTableName",
"(",
"String",
"tableName",
")",
"throws",
"SQLException",
"{",
"DeleteBuilder",
"<",
"FeatureTileLink",
",",
"FeatureTileLinkKey",
">",
"db",
"=",
"deleteBuilder",
"(",
")",
";",
"db",
".",
"where",
"(",
")",
".",
"eq",
"(",
"FeatureTileLink",
".",
"COLUMN_FEATURE_TABLE_NAME",
",",
"tableName",
")",
".",
"or",
"(",
")",
".",
"eq",
"(",
"FeatureTileLink",
".",
"COLUMN_TILE_TABLE_NAME",
",",
"tableName",
")",
";",
"PreparedDelete",
"<",
"FeatureTileLink",
">",
"deleteQuery",
"=",
"db",
".",
"prepare",
"(",
")",
";",
"int",
"deleted",
"=",
"delete",
"(",
"deleteQuery",
")",
";",
"return",
"deleted",
";",
"}"
] |
Delete by table name, either feature or tile table name
@param tableName
table name, feature or tile
@return rows deleted
@throws SQLException
upon failure
|
[
"Delete",
"by",
"table",
"name",
"either",
"feature",
"or",
"tile",
"table",
"name"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/link/FeatureTileLinkDao.java#L234-L243
|
6,093 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/link/FeatureTileLinkDao.java
|
FeatureTileLinkDao.deleteAll
|
public int deleteAll() throws SQLException {
int count = 0;
if (isTableExists()) {
DeleteBuilder<FeatureTileLink, FeatureTileLinkKey> db = deleteBuilder();
PreparedDelete<FeatureTileLink> deleteQuery = db.prepare();
count = delete(deleteQuery);
}
return count;
}
|
java
|
public int deleteAll() throws SQLException {
int count = 0;
if (isTableExists()) {
DeleteBuilder<FeatureTileLink, FeatureTileLinkKey> db = deleteBuilder();
PreparedDelete<FeatureTileLink> deleteQuery = db.prepare();
count = delete(deleteQuery);
}
return count;
}
|
[
"public",
"int",
"deleteAll",
"(",
")",
"throws",
"SQLException",
"{",
"int",
"count",
"=",
"0",
";",
"if",
"(",
"isTableExists",
"(",
")",
")",
"{",
"DeleteBuilder",
"<",
"FeatureTileLink",
",",
"FeatureTileLinkKey",
">",
"db",
"=",
"deleteBuilder",
"(",
")",
";",
"PreparedDelete",
"<",
"FeatureTileLink",
">",
"deleteQuery",
"=",
"db",
".",
"prepare",
"(",
")",
";",
"count",
"=",
"delete",
"(",
"deleteQuery",
")",
";",
"}",
"return",
"count",
";",
"}"
] |
Delete all feature tile links
@return rows deleted
@throws SQLException
upon failure
@since 1.1.5
|
[
"Delete",
"all",
"feature",
"tile",
"links"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/link/FeatureTileLinkDao.java#L253-L264
|
6,094 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/style/StyleMappingTable.java
|
StyleMappingTable.createColumns
|
private static List<UserCustomColumn> createColumns() {
List<UserCustomColumn> columns = new ArrayList<>();
columns.addAll(createRequiredColumns());
int index = columns.size();
columns.add(UserCustomColumn
.createColumn(index++, COLUMN_GEOMETRY_TYPE_NAME,
GeoPackageDataType.TEXT, false, null));
return columns;
}
|
java
|
private static List<UserCustomColumn> createColumns() {
List<UserCustomColumn> columns = new ArrayList<>();
columns.addAll(createRequiredColumns());
int index = columns.size();
columns.add(UserCustomColumn
.createColumn(index++, COLUMN_GEOMETRY_TYPE_NAME,
GeoPackageDataType.TEXT, false, null));
return columns;
}
|
[
"private",
"static",
"List",
"<",
"UserCustomColumn",
">",
"createColumns",
"(",
")",
"{",
"List",
"<",
"UserCustomColumn",
">",
"columns",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"columns",
".",
"addAll",
"(",
"createRequiredColumns",
"(",
")",
")",
";",
"int",
"index",
"=",
"columns",
".",
"size",
"(",
")",
";",
"columns",
".",
"add",
"(",
"UserCustomColumn",
".",
"createColumn",
"(",
"index",
"++",
",",
"COLUMN_GEOMETRY_TYPE_NAME",
",",
"GeoPackageDataType",
".",
"TEXT",
",",
"false",
",",
"null",
")",
")",
";",
"return",
"columns",
";",
"}"
] |
Create the style mapping columns
@return columns
|
[
"Create",
"the",
"style",
"mapping",
"columns"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/style/StyleMappingTable.java#L49-L60
|
6,095 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/metadata/MetadataDao.java
|
MetadataDao.deleteCascade
|
public int deleteCascade(Metadata metadata) throws SQLException {
int count = 0;
if (metadata != null) {
// Delete Metadata References and remove parent references
MetadataReferenceDao dao = getMetadataReferenceDao();
dao.deleteByMetadata(metadata.getId());
dao.removeMetadataParent(metadata.getId());
// Delete
count = delete(metadata);
}
return count;
}
|
java
|
public int deleteCascade(Metadata metadata) throws SQLException {
int count = 0;
if (metadata != null) {
// Delete Metadata References and remove parent references
MetadataReferenceDao dao = getMetadataReferenceDao();
dao.deleteByMetadata(metadata.getId());
dao.removeMetadataParent(metadata.getId());
// Delete
count = delete(metadata);
}
return count;
}
|
[
"public",
"int",
"deleteCascade",
"(",
"Metadata",
"metadata",
")",
"throws",
"SQLException",
"{",
"int",
"count",
"=",
"0",
";",
"if",
"(",
"metadata",
"!=",
"null",
")",
"{",
"// Delete Metadata References and remove parent references",
"MetadataReferenceDao",
"dao",
"=",
"getMetadataReferenceDao",
"(",
")",
";",
"dao",
".",
"deleteByMetadata",
"(",
"metadata",
".",
"getId",
"(",
")",
")",
";",
"dao",
".",
"removeMetadataParent",
"(",
"metadata",
".",
"getId",
"(",
")",
")",
";",
"// Delete",
"count",
"=",
"delete",
"(",
"metadata",
")",
";",
"}",
"return",
"count",
";",
"}"
] |
Delete the Metadata, cascading
@param metadata
metadata
@return deleted count
@throws SQLException
upon failure
|
[
"Delete",
"the",
"Metadata",
"cascading"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/metadata/MetadataDao.java#L51-L65
|
6,096 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/metadata/MetadataDao.java
|
MetadataDao.deleteCascade
|
public int deleteCascade(Collection<Metadata> metadataCollection)
throws SQLException {
int count = 0;
if (metadataCollection != null) {
for (Metadata metadata : metadataCollection) {
count += deleteCascade(metadata);
}
}
return count;
}
|
java
|
public int deleteCascade(Collection<Metadata> metadataCollection)
throws SQLException {
int count = 0;
if (metadataCollection != null) {
for (Metadata metadata : metadataCollection) {
count += deleteCascade(metadata);
}
}
return count;
}
|
[
"public",
"int",
"deleteCascade",
"(",
"Collection",
"<",
"Metadata",
">",
"metadataCollection",
")",
"throws",
"SQLException",
"{",
"int",
"count",
"=",
"0",
";",
"if",
"(",
"metadataCollection",
"!=",
"null",
")",
"{",
"for",
"(",
"Metadata",
"metadata",
":",
"metadataCollection",
")",
"{",
"count",
"+=",
"deleteCascade",
"(",
"metadata",
")",
";",
"}",
"}",
"return",
"count",
";",
"}"
] |
Delete the collection of Metadata, cascading
@param metadataCollection
metadata collection
@return deleted count
@throws SQLException
upon failure
|
[
"Delete",
"the",
"collection",
"of",
"Metadata",
"cascading"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/metadata/MetadataDao.java#L76-L85
|
6,097 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/metadata/MetadataDao.java
|
MetadataDao.deleteCascade
|
public int deleteCascade(PreparedQuery<Metadata> preparedDelete)
throws SQLException {
int count = 0;
if (preparedDelete != null) {
List<Metadata> metadataList = query(preparedDelete);
count = deleteCascade(metadataList);
}
return count;
}
|
java
|
public int deleteCascade(PreparedQuery<Metadata> preparedDelete)
throws SQLException {
int count = 0;
if (preparedDelete != null) {
List<Metadata> metadataList = query(preparedDelete);
count = deleteCascade(metadataList);
}
return count;
}
|
[
"public",
"int",
"deleteCascade",
"(",
"PreparedQuery",
"<",
"Metadata",
">",
"preparedDelete",
")",
"throws",
"SQLException",
"{",
"int",
"count",
"=",
"0",
";",
"if",
"(",
"preparedDelete",
"!=",
"null",
")",
"{",
"List",
"<",
"Metadata",
">",
"metadataList",
"=",
"query",
"(",
"preparedDelete",
")",
";",
"count",
"=",
"deleteCascade",
"(",
"metadataList",
")",
";",
"}",
"return",
"count",
";",
"}"
] |
Delete the Metadata matching the prepared query, cascading
@param preparedDelete
prepared delete query
@return deleted count
@throws SQLException
upon failure
|
[
"Delete",
"the",
"Metadata",
"matching",
"the",
"prepared",
"query",
"cascading"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/metadata/MetadataDao.java#L96-L104
|
6,098 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/metadata/MetadataDao.java
|
MetadataDao.deleteByIdCascade
|
public int deleteByIdCascade(Long id) throws SQLException {
int count = 0;
if (id != null) {
Metadata metadata = queryForId(id);
if (metadata != null) {
count = deleteCascade(metadata);
}
}
return count;
}
|
java
|
public int deleteByIdCascade(Long id) throws SQLException {
int count = 0;
if (id != null) {
Metadata metadata = queryForId(id);
if (metadata != null) {
count = deleteCascade(metadata);
}
}
return count;
}
|
[
"public",
"int",
"deleteByIdCascade",
"(",
"Long",
"id",
")",
"throws",
"SQLException",
"{",
"int",
"count",
"=",
"0",
";",
"if",
"(",
"id",
"!=",
"null",
")",
"{",
"Metadata",
"metadata",
"=",
"queryForId",
"(",
"id",
")",
";",
"if",
"(",
"metadata",
"!=",
"null",
")",
"{",
"count",
"=",
"deleteCascade",
"(",
"metadata",
")",
";",
"}",
"}",
"return",
"count",
";",
"}"
] |
Delete a Metadata by id, cascading
@param id
id
@return deleted count
@throws SQLException
upon failure
|
[
"Delete",
"a",
"Metadata",
"by",
"id",
"cascading"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/metadata/MetadataDao.java#L115-L124
|
6,099 |
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/metadata/MetadataDao.java
|
MetadataDao.getMetadataReferenceDao
|
private MetadataReferenceDao getMetadataReferenceDao() throws SQLException {
if (metadataReferenceDao == null) {
metadataReferenceDao = DaoManager.createDao(connectionSource,
MetadataReference.class);
}
return metadataReferenceDao;
}
|
java
|
private MetadataReferenceDao getMetadataReferenceDao() throws SQLException {
if (metadataReferenceDao == null) {
metadataReferenceDao = DaoManager.createDao(connectionSource,
MetadataReference.class);
}
return metadataReferenceDao;
}
|
[
"private",
"MetadataReferenceDao",
"getMetadataReferenceDao",
"(",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"metadataReferenceDao",
"==",
"null",
")",
"{",
"metadataReferenceDao",
"=",
"DaoManager",
".",
"createDao",
"(",
"connectionSource",
",",
"MetadataReference",
".",
"class",
")",
";",
"}",
"return",
"metadataReferenceDao",
";",
"}"
] |
Get or create a Metadata Reference DAO
@return metadata reference dao
@throws SQLException
|
[
"Get",
"or",
"create",
"a",
"Metadata",
"Reference",
"DAO"
] |
6431c3b041a45b7f3802904ea4156b4082a72daa
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/metadata/MetadataDao.java#L152-L158
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.