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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
149,400
|
Omertron/api-fanarttv
|
src/main/java/com/omertron/fanarttvapi/FanartTvApi.java
|
FanartTvApi.getMusicArtist
|
public FTMusicArtist getMusicArtist(String id) throws FanartTvException {
URL url = ftapi.getImageUrl(BaseType.ARTIST, id);
String page = requestWebPage(url);
FTMusicArtist artist = null;
try {
artist = mapper.readValue(page, FTMusicArtist.class);
} catch (IOException ex) {
throw new FanartTvException(ApiExceptionType.MAPPING_FAILED, "Fauled to get Music Artist with ID " + id, url, ex);
}
return artist;
}
|
java
|
public FTMusicArtist getMusicArtist(String id) throws FanartTvException {
URL url = ftapi.getImageUrl(BaseType.ARTIST, id);
String page = requestWebPage(url);
FTMusicArtist artist = null;
try {
artist = mapper.readValue(page, FTMusicArtist.class);
} catch (IOException ex) {
throw new FanartTvException(ApiExceptionType.MAPPING_FAILED, "Fauled to get Music Artist with ID " + id, url, ex);
}
return artist;
}
|
[
"public",
"FTMusicArtist",
"getMusicArtist",
"(",
"String",
"id",
")",
"throws",
"FanartTvException",
"{",
"URL",
"url",
"=",
"ftapi",
".",
"getImageUrl",
"(",
"BaseType",
".",
"ARTIST",
",",
"id",
")",
";",
"String",
"page",
"=",
"requestWebPage",
"(",
"url",
")",
";",
"FTMusicArtist",
"artist",
"=",
"null",
";",
"try",
"{",
"artist",
"=",
"mapper",
".",
"readValue",
"(",
"page",
",",
"FTMusicArtist",
".",
"class",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"FanartTvException",
"(",
"ApiExceptionType",
".",
"MAPPING_FAILED",
",",
"\"Fauled to get Music Artist with ID \"",
"+",
"id",
",",
"url",
",",
"ex",
")",
";",
"}",
"return",
"artist",
";",
"}"
] |
Get images for artist
@param id
@return
@throws FanartTvException
|
[
"Get",
"images",
"for",
"artist"
] |
2a1854c840d8111935d0f6abe5232e2c3c3f318b
|
https://github.com/Omertron/api-fanarttv/blob/2a1854c840d8111935d0f6abe5232e2c3c3f318b/src/main/java/com/omertron/fanarttvapi/FanartTvApi.java#L216-L229
|
149,401
|
Omertron/api-fanarttv
|
src/main/java/com/omertron/fanarttvapi/FanartTvApi.java
|
FanartTvApi.requestWebPage
|
private String requestWebPage(URL url) throws FanartTvException {
try {
HttpGet httpGet = new HttpGet(url.toURI());
httpGet.addHeader("accept", "application/json");
final DigestedResponse response = DigestedResponseReader.requestContent(httpClient, httpGet, charset);
if (response.getStatusCode() >= 500) {
throw new FanartTvException(ApiExceptionType.HTTP_503_ERROR, response.getContent(), response.getStatusCode(), url);
} else if (response.getStatusCode() >= 300) {
throw new FanartTvException(ApiExceptionType.HTTP_404_ERROR, response.getContent(), response.getStatusCode(), url);
}
return response.getContent();
} catch (URISyntaxException ex) {
throw new FanartTvException(ApiExceptionType.CONNECTION_ERROR, "Invalid URL", url, ex);
} catch (IOException ex) {
throw new FanartTvException(ApiExceptionType.CONNECTION_ERROR, "Error retrieving URL", url, ex);
}
}
|
java
|
private String requestWebPage(URL url) throws FanartTvException {
try {
HttpGet httpGet = new HttpGet(url.toURI());
httpGet.addHeader("accept", "application/json");
final DigestedResponse response = DigestedResponseReader.requestContent(httpClient, httpGet, charset);
if (response.getStatusCode() >= 500) {
throw new FanartTvException(ApiExceptionType.HTTP_503_ERROR, response.getContent(), response.getStatusCode(), url);
} else if (response.getStatusCode() >= 300) {
throw new FanartTvException(ApiExceptionType.HTTP_404_ERROR, response.getContent(), response.getStatusCode(), url);
}
return response.getContent();
} catch (URISyntaxException ex) {
throw new FanartTvException(ApiExceptionType.CONNECTION_ERROR, "Invalid URL", url, ex);
} catch (IOException ex) {
throw new FanartTvException(ApiExceptionType.CONNECTION_ERROR, "Error retrieving URL", url, ex);
}
}
|
[
"private",
"String",
"requestWebPage",
"(",
"URL",
"url",
")",
"throws",
"FanartTvException",
"{",
"try",
"{",
"HttpGet",
"httpGet",
"=",
"new",
"HttpGet",
"(",
"url",
".",
"toURI",
"(",
")",
")",
";",
"httpGet",
".",
"addHeader",
"(",
"\"accept\"",
",",
"\"application/json\"",
")",
";",
"final",
"DigestedResponse",
"response",
"=",
"DigestedResponseReader",
".",
"requestContent",
"(",
"httpClient",
",",
"httpGet",
",",
"charset",
")",
";",
"if",
"(",
"response",
".",
"getStatusCode",
"(",
")",
">=",
"500",
")",
"{",
"throw",
"new",
"FanartTvException",
"(",
"ApiExceptionType",
".",
"HTTP_503_ERROR",
",",
"response",
".",
"getContent",
"(",
")",
",",
"response",
".",
"getStatusCode",
"(",
")",
",",
"url",
")",
";",
"}",
"else",
"if",
"(",
"response",
".",
"getStatusCode",
"(",
")",
">=",
"300",
")",
"{",
"throw",
"new",
"FanartTvException",
"(",
"ApiExceptionType",
".",
"HTTP_404_ERROR",
",",
"response",
".",
"getContent",
"(",
")",
",",
"response",
".",
"getStatusCode",
"(",
")",
",",
"url",
")",
";",
"}",
"return",
"response",
".",
"getContent",
"(",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"ex",
")",
"{",
"throw",
"new",
"FanartTvException",
"(",
"ApiExceptionType",
".",
"CONNECTION_ERROR",
",",
"\"Invalid URL\"",
",",
"url",
",",
"ex",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"FanartTvException",
"(",
"ApiExceptionType",
".",
"CONNECTION_ERROR",
",",
"\"Error retrieving URL\"",
",",
"url",
",",
"ex",
")",
";",
"}",
"}"
] |
Download the URL into a String
@param url
@return
@throws FanartTvException
|
[
"Download",
"the",
"URL",
"into",
"a",
"String"
] |
2a1854c840d8111935d0f6abe5232e2c3c3f318b
|
https://github.com/Omertron/api-fanarttv/blob/2a1854c840d8111935d0f6abe5232e2c3c3f318b/src/main/java/com/omertron/fanarttvapi/FanartTvApi.java#L305-L323
|
149,402
|
julienledem/brennus
|
brennus-builder/src/main/java/brennus/MethodCallBuilder.java
|
MethodCallBuilder.param
|
ParamExpressionBuilder<T, EB, VEB> param() {
return new ParamExpressionBuilder<T, EB, VEB>(
new ExpressionHandler<MethodCallBuilder<T, EB, VEB>>() {
public MethodCallBuilder<T, EB, VEB> handleExpression(Expression e) {
return new MethodCallBuilder<T, EB, VEB>(
factory,
callee,
methodName,
expressionHandler,
parameters.append(e));
}
});
}
|
java
|
ParamExpressionBuilder<T, EB, VEB> param() {
return new ParamExpressionBuilder<T, EB, VEB>(
new ExpressionHandler<MethodCallBuilder<T, EB, VEB>>() {
public MethodCallBuilder<T, EB, VEB> handleExpression(Expression e) {
return new MethodCallBuilder<T, EB, VEB>(
factory,
callee,
methodName,
expressionHandler,
parameters.append(e));
}
});
}
|
[
"ParamExpressionBuilder",
"<",
"T",
",",
"EB",
",",
"VEB",
">",
"param",
"(",
")",
"{",
"return",
"new",
"ParamExpressionBuilder",
"<",
"T",
",",
"EB",
",",
"VEB",
">",
"(",
"new",
"ExpressionHandler",
"<",
"MethodCallBuilder",
"<",
"T",
",",
"EB",
",",
"VEB",
">",
">",
"(",
")",
"{",
"public",
"MethodCallBuilder",
"<",
"T",
",",
"EB",
",",
"VEB",
">",
"handleExpression",
"(",
"Expression",
"e",
")",
"{",
"return",
"new",
"MethodCallBuilder",
"<",
"T",
",",
"EB",
",",
"VEB",
">",
"(",
"factory",
",",
"callee",
",",
"methodName",
",",
"expressionHandler",
",",
"parameters",
".",
"append",
"(",
"e",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
pass a parameter to the method
@return the expressionbuilder to build the parameter value
|
[
"pass",
"a",
"parameter",
"to",
"the",
"method"
] |
0798fb565d95af19ddc5accd084e58c4e882dbd0
|
https://github.com/julienledem/brennus/blob/0798fb565d95af19ddc5accd084e58c4e882dbd0/brennus-builder/src/main/java/brennus/MethodCallBuilder.java#L50-L62
|
149,403
|
Viascom/groundwork
|
foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/builder/FoxHttpRequestBuilder.java
|
FoxHttpRequestBuilder.addRequestQueryEntry
|
public FoxHttpRequestBuilder addRequestQueryEntry(String name, String value) {
foxHttpRequest.getRequestQuery().addQueryEntry(name, value);
return this;
}
|
java
|
public FoxHttpRequestBuilder addRequestQueryEntry(String name, String value) {
foxHttpRequest.getRequestQuery().addQueryEntry(name, value);
return this;
}
|
[
"public",
"FoxHttpRequestBuilder",
"addRequestQueryEntry",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"foxHttpRequest",
".",
"getRequestQuery",
"(",
")",
".",
"addQueryEntry",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Add a new query entry
@param name name of the query entry
@param value value of the query entry
@return FoxHttpRequestBuilder (this)
|
[
"Add",
"a",
"new",
"query",
"entry"
] |
d3f7d0df65e2e75861fc7db938090683f2cdf919
|
https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/builder/FoxHttpRequestBuilder.java#L146-L149
|
149,404
|
Viascom/groundwork
|
foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/builder/FoxHttpRequestBuilder.java
|
FoxHttpRequestBuilder.build
|
public FoxHttpRequest build() throws MalformedURLException, FoxHttpRequestException {
if (this.url != null) {
foxHttpRequest.setUrl(this.url);
}
return foxHttpRequest;
}
|
java
|
public FoxHttpRequest build() throws MalformedURLException, FoxHttpRequestException {
if (this.url != null) {
foxHttpRequest.setUrl(this.url);
}
return foxHttpRequest;
}
|
[
"public",
"FoxHttpRequest",
"build",
"(",
")",
"throws",
"MalformedURLException",
",",
"FoxHttpRequestException",
"{",
"if",
"(",
"this",
".",
"url",
"!=",
"null",
")",
"{",
"foxHttpRequest",
".",
"setUrl",
"(",
"this",
".",
"url",
")",
";",
"}",
"return",
"foxHttpRequest",
";",
"}"
] |
Get the FoxHttpRequest of this builder
@return FoxHttpRequest
|
[
"Get",
"the",
"FoxHttpRequest",
"of",
"this",
"builder"
] |
d3f7d0df65e2e75861fc7db938090683f2cdf919
|
https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/builder/FoxHttpRequestBuilder.java#L261-L266
|
149,405
|
lightblueseas/wicket-js-addons
|
wicket-js-addons-core/src/main/java/de/alpharogroup/wicket/js/addon/core/JavascriptGenerator.java
|
JavascriptGenerator.generateJs
|
public String generateJs(final Settings settings, final String methodName)
{
// 1. Create an empty map...
final Map<String, Object> variables = initializeVariables(settings.asSet());
// 4. Generate the js template with the map and the method name...
final String stringTemplateContent = generateJavascriptTemplateContent(variables,
methodName);
// 5. Create the StringTextTemplate with the generated template...
final StringTextTemplate stringTextTemplate = new StringTextTemplate(stringTemplateContent);
// 6. Interpolate the template with the values of the map...
stringTextTemplate.interpolate(variables);
try
{
// 7. return it as String...
return stringTextTemplate.asString();
}
finally
{
try
{
stringTextTemplate.close();
}
catch (final IOException e)
{
LOGGER.error(e.getMessage(), e);
}
}
}
|
java
|
public String generateJs(final Settings settings, final String methodName)
{
// 1. Create an empty map...
final Map<String, Object> variables = initializeVariables(settings.asSet());
// 4. Generate the js template with the map and the method name...
final String stringTemplateContent = generateJavascriptTemplateContent(variables,
methodName);
// 5. Create the StringTextTemplate with the generated template...
final StringTextTemplate stringTextTemplate = new StringTextTemplate(stringTemplateContent);
// 6. Interpolate the template with the values of the map...
stringTextTemplate.interpolate(variables);
try
{
// 7. return it as String...
return stringTextTemplate.asString();
}
finally
{
try
{
stringTextTemplate.close();
}
catch (final IOException e)
{
LOGGER.error(e.getMessage(), e);
}
}
}
|
[
"public",
"String",
"generateJs",
"(",
"final",
"Settings",
"settings",
",",
"final",
"String",
"methodName",
")",
"{",
"// 1. Create an empty map...\r",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"variables",
"=",
"initializeVariables",
"(",
"settings",
".",
"asSet",
"(",
")",
")",
";",
"// 4. Generate the js template with the map and the method name...\r",
"final",
"String",
"stringTemplateContent",
"=",
"generateJavascriptTemplateContent",
"(",
"variables",
",",
"methodName",
")",
";",
"// 5. Create the StringTextTemplate with the generated template...\r",
"final",
"StringTextTemplate",
"stringTextTemplate",
"=",
"new",
"StringTextTemplate",
"(",
"stringTemplateContent",
")",
";",
"// 6. Interpolate the template with the values of the map...\r",
"stringTextTemplate",
".",
"interpolate",
"(",
"variables",
")",
";",
"try",
"{",
"// 7. return it as String...\r",
"return",
"stringTextTemplate",
".",
"asString",
"(",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"stringTextTemplate",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Generate the javascript code.
@param settings
the settings
@param methodName
the method name
@return the string
|
[
"Generate",
"the",
"javascript",
"code",
"."
] |
b1c88c1abafd1e965f2e32ef13d66be0b28d76f6
|
https://github.com/lightblueseas/wicket-js-addons/blob/b1c88c1abafd1e965f2e32ef13d66be0b28d76f6/wicket-js-addons-core/src/main/java/de/alpharogroup/wicket/js/addon/core/JavascriptGenerator.java#L163-L190
|
149,406
|
lightblueseas/wicket-js-addons
|
wicket-js-addons-core/src/main/java/de/alpharogroup/wicket/js/addon/core/JavascriptGenerator.java
|
JavascriptGenerator.generateJsOptionsForTemplateContent
|
protected void generateJsOptionsForTemplateContent(final Map<String, Object> variables,
final StringBuilder sb)
{
sb.append("{\n");
int count = 1;
Object localComponentId = null;
if (withComponentId)
{
localComponentId = variables.get(COMPONENT_ID);
variables.remove(COMPONENT_ID);
}
for (final Map.Entry<String, Object> entry : variables.entrySet())
{
final String key = entry.getKey();
sb.append(key).append(": ${").append(key).append("}");
if (count < variables.size())
{
sb.append(",\n");
}
else
{
sb.append("\n");
}
count++;
}
if (withComponentId)
{
variables.put(COMPONENT_ID, localComponentId);
}
sb.append("}");
}
|
java
|
protected void generateJsOptionsForTemplateContent(final Map<String, Object> variables,
final StringBuilder sb)
{
sb.append("{\n");
int count = 1;
Object localComponentId = null;
if (withComponentId)
{
localComponentId = variables.get(COMPONENT_ID);
variables.remove(COMPONENT_ID);
}
for (final Map.Entry<String, Object> entry : variables.entrySet())
{
final String key = entry.getKey();
sb.append(key).append(": ${").append(key).append("}");
if (count < variables.size())
{
sb.append(",\n");
}
else
{
sb.append("\n");
}
count++;
}
if (withComponentId)
{
variables.put(COMPONENT_ID, localComponentId);
}
sb.append("}");
}
|
[
"protected",
"void",
"generateJsOptionsForTemplateContent",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"variables",
",",
"final",
"StringBuilder",
"sb",
")",
"{",
"sb",
".",
"append",
"(",
"\"{\\n\"",
")",
";",
"int",
"count",
"=",
"1",
";",
"Object",
"localComponentId",
"=",
"null",
";",
"if",
"(",
"withComponentId",
")",
"{",
"localComponentId",
"=",
"variables",
".",
"get",
"(",
"COMPONENT_ID",
")",
";",
"variables",
".",
"remove",
"(",
"COMPONENT_ID",
")",
";",
"}",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"variables",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"sb",
".",
"append",
"(",
"key",
")",
".",
"append",
"(",
"\": ${\"",
")",
".",
"append",
"(",
"key",
")",
".",
"append",
"(",
"\"}\"",
")",
";",
"if",
"(",
"count",
"<",
"variables",
".",
"size",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\",\\n\"",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}",
"count",
"++",
";",
"}",
"if",
"(",
"withComponentId",
")",
"{",
"variables",
".",
"put",
"(",
"COMPONENT_ID",
",",
"localComponentId",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"}\"",
")",
";",
"}"
] |
Generate the javascript options for template content.
@param variables
the map with the javascript options.
@param sb
the {@link StringBuilder} to add the javascript options.
|
[
"Generate",
"the",
"javascript",
"options",
"for",
"template",
"content",
"."
] |
b1c88c1abafd1e965f2e32ef13d66be0b28d76f6
|
https://github.com/lightblueseas/wicket-js-addons/blob/b1c88c1abafd1e965f2e32ef13d66be0b28d76f6/wicket-js-addons-core/src/main/java/de/alpharogroup/wicket/js/addon/core/JavascriptGenerator.java#L200-L230
|
149,407
|
lightblueseas/wicket-js-addons
|
wicket-js-addons-core/src/main/java/de/alpharogroup/wicket/js/addon/core/JavascriptGenerator.java
|
JavascriptGenerator.initializeVariables
|
protected Map<String, Object> initializeVariables(final Set<StringTextValue<?>> allSettings)
{
final Map<String, Object> variables = new HashMap<>();
// 2. put the component id that is the initiator for the js code...
if (withComponentId)
{
variables.put(JavascriptGenerator.COMPONENT_ID, componentId);
}
for (final StringTextValue<?> textValue : allSettings)
{
if (!textValue.isInitialValue())
{
switch (textValue.getType())
{
case STRING :
if (textValue.getQuotationMarkType().equals(QuotationMarkType.NONE))
{
variables.put(textValue.getName(), textValue.getValue());
break;
}
TextTemplateExtensions.setVariableWithSingleQuotationMarks(
textValue.getName(), textValue.getValue(), variables);
break;
case ENUM :
TextTemplateExtensions.setVariableWithSingleQuotationMarks(
textValue.getName(), ((ValueEnum)textValue.getValue()).getValue(),
variables);
break;
case STRING_INTEGER :
TextTemplateExtensions.setVariableWithSingleQuotationMarks(
textValue.getName(), textValue.getValue(), variables);
break;
default :
variables.put(textValue.getName(), textValue.getValue());
break;
}
}
}
return variables;
}
|
java
|
protected Map<String, Object> initializeVariables(final Set<StringTextValue<?>> allSettings)
{
final Map<String, Object> variables = new HashMap<>();
// 2. put the component id that is the initiator for the js code...
if (withComponentId)
{
variables.put(JavascriptGenerator.COMPONENT_ID, componentId);
}
for (final StringTextValue<?> textValue : allSettings)
{
if (!textValue.isInitialValue())
{
switch (textValue.getType())
{
case STRING :
if (textValue.getQuotationMarkType().equals(QuotationMarkType.NONE))
{
variables.put(textValue.getName(), textValue.getValue());
break;
}
TextTemplateExtensions.setVariableWithSingleQuotationMarks(
textValue.getName(), textValue.getValue(), variables);
break;
case ENUM :
TextTemplateExtensions.setVariableWithSingleQuotationMarks(
textValue.getName(), ((ValueEnum)textValue.getValue()).getValue(),
variables);
break;
case STRING_INTEGER :
TextTemplateExtensions.setVariableWithSingleQuotationMarks(
textValue.getName(), textValue.getValue(), variables);
break;
default :
variables.put(textValue.getName(), textValue.getValue());
break;
}
}
}
return variables;
}
|
[
"protected",
"Map",
"<",
"String",
",",
"Object",
">",
"initializeVariables",
"(",
"final",
"Set",
"<",
"StringTextValue",
"<",
"?",
">",
">",
"allSettings",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"variables",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"// 2. put the component id that is the initiator for the js code...\r",
"if",
"(",
"withComponentId",
")",
"{",
"variables",
".",
"put",
"(",
"JavascriptGenerator",
".",
"COMPONENT_ID",
",",
"componentId",
")",
";",
"}",
"for",
"(",
"final",
"StringTextValue",
"<",
"?",
">",
"textValue",
":",
"allSettings",
")",
"{",
"if",
"(",
"!",
"textValue",
".",
"isInitialValue",
"(",
")",
")",
"{",
"switch",
"(",
"textValue",
".",
"getType",
"(",
")",
")",
"{",
"case",
"STRING",
":",
"if",
"(",
"textValue",
".",
"getQuotationMarkType",
"(",
")",
".",
"equals",
"(",
"QuotationMarkType",
".",
"NONE",
")",
")",
"{",
"variables",
".",
"put",
"(",
"textValue",
".",
"getName",
"(",
")",
",",
"textValue",
".",
"getValue",
"(",
")",
")",
";",
"break",
";",
"}",
"TextTemplateExtensions",
".",
"setVariableWithSingleQuotationMarks",
"(",
"textValue",
".",
"getName",
"(",
")",
",",
"textValue",
".",
"getValue",
"(",
")",
",",
"variables",
")",
";",
"break",
";",
"case",
"ENUM",
":",
"TextTemplateExtensions",
".",
"setVariableWithSingleQuotationMarks",
"(",
"textValue",
".",
"getName",
"(",
")",
",",
"(",
"(",
"ValueEnum",
")",
"textValue",
".",
"getValue",
"(",
")",
")",
".",
"getValue",
"(",
")",
",",
"variables",
")",
";",
"break",
";",
"case",
"STRING_INTEGER",
":",
"TextTemplateExtensions",
".",
"setVariableWithSingleQuotationMarks",
"(",
"textValue",
".",
"getName",
"(",
")",
",",
"textValue",
".",
"getValue",
"(",
")",
",",
"variables",
")",
";",
"break",
";",
"default",
":",
"variables",
".",
"put",
"(",
"textValue",
".",
"getName",
"(",
")",
",",
"textValue",
".",
"getValue",
"(",
")",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"variables",
";",
"}"
] |
Sets the values to the map. If the default value is set than it will not be added to the map
for later not to generate js for it.
@param allSettings
All settings as a list of StringTextValue(s).
@return the map
|
[
"Sets",
"the",
"values",
"to",
"the",
"map",
".",
"If",
"the",
"default",
"value",
"is",
"set",
"than",
"it",
"will",
"not",
"be",
"added",
"to",
"the",
"map",
"for",
"later",
"not",
"to",
"generate",
"js",
"for",
"it",
"."
] |
b1c88c1abafd1e965f2e32ef13d66be0b28d76f6
|
https://github.com/lightblueseas/wicket-js-addons/blob/b1c88c1abafd1e965f2e32ef13d66be0b28d76f6/wicket-js-addons-core/src/main/java/de/alpharogroup/wicket/js/addon/core/JavascriptGenerator.java#L240-L280
|
149,408
|
yangjm/winlet
|
dao/src/main/java/com/aggrepoint/dao/DaoFactoryBean.java
|
DaoFactoryBean.getConversionService
|
private ConversionService getConversionService() {
if (conversionService != null)
return conversionService;
try {
conversionService = (ConversionService) ctx.getBean("daoConversionService");
if (conversionService != null)
return conversionService;
} catch (Exception e) {
}
ConversionServiceFactoryBean factory = new ConversionServiceFactoryBean();
factory.afterPropertiesSet();
conversionService = factory.getObject();
return conversionService;
}
|
java
|
private ConversionService getConversionService() {
if (conversionService != null)
return conversionService;
try {
conversionService = (ConversionService) ctx.getBean("daoConversionService");
if (conversionService != null)
return conversionService;
} catch (Exception e) {
}
ConversionServiceFactoryBean factory = new ConversionServiceFactoryBean();
factory.afterPropertiesSet();
conversionService = factory.getObject();
return conversionService;
}
|
[
"private",
"ConversionService",
"getConversionService",
"(",
")",
"{",
"if",
"(",
"conversionService",
"!=",
"null",
")",
"return",
"conversionService",
";",
"try",
"{",
"conversionService",
"=",
"(",
"ConversionService",
")",
"ctx",
".",
"getBean",
"(",
"\"daoConversionService\"",
")",
";",
"if",
"(",
"conversionService",
"!=",
"null",
")",
"return",
"conversionService",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"ConversionServiceFactoryBean",
"factory",
"=",
"new",
"ConversionServiceFactoryBean",
"(",
")",
";",
"factory",
".",
"afterPropertiesSet",
"(",
")",
";",
"conversionService",
"=",
"factory",
".",
"getObject",
"(",
")",
";",
"return",
"conversionService",
";",
"}"
] |
get ConversionService. If a service is defined in context with name
daoConversionService then use it, otherwise create a default one
@return
|
[
"get",
"ConversionService",
".",
"If",
"a",
"service",
"is",
"defined",
"in",
"context",
"with",
"name",
"daoConversionService",
"then",
"use",
"it",
"otherwise",
"create",
"a",
"default",
"one"
] |
2126236f56858e283fa6ad69fe9279ee30f47b67
|
https://github.com/yangjm/winlet/blob/2126236f56858e283fa6ad69fe9279ee30f47b67/dao/src/main/java/com/aggrepoint/dao/DaoFactoryBean.java#L110-L125
|
149,409
|
javagl/Common
|
src/main/java/de/javagl/common/beans/PropertyChangeUtils.java
|
PropertyChangeUtils.isPublicInstanceMethod
|
private static boolean isPublicInstanceMethod(Method method)
{
return Modifier.isPublic(method.getModifiers()) &&
!Modifier.isStatic(method.getModifiers());
}
|
java
|
private static boolean isPublicInstanceMethod(Method method)
{
return Modifier.isPublic(method.getModifiers()) &&
!Modifier.isStatic(method.getModifiers());
}
|
[
"private",
"static",
"boolean",
"isPublicInstanceMethod",
"(",
"Method",
"method",
")",
"{",
"return",
"Modifier",
".",
"isPublic",
"(",
"method",
".",
"getModifiers",
"(",
")",
")",
"&&",
"!",
"Modifier",
".",
"isStatic",
"(",
"method",
".",
"getModifiers",
"(",
")",
")",
";",
"}"
] |
Returns whether the modifiers of the given method show that it is
a public instance method.
@param method The method
@return Whether the given method is a public instance method
|
[
"Returns",
"whether",
"the",
"modifiers",
"of",
"the",
"given",
"method",
"show",
"that",
"it",
"is",
"a",
"public",
"instance",
"method",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/beans/PropertyChangeUtils.java#L353-L357
|
149,410
|
Omertron/api-rottentomatoes
|
src/main/java/com/omertron/rottentomatoesapi/tools/ApiBuilder.java
|
ApiBuilder.create
|
public static String create(Map<String, String> properties) throws RottenTomatoesException {
if (StringUtils.isBlank(apiKey)) {
throw new RottenTomatoesException(ApiExceptionType.INVALID_URL, "Missing API Key");
}
StringBuilder urlBuilder = new StringBuilder(API_SITE);
urlBuilder.append(API_VERSION);
urlBuilder.append(getUrlFromProps(properties));
urlBuilder.append(API_PREFIX).append(apiKey);
for (Map.Entry<String, String> property : properties.entrySet()) {
// Validate the key/value
if (StringUtils.isNotBlank(property.getKey()) && StringUtils.isNotBlank(property.getValue())) {
urlBuilder.append("&").append(property.getKey()).append("=").append(property.getValue());
}
}
LOG.trace("URL: {}", urlBuilder.toString());
return urlBuilder.toString();
}
|
java
|
public static String create(Map<String, String> properties) throws RottenTomatoesException {
if (StringUtils.isBlank(apiKey)) {
throw new RottenTomatoesException(ApiExceptionType.INVALID_URL, "Missing API Key");
}
StringBuilder urlBuilder = new StringBuilder(API_SITE);
urlBuilder.append(API_VERSION);
urlBuilder.append(getUrlFromProps(properties));
urlBuilder.append(API_PREFIX).append(apiKey);
for (Map.Entry<String, String> property : properties.entrySet()) {
// Validate the key/value
if (StringUtils.isNotBlank(property.getKey()) && StringUtils.isNotBlank(property.getValue())) {
urlBuilder.append("&").append(property.getKey()).append("=").append(property.getValue());
}
}
LOG.trace("URL: {}", urlBuilder.toString());
return urlBuilder.toString();
}
|
[
"public",
"static",
"String",
"create",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"properties",
")",
"throws",
"RottenTomatoesException",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"apiKey",
")",
")",
"{",
"throw",
"new",
"RottenTomatoesException",
"(",
"ApiExceptionType",
".",
"INVALID_URL",
",",
"\"Missing API Key\"",
")",
";",
"}",
"StringBuilder",
"urlBuilder",
"=",
"new",
"StringBuilder",
"(",
"API_SITE",
")",
";",
"urlBuilder",
".",
"append",
"(",
"API_VERSION",
")",
";",
"urlBuilder",
".",
"append",
"(",
"getUrlFromProps",
"(",
"properties",
")",
")",
";",
"urlBuilder",
".",
"append",
"(",
"API_PREFIX",
")",
".",
"append",
"(",
"apiKey",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"property",
":",
"properties",
".",
"entrySet",
"(",
")",
")",
"{",
"// Validate the key/value",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"property",
".",
"getKey",
"(",
")",
")",
"&&",
"StringUtils",
".",
"isNotBlank",
"(",
"property",
".",
"getValue",
"(",
")",
")",
")",
"{",
"urlBuilder",
".",
"append",
"(",
"\"&\"",
")",
".",
"append",
"(",
"property",
".",
"getKey",
"(",
")",
")",
".",
"append",
"(",
"\"=\"",
")",
".",
"append",
"(",
"property",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"LOG",
".",
"trace",
"(",
"\"URL: {}\"",
",",
"urlBuilder",
".",
"toString",
"(",
")",
")",
";",
"return",
"urlBuilder",
".",
"toString",
"(",
")",
";",
"}"
] |
Create the URL
@param properties
@return
@throws RottenTomatoesException
|
[
"Create",
"the",
"URL"
] |
abaf1833acafc6ada593d52b14ff1bacb4e441ee
|
https://github.com/Omertron/api-rottentomatoes/blob/abaf1833acafc6ada593d52b14ff1bacb4e441ee/src/main/java/com/omertron/rottentomatoesapi/tools/ApiBuilder.java#L69-L90
|
149,411
|
Omertron/api-rottentomatoes
|
src/main/java/com/omertron/rottentomatoesapi/tools/ApiBuilder.java
|
ApiBuilder.getUrlFromProps
|
private static String getUrlFromProps(Map<String, String> properties) throws RottenTomatoesException {
if (properties.containsKey(PROPERTY_URL) && StringUtils.isNotBlank(properties.get(PROPERTY_URL))) {
String url = properties.get(PROPERTY_URL);
// If we have the ID, then we need to replace the "{movie-id}" in the URL
if (properties.containsKey(PROPERTY_ID) && StringUtils.isNotBlank(properties.get(PROPERTY_ID))) {
url = url.replace(MOVIE_ID, String.valueOf(properties.get(PROPERTY_ID)));
// We don't need this property anymore
properties.remove(PROPERTY_ID);
}
// We don't need this property anymore
properties.remove(PROPERTY_URL);
return url;
} else {
throw new RottenTomatoesException(ApiExceptionType.INVALID_URL, "No URL specified");
}
}
|
java
|
private static String getUrlFromProps(Map<String, String> properties) throws RottenTomatoesException {
if (properties.containsKey(PROPERTY_URL) && StringUtils.isNotBlank(properties.get(PROPERTY_URL))) {
String url = properties.get(PROPERTY_URL);
// If we have the ID, then we need to replace the "{movie-id}" in the URL
if (properties.containsKey(PROPERTY_ID) && StringUtils.isNotBlank(properties.get(PROPERTY_ID))) {
url = url.replace(MOVIE_ID, String.valueOf(properties.get(PROPERTY_ID)));
// We don't need this property anymore
properties.remove(PROPERTY_ID);
}
// We don't need this property anymore
properties.remove(PROPERTY_URL);
return url;
} else {
throw new RottenTomatoesException(ApiExceptionType.INVALID_URL, "No URL specified");
}
}
|
[
"private",
"static",
"String",
"getUrlFromProps",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"properties",
")",
"throws",
"RottenTomatoesException",
"{",
"if",
"(",
"properties",
".",
"containsKey",
"(",
"PROPERTY_URL",
")",
"&&",
"StringUtils",
".",
"isNotBlank",
"(",
"properties",
".",
"get",
"(",
"PROPERTY_URL",
")",
")",
")",
"{",
"String",
"url",
"=",
"properties",
".",
"get",
"(",
"PROPERTY_URL",
")",
";",
"// If we have the ID, then we need to replace the \"{movie-id}\" in the URL",
"if",
"(",
"properties",
".",
"containsKey",
"(",
"PROPERTY_ID",
")",
"&&",
"StringUtils",
".",
"isNotBlank",
"(",
"properties",
".",
"get",
"(",
"PROPERTY_ID",
")",
")",
")",
"{",
"url",
"=",
"url",
".",
"replace",
"(",
"MOVIE_ID",
",",
"String",
".",
"valueOf",
"(",
"properties",
".",
"get",
"(",
"PROPERTY_ID",
")",
")",
")",
";",
"// We don't need this property anymore",
"properties",
".",
"remove",
"(",
"PROPERTY_ID",
")",
";",
"}",
"// We don't need this property anymore",
"properties",
".",
"remove",
"(",
"PROPERTY_URL",
")",
";",
"return",
"url",
";",
"}",
"else",
"{",
"throw",
"new",
"RottenTomatoesException",
"(",
"ApiExceptionType",
".",
"INVALID_URL",
",",
"\"No URL specified\"",
")",
";",
"}",
"}"
] |
Get and process the URL from the properties map
@param properties
@return The processed URL
@throws RottenTomatoesException
|
[
"Get",
"and",
"process",
"the",
"URL",
"from",
"the",
"properties",
"map"
] |
abaf1833acafc6ada593d52b14ff1bacb4e441ee
|
https://github.com/Omertron/api-rottentomatoes/blob/abaf1833acafc6ada593d52b14ff1bacb4e441ee/src/main/java/com/omertron/rottentomatoesapi/tools/ApiBuilder.java#L99-L115
|
149,412
|
Omertron/api-rottentomatoes
|
src/main/java/com/omertron/rottentomatoesapi/tools/ApiBuilder.java
|
ApiBuilder.validateProperty
|
public static boolean validateProperty(String key, String value) {
return !StringUtils.isBlank(key) && !StringUtils.isBlank(value);
}
|
java
|
public static boolean validateProperty(String key, String value) {
return !StringUtils.isBlank(key) && !StringUtils.isBlank(value);
}
|
[
"public",
"static",
"boolean",
"validateProperty",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"return",
"!",
"StringUtils",
".",
"isBlank",
"(",
"key",
")",
"&&",
"!",
"StringUtils",
".",
"isBlank",
"(",
"value",
")",
";",
"}"
] |
Validate the key and value of a property
@param key
@param value
@return
|
[
"Validate",
"the",
"key",
"and",
"value",
"of",
"a",
"property"
] |
abaf1833acafc6ada593d52b14ff1bacb4e441ee
|
https://github.com/Omertron/api-rottentomatoes/blob/abaf1833acafc6ada593d52b14ff1bacb4e441ee/src/main/java/com/omertron/rottentomatoesapi/tools/ApiBuilder.java#L124-L126
|
149,413
|
Omertron/api-rottentomatoes
|
src/main/java/com/omertron/rottentomatoesapi/tools/ApiBuilder.java
|
ApiBuilder.validateLimit
|
public static String validateLimit(int limit) {
if (limit < 1) {
// 0 is a valid, null value
return "";
}
if (limit > LIMIT_MAX) {
return String.valueOf(LIMIT_MAX);
}
return String.valueOf(limit);
}
|
java
|
public static String validateLimit(int limit) {
if (limit < 1) {
// 0 is a valid, null value
return "";
}
if (limit > LIMIT_MAX) {
return String.valueOf(LIMIT_MAX);
}
return String.valueOf(limit);
}
|
[
"public",
"static",
"String",
"validateLimit",
"(",
"int",
"limit",
")",
"{",
"if",
"(",
"limit",
"<",
"1",
")",
"{",
"// 0 is a valid, null value",
"return",
"\"\"",
";",
"}",
"if",
"(",
"limit",
">",
"LIMIT_MAX",
")",
"{",
"return",
"String",
".",
"valueOf",
"(",
"LIMIT_MAX",
")",
";",
"}",
"return",
"String",
".",
"valueOf",
"(",
"limit",
")",
";",
"}"
] |
Validate and convert the limit property
@param limit
@return
|
[
"Validate",
"and",
"convert",
"the",
"limit",
"property"
] |
abaf1833acafc6ada593d52b14ff1bacb4e441ee
|
https://github.com/Omertron/api-rottentomatoes/blob/abaf1833acafc6ada593d52b14ff1bacb4e441ee/src/main/java/com/omertron/rottentomatoesapi/tools/ApiBuilder.java#L134-L145
|
149,414
|
Omertron/api-rottentomatoes
|
src/main/java/com/omertron/rottentomatoesapi/tools/ApiBuilder.java
|
ApiBuilder.validateCountry
|
public static String validateCountry(String country) {
if (country.length() > DEFAULT_COUNTRY_LEN) {
return country.substring(0, DEFAULT_COUNTRY_LEN);
}
return country;
}
|
java
|
public static String validateCountry(String country) {
if (country.length() > DEFAULT_COUNTRY_LEN) {
return country.substring(0, DEFAULT_COUNTRY_LEN);
}
return country;
}
|
[
"public",
"static",
"String",
"validateCountry",
"(",
"String",
"country",
")",
"{",
"if",
"(",
"country",
".",
"length",
"(",
")",
">",
"DEFAULT_COUNTRY_LEN",
")",
"{",
"return",
"country",
".",
"substring",
"(",
"0",
",",
"DEFAULT_COUNTRY_LEN",
")",
";",
"}",
"return",
"country",
";",
"}"
] |
Validate the country property
@param country
@return
|
[
"Validate",
"the",
"country",
"property"
] |
abaf1833acafc6ada593d52b14ff1bacb4e441ee
|
https://github.com/Omertron/api-rottentomatoes/blob/abaf1833acafc6ada593d52b14ff1bacb4e441ee/src/main/java/com/omertron/rottentomatoesapi/tools/ApiBuilder.java#L178-L184
|
149,415
|
Omertron/api-fanarttv
|
src/main/java/com/omertron/fanarttvapi/model/ArtworkList.java
|
ArtworkList.addArtwork
|
public void addArtwork(FTArtworkType artworkType, List<FTArtwork> artworkList) {
artwork.put(artworkType, artworkList);
}
|
java
|
public void addArtwork(FTArtworkType artworkType, List<FTArtwork> artworkList) {
artwork.put(artworkType, artworkList);
}
|
[
"public",
"void",
"addArtwork",
"(",
"FTArtworkType",
"artworkType",
",",
"List",
"<",
"FTArtwork",
">",
"artworkList",
")",
"{",
"artwork",
".",
"put",
"(",
"artworkType",
",",
"artworkList",
")",
";",
"}"
] |
Add artwork to the list
@param artworkType
@param artworkList
|
[
"Add",
"artwork",
"to",
"the",
"list"
] |
2a1854c840d8111935d0f6abe5232e2c3c3f318b
|
https://github.com/Omertron/api-fanarttv/blob/2a1854c840d8111935d0f6abe5232e2c3c3f318b/src/main/java/com/omertron/fanarttvapi/model/ArtworkList.java#L47-L49
|
149,416
|
Omertron/api-fanarttv
|
src/main/java/com/omertron/fanarttvapi/model/ArtworkList.java
|
ArtworkList.getArtwork
|
@Override
public List<FTArtwork> getArtwork(FTArtworkType artworkType) {
if (artwork.containsKey(artworkType)) {
return artwork.get(artworkType);
}
return Collections.emptyList();
}
|
java
|
@Override
public List<FTArtwork> getArtwork(FTArtworkType artworkType) {
if (artwork.containsKey(artworkType)) {
return artwork.get(artworkType);
}
return Collections.emptyList();
}
|
[
"@",
"Override",
"public",
"List",
"<",
"FTArtwork",
">",
"getArtwork",
"(",
"FTArtworkType",
"artworkType",
")",
"{",
"if",
"(",
"artwork",
".",
"containsKey",
"(",
"artworkType",
")",
")",
"{",
"return",
"artwork",
".",
"get",
"(",
"artworkType",
")",
";",
"}",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}"
] |
Get a specific type of artwork
@param artworkType
@return
|
[
"Get",
"a",
"specific",
"type",
"of",
"artwork"
] |
2a1854c840d8111935d0f6abe5232e2c3c3f318b
|
https://github.com/Omertron/api-fanarttv/blob/2a1854c840d8111935d0f6abe5232e2c3c3f318b/src/main/java/com/omertron/fanarttvapi/model/ArtworkList.java#L67-L73
|
149,417
|
Omertron/api-fanarttv
|
src/main/java/com/omertron/fanarttvapi/model/ArtworkList.java
|
ArtworkList.hasArtwork
|
@Override
public boolean hasArtwork() {
for (FTArtworkType at : FTArtworkType.values()) {
// We're not countin the artwork, we're seeing if any exists, so quit when we find something
if (hasArtwork(at) && !artwork.isEmpty()) {
return true;
}
}
return false;
}
|
java
|
@Override
public boolean hasArtwork() {
for (FTArtworkType at : FTArtworkType.values()) {
// We're not countin the artwork, we're seeing if any exists, so quit when we find something
if (hasArtwork(at) && !artwork.isEmpty()) {
return true;
}
}
return false;
}
|
[
"@",
"Override",
"public",
"boolean",
"hasArtwork",
"(",
")",
"{",
"for",
"(",
"FTArtworkType",
"at",
":",
"FTArtworkType",
".",
"values",
"(",
")",
")",
"{",
"// We're not countin the artwork, we're seeing if any exists, so quit when we find something",
"if",
"(",
"hasArtwork",
"(",
"at",
")",
"&&",
"!",
"artwork",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Determines if there is any artwork associated with the series
@return
|
[
"Determines",
"if",
"there",
"is",
"any",
"artwork",
"associated",
"with",
"the",
"series"
] |
2a1854c840d8111935d0f6abe5232e2c3c3f318b
|
https://github.com/Omertron/api-fanarttv/blob/2a1854c840d8111935d0f6abe5232e2c3c3f318b/src/main/java/com/omertron/fanarttvapi/model/ArtworkList.java#L80-L89
|
149,418
|
Omertron/api-fanarttv
|
src/main/java/com/omertron/fanarttvapi/model/ArtworkList.java
|
ArtworkList.hasArtwork
|
@Override
public boolean hasArtwork(FTArtworkType artworkType) {
return artwork.containsKey(artworkType) && !artwork.get(artworkType).isEmpty();
}
|
java
|
@Override
public boolean hasArtwork(FTArtworkType artworkType) {
return artwork.containsKey(artworkType) && !artwork.get(artworkType).isEmpty();
}
|
[
"@",
"Override",
"public",
"boolean",
"hasArtwork",
"(",
"FTArtworkType",
"artworkType",
")",
"{",
"return",
"artwork",
".",
"containsKey",
"(",
"artworkType",
")",
"&&",
"!",
"artwork",
".",
"get",
"(",
"artworkType",
")",
".",
"isEmpty",
"(",
")",
";",
"}"
] |
Determines if the series has a specific type of artwork
@param artworkType
@return
|
[
"Determines",
"if",
"the",
"series",
"has",
"a",
"specific",
"type",
"of",
"artwork"
] |
2a1854c840d8111935d0f6abe5232e2c3c3f318b
|
https://github.com/Omertron/api-fanarttv/blob/2a1854c840d8111935d0f6abe5232e2c3c3f318b/src/main/java/com/omertron/fanarttvapi/model/ArtworkList.java#L97-L100
|
149,419
|
Viascom/groundwork
|
foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/response/serviceresult/FoxHttpServiceResultResponse.java
|
FoxHttpServiceResultResponse.getFault
|
public ServiceFault getFault(boolean checkHash) throws FoxHttpResponseException {
try {
String body = getStringBody();
ServiceResult<ServiceFault> result = parser.fromJson(body, new TypeToken<ServiceResult<ServiceFault>>() {
}.getType());
foxHttpClient.getFoxHttpLogger().log("processFault(" + result + ")");
checkHash(checkHash, body, result);
return result.getContent();
} catch (IOException e) {
throw new FoxHttpResponseException(e);
}
}
|
java
|
public ServiceFault getFault(boolean checkHash) throws FoxHttpResponseException {
try {
String body = getStringBody();
ServiceResult<ServiceFault> result = parser.fromJson(body, new TypeToken<ServiceResult<ServiceFault>>() {
}.getType());
foxHttpClient.getFoxHttpLogger().log("processFault(" + result + ")");
checkHash(checkHash, body, result);
return result.getContent();
} catch (IOException e) {
throw new FoxHttpResponseException(e);
}
}
|
[
"public",
"ServiceFault",
"getFault",
"(",
"boolean",
"checkHash",
")",
"throws",
"FoxHttpResponseException",
"{",
"try",
"{",
"String",
"body",
"=",
"getStringBody",
"(",
")",
";",
"ServiceResult",
"<",
"ServiceFault",
">",
"result",
"=",
"parser",
".",
"fromJson",
"(",
"body",
",",
"new",
"TypeToken",
"<",
"ServiceResult",
"<",
"ServiceFault",
">",
">",
"(",
")",
"{",
"}",
".",
"getType",
"(",
")",
")",
";",
"foxHttpClient",
".",
"getFoxHttpLogger",
"(",
")",
".",
"log",
"(",
"\"processFault(\"",
"+",
"result",
"+",
"\")\"",
")",
";",
"checkHash",
"(",
"checkHash",
",",
"body",
",",
"result",
")",
";",
"return",
"result",
".",
"getContent",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"FoxHttpResponseException",
"(",
"e",
")",
";",
"}",
"}"
] |
Get the fault of the service result
@param checkHash should the result be checked
@return deserialized fault of the service result
@throws FoxHttpResponseException Exception during the deserialization
|
[
"Get",
"the",
"fault",
"of",
"the",
"service",
"result"
] |
d3f7d0df65e2e75861fc7db938090683f2cdf919
|
https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/response/serviceresult/FoxHttpServiceResultResponse.java#L285-L301
|
149,420
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.create
|
public TableRef create(Key key, Throughput throughput, OnTableCreation onTableCreation, OnError onError) {
PostBodyBuilder pbb = new PostBodyBuilder(context);
pbb.addObject("table", this.name);
pbb.addObject("provisionType", StorageProvisionType.CUSTOM.getValue());
pbb.addObject("key", key.map());
pbb.addObject("throughput", throughput.map());
Rest r = new Rest(context, RestType.CREATETABLE, pbb, null);
r.onError = onError;
r.onTableCreation = onTableCreation;
context.processRest(r);
return this;
}
|
java
|
public TableRef create(Key key, Throughput throughput, OnTableCreation onTableCreation, OnError onError) {
PostBodyBuilder pbb = new PostBodyBuilder(context);
pbb.addObject("table", this.name);
pbb.addObject("provisionType", StorageProvisionType.CUSTOM.getValue());
pbb.addObject("key", key.map());
pbb.addObject("throughput", throughput.map());
Rest r = new Rest(context, RestType.CREATETABLE, pbb, null);
r.onError = onError;
r.onTableCreation = onTableCreation;
context.processRest(r);
return this;
}
|
[
"public",
"TableRef",
"create",
"(",
"Key",
"key",
",",
"Throughput",
"throughput",
",",
"OnTableCreation",
"onTableCreation",
",",
"OnError",
"onError",
")",
"{",
"PostBodyBuilder",
"pbb",
"=",
"new",
"PostBodyBuilder",
"(",
"context",
")",
";",
"pbb",
".",
"addObject",
"(",
"\"table\"",
",",
"this",
".",
"name",
")",
";",
"pbb",
".",
"addObject",
"(",
"\"provisionType\"",
",",
"StorageProvisionType",
".",
"CUSTOM",
".",
"getValue",
"(",
")",
")",
";",
"pbb",
".",
"addObject",
"(",
"\"key\"",
",",
"key",
".",
"map",
"(",
")",
")",
";",
"pbb",
".",
"addObject",
"(",
"\"throughput\"",
",",
"throughput",
".",
"map",
"(",
")",
")",
";",
"Rest",
"r",
"=",
"new",
"Rest",
"(",
"context",
",",
"RestType",
".",
"CREATETABLE",
",",
"pbb",
",",
"null",
")",
";",
"r",
".",
"onError",
"=",
"onError",
";",
"r",
".",
"onTableCreation",
"=",
"onTableCreation",
";",
"context",
".",
"processRest",
"(",
"r",
")",
";",
"return",
"this",
";",
"}"
] |
Creates a table with a custom throughput. The provision type is Custom and the provision load is ignored.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Create table 'myTable' with the following schema (with custom provisioning)
tableRef.create(new Key(new KeySchema("id", StorageRef.StorageDataType.STRING),new KeySchema("timestamp", StorageRef.StorageDataType.NUMBER)),
new Throughput(1,1),new OnTableCreation() {
@Override
public void run(String table, Double creationDate, String status) {
Log.d("TableRef", "Table with name: " + table + ", created at: " + new Date((long)(creationDate*1000.0)).toString() + ", with status: "+status);
}
},new OnError() {
@Override
public void run(Integer code, String errorMessage) {
Log.e("TableRef", "Error creating table: " + errorMessage);
}
});
</pre>
@param key The schema of the primary and secondary (optional) keys.
@param throughput The number of read and write operations per second.
@param onTableCreation
@param onError
@return Table reference
|
[
"Creates",
"a",
"table",
"with",
"a",
"custom",
"throughput",
".",
"The",
"provision",
"type",
"is",
"Custom",
"and",
"the",
"provision",
"load",
"is",
"ignored",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L194-L206
|
149,421
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.create
|
public TableRef create(Key key, StorageProvisionType provisionType, StorageProvisionLoad provisionLoad, OnTableCreation onTableCreation, OnError onError) {
PostBodyBuilder pbb = new PostBodyBuilder(context);
pbb.addObject("table", this.name);
pbb.addObject("provisionLoad", provisionLoad.getValue());
pbb.addObject("provisionType", provisionType.getValue());
pbb.addObject("key", key.map());
Rest r = new Rest(context, RestType.CREATETABLE, pbb, null);
r.onError = onError;
r.onTableCreation = onTableCreation;
context.processRest(r);
return this;
}
|
java
|
public TableRef create(Key key, StorageProvisionType provisionType, StorageProvisionLoad provisionLoad, OnTableCreation onTableCreation, OnError onError) {
PostBodyBuilder pbb = new PostBodyBuilder(context);
pbb.addObject("table", this.name);
pbb.addObject("provisionLoad", provisionLoad.getValue());
pbb.addObject("provisionType", provisionType.getValue());
pbb.addObject("key", key.map());
Rest r = new Rest(context, RestType.CREATETABLE, pbb, null);
r.onError = onError;
r.onTableCreation = onTableCreation;
context.processRest(r);
return this;
}
|
[
"public",
"TableRef",
"create",
"(",
"Key",
"key",
",",
"StorageProvisionType",
"provisionType",
",",
"StorageProvisionLoad",
"provisionLoad",
",",
"OnTableCreation",
"onTableCreation",
",",
"OnError",
"onError",
")",
"{",
"PostBodyBuilder",
"pbb",
"=",
"new",
"PostBodyBuilder",
"(",
"context",
")",
";",
"pbb",
".",
"addObject",
"(",
"\"table\"",
",",
"this",
".",
"name",
")",
";",
"pbb",
".",
"addObject",
"(",
"\"provisionLoad\"",
",",
"provisionLoad",
".",
"getValue",
"(",
")",
")",
";",
"pbb",
".",
"addObject",
"(",
"\"provisionType\"",
",",
"provisionType",
".",
"getValue",
"(",
")",
")",
";",
"pbb",
".",
"addObject",
"(",
"\"key\"",
",",
"key",
".",
"map",
"(",
")",
")",
";",
"Rest",
"r",
"=",
"new",
"Rest",
"(",
"context",
",",
"RestType",
".",
"CREATETABLE",
",",
"pbb",
",",
"null",
")",
";",
"r",
".",
"onError",
"=",
"onError",
";",
"r",
".",
"onTableCreation",
"=",
"onTableCreation",
";",
"context",
".",
"processRest",
"(",
"r",
")",
";",
"return",
"this",
";",
"}"
] |
Creates a table with a
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Create table "your_table" with the following schema
tableRef.create(new Key(new KeySchema("id", StorageRef.StorageDataType.STRING),new KeySchema("timestamp", StorageRef.StorageDataType.NUMBER)),
StorageRef.StorageProvisionType.LIGHT, StorageRef.StorageProvisionLoad.BALANCED,new OnTableCreation() {
@Override
public void run(String table, Double creationDate, String status) {
Log.d("TableRef", "Table with name: " + table + ", created at: " + new Date((long)(creationDate*1000.0)).toString() + ", with status: "+status);
}
},new OnError() {
@Override
public void run(Integer code, String errorMessage) {
Log.e("TableRef", "Error creating table: " + errorMessage);
}
});
</pre>
@param key The schema of the primary and secondary (optional) keys.
@param provisionType
@param provisionLoad
@param onTableCreation
@param onError
@return Table reference
|
[
"Creates",
"a",
"table",
"with",
"a"
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L238-L250
|
149,422
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.del
|
public void del(OnBooleanResponse onBooleanResponse, OnError onError){
PostBodyBuilder pbb = new PostBodyBuilder(context);
pbb.addObject("table", this.name);
Rest r = new Rest(context, RestType.DELETETABLE, pbb, null);
r.onError = onError;
r.onBooleanResponse = onBooleanResponse;
context.processRest(r);
}
|
java
|
public void del(OnBooleanResponse onBooleanResponse, OnError onError){
PostBodyBuilder pbb = new PostBodyBuilder(context);
pbb.addObject("table", this.name);
Rest r = new Rest(context, RestType.DELETETABLE, pbb, null);
r.onError = onError;
r.onBooleanResponse = onBooleanResponse;
context.processRest(r);
}
|
[
"public",
"void",
"del",
"(",
"OnBooleanResponse",
"onBooleanResponse",
",",
"OnError",
"onError",
")",
"{",
"PostBodyBuilder",
"pbb",
"=",
"new",
"PostBodyBuilder",
"(",
"context",
")",
";",
"pbb",
".",
"addObject",
"(",
"\"table\"",
",",
"this",
".",
"name",
")",
";",
"Rest",
"r",
"=",
"new",
"Rest",
"(",
"context",
",",
"RestType",
".",
"DELETETABLE",
",",
"pbb",
",",
"null",
")",
";",
"r",
".",
"onError",
"=",
"onError",
";",
"r",
".",
"onBooleanResponse",
"=",
"onBooleanResponse",
";",
"context",
".",
"processRest",
"(",
"r",
")",
";",
"}"
] |
Delete this table.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Delete table 'your_table'
tableRef.del(new OnBooleanResponse() {
@Override
public void run(Boolean aBoolean) {
Log.d("TableRef", "Deleted? : " + aBoolean);
}
},new OnError() {
@Override
public void run(Integer integer, String errorMessage) {
Log.e("TableRef", "Error deleting table: " + errorMessage);
}
});
</pre>
@param onBooleanResponse
The callback to run once the table is deleted
@param onError
The callback to call if an exception occurred
|
[
"Delete",
"this",
"table",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L279-L286
|
149,423
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.meta
|
public TableRef meta(OnTableMetadata onTableMetadata, OnError onError){
PostBodyBuilder pbb = new PostBodyBuilder(context);
pbb.addObject("table", this.name);
Rest r = new Rest(context, RestType.DESCRIBETABLE, pbb, null);
r.onError = onError;
r.onTableMetadata = onTableMetadata;
context.processRest(r);
return this;
}
|
java
|
public TableRef meta(OnTableMetadata onTableMetadata, OnError onError){
PostBodyBuilder pbb = new PostBodyBuilder(context);
pbb.addObject("table", this.name);
Rest r = new Rest(context, RestType.DESCRIBETABLE, pbb, null);
r.onError = onError;
r.onTableMetadata = onTableMetadata;
context.processRest(r);
return this;
}
|
[
"public",
"TableRef",
"meta",
"(",
"OnTableMetadata",
"onTableMetadata",
",",
"OnError",
"onError",
")",
"{",
"PostBodyBuilder",
"pbb",
"=",
"new",
"PostBodyBuilder",
"(",
"context",
")",
";",
"pbb",
".",
"addObject",
"(",
"\"table\"",
",",
"this",
".",
"name",
")",
";",
"Rest",
"r",
"=",
"new",
"Rest",
"(",
"context",
",",
"RestType",
".",
"DESCRIBETABLE",
",",
"pbb",
",",
"null",
")",
";",
"r",
".",
"onError",
"=",
"onError",
";",
"r",
".",
"onTableMetadata",
"=",
"onTableMetadata",
";",
"context",
".",
"processRest",
"(",
"r",
")",
";",
"return",
"this",
";",
"}"
] |
Gets the metadata of the table reference.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
tableRef.meta(new OnTableMetadata() {
@Override
public void run(TableMetadata tableMetadata) {
if(tableMetadata != null){
Log.d("TableRef", "TableMetadata: " + tableMetadata.toString());
}
}
}, new OnError() {
@Override
public void run(Integer integer, String errorMessage) {
Log.e("TableRef", "Error retrieving table metadata : " + errorMessage);
}
});
</pre>
@param onTableMetadata
The callback to run once the metadata is retrieved
@param onError
The callback to call if an exception occurred
@return Current table reference
|
[
"Gets",
"the",
"metadata",
"of",
"the",
"table",
"reference",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L318-L326
|
149,424
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.push
|
public TableRef push(LinkedHashMap<String, ItemAttribute> item, OnItemSnapshot onItemSnapshot, OnError onError){
PostBodyBuilder pbb = new PostBodyBuilder(context);
pbb.addObject("table", this.name);
pbb.addObject("item", item);
Rest r = new Rest(context, RestType.PUTITEM, pbb, this);
r.onError = onError;
r.onItemSnapshot = onItemSnapshot;
context.processRest(r);
return this;
}
|
java
|
public TableRef push(LinkedHashMap<String, ItemAttribute> item, OnItemSnapshot onItemSnapshot, OnError onError){
PostBodyBuilder pbb = new PostBodyBuilder(context);
pbb.addObject("table", this.name);
pbb.addObject("item", item);
Rest r = new Rest(context, RestType.PUTITEM, pbb, this);
r.onError = onError;
r.onItemSnapshot = onItemSnapshot;
context.processRest(r);
return this;
}
|
[
"public",
"TableRef",
"push",
"(",
"LinkedHashMap",
"<",
"String",
",",
"ItemAttribute",
">",
"item",
",",
"OnItemSnapshot",
"onItemSnapshot",
",",
"OnError",
"onError",
")",
"{",
"PostBodyBuilder",
"pbb",
"=",
"new",
"PostBodyBuilder",
"(",
"context",
")",
";",
"pbb",
".",
"addObject",
"(",
"\"table\"",
",",
"this",
".",
"name",
")",
";",
"pbb",
".",
"addObject",
"(",
"\"item\"",
",",
"item",
")",
";",
"Rest",
"r",
"=",
"new",
"Rest",
"(",
"context",
",",
"RestType",
".",
"PUTITEM",
",",
"pbb",
",",
"this",
")",
";",
"r",
".",
"onError",
"=",
"onError",
";",
"r",
".",
"onItemSnapshot",
"=",
"onItemSnapshot",
";",
"context",
".",
"processRest",
"(",
"r",
")",
";",
"return",
"this",
";",
"}"
] |
Adds a new item to the table.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
LinkedHashMap<String,ItemAttribute> lhm = new LinkedHashMap<String,ItemAttribute>();
// Put elements to the map
lhm.put("your_primary_key", new ItemAttribute("new_primary_key_value"));
lhm.put("your_secondary_key", new ItemAttribute("new_secondary_key_value"));
lhm.put("itemProperty", new ItemAttribute("new_itemproperty_value"));
tableRef.push(lhm,new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item inserted: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer integer, String errorMessage) {
Log.e("TableRef", "Error inserting item: " + errorMessage);
}
});
</pre>
@param item
The item to add
@param onItemSnapshot
The callback to run once the insertion is done.
@param onError
The callback to call if an exception occurred
@return Current table reference
|
[
"Adds",
"a",
"new",
"item",
"to",
"the",
"table",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L445-L454
|
149,425
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.update
|
public TableRef update(final StorageProvisionLoad provisionLoad, final StorageProvisionType provisionType, final OnTableUpdate onTableUpdate, final OnError onError){
TableMetadata tm = context.getTableMeta(this.name);
if(tm == null){
this.meta(new OnTableMetadata(){
@Override
public void run(TableMetadata tableMetadata) {
_update(provisionLoad, provisionType, onTableUpdate, onError);
}
}, onError);
} else {
this._update(provisionLoad, provisionType, onTableUpdate, onError);
}
return this;
}
|
java
|
public TableRef update(final StorageProvisionLoad provisionLoad, final StorageProvisionType provisionType, final OnTableUpdate onTableUpdate, final OnError onError){
TableMetadata tm = context.getTableMeta(this.name);
if(tm == null){
this.meta(new OnTableMetadata(){
@Override
public void run(TableMetadata tableMetadata) {
_update(provisionLoad, provisionType, onTableUpdate, onError);
}
}, onError);
} else {
this._update(provisionLoad, provisionType, onTableUpdate, onError);
}
return this;
}
|
[
"public",
"TableRef",
"update",
"(",
"final",
"StorageProvisionLoad",
"provisionLoad",
",",
"final",
"StorageProvisionType",
"provisionType",
",",
"final",
"OnTableUpdate",
"onTableUpdate",
",",
"final",
"OnError",
"onError",
")",
"{",
"TableMetadata",
"tm",
"=",
"context",
".",
"getTableMeta",
"(",
"this",
".",
"name",
")",
";",
"if",
"(",
"tm",
"==",
"null",
")",
"{",
"this",
".",
"meta",
"(",
"new",
"OnTableMetadata",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
"TableMetadata",
"tableMetadata",
")",
"{",
"_update",
"(",
"provisionLoad",
",",
"provisionType",
",",
"onTableUpdate",
",",
"onError",
")",
";",
"}",
"}",
",",
"onError",
")",
";",
"}",
"else",
"{",
"this",
".",
"_update",
"(",
"provisionLoad",
",",
"provisionType",
",",
"onTableUpdate",
",",
"onError",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Updates the provision type and provision load of the referenced table.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
//change ProvisionType
//Note: you can't change ProvisionType and ProvisionLoad at the same time
tableRef.update(StorageRef.StorageProvisionLoad.READ, StorageRef.StorageProvisionType.MEDIUM,new OnTableUpdate() {
@Override
public void run(String tableName, String status) {
Log.d("TableRef", "Table : " + tableName + ", status : "+status);
}
}, new OnError() {
@Override
public void run(Integer integer, String errorMessage) {
Log.e("TableRef", "Error updating table: " + errorMessage);
}
});
</pre>
@param provisionLoad
The new provision load
@param provisionType
The new provision type
@param onTableUpdate
The callback to run once the table is updated
@param onError
The callback to call if an exception occurred
@return Current table reference
|
[
"Updates",
"the",
"provision",
"type",
"and",
"provision",
"load",
"of",
"the",
"referenced",
"table",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L542-L555
|
149,426
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.notEqual
|
public TableRef notEqual(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.NOTEQUAL, attributeName, value, null));
return this;
}
|
java
|
public TableRef notEqual(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.NOTEQUAL, attributeName, value, null));
return this;
}
|
[
"public",
"TableRef",
"notEqual",
"(",
"String",
"attributeName",
",",
"ItemAttribute",
"value",
")",
"{",
"filters",
".",
"add",
"(",
"new",
"Filter",
"(",
"StorageFilter",
".",
"NOTEQUAL",
",",
"attributeName",
",",
"value",
",",
"null",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Applies a filter to the table. When fetched, it will return the items that does not match the filter property value.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Retrieve all items that have their "itemProperty" value equal to "theValue"
tableRef.notEqual("itemProperty",new ItemAttribute("theValue")).getItems(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item retrieved: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer code, String errorMessage) {
Log.e("TableRef", "Error retrieving items: " + errorMessage);
}
});
</pre>
@param attributeName
The name of the property to filter.
@param value
The value of the property to filter.
@return Current table reference
|
[
"Applies",
"a",
"filter",
"to",
"the",
"table",
".",
"When",
"fetched",
"it",
"will",
"return",
"the",
"items",
"that",
"does",
"not",
"match",
"the",
"filter",
"property",
"value",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L623-L626
|
149,427
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.greaterEqual
|
public TableRef greaterEqual(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.GREATEREQUAL, attributeName, value, null));
return this;
}
|
java
|
public TableRef greaterEqual(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.GREATEREQUAL, attributeName, value, null));
return this;
}
|
[
"public",
"TableRef",
"greaterEqual",
"(",
"String",
"attributeName",
",",
"ItemAttribute",
"value",
")",
"{",
"filters",
".",
"add",
"(",
"new",
"Filter",
"(",
"StorageFilter",
".",
"GREATEREQUAL",
",",
"attributeName",
",",
"value",
",",
"null",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Applies a filter to the table. When fetched, it will return the items greater or equal to filter property value.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = tableRef = storage.table("your_table");
// Retrieve all items that have their "itemProperty" value greater or equal to 10
tableRef.greaterEqual("itemProperty",new ItemAttribute(10)).getItems(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item retrieved: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer code, String errorMessage) {
Log.e("TableRef", "Error retrieving items: " + errorMessage);
}
});
</pre>
@param attributeName
The name of the property to filter.
@param value
The value of the property to filter.
@return Current table reference
|
[
"Applies",
"a",
"filter",
"to",
"the",
"table",
".",
"When",
"fetched",
"it",
"will",
"return",
"the",
"items",
"greater",
"or",
"equal",
"to",
"filter",
"property",
"value",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L658-L661
|
149,428
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.greaterThan
|
public TableRef greaterThan(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.GREATERTHAN, attributeName, value, null));
return this;
}
|
java
|
public TableRef greaterThan(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.GREATERTHAN, attributeName, value, null));
return this;
}
|
[
"public",
"TableRef",
"greaterThan",
"(",
"String",
"attributeName",
",",
"ItemAttribute",
"value",
")",
"{",
"filters",
".",
"add",
"(",
"new",
"Filter",
"(",
"StorageFilter",
".",
"GREATERTHAN",
",",
"attributeName",
",",
"value",
",",
"null",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Applies a filter to the table. When fetched, it will return the items greater than the filter property value.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Retrieve all items that have their "itemProperty" value greater than 10
tableRef.greaterThan("itemProperty",new ItemAttribute(10)).getItems(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item retrieved: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer code, String errorMessage) {
Log.e("TableRef", "Error retrieving items: " + errorMessage);
}
});
</pre>
@param attributeName
The name of the property to filter.
@param value
The value of the property to filter.
@return Current table reference
|
[
"Applies",
"a",
"filter",
"to",
"the",
"table",
".",
"When",
"fetched",
"it",
"will",
"return",
"the",
"items",
"greater",
"than",
"the",
"filter",
"property",
"value",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L693-L696
|
149,429
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.lessEqual
|
public TableRef lessEqual(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.LESSEREQUAL, attributeName, value, null));
return this;
}
|
java
|
public TableRef lessEqual(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.LESSEREQUAL, attributeName, value, null));
return this;
}
|
[
"public",
"TableRef",
"lessEqual",
"(",
"String",
"attributeName",
",",
"ItemAttribute",
"value",
")",
"{",
"filters",
".",
"add",
"(",
"new",
"Filter",
"(",
"StorageFilter",
".",
"LESSEREQUAL",
",",
"attributeName",
",",
"value",
",",
"null",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Applies a filter to the table. When fetched, it will return the items lesser or equals to the filter property value.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Retrieve all items that have their "itemProperty" value lesser or equal 10
tableRef.lessEqual("itemProperty",new ItemAttribute(10)).getItems(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item retrieved: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer code, String errorMessage) {
Log.e("TableRef", "Error retrieving items: " + errorMessage);
}
});
</pre>
@param attributeName
The name of the property to filter.
@param value
The value of the property to filter.
@return Current table reference
|
[
"Applies",
"a",
"filter",
"to",
"the",
"table",
".",
"When",
"fetched",
"it",
"will",
"return",
"the",
"items",
"lesser",
"or",
"equals",
"to",
"the",
"filter",
"property",
"value",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L728-L731
|
149,430
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.lessThan
|
public TableRef lessThan(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.LESSERTHAN, attributeName, value, null));
return this;
}
|
java
|
public TableRef lessThan(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.LESSERTHAN, attributeName, value, null));
return this;
}
|
[
"public",
"TableRef",
"lessThan",
"(",
"String",
"attributeName",
",",
"ItemAttribute",
"value",
")",
"{",
"filters",
".",
"add",
"(",
"new",
"Filter",
"(",
"StorageFilter",
".",
"LESSERTHAN",
",",
"attributeName",
",",
"value",
",",
"null",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Applies a filter to the table. When fetched, it will return the items lesser than the filter property value.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Retrieve all items that have their "itemProperty" value lesser than 10
tableRef.lessThan("itemProperty",new ItemAttribute(10)).getItems(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item retrieved: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer code, String errorMessage) {
Log.e("TableRef", "Error retrieving items: " + errorMessage);
}
});
</pre>
@param attributeName
The name of the property to filter.
@param value
The value of the property to filter.
@return Current table reference
|
[
"Applies",
"a",
"filter",
"to",
"the",
"table",
".",
"When",
"fetched",
"it",
"will",
"return",
"the",
"items",
"lesser",
"than",
"the",
"filter",
"property",
"value",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L763-L766
|
149,431
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.notNull
|
public TableRef notNull(String attributeName){
filters.add(new Filter(StorageFilter.NOTNULL, attributeName, null, null));
return this;
}
|
java
|
public TableRef notNull(String attributeName){
filters.add(new Filter(StorageFilter.NOTNULL, attributeName, null, null));
return this;
}
|
[
"public",
"TableRef",
"notNull",
"(",
"String",
"attributeName",
")",
"{",
"filters",
".",
"add",
"(",
"new",
"Filter",
"(",
"StorageFilter",
".",
"NOTNULL",
",",
"attributeName",
",",
"null",
",",
"null",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Applies a filter to the table reference. When fetched, it will return the non null values.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Retrieve all items where their "itemProperty" value is not null
tableRef.notNull("itemProperty").getItems(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item retrieved: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer code, String errorMessage) {
Log.e("TableRef", "Error retrieving items: " + errorMessage);
}
});
</pre>
@param attributeName
The name of the property to filter.
@return Current table reference
|
[
"Applies",
"a",
"filter",
"to",
"the",
"table",
"reference",
".",
"When",
"fetched",
"it",
"will",
"return",
"the",
"non",
"null",
"values",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L796-L799
|
149,432
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.isNull
|
public TableRef isNull(String attributeName){
filters.add(new Filter(StorageFilter.NULL, attributeName, null, null));
return this;
}
|
java
|
public TableRef isNull(String attributeName){
filters.add(new Filter(StorageFilter.NULL, attributeName, null, null));
return this;
}
|
[
"public",
"TableRef",
"isNull",
"(",
"String",
"attributeName",
")",
"{",
"filters",
".",
"add",
"(",
"new",
"Filter",
"(",
"StorageFilter",
".",
"NULL",
",",
"attributeName",
",",
"null",
",",
"null",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Applies a filter to the table. When fetched, it will return the null values.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Retrieve all items where their "itemProperty" value is null
tableRef.isNull("itemProperty").getItems(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item retrieved: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer code, String errorMessage) {
Log.e("TableRef", "Error retrieving items: " + errorMessage);
}
});
</pre>
@param attributeName
The name of the property to filter.
@return Current table reference
|
[
"Applies",
"a",
"filter",
"to",
"the",
"table",
".",
"When",
"fetched",
"it",
"will",
"return",
"the",
"null",
"values",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L829-L832
|
149,433
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.contains
|
public TableRef contains(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.CONTAINS, attributeName, value, null));
return this;
}
|
java
|
public TableRef contains(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.CONTAINS, attributeName, value, null));
return this;
}
|
[
"public",
"TableRef",
"contains",
"(",
"String",
"attributeName",
",",
"ItemAttribute",
"value",
")",
"{",
"filters",
".",
"add",
"(",
"new",
"Filter",
"(",
"StorageFilter",
".",
"CONTAINS",
",",
"attributeName",
",",
"value",
",",
"null",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Applies a filter to the table. When fetched, it will return the items that contains the filter property value.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Retrieve all items with property "itemProperty" contains the value "xpto"
tableRef.contains("itemProperty",new ItemAttribute("xpto")).getItems(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item retrieved: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer code, String errorMessage) {
Log.e("TableRef", "Error retrieving items: " + errorMessage);
}
});
</pre>
@param attributeName
The name of the property to filter.
@param value
The value of the property to filter.
@return Current table reference
|
[
"Applies",
"a",
"filter",
"to",
"the",
"table",
".",
"When",
"fetched",
"it",
"will",
"return",
"the",
"items",
"that",
"contains",
"the",
"filter",
"property",
"value",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L863-L866
|
149,434
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.notContains
|
public TableRef notContains(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.NOTCONTAINS, attributeName, value, null));
return this;
}
|
java
|
public TableRef notContains(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.NOTCONTAINS, attributeName, value, null));
return this;
}
|
[
"public",
"TableRef",
"notContains",
"(",
"String",
"attributeName",
",",
"ItemAttribute",
"value",
")",
"{",
"filters",
".",
"add",
"(",
"new",
"Filter",
"(",
"StorageFilter",
".",
"NOTCONTAINS",
",",
"attributeName",
",",
"value",
",",
"null",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Applies a filter to the table. When fetched, it will return the items that does not contains the filter property value.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Retrieve all items with property "itemProperty" contains the value "xpto"
tableRef.notContains("itemProperty",new ItemAttribute("xpto")).getItems(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item retrieved: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer code, String errorMessage) {
Log.e("TableRef", "Error retrieving items: " + errorMessage);
}
});
</pre>
@param attributeName
The name of the property to filter.
@param value
The value of the property to filter.
@return Current table reference
|
[
"Applies",
"a",
"filter",
"to",
"the",
"table",
".",
"When",
"fetched",
"it",
"will",
"return",
"the",
"items",
"that",
"does",
"not",
"contains",
"the",
"filter",
"property",
"value",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L897-L900
|
149,435
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.beginsWith
|
public TableRef beginsWith(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.BEGINSWITH, attributeName, value, null));
return this;
}
|
java
|
public TableRef beginsWith(String attributeName, ItemAttribute value){
filters.add(new Filter(StorageFilter.BEGINSWITH, attributeName, value, null));
return this;
}
|
[
"public",
"TableRef",
"beginsWith",
"(",
"String",
"attributeName",
",",
"ItemAttribute",
"value",
")",
"{",
"filters",
".",
"add",
"(",
"new",
"Filter",
"(",
"StorageFilter",
".",
"BEGINSWITH",
",",
"attributeName",
",",
"value",
",",
"null",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Applies a filter to the table. When fetched, it will return the items that begins with the filter property value.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Retrieve all items with property "itemProperty" value starting with "xpto"
tableRef.beginsWith("itemProperty",new ItemAttribute("xpto")).getItems(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item retrieved: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer code, String errorMessage) {
Log.e("TableRef", "Error retrieving items: " + errorMessage);
}
});
</pre>
@param attributeName
The name of the property to filter.
@param value
The value of the property to filter.
@return Current table reference
|
[
"Applies",
"a",
"filter",
"to",
"the",
"table",
".",
"When",
"fetched",
"it",
"will",
"return",
"the",
"items",
"that",
"begins",
"with",
"the",
"filter",
"property",
"value",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L931-L934
|
149,436
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.between
|
public TableRef between(String attributeName, ItemAttribute startValue, ItemAttribute endValue){
filters.add(new Filter(StorageFilter.BETWEEN, attributeName, startValue, endValue));
return this;
}
|
java
|
public TableRef between(String attributeName, ItemAttribute startValue, ItemAttribute endValue){
filters.add(new Filter(StorageFilter.BETWEEN, attributeName, startValue, endValue));
return this;
}
|
[
"public",
"TableRef",
"between",
"(",
"String",
"attributeName",
",",
"ItemAttribute",
"startValue",
",",
"ItemAttribute",
"endValue",
")",
"{",
"filters",
".",
"add",
"(",
"new",
"Filter",
"(",
"StorageFilter",
".",
"BETWEEN",
",",
"attributeName",
",",
"startValue",
",",
"endValue",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Applies a filter to the table. When fetched, it will return the items in range of the filter property value.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Retrieve all items where property "itemProperty" has a value between 1 and 10
tableRef.between("itemProperty",new ItemAttribute(1),new ItemAttribute(10)).getItems(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item retrieved: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer code, String errorMessage) {
Log.e("TableRef", "Error retrieving items: " + errorMessage);
}
});
</pre>
@param attributeName
The name of the property to filter.
@param startValue
The value of property indicates the beginning of range.
@param endValue
The value of property indicates the end of range.
@return Current table reference
|
[
"Applies",
"a",
"filter",
"to",
"the",
"table",
".",
"When",
"fetched",
"it",
"will",
"return",
"the",
"items",
"in",
"range",
"of",
"the",
"filter",
"property",
"value",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L967-L970
|
149,437
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef._tryConstructKey
|
private RestType _tryConstructKey(TableMetadata tm) {
for(Filter f : filters)
if(f.operator==StorageFilter.NOTEQUAL || f.operator==StorageFilter.NOTNULL || f.operator==StorageFilter.NULL ||
f.operator==StorageFilter.CONTAINS || f.operator==StorageFilter.NOTCONTAINS)
return RestType.LISTITEMS; //because queryItems do not support notEqual, notNull, null, contains and notContains
if(tm.getSecondaryKeyName()!=null){
if(filters.size() == 1){
Iterator<Filter> itr = filters.iterator();
Filter f = itr.next();
if(f.itemName.equals(tm.getPrimaryKeyName()) && f.operator == StorageFilter.EQUALS){
this.key = new LinkedHashMap<String, Object>();
this.key.put("primary", f.value);
filters.clear();
return RestType.QUERYITEMS;
}
} else if (filters.size() == 2) {
Object tValue = null;
Filter tFilter = null;
for(Filter f : filters){
if(f.itemName.equals(tm.getPrimaryKeyName()) && f.operator == StorageFilter.EQUALS){
tValue = f.value;
}
if(f.itemName.equals(tm.getSecondaryKeyName())){
tFilter = f;
}
}
if(tValue!=null && tFilter!=null){
filters.clear();
filters.add(tFilter);
this.key = new LinkedHashMap<String, Object>();
this.key.put("primary", tValue);
return RestType.QUERYITEMS;
} else {
return RestType.LISTITEMS;
}
}
} else {
if(filters.size()==1){
Iterator<Filter> itr = filters.iterator();
Filter f = itr.next();
if(f.itemName.equals(tm.getPrimaryKeyName()) && f.operator == StorageFilter.EQUALS){
return RestType.GETITEM;
}
}
}
return RestType.LISTITEMS;
}
|
java
|
private RestType _tryConstructKey(TableMetadata tm) {
for(Filter f : filters)
if(f.operator==StorageFilter.NOTEQUAL || f.operator==StorageFilter.NOTNULL || f.operator==StorageFilter.NULL ||
f.operator==StorageFilter.CONTAINS || f.operator==StorageFilter.NOTCONTAINS)
return RestType.LISTITEMS; //because queryItems do not support notEqual, notNull, null, contains and notContains
if(tm.getSecondaryKeyName()!=null){
if(filters.size() == 1){
Iterator<Filter> itr = filters.iterator();
Filter f = itr.next();
if(f.itemName.equals(tm.getPrimaryKeyName()) && f.operator == StorageFilter.EQUALS){
this.key = new LinkedHashMap<String, Object>();
this.key.put("primary", f.value);
filters.clear();
return RestType.QUERYITEMS;
}
} else if (filters.size() == 2) {
Object tValue = null;
Filter tFilter = null;
for(Filter f : filters){
if(f.itemName.equals(tm.getPrimaryKeyName()) && f.operator == StorageFilter.EQUALS){
tValue = f.value;
}
if(f.itemName.equals(tm.getSecondaryKeyName())){
tFilter = f;
}
}
if(tValue!=null && tFilter!=null){
filters.clear();
filters.add(tFilter);
this.key = new LinkedHashMap<String, Object>();
this.key.put("primary", tValue);
return RestType.QUERYITEMS;
} else {
return RestType.LISTITEMS;
}
}
} else {
if(filters.size()==1){
Iterator<Filter> itr = filters.iterator();
Filter f = itr.next();
if(f.itemName.equals(tm.getPrimaryKeyName()) && f.operator == StorageFilter.EQUALS){
return RestType.GETITEM;
}
}
}
return RestType.LISTITEMS;
}
|
[
"private",
"RestType",
"_tryConstructKey",
"(",
"TableMetadata",
"tm",
")",
"{",
"for",
"(",
"Filter",
"f",
":",
"filters",
")",
"if",
"(",
"f",
".",
"operator",
"==",
"StorageFilter",
".",
"NOTEQUAL",
"||",
"f",
".",
"operator",
"==",
"StorageFilter",
".",
"NOTNULL",
"||",
"f",
".",
"operator",
"==",
"StorageFilter",
".",
"NULL",
"||",
"f",
".",
"operator",
"==",
"StorageFilter",
".",
"CONTAINS",
"||",
"f",
".",
"operator",
"==",
"StorageFilter",
".",
"NOTCONTAINS",
")",
"return",
"RestType",
".",
"LISTITEMS",
";",
"//because queryItems do not support notEqual, notNull, null, contains and notContains",
"if",
"(",
"tm",
".",
"getSecondaryKeyName",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"filters",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"Iterator",
"<",
"Filter",
">",
"itr",
"=",
"filters",
".",
"iterator",
"(",
")",
";",
"Filter",
"f",
"=",
"itr",
".",
"next",
"(",
")",
";",
"if",
"(",
"f",
".",
"itemName",
".",
"equals",
"(",
"tm",
".",
"getPrimaryKeyName",
"(",
")",
")",
"&&",
"f",
".",
"operator",
"==",
"StorageFilter",
".",
"EQUALS",
")",
"{",
"this",
".",
"key",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"this",
".",
"key",
".",
"put",
"(",
"\"primary\"",
",",
"f",
".",
"value",
")",
";",
"filters",
".",
"clear",
"(",
")",
";",
"return",
"RestType",
".",
"QUERYITEMS",
";",
"}",
"}",
"else",
"if",
"(",
"filters",
".",
"size",
"(",
")",
"==",
"2",
")",
"{",
"Object",
"tValue",
"=",
"null",
";",
"Filter",
"tFilter",
"=",
"null",
";",
"for",
"(",
"Filter",
"f",
":",
"filters",
")",
"{",
"if",
"(",
"f",
".",
"itemName",
".",
"equals",
"(",
"tm",
".",
"getPrimaryKeyName",
"(",
")",
")",
"&&",
"f",
".",
"operator",
"==",
"StorageFilter",
".",
"EQUALS",
")",
"{",
"tValue",
"=",
"f",
".",
"value",
";",
"}",
"if",
"(",
"f",
".",
"itemName",
".",
"equals",
"(",
"tm",
".",
"getSecondaryKeyName",
"(",
")",
")",
")",
"{",
"tFilter",
"=",
"f",
";",
"}",
"}",
"if",
"(",
"tValue",
"!=",
"null",
"&&",
"tFilter",
"!=",
"null",
")",
"{",
"filters",
".",
"clear",
"(",
")",
";",
"filters",
".",
"add",
"(",
"tFilter",
")",
";",
"this",
".",
"key",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"this",
".",
"key",
".",
"put",
"(",
"\"primary\"",
",",
"tValue",
")",
";",
"return",
"RestType",
".",
"QUERYITEMS",
";",
"}",
"else",
"{",
"return",
"RestType",
".",
"LISTITEMS",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"filters",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"Iterator",
"<",
"Filter",
">",
"itr",
"=",
"filters",
".",
"iterator",
"(",
")",
";",
"Filter",
"f",
"=",
"itr",
".",
"next",
"(",
")",
";",
"if",
"(",
"f",
".",
"itemName",
".",
"equals",
"(",
"tm",
".",
"getPrimaryKeyName",
"(",
")",
")",
"&&",
"f",
".",
"operator",
"==",
"StorageFilter",
".",
"EQUALS",
")",
"{",
"return",
"RestType",
".",
"GETITEM",
";",
"}",
"}",
"}",
"return",
"RestType",
".",
"LISTITEMS",
";",
"}"
] |
if returns null the rest type is listItems, otherwise queryItems
|
[
"if",
"returns",
"null",
"the",
"rest",
"type",
"is",
"listItems",
"otherwise",
"queryItems"
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L1025-L1072
|
149,438
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.getItems
|
public TableRef getItems(final OnItemSnapshot onItemSnapshot, final OnError onError){
TableMetadata tm = context.getTableMeta(this.name);
if(tm == null){
this.meta(new OnTableMetadata(){
@Override
public void run(TableMetadata tableMetadata) {
_getItems(onItemSnapshot, onError);
}
}, onError);
} else {
this._getItems(onItemSnapshot, onError);
}
return this;
}
|
java
|
public TableRef getItems(final OnItemSnapshot onItemSnapshot, final OnError onError){
TableMetadata tm = context.getTableMeta(this.name);
if(tm == null){
this.meta(new OnTableMetadata(){
@Override
public void run(TableMetadata tableMetadata) {
_getItems(onItemSnapshot, onError);
}
}, onError);
} else {
this._getItems(onItemSnapshot, onError);
}
return this;
}
|
[
"public",
"TableRef",
"getItems",
"(",
"final",
"OnItemSnapshot",
"onItemSnapshot",
",",
"final",
"OnError",
"onError",
")",
"{",
"TableMetadata",
"tm",
"=",
"context",
".",
"getTableMeta",
"(",
"this",
".",
"name",
")",
";",
"if",
"(",
"tm",
"==",
"null",
")",
"{",
"this",
".",
"meta",
"(",
"new",
"OnTableMetadata",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
"TableMetadata",
"tableMetadata",
")",
"{",
"_getItems",
"(",
"onItemSnapshot",
",",
"onError",
")",
";",
"}",
"}",
",",
"onError",
")",
";",
"}",
"else",
"{",
"this",
".",
"_getItems",
"(",
"onItemSnapshot",
",",
"onError",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Get the items of this tableRef.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
tableRef.getItems(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item retrieved: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer code, String errorMessage) {
Log.e("TableRef", "Error retrieving items: " + errorMessage);
}
});
</pre>
@param onItemSnapshot
The callback to call once the items are available. The success function will be called for each existent item. The argument is an item snapshot. In the end, when all calls are done, the success function will be called with null as argument to signal that there are no more items.
@param onError
The callback to call if an exception occurred
@return Current table reference
|
[
"Get",
"the",
"items",
"of",
"this",
"tableRef",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L1104-L1117
|
149,439
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.item
|
public ItemRef item(ItemAttribute primaryKeyValue, ItemAttribute secondaryKeyValue){
return new ItemRef(context, this, primaryKeyValue, secondaryKeyValue);
}
|
java
|
public ItemRef item(ItemAttribute primaryKeyValue, ItemAttribute secondaryKeyValue){
return new ItemRef(context, this, primaryKeyValue, secondaryKeyValue);
}
|
[
"public",
"ItemRef",
"item",
"(",
"ItemAttribute",
"primaryKeyValue",
",",
"ItemAttribute",
"secondaryKeyValue",
")",
"{",
"return",
"new",
"ItemRef",
"(",
"context",
",",
"this",
",",
"primaryKeyValue",
",",
"secondaryKeyValue",
")",
";",
"}"
] |
Creates a new item reference.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
ItemRef itemRef = tableRef.item(new ItemAttribute("your_primary_key_value"),new ItemAttribute("your_secondary_key_value"));
</pre>
@param primaryKeyValue
The primary key. Must match the table schema.
@param secondaryKeyValue
The secondary key. Must match the table schema.
@return Current table reference
|
[
"Creates",
"a",
"new",
"item",
"reference",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L1157-L1159
|
149,440
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.on
|
public TableRef on(StorageEvent eventType, final OnItemSnapshot onItemSnapshot) {
return on(eventType, onItemSnapshot, null);
}
|
java
|
public TableRef on(StorageEvent eventType, final OnItemSnapshot onItemSnapshot) {
return on(eventType, onItemSnapshot, null);
}
|
[
"public",
"TableRef",
"on",
"(",
"StorageEvent",
"eventType",
",",
"final",
"OnItemSnapshot",
"onItemSnapshot",
")",
"{",
"return",
"on",
"(",
"eventType",
",",
"onItemSnapshot",
",",
"null",
")",
";",
"}"
] |
Attach a listener to run every time the eventType occurs.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Add an update listener
tableRef.on(StorageRef.StorageEvent.UPDATE, new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item updated: " + itemSnapshot.val());
}
}
});
</pre>
@param eventType
The type of the event to listen. Possible values: put, update, delete
@param onItemSnapshot
The function to run whenever the event occurs. The function is called with the snapshot of affected item as argument. If the event type is "put", it will immediately trigger a "getItems" to get the initial data and run the callback with each item snapshot as argument. Note: If you are using GCM the value of received ItemSnapshot can be null.
@return Current table reference
|
[
"Attach",
"a",
"listener",
"to",
"run",
"every",
"time",
"the",
"eventType",
"occurs",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L1245-L1247
|
149,441
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.once
|
public TableRef once(StorageEvent eventType, final OnItemSnapshot onItemSnapshot, final OnError onError) {
if(eventType == StorageEvent.PUT) {
getItems(onItemSnapshot, onError);
}
Event ev = new Event(eventType, this.name, null, null, true, true, pushNotificationsEnabled, onItemSnapshot);
context.addEvent(ev);
return this;
}
|
java
|
public TableRef once(StorageEvent eventType, final OnItemSnapshot onItemSnapshot, final OnError onError) {
if(eventType == StorageEvent.PUT) {
getItems(onItemSnapshot, onError);
}
Event ev = new Event(eventType, this.name, null, null, true, true, pushNotificationsEnabled, onItemSnapshot);
context.addEvent(ev);
return this;
}
|
[
"public",
"TableRef",
"once",
"(",
"StorageEvent",
"eventType",
",",
"final",
"OnItemSnapshot",
"onItemSnapshot",
",",
"final",
"OnError",
"onError",
")",
"{",
"if",
"(",
"eventType",
"==",
"StorageEvent",
".",
"PUT",
")",
"{",
"getItems",
"(",
"onItemSnapshot",
",",
"onError",
")",
";",
"}",
"Event",
"ev",
"=",
"new",
"Event",
"(",
"eventType",
",",
"this",
".",
"name",
",",
"null",
",",
"null",
",",
"true",
",",
"true",
",",
"pushNotificationsEnabled",
",",
"onItemSnapshot",
")",
";",
"context",
".",
"addEvent",
"(",
"ev",
")",
";",
"return",
"this",
";",
"}"
] |
Attach a listener to run only once the event type occurs.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
// Add an update listener. Only one notification is received once the item is updated after the listener is set
tableRef.once(StorageRef.StorageEvent.UPDATE,new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item updated: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer integer, String errorMessage) {
Log.e("TableRef", "Error adding an update event listener: " + errorMessage);
}
});
</pre>
@param eventType
The type of the event to listen. Possible values: put, update, delete
@param onItemSnapshot
The function to run when the event occurs. The function is called with the snapshot of affected item as argument.
@param onError
Response if client side validation failed or if an error was returned from the server.
@return Current table reference
|
[
"Attach",
"a",
"listener",
"to",
"run",
"only",
"once",
"the",
"event",
"type",
"occurs",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L1381-L1388
|
149,442
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/TableRef.java
|
TableRef.off
|
public TableRef off(StorageEvent eventType, OnItemSnapshot onItemSnapshot) {
Event ev = new Event(eventType, this.name, null, null, false, true, false, onItemSnapshot);
context.removeEvent(ev);
return this;
}
|
java
|
public TableRef off(StorageEvent eventType, OnItemSnapshot onItemSnapshot) {
Event ev = new Event(eventType, this.name, null, null, false, true, false, onItemSnapshot);
context.removeEvent(ev);
return this;
}
|
[
"public",
"TableRef",
"off",
"(",
"StorageEvent",
"eventType",
",",
"OnItemSnapshot",
"onItemSnapshot",
")",
"{",
"Event",
"ev",
"=",
"new",
"Event",
"(",
"eventType",
",",
"this",
".",
"name",
",",
"null",
",",
"null",
",",
"false",
",",
"true",
",",
"false",
",",
"onItemSnapshot",
")",
";",
"context",
".",
"removeEvent",
"(",
"ev",
")",
";",
"return",
"this",
";",
"}"
] |
Remove an event handler.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
TableRef tableRef = storage.table("your_table");
//Define handler function
final OnItemSnapshot itemSnapshot = new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item : " + itemSnapshot.val());
}
}
};
// Add an update listener
tableRef.on(StorageRef.StorageEvent.UPDATE,itemSnapshot,new OnError() {
@Override
public void run(Integer integer, String errorMessage) {
Log.e("TableRef", "Error adding an update event listener: " + errorMessage);
}
});
Handler handler=new Handler();
final Runnable r = new Runnable()
{
public void run()
{ //remove the update listener
tableRef.off(StorageRef.StorageEvent.UPDATE,itemSnapshot);
}
};
// Stop listening after 5 seconds
handler.postDelayed(r, 5000);
</pre>
@param eventType
The type of the event to listen. Possible values: put, update, delete
@param onItemSnapshot
The callback previously attached.
@return Current table reference
|
[
"Remove",
"an",
"event",
"handler",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/TableRef.java#L1503-L1507
|
149,443
|
jiaqi/caff
|
src/main/java/org/cyclopsgroup/caff/util/UUIDUtils.java
|
UUIDUtils.fromBytes
|
public static UUID fromBytes(byte[] bytes) {
long mostBits = ByteUtils.readLong(bytes, 0);
long leastBits = 0;
if (bytes.length > 8) {
leastBits = ByteUtils.readLong(bytes, 8);
}
return new UUID(mostBits, leastBits);
}
|
java
|
public static UUID fromBytes(byte[] bytes) {
long mostBits = ByteUtils.readLong(bytes, 0);
long leastBits = 0;
if (bytes.length > 8) {
leastBits = ByteUtils.readLong(bytes, 8);
}
return new UUID(mostBits, leastBits);
}
|
[
"public",
"static",
"UUID",
"fromBytes",
"(",
"byte",
"[",
"]",
"bytes",
")",
"{",
"long",
"mostBits",
"=",
"ByteUtils",
".",
"readLong",
"(",
"bytes",
",",
"0",
")",
";",
"long",
"leastBits",
"=",
"0",
";",
"if",
"(",
"bytes",
".",
"length",
">",
"8",
")",
"{",
"leastBits",
"=",
"ByteUtils",
".",
"readLong",
"(",
"bytes",
",",
"8",
")",
";",
"}",
"return",
"new",
"UUID",
"(",
"mostBits",
",",
"leastBits",
")",
";",
"}"
] |
Convert byte array into UUID. Byte array is a compact form of bits in UUID
@param bytes Byte array to convert from
@return UUID result
|
[
"Convert",
"byte",
"array",
"into",
"UUID",
".",
"Byte",
"array",
"is",
"a",
"compact",
"form",
"of",
"bits",
"in",
"UUID"
] |
dba4b937a0afc844eb37ccf74dd04dd78f0c1314
|
https://github.com/jiaqi/caff/blob/dba4b937a0afc844eb37ccf74dd04dd78f0c1314/src/main/java/org/cyclopsgroup/caff/util/UUIDUtils.java#L18-L25
|
149,444
|
jiaqi/caff
|
src/main/java/org/cyclopsgroup/caff/util/UUIDUtils.java
|
UUIDUtils.toBytes
|
public static byte[] toBytes(UUID id) {
byte[] bytes = new byte[16];
ByteUtils.writeLong(id.getMostSignificantBits(), bytes, 0);
ByteUtils.writeLong(id.getLeastSignificantBits(), bytes, 8);
return bytes;
}
|
java
|
public static byte[] toBytes(UUID id) {
byte[] bytes = new byte[16];
ByteUtils.writeLong(id.getMostSignificantBits(), bytes, 0);
ByteUtils.writeLong(id.getLeastSignificantBits(), bytes, 8);
return bytes;
}
|
[
"public",
"static",
"byte",
"[",
"]",
"toBytes",
"(",
"UUID",
"id",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"16",
"]",
";",
"ByteUtils",
".",
"writeLong",
"(",
"id",
".",
"getMostSignificantBits",
"(",
")",
",",
"bytes",
",",
"0",
")",
";",
"ByteUtils",
".",
"writeLong",
"(",
"id",
".",
"getLeastSignificantBits",
"(",
")",
",",
"bytes",
",",
"8",
")",
";",
"return",
"bytes",
";",
"}"
] |
Convert UUID in compact form of byte array
@param id UUID to convert from
@return Byte array result
|
[
"Convert",
"UUID",
"in",
"compact",
"form",
"of",
"byte",
"array"
] |
dba4b937a0afc844eb37ccf74dd04dd78f0c1314
|
https://github.com/jiaqi/caff/blob/dba4b937a0afc844eb37ccf74dd04dd78f0c1314/src/main/java/org/cyclopsgroup/caff/util/UUIDUtils.java#L43-L48
|
149,445
|
jiaqi/caff
|
src/main/java/org/cyclopsgroup/caff/format/Formats.java
|
Formats.newFixLengthFormat
|
public static <T> Format<T> newFixLengthFormat(Class<T> beanType) {
return new FixLengthFormat<T>(beanType);
}
|
java
|
public static <T> Format<T> newFixLengthFormat(Class<T> beanType) {
return new FixLengthFormat<T>(beanType);
}
|
[
"public",
"static",
"<",
"T",
">",
"Format",
"<",
"T",
">",
"newFixLengthFormat",
"(",
"Class",
"<",
"T",
">",
"beanType",
")",
"{",
"return",
"new",
"FixLengthFormat",
"<",
"T",
">",
"(",
"beanType",
")",
";",
"}"
] |
Create new text format for fix-length syntax
@param <T> Type of bean
@param beanType Type of bean
@return Fix length format of given type
|
[
"Create",
"new",
"text",
"format",
"for",
"fix",
"-",
"length",
"syntax"
] |
dba4b937a0afc844eb37ccf74dd04dd78f0c1314
|
https://github.com/jiaqi/caff/blob/dba4b937a0afc844eb37ccf74dd04dd78f0c1314/src/main/java/org/cyclopsgroup/caff/format/Formats.java#L18-L20
|
149,446
|
jiaqi/caff
|
src/main/java/org/cyclopsgroup/caff/format/Formats.java
|
Formats.newCSVFormat
|
public static <T> Format<T> newCSVFormat(Class<T> beanType) {
return new CSVFormat<T>(beanType);
}
|
java
|
public static <T> Format<T> newCSVFormat(Class<T> beanType) {
return new CSVFormat<T>(beanType);
}
|
[
"public",
"static",
"<",
"T",
">",
"Format",
"<",
"T",
">",
"newCSVFormat",
"(",
"Class",
"<",
"T",
">",
"beanType",
")",
"{",
"return",
"new",
"CSVFormat",
"<",
"T",
">",
"(",
"beanType",
")",
";",
"}"
] |
Create new text format for CSV syntax
@param <T> Type of bean
@param beanType Type of bean
@return CSV implementation of format
|
[
"Create",
"new",
"text",
"format",
"for",
"CSV",
"syntax"
] |
dba4b937a0afc844eb37ccf74dd04dd78f0c1314
|
https://github.com/jiaqi/caff/blob/dba4b937a0afc844eb37ccf74dd04dd78f0c1314/src/main/java/org/cyclopsgroup/caff/format/Formats.java#L29-L31
|
149,447
|
yangjm/winlet
|
dao/src/main/java/com/aggrepoint/service/ServiceClassLoader.java
|
ServiceClassLoader.implementsInterface
|
public static boolean implementsInterface(Class<?> c, Class<?> i) {
if (c == i)
return true;
for (Class<?> x : c.getInterfaces())
if (implementsInterface(x, i))
return true;
return false;
}
|
java
|
public static boolean implementsInterface(Class<?> c, Class<?> i) {
if (c == i)
return true;
for (Class<?> x : c.getInterfaces())
if (implementsInterface(x, i))
return true;
return false;
}
|
[
"public",
"static",
"boolean",
"implementsInterface",
"(",
"Class",
"<",
"?",
">",
"c",
",",
"Class",
"<",
"?",
">",
"i",
")",
"{",
"if",
"(",
"c",
"==",
"i",
")",
"return",
"true",
";",
"for",
"(",
"Class",
"<",
"?",
">",
"x",
":",
"c",
".",
"getInterfaces",
"(",
")",
")",
"if",
"(",
"implementsInterface",
"(",
"x",
",",
"i",
")",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
] |
Check whether c implements interface i
@param c
@param i
@return
|
[
"Check",
"whether",
"c",
"implements",
"interface",
"i"
] |
2126236f56858e283fa6ad69fe9279ee30f47b67
|
https://github.com/yangjm/winlet/blob/2126236f56858e283fa6ad69fe9279ee30f47b67/dao/src/main/java/com/aggrepoint/service/ServiceClassLoader.java#L108-L117
|
149,448
|
lightblueseas/wicket-js-addons
|
wicket-js-addons-core/src/main/java/de/alpharogroup/wicket/js/addon/core/StringTextValue.java
|
StringTextValue.setValue
|
public StringTextValue<T> setValue(final T value, final boolean initialValue)
{
this.initialValue = initialValue;
this.value = value;
return this;
}
|
java
|
public StringTextValue<T> setValue(final T value, final boolean initialValue)
{
this.initialValue = initialValue;
this.value = value;
return this;
}
|
[
"public",
"StringTextValue",
"<",
"T",
">",
"setValue",
"(",
"final",
"T",
"value",
",",
"final",
"boolean",
"initialValue",
")",
"{",
"this",
".",
"initialValue",
"=",
"initialValue",
";",
"this",
".",
"value",
"=",
"value",
";",
"return",
"this",
";",
"}"
] |
Sets the given value and set the initalValue flag if the flag should keep his state.
@param value
the value
@param initialValue
this flag tells the generator if the value is initial. This flag is taken for the
generation of javascript, if false this {@link StringTextValue} will be not added.
@return the string text value
|
[
"Sets",
"the",
"given",
"value",
"and",
"set",
"the",
"initalValue",
"flag",
"if",
"the",
"flag",
"should",
"keep",
"his",
"state",
"."
] |
b1c88c1abafd1e965f2e32ef13d66be0b28d76f6
|
https://github.com/lightblueseas/wicket-js-addons/blob/b1c88c1abafd1e965f2e32ef13d66be0b28d76f6/wicket-js-addons-core/src/main/java/de/alpharogroup/wicket/js/addon/core/StringTextValue.java#L164-L169
|
149,449
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/metadata/StoredProcedure.java
|
StoredProcedure.equalsNull
|
private boolean equalsNull(String value1, String value2) {
return (value1 == value2 || value1 == null || (value1 != null && value1.equalsIgnoreCase(value2)));
}
|
java
|
private boolean equalsNull(String value1, String value2) {
return (value1 == value2 || value1 == null || (value1 != null && value1.equalsIgnoreCase(value2)));
}
|
[
"private",
"boolean",
"equalsNull",
"(",
"String",
"value1",
",",
"String",
"value2",
")",
"{",
"return",
"(",
"value1",
"==",
"value2",
"||",
"value1",
"==",
"null",
"||",
"(",
"value1",
"!=",
"null",
"&&",
"value1",
".",
"equalsIgnoreCase",
"(",
"value2",
")",
")",
")",
";",
"}"
] |
Compares two values. Treats null as equal and is case insensitive
@param value1 First value to compare
@param value2 Second value to compare
@return true if two values equals
|
[
"Compares",
"two",
"values",
".",
"Treats",
"null",
"as",
"equal",
"and",
"is",
"case",
"insensitive"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/metadata/StoredProcedure.java#L126-L128
|
149,450
|
javagl/Common
|
src/main/java/de/javagl/common/beans/PropertyChangeListeners.java
|
PropertyChangeListeners.addDeepLogger
|
public static void addDeepLogger(Object object, Level level)
{
addDeepLogger(object, m -> logger.log(level, m));
}
|
java
|
public static void addDeepLogger(Object object, Level level)
{
addDeepLogger(object, m -> logger.log(level, m));
}
|
[
"public",
"static",
"void",
"addDeepLogger",
"(",
"Object",
"object",
",",
"Level",
"level",
")",
"{",
"addDeepLogger",
"(",
"object",
",",
"m",
"->",
"logger",
".",
"log",
"(",
"level",
",",
"m",
")",
")",
";",
"}"
] |
Attaches a deep property change listener to the given object, that
generates logging information about the property change events,
and prints them as log messages.
@param object The object
@param level The log level
|
[
"Attaches",
"a",
"deep",
"property",
"change",
"listener",
"to",
"the",
"given",
"object",
"that",
"generates",
"logging",
"information",
"about",
"the",
"property",
"change",
"events",
"and",
"prints",
"them",
"as",
"log",
"messages",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/beans/PropertyChangeListeners.java#L71-L74
|
149,451
|
javagl/Common
|
src/main/java/de/javagl/common/beans/PropertyChangeListeners.java
|
PropertyChangeListeners.addDeepConsoleLogger
|
public static void addDeepConsoleLogger(Object object)
{
addDeepLogger(object, m -> System.out.println(m));
}
|
java
|
public static void addDeepConsoleLogger(Object object)
{
addDeepLogger(object, m -> System.out.println(m));
}
|
[
"public",
"static",
"void",
"addDeepConsoleLogger",
"(",
"Object",
"object",
")",
"{",
"addDeepLogger",
"(",
"object",
",",
"m",
"->",
"System",
".",
"out",
".",
"println",
"(",
"m",
")",
")",
";",
"}"
] |
Attaches a deep property change listener to the given object, that
generates logging information about the property change events,
and prints them to the standard output.
@param object The object
|
[
"Attaches",
"a",
"deep",
"property",
"change",
"listener",
"to",
"the",
"given",
"object",
"that",
"generates",
"logging",
"information",
"about",
"the",
"property",
"change",
"events",
"and",
"prints",
"them",
"to",
"the",
"standard",
"output",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/beans/PropertyChangeListeners.java#L83-L86
|
149,452
|
javagl/Common
|
src/main/java/de/javagl/common/beans/PropertyChangeListeners.java
|
PropertyChangeListeners.addDeepLogger
|
public static void addDeepLogger(
Object object, Consumer<? super String> consumer)
{
Objects.requireNonNull(consumer, "The consumer may not be null");
PropertyChangeListener propertyChangeListener =
new PropertyChangeListener()
{
@Override
public void propertyChange(PropertyChangeEvent event)
{
Object source = event.getSource();
String propertyName = event.getPropertyName();
Object oldValue = event.getOldValue();
String oldValueString = createLoggingString(oldValue);
Object newValue = event.getNewValue();
String newValueString = createLoggingString(newValue);
String message =
"Property " + propertyName + " changed from " +
oldValueString + " to " + newValueString + " in " + source;
consumer.accept(message);
}
};
addDeepPropertyChangeListener(object, propertyChangeListener);
}
|
java
|
public static void addDeepLogger(
Object object, Consumer<? super String> consumer)
{
Objects.requireNonNull(consumer, "The consumer may not be null");
PropertyChangeListener propertyChangeListener =
new PropertyChangeListener()
{
@Override
public void propertyChange(PropertyChangeEvent event)
{
Object source = event.getSource();
String propertyName = event.getPropertyName();
Object oldValue = event.getOldValue();
String oldValueString = createLoggingString(oldValue);
Object newValue = event.getNewValue();
String newValueString = createLoggingString(newValue);
String message =
"Property " + propertyName + " changed from " +
oldValueString + " to " + newValueString + " in " + source;
consumer.accept(message);
}
};
addDeepPropertyChangeListener(object, propertyChangeListener);
}
|
[
"public",
"static",
"void",
"addDeepLogger",
"(",
"Object",
"object",
",",
"Consumer",
"<",
"?",
"super",
"String",
">",
"consumer",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"consumer",
",",
"\"The consumer may not be null\"",
")",
";",
"PropertyChangeListener",
"propertyChangeListener",
"=",
"new",
"PropertyChangeListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"propertyChange",
"(",
"PropertyChangeEvent",
"event",
")",
"{",
"Object",
"source",
"=",
"event",
".",
"getSource",
"(",
")",
";",
"String",
"propertyName",
"=",
"event",
".",
"getPropertyName",
"(",
")",
";",
"Object",
"oldValue",
"=",
"event",
".",
"getOldValue",
"(",
")",
";",
"String",
"oldValueString",
"=",
"createLoggingString",
"(",
"oldValue",
")",
";",
"Object",
"newValue",
"=",
"event",
".",
"getNewValue",
"(",
")",
";",
"String",
"newValueString",
"=",
"createLoggingString",
"(",
"newValue",
")",
";",
"String",
"message",
"=",
"\"Property \"",
"+",
"propertyName",
"+",
"\" changed from \"",
"+",
"oldValueString",
"+",
"\" to \"",
"+",
"newValueString",
"+",
"\" in \"",
"+",
"source",
";",
"consumer",
".",
"accept",
"(",
"message",
")",
";",
"}",
"}",
";",
"addDeepPropertyChangeListener",
"(",
"object",
",",
"propertyChangeListener",
")",
";",
"}"
] |
Attaches a deep property change listener to the given object, that
generates logging information about the property change events,
and passes them to the given consumer.
@param object The object
@param consumer The log message consumer. May not be <code>null</code>.
|
[
"Attaches",
"a",
"deep",
"property",
"change",
"listener",
"to",
"the",
"given",
"object",
"that",
"generates",
"logging",
"information",
"about",
"the",
"property",
"change",
"events",
"and",
"passes",
"them",
"to",
"the",
"given",
"consumer",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/beans/PropertyChangeListeners.java#L96-L119
|
149,453
|
javagl/Common
|
src/main/java/de/javagl/common/beans/PropertyChangeListeners.java
|
PropertyChangeListeners.createLoggingString
|
private static String createLoggingString(Object object)
{
if (object == null)
{
return "null";
}
Class<? extends Object> objectClass = object.getClass();
if (!objectClass.isArray())
{
return String.valueOf(object);
}
StringBuilder sb = new StringBuilder();
int length = Array.getLength(object);
sb.append("[");
for (int i = 0; i < length; i++)
{
if (i > 0)
{
sb.append(", ");
}
Object element = Array.get(object, i);
sb.append(createLoggingString(element));
}
sb.append("]");
return sb.toString();
}
|
java
|
private static String createLoggingString(Object object)
{
if (object == null)
{
return "null";
}
Class<? extends Object> objectClass = object.getClass();
if (!objectClass.isArray())
{
return String.valueOf(object);
}
StringBuilder sb = new StringBuilder();
int length = Array.getLength(object);
sb.append("[");
for (int i = 0; i < length; i++)
{
if (i > 0)
{
sb.append(", ");
}
Object element = Array.get(object, i);
sb.append(createLoggingString(element));
}
sb.append("]");
return sb.toString();
}
|
[
"private",
"static",
"String",
"createLoggingString",
"(",
"Object",
"object",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"return",
"\"null\"",
";",
"}",
"Class",
"<",
"?",
"extends",
"Object",
">",
"objectClass",
"=",
"object",
".",
"getClass",
"(",
")",
";",
"if",
"(",
"!",
"objectClass",
".",
"isArray",
"(",
")",
")",
"{",
"return",
"String",
".",
"valueOf",
"(",
"object",
")",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"int",
"length",
"=",
"Array",
".",
"getLength",
"(",
"object",
")",
";",
"sb",
".",
"append",
"(",
"\"[\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"Object",
"element",
"=",
"Array",
".",
"get",
"(",
"object",
",",
"i",
")",
";",
"sb",
".",
"append",
"(",
"createLoggingString",
"(",
"element",
")",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"]\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Create a string suitable for logging the given object
@param object The object
@return The string
|
[
"Create",
"a",
"string",
"suitable",
"for",
"logging",
"the",
"given",
"object"
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/beans/PropertyChangeListeners.java#L127-L152
|
149,454
|
javagl/Common
|
src/main/java/de/javagl/common/beans/PropertyChangeListeners.java
|
PropertyChangeListeners.removeDeepPropertyChangeListener
|
public static void removeDeepPropertyChangeListener(
Object object, PropertyChangeListener propertyChangeListener)
{
Objects.requireNonNull(object, "The object may not be null");
Objects.requireNonNull(propertyChangeListener,
"The propertyChangeListener may not be null");
removeRecursive(object, propertyChangeListener);
}
|
java
|
public static void removeDeepPropertyChangeListener(
Object object, PropertyChangeListener propertyChangeListener)
{
Objects.requireNonNull(object, "The object may not be null");
Objects.requireNonNull(propertyChangeListener,
"The propertyChangeListener may not be null");
removeRecursive(object, propertyChangeListener);
}
|
[
"public",
"static",
"void",
"removeDeepPropertyChangeListener",
"(",
"Object",
"object",
",",
"PropertyChangeListener",
"propertyChangeListener",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"object",
",",
"\"The object may not be null\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"propertyChangeListener",
",",
"\"The propertyChangeListener may not be null\"",
")",
";",
"removeRecursive",
"(",
"object",
",",
"propertyChangeListener",
")",
";",
"}"
] |
Remove the given property change listener from the given object
and all its sub-objects.
@param object The object
@param propertyChangeListener The property change listener
|
[
"Remove",
"the",
"given",
"property",
"change",
"listener",
"from",
"the",
"given",
"object",
"and",
"all",
"its",
"sub",
"-",
"objects",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/beans/PropertyChangeListeners.java#L273-L280
|
149,455
|
javagl/Common
|
src/main/java/de/javagl/common/beans/PropertyChangeListeners.java
|
PropertyChangeListeners.removeRecursive
|
private static void removeRecursive(
Object object, PropertyChangeListener propertyChangeListener)
{
removeRecursive(object, propertyChangeListener,
new LinkedHashSet<Object>());
}
|
java
|
private static void removeRecursive(
Object object, PropertyChangeListener propertyChangeListener)
{
removeRecursive(object, propertyChangeListener,
new LinkedHashSet<Object>());
}
|
[
"private",
"static",
"void",
"removeRecursive",
"(",
"Object",
"object",
",",
"PropertyChangeListener",
"propertyChangeListener",
")",
"{",
"removeRecursive",
"(",
"object",
",",
"propertyChangeListener",
",",
"new",
"LinkedHashSet",
"<",
"Object",
">",
"(",
")",
")",
";",
"}"
] |
Recursively remove the given property change listener from the given
object and all its sub-objects
@param object The object
@param propertyChangeListener The property change listener
|
[
"Recursively",
"remove",
"the",
"given",
"property",
"change",
"listener",
"from",
"the",
"given",
"object",
"and",
"all",
"its",
"sub",
"-",
"objects"
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/beans/PropertyChangeListeners.java#L350-L355
|
149,456
|
greese/dasein-util
|
src/main/java/org/dasein/util/Translator.java
|
Translator.copy
|
public Translator<T> copy() {
Translator<T> trans = new Translator<T>();
if( isBundleBased() ) {
for( Translation<T> t : values() ) {
Locale loc = t.getLocale();
trans.store(loc, t.getData());
}
}
else {
for( String lang : translations.keySet() ) {
Map<String,Translation<T>> map = translations.get(lang);
for( String ctry : map.keySet() ) {
trans.store(lang, ctry, map.get(ctry));
}
}
}
return trans;
}
|
java
|
public Translator<T> copy() {
Translator<T> trans = new Translator<T>();
if( isBundleBased() ) {
for( Translation<T> t : values() ) {
Locale loc = t.getLocale();
trans.store(loc, t.getData());
}
}
else {
for( String lang : translations.keySet() ) {
Map<String,Translation<T>> map = translations.get(lang);
for( String ctry : map.keySet() ) {
trans.store(lang, ctry, map.get(ctry));
}
}
}
return trans;
}
|
[
"public",
"Translator",
"<",
"T",
">",
"copy",
"(",
")",
"{",
"Translator",
"<",
"T",
">",
"trans",
"=",
"new",
"Translator",
"<",
"T",
">",
"(",
")",
";",
"if",
"(",
"isBundleBased",
"(",
")",
")",
"{",
"for",
"(",
"Translation",
"<",
"T",
">",
"t",
":",
"values",
"(",
")",
")",
"{",
"Locale",
"loc",
"=",
"t",
".",
"getLocale",
"(",
")",
";",
"trans",
".",
"store",
"(",
"loc",
",",
"t",
".",
"getData",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"for",
"(",
"String",
"lang",
":",
"translations",
".",
"keySet",
"(",
")",
")",
"{",
"Map",
"<",
"String",
",",
"Translation",
"<",
"T",
">",
">",
"map",
"=",
"translations",
".",
"get",
"(",
"lang",
")",
";",
"for",
"(",
"String",
"ctry",
":",
"map",
".",
"keySet",
"(",
")",
")",
"{",
"trans",
".",
"store",
"(",
"lang",
",",
"ctry",
",",
"map",
".",
"get",
"(",
"ctry",
")",
")",
";",
"}",
"}",
"}",
"return",
"trans",
";",
"}"
] |
Copies the current translator into a new translator object. Even if this translator is resource bundle based,
the copy will not be.
@return a copy of the current translator
|
[
"Copies",
"the",
"current",
"translator",
"into",
"a",
"new",
"translator",
"object",
".",
"Even",
"if",
"this",
"translator",
"is",
"resource",
"bundle",
"based",
"the",
"copy",
"will",
"not",
"be",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/Translator.java#L198-L218
|
149,457
|
ahome-it/lienzo-charts
|
src/main/java/com/ait/lienzo/charts/client/core/xy/label/XYChartLabelFormatter.java
|
XYChartLabelFormatter.cut
|
private void cut(XYChartLabel label, double maxWidth, double maxHeight, double rotation)
{
String text = label.getLabel().getText();
// Cut text.
cutLabelText(label, maxWidth - 5, maxHeight - 5, rotation);
String cutText = label.getLabel().getText();
// If text is cut, add suffix characters.
if (text.length() != cutText.length())
{
label.getLabel().setText(label.getLabel().getText() + "...");
}
// TODO: Animate.
// animate(label, text, cutText, originalRotation);
// Move label to top.
label.getLabelContainer().moveToTop();
}
|
java
|
private void cut(XYChartLabel label, double maxWidth, double maxHeight, double rotation)
{
String text = label.getLabel().getText();
// Cut text.
cutLabelText(label, maxWidth - 5, maxHeight - 5, rotation);
String cutText = label.getLabel().getText();
// If text is cut, add suffix characters.
if (text.length() != cutText.length())
{
label.getLabel().setText(label.getLabel().getText() + "...");
}
// TODO: Animate.
// animate(label, text, cutText, originalRotation);
// Move label to top.
label.getLabelContainer().moveToTop();
}
|
[
"private",
"void",
"cut",
"(",
"XYChartLabel",
"label",
",",
"double",
"maxWidth",
",",
"double",
"maxHeight",
",",
"double",
"rotation",
")",
"{",
"String",
"text",
"=",
"label",
".",
"getLabel",
"(",
")",
".",
"getText",
"(",
")",
";",
"// Cut text.",
"cutLabelText",
"(",
"label",
",",
"maxWidth",
"-",
"5",
",",
"maxHeight",
"-",
"5",
",",
"rotation",
")",
";",
"String",
"cutText",
"=",
"label",
".",
"getLabel",
"(",
")",
".",
"getText",
"(",
")",
";",
"// If text is cut, add suffix characters.",
"if",
"(",
"text",
".",
"length",
"(",
")",
"!=",
"cutText",
".",
"length",
"(",
")",
")",
"{",
"label",
".",
"getLabel",
"(",
")",
".",
"setText",
"(",
"label",
".",
"getLabel",
"(",
")",
".",
"getText",
"(",
")",
"+",
"\"...\"",
")",
";",
"}",
"// TODO: Animate.",
"// animate(label, text, cutText, originalRotation);",
"// Move label to top.",
"label",
".",
"getLabelContainer",
"(",
")",
".",
"moveToTop",
"(",
")",
";",
"}"
] |
Formats the label Text shapes in the given axis by cutting text value.
|
[
"Formats",
"the",
"label",
"Text",
"shapes",
"in",
"the",
"given",
"axis",
"by",
"cutting",
"text",
"value",
"."
] |
4237150a5758265eb19ce5b45e50b54fe0168616
|
https://github.com/ahome-it/lienzo-charts/blob/4237150a5758265eb19ce5b45e50b54fe0168616/src/main/java/com/ait/lienzo/charts/client/core/xy/label/XYChartLabelFormatter.java#L84-L103
|
149,458
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/profiler/ProfilerFactory.java
|
ProfilerFactory.newInstance
|
public static Object newInstance(Object obj) {
if (MjdbcLogger.isSLF4jAvailable() == true && MjdbcLogger.isSLF4jImplementationAvailable() == false) {
// Logging depends on slf4j. If it haven't found any logging system
// connected - it is turned off.
// In such case there is no need to output profiling information as
// it won't be printed out.
return obj;
} else {
if (MjdbcConfig.isProfilerEnabled() == true) {
return java.lang.reflect.Proxy.newProxyInstance(obj.getClass().getClassLoader(), obj.getClass().getInterfaces(),
new BaseInvocationHandler(obj, MjdbcConfig.getProfilerOutputFormat()));
} else {
return obj;
}
}
}
|
java
|
public static Object newInstance(Object obj) {
if (MjdbcLogger.isSLF4jAvailable() == true && MjdbcLogger.isSLF4jImplementationAvailable() == false) {
// Logging depends on slf4j. If it haven't found any logging system
// connected - it is turned off.
// In such case there is no need to output profiling information as
// it won't be printed out.
return obj;
} else {
if (MjdbcConfig.isProfilerEnabled() == true) {
return java.lang.reflect.Proxy.newProxyInstance(obj.getClass().getClassLoader(), obj.getClass().getInterfaces(),
new BaseInvocationHandler(obj, MjdbcConfig.getProfilerOutputFormat()));
} else {
return obj;
}
}
}
|
[
"public",
"static",
"Object",
"newInstance",
"(",
"Object",
"obj",
")",
"{",
"if",
"(",
"MjdbcLogger",
".",
"isSLF4jAvailable",
"(",
")",
"==",
"true",
"&&",
"MjdbcLogger",
".",
"isSLF4jImplementationAvailable",
"(",
")",
"==",
"false",
")",
"{",
"// Logging depends on slf4j. If it haven't found any logging system",
"// connected - it is turned off.",
"// In such case there is no need to output profiling information as",
"// it won't be printed out.",
"return",
"obj",
";",
"}",
"else",
"{",
"if",
"(",
"MjdbcConfig",
".",
"isProfilerEnabled",
"(",
")",
"==",
"true",
")",
"{",
"return",
"java",
".",
"lang",
".",
"reflect",
".",
"Proxy",
".",
"newProxyInstance",
"(",
"obj",
".",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
",",
"obj",
".",
"getClass",
"(",
")",
".",
"getInterfaces",
"(",
")",
",",
"new",
"BaseInvocationHandler",
"(",
"obj",
",",
"MjdbcConfig",
".",
"getProfilerOutputFormat",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"obj",
";",
"}",
"}",
"}"
] |
Function wraps Object into Profiling Java Proxy.
Used to wrap QueryRunner instance with Java Proxy
@param obj Object which would be wrapped into Profiling Proxy
@return Java Proxy with wrapped input object
|
[
"Function",
"wraps",
"Object",
"into",
"Profiling",
"Java",
"Proxy",
".",
"Used",
"to",
"wrap",
"QueryRunner",
"instance",
"with",
"Java",
"Proxy"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/profiler/ProfilerFactory.java#L36-L52
|
149,459
|
Viascom/groundwork
|
foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/FoxHttpRequest.java
|
FoxHttpRequest.execute
|
public FoxHttpResponse execute(FoxHttpClient foxHttpClient) throws FoxHttpException {
verifyRequest();
foxHttpClient.getFoxHttpLogger().log("========= Request =========");
foxHttpClient.getFoxHttpLogger().log("setFoxHttpClient(" + foxHttpClient + ")");
this.foxHttpClient = foxHttpClient;
return executeHttp("https".equals(url.getProtocol()));
}
|
java
|
public FoxHttpResponse execute(FoxHttpClient foxHttpClient) throws FoxHttpException {
verifyRequest();
foxHttpClient.getFoxHttpLogger().log("========= Request =========");
foxHttpClient.getFoxHttpLogger().log("setFoxHttpClient(" + foxHttpClient + ")");
this.foxHttpClient = foxHttpClient;
return executeHttp("https".equals(url.getProtocol()));
}
|
[
"public",
"FoxHttpResponse",
"execute",
"(",
"FoxHttpClient",
"foxHttpClient",
")",
"throws",
"FoxHttpException",
"{",
"verifyRequest",
"(",
")",
";",
"foxHttpClient",
".",
"getFoxHttpLogger",
"(",
")",
".",
"log",
"(",
"\"========= Request =========\"",
")",
";",
"foxHttpClient",
".",
"getFoxHttpLogger",
"(",
")",
".",
"log",
"(",
"\"setFoxHttpClient(\"",
"+",
"foxHttpClient",
"+",
"\")\"",
")",
";",
"this",
".",
"foxHttpClient",
"=",
"foxHttpClient",
";",
"return",
"executeHttp",
"(",
"\"https\"",
".",
"equals",
"(",
"url",
".",
"getProtocol",
"(",
")",
")",
")",
";",
"}"
] |
Execute a this request
@param foxHttpClient a specific client which will be used for this request
@return Response if this request
@throws FoxHttpException
|
[
"Execute",
"a",
"this",
"request"
] |
d3f7d0df65e2e75861fc7db938090683f2cdf919
|
https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/FoxHttpRequest.java#L114-L121
|
149,460
|
lightblueseas/wicket-js-addons
|
wicket-toastr/src/main/java/de/alpharogroup/wicket/js/addon/toastr/ToastJsGenerator.java
|
ToastJsGenerator.getCommand
|
public String getCommand(final ToastrSettings settings)
{
final StringBuilder sb = new StringBuilder();
sb.append("toastr.");
sb.append(settings.getToastrType().getValue().getValue());
sb.append("('");
sb.append(settings.getNotificationContent().getValue());
sb.append("'");
if (StringUtils.isNotEmpty(settings.getNotificationTitle().getValue()))
{
sb.append(", '");
sb.append(settings.getNotificationTitle().getValue());
sb.append("'");
}
sb.append(")");
return sb.toString();
}
|
java
|
public String getCommand(final ToastrSettings settings)
{
final StringBuilder sb = new StringBuilder();
sb.append("toastr.");
sb.append(settings.getToastrType().getValue().getValue());
sb.append("('");
sb.append(settings.getNotificationContent().getValue());
sb.append("'");
if (StringUtils.isNotEmpty(settings.getNotificationTitle().getValue()))
{
sb.append(", '");
sb.append(settings.getNotificationTitle().getValue());
sb.append("'");
}
sb.append(")");
return sb.toString();
}
|
[
"public",
"String",
"getCommand",
"(",
"final",
"ToastrSettings",
"settings",
")",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"toastr.\"",
")",
";",
"sb",
".",
"append",
"(",
"settings",
".",
"getToastrType",
"(",
")",
".",
"getValue",
"(",
")",
".",
"getValue",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"('\"",
")",
";",
"sb",
".",
"append",
"(",
"settings",
".",
"getNotificationContent",
"(",
")",
".",
"getValue",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"'\"",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"settings",
".",
"getNotificationTitle",
"(",
")",
".",
"getValue",
"(",
")",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\", '\"",
")",
";",
"sb",
".",
"append",
"(",
"settings",
".",
"getNotificationTitle",
"(",
")",
".",
"getValue",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"'\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\")\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Gets the command.
@param settings
the toastrSettings
@return the command
|
[
"Gets",
"the",
"command",
"."
] |
b1c88c1abafd1e965f2e32ef13d66be0b28d76f6
|
https://github.com/lightblueseas/wicket-js-addons/blob/b1c88c1abafd1e965f2e32ef13d66be0b28d76f6/wicket-toastr/src/main/java/de/alpharogroup/wicket/js/addon/toastr/ToastJsGenerator.java#L131-L147
|
149,461
|
RogerParkinson/madura-workflows
|
madura-workflow-vaadin/src/main/java/nz/co/senanque/workflowui/conf/QueueProcessManager.java
|
QueueProcessManager.getVisibleQueues
|
public Set<String> getVisibleQueues(PermissionManager permissionManager) {
Set<String> ret = new HashSet<String>();
for (QueueDefinition queueDefinition: m_queues) {
if (permissionManager.hasPermission(FixedPermissions.ADMIN)) {
ret.add(queueDefinition.getName());
continue;
}
if (!ret.contains(queueDefinition.getName())) {
if (permissionManager.hasPermission(queueDefinition.getPermission()) ||
permissionManager.hasPermission(queueDefinition.getReadPermission())) {
ret.add(queueDefinition.getName());
}
}
}
return ret;
}
|
java
|
public Set<String> getVisibleQueues(PermissionManager permissionManager) {
Set<String> ret = new HashSet<String>();
for (QueueDefinition queueDefinition: m_queues) {
if (permissionManager.hasPermission(FixedPermissions.ADMIN)) {
ret.add(queueDefinition.getName());
continue;
}
if (!ret.contains(queueDefinition.getName())) {
if (permissionManager.hasPermission(queueDefinition.getPermission()) ||
permissionManager.hasPermission(queueDefinition.getReadPermission())) {
ret.add(queueDefinition.getName());
}
}
}
return ret;
}
|
[
"public",
"Set",
"<",
"String",
">",
"getVisibleQueues",
"(",
"PermissionManager",
"permissionManager",
")",
"{",
"Set",
"<",
"String",
">",
"ret",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"QueueDefinition",
"queueDefinition",
":",
"m_queues",
")",
"{",
"if",
"(",
"permissionManager",
".",
"hasPermission",
"(",
"FixedPermissions",
".",
"ADMIN",
")",
")",
"{",
"ret",
".",
"add",
"(",
"queueDefinition",
".",
"getName",
"(",
")",
")",
";",
"continue",
";",
"}",
"if",
"(",
"!",
"ret",
".",
"contains",
"(",
"queueDefinition",
".",
"getName",
"(",
")",
")",
")",
"{",
"if",
"(",
"permissionManager",
".",
"hasPermission",
"(",
"queueDefinition",
".",
"getPermission",
"(",
")",
")",
"||",
"permissionManager",
".",
"hasPermission",
"(",
"queueDefinition",
".",
"getReadPermission",
"(",
")",
")",
")",
"{",
"ret",
".",
"add",
"(",
"queueDefinition",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"ret",
";",
"}"
] |
Get the list of queues visible to this user ie to the user with the permissions
defined in the given permissions manager. ADMIN permission means all are visible.
@param permissionManager
@return list of queue names.
|
[
"Get",
"the",
"list",
"of",
"queues",
"visible",
"to",
"this",
"user",
"ie",
"to",
"the",
"user",
"with",
"the",
"permissions",
"defined",
"in",
"the",
"given",
"permissions",
"manager",
".",
"ADMIN",
"permission",
"means",
"all",
"are",
"visible",
"."
] |
3d26c322fc85a006ff0d0cbebacbc453aed8e492
|
https://github.com/RogerParkinson/madura-workflows/blob/3d26c322fc85a006ff0d0cbebacbc453aed8e492/madura-workflow-vaadin/src/main/java/nz/co/senanque/workflowui/conf/QueueProcessManager.java#L70-L85
|
149,462
|
RogerParkinson/madura-workflows
|
madura-workflow-vaadin/src/main/java/nz/co/senanque/workflowui/conf/QueueProcessManager.java
|
QueueProcessManager.getQueueFilter
|
public Filter getQueueFilter(PermissionManager permissionManager) {
if (permissionManager.hasPermission(FixedPermissions.TECHSUPPORT) || permissionManager.hasPermission(FixedPermissions.ADMIN)) {
return null;
}
Set<String> visibleQueues = getVisibleQueues(permissionManager);
Filter filters[] = new Filter[visibleQueues.size()];
int i=0;
for (String queueName: visibleQueues) {
filters[i++] = new Compare.Equal("queueName", queueName);
}
Filter statusFilter[] = new Filter[2];
statusFilter[0] = new Or(filters);
statusFilter[1] = new Compare.Equal("status", TaskStatus.WAIT);
Filter userFilter[] = new Filter[2];
userFilter[0] = new Compare.Equal("lockedBy",permissionManager.getCurrentUser());
userFilter[1] = new Compare.Equal("status", TaskStatus.BUSY);
return new Or(new And(statusFilter),new And(userFilter));
}
|
java
|
public Filter getQueueFilter(PermissionManager permissionManager) {
if (permissionManager.hasPermission(FixedPermissions.TECHSUPPORT) || permissionManager.hasPermission(FixedPermissions.ADMIN)) {
return null;
}
Set<String> visibleQueues = getVisibleQueues(permissionManager);
Filter filters[] = new Filter[visibleQueues.size()];
int i=0;
for (String queueName: visibleQueues) {
filters[i++] = new Compare.Equal("queueName", queueName);
}
Filter statusFilter[] = new Filter[2];
statusFilter[0] = new Or(filters);
statusFilter[1] = new Compare.Equal("status", TaskStatus.WAIT);
Filter userFilter[] = new Filter[2];
userFilter[0] = new Compare.Equal("lockedBy",permissionManager.getCurrentUser());
userFilter[1] = new Compare.Equal("status", TaskStatus.BUSY);
return new Or(new And(statusFilter),new And(userFilter));
}
|
[
"public",
"Filter",
"getQueueFilter",
"(",
"PermissionManager",
"permissionManager",
")",
"{",
"if",
"(",
"permissionManager",
".",
"hasPermission",
"(",
"FixedPermissions",
".",
"TECHSUPPORT",
")",
"||",
"permissionManager",
".",
"hasPermission",
"(",
"FixedPermissions",
".",
"ADMIN",
")",
")",
"{",
"return",
"null",
";",
"}",
"Set",
"<",
"String",
">",
"visibleQueues",
"=",
"getVisibleQueues",
"(",
"permissionManager",
")",
";",
"Filter",
"filters",
"[",
"]",
"=",
"new",
"Filter",
"[",
"visibleQueues",
".",
"size",
"(",
")",
"]",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"String",
"queueName",
":",
"visibleQueues",
")",
"{",
"filters",
"[",
"i",
"++",
"]",
"=",
"new",
"Compare",
".",
"Equal",
"(",
"\"queueName\"",
",",
"queueName",
")",
";",
"}",
"Filter",
"statusFilter",
"[",
"]",
"=",
"new",
"Filter",
"[",
"2",
"]",
";",
"statusFilter",
"[",
"0",
"]",
"=",
"new",
"Or",
"(",
"filters",
")",
";",
"statusFilter",
"[",
"1",
"]",
"=",
"new",
"Compare",
".",
"Equal",
"(",
"\"status\"",
",",
"TaskStatus",
".",
"WAIT",
")",
";",
"Filter",
"userFilter",
"[",
"]",
"=",
"new",
"Filter",
"[",
"2",
"]",
";",
"userFilter",
"[",
"0",
"]",
"=",
"new",
"Compare",
".",
"Equal",
"(",
"\"lockedBy\"",
",",
"permissionManager",
".",
"getCurrentUser",
"(",
")",
")",
";",
"userFilter",
"[",
"1",
"]",
"=",
"new",
"Compare",
".",
"Equal",
"(",
"\"status\"",
",",
"TaskStatus",
".",
"BUSY",
")",
";",
"return",
"new",
"Or",
"(",
"new",
"And",
"(",
"statusFilter",
")",
",",
"new",
"And",
"(",
"userFilter",
")",
")",
";",
"}"
] |
If we have the TECHSUPPORT or ADMIN permission then return null. Those users can see everything so no filter required.
For the rest we only display queues they have permission to see and only processes in WAIT status.
@param permissionManager
@return filter
|
[
"If",
"we",
"have",
"the",
"TECHSUPPORT",
"or",
"ADMIN",
"permission",
"then",
"return",
"null",
".",
"Those",
"users",
"can",
"see",
"everything",
"so",
"no",
"filter",
"required",
".",
"For",
"the",
"rest",
"we",
"only",
"display",
"queues",
"they",
"have",
"permission",
"to",
"see",
"and",
"only",
"processes",
"in",
"WAIT",
"status",
"."
] |
3d26c322fc85a006ff0d0cbebacbc453aed8e492
|
https://github.com/RogerParkinson/madura-workflows/blob/3d26c322fc85a006ff0d0cbebacbc453aed8e492/madura-workflow-vaadin/src/main/java/nz/co/senanque/workflowui/conf/QueueProcessManager.java#L114-L133
|
149,463
|
RogerParkinson/madura-workflows
|
madura-workflow-vaadin/src/main/java/nz/co/senanque/workflowui/conf/QueueProcessManager.java
|
QueueProcessManager.getVisibleProcesses
|
public Set<ProcessDefinition> getVisibleProcesses(PermissionManager permissionManager) {
Set<ProcessDefinition> ret = new HashSet<>();
Set<String> queues = getWriteableQueues(permissionManager);
String lastProcessName = "";
for (ProcessDefinition processDefinition: m_processes) {
String processName = processDefinition.getName();
if (!processName.equals(lastProcessName)) {
String queueName = processDefinition.getQueueName();
if (StringUtils.hasText(queueName)) {
if (queues.contains(queueName)) {
ret.add(processDefinition);
}
} else {
ret.add(processDefinition);
}
lastProcessName = processName;
}
}
return ret;
}
|
java
|
public Set<ProcessDefinition> getVisibleProcesses(PermissionManager permissionManager) {
Set<ProcessDefinition> ret = new HashSet<>();
Set<String> queues = getWriteableQueues(permissionManager);
String lastProcessName = "";
for (ProcessDefinition processDefinition: m_processes) {
String processName = processDefinition.getName();
if (!processName.equals(lastProcessName)) {
String queueName = processDefinition.getQueueName();
if (StringUtils.hasText(queueName)) {
if (queues.contains(queueName)) {
ret.add(processDefinition);
}
} else {
ret.add(processDefinition);
}
lastProcessName = processName;
}
}
return ret;
}
|
[
"public",
"Set",
"<",
"ProcessDefinition",
">",
"getVisibleProcesses",
"(",
"PermissionManager",
"permissionManager",
")",
"{",
"Set",
"<",
"ProcessDefinition",
">",
"ret",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"Set",
"<",
"String",
">",
"queues",
"=",
"getWriteableQueues",
"(",
"permissionManager",
")",
";",
"String",
"lastProcessName",
"=",
"\"\"",
";",
"for",
"(",
"ProcessDefinition",
"processDefinition",
":",
"m_processes",
")",
"{",
"String",
"processName",
"=",
"processDefinition",
".",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"processName",
".",
"equals",
"(",
"lastProcessName",
")",
")",
"{",
"String",
"queueName",
"=",
"processDefinition",
".",
"getQueueName",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"hasText",
"(",
"queueName",
")",
")",
"{",
"if",
"(",
"queues",
".",
"contains",
"(",
"queueName",
")",
")",
"{",
"ret",
".",
"add",
"(",
"processDefinition",
")",
";",
"}",
"}",
"else",
"{",
"ret",
".",
"add",
"(",
"processDefinition",
")",
";",
"}",
"lastProcessName",
"=",
"processName",
";",
"}",
"}",
"return",
"ret",
";",
"}"
] |
Get the list of queues visible to this user ie to the user with the permissions
defined in the given permissions manager,
@param permissionManager
@return
|
[
"Get",
"the",
"list",
"of",
"queues",
"visible",
"to",
"this",
"user",
"ie",
"to",
"the",
"user",
"with",
"the",
"permissions",
"defined",
"in",
"the",
"given",
"permissions",
"manager"
] |
3d26c322fc85a006ff0d0cbebacbc453aed8e492
|
https://github.com/RogerParkinson/madura-workflows/blob/3d26c322fc85a006ff0d0cbebacbc453aed8e492/madura-workflow-vaadin/src/main/java/nz/co/senanque/workflowui/conf/QueueProcessManager.java#L141-L160
|
149,464
|
greese/dasein-util
|
src/main/java/org/dasein/attributes/types/BooleanFactory.java
|
BooleanFactory.getType
|
public DataType<Boolean> getType(String grp, Number idx, boolean ml, boolean mv, boolean req, String... params) {
return new BooleanAttribute(grp, idx, ml, mv, req);
}
|
java
|
public DataType<Boolean> getType(String grp, Number idx, boolean ml, boolean mv, boolean req, String... params) {
return new BooleanAttribute(grp, idx, ml, mv, req);
}
|
[
"public",
"DataType",
"<",
"Boolean",
">",
"getType",
"(",
"String",
"grp",
",",
"Number",
"idx",
",",
"boolean",
"ml",
",",
"boolean",
"mv",
",",
"boolean",
"req",
",",
"String",
"...",
"params",
")",
"{",
"return",
"new",
"BooleanAttribute",
"(",
"grp",
",",
"idx",
",",
"ml",
",",
"mv",
",",
"req",
")",
";",
"}"
] |
Technically, you can have a multi-lingual or multi-valued boolean, but why would you?
@param ml true if the boolean is multi-lingual
@param mv true if the boolean can support multiple values
@param req true if the boolean is required
@param params unused
@return a boolean instance
|
[
"Technically",
"you",
"can",
"have",
"a",
"multi",
"-",
"lingual",
"or",
"multi",
"-",
"valued",
"boolean",
"but",
"why",
"would",
"you?"
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/attributes/types/BooleanFactory.java#L94-L96
|
149,465
|
workplacesystems/queuj
|
src/main/java/com/workplacesystems/queuj/utils/BackgroundProcess.java
|
BackgroundProcess.joinThread
|
public void joinThread(long timeout)
{
// take local ref copy, so can reliably check if ref is null,
Thread local_thread_ref = thread;
if (local_thread_ref != null)
{
try
{
long millis = 0l;
if (log.isDebugEnabled())
{
log.debug("BackgroundProcess.joinThread() Waiting " + timeout + " millis for " + this + " to finish");
millis = System.currentTimeMillis();
}
if (thread_pool != null)
{
synchronized (pool_mutex)
{
pool_mutex.wait(timeout);
}
}
else
local_thread_ref.join(timeout);
if (log.isDebugEnabled())
{
millis = System.currentTimeMillis() - millis;
log.debug("BackgroundProcess.joinThread() Process " + this + " finished in " + millis + " millis");
}
}
catch (InterruptedException e)
{
if (log.isDebugEnabled())
log.debug("BackgroundProcess.joinThread() Timed out waiting " + timeout + " millis for " + this + " to finish");
}
}
else
{
if (log.isDebugEnabled())
log.debug("BackgroundProcess.joinThread() " + name + " was not running, thread was null");
}
}
|
java
|
public void joinThread(long timeout)
{
// take local ref copy, so can reliably check if ref is null,
Thread local_thread_ref = thread;
if (local_thread_ref != null)
{
try
{
long millis = 0l;
if (log.isDebugEnabled())
{
log.debug("BackgroundProcess.joinThread() Waiting " + timeout + " millis for " + this + " to finish");
millis = System.currentTimeMillis();
}
if (thread_pool != null)
{
synchronized (pool_mutex)
{
pool_mutex.wait(timeout);
}
}
else
local_thread_ref.join(timeout);
if (log.isDebugEnabled())
{
millis = System.currentTimeMillis() - millis;
log.debug("BackgroundProcess.joinThread() Process " + this + " finished in " + millis + " millis");
}
}
catch (InterruptedException e)
{
if (log.isDebugEnabled())
log.debug("BackgroundProcess.joinThread() Timed out waiting " + timeout + " millis for " + this + " to finish");
}
}
else
{
if (log.isDebugEnabled())
log.debug("BackgroundProcess.joinThread() " + name + " was not running, thread was null");
}
}
|
[
"public",
"void",
"joinThread",
"(",
"long",
"timeout",
")",
"{",
"// take local ref copy, so can reliably check if ref is null,\r",
"Thread",
"local_thread_ref",
"=",
"thread",
";",
"if",
"(",
"local_thread_ref",
"!=",
"null",
")",
"{",
"try",
"{",
"long",
"millis",
"=",
"0l",
";",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"BackgroundProcess.joinThread() Waiting \"",
"+",
"timeout",
"+",
"\" millis for \"",
"+",
"this",
"+",
"\" to finish\"",
")",
";",
"millis",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"}",
"if",
"(",
"thread_pool",
"!=",
"null",
")",
"{",
"synchronized",
"(",
"pool_mutex",
")",
"{",
"pool_mutex",
".",
"wait",
"(",
"timeout",
")",
";",
"}",
"}",
"else",
"local_thread_ref",
".",
"join",
"(",
"timeout",
")",
";",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"millis",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"millis",
";",
"log",
".",
"debug",
"(",
"\"BackgroundProcess.joinThread() Process \"",
"+",
"this",
"+",
"\" finished in \"",
"+",
"millis",
"+",
"\" millis\"",
")",
";",
"}",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"log",
".",
"debug",
"(",
"\"BackgroundProcess.joinThread() Timed out waiting \"",
"+",
"timeout",
"+",
"\" millis for \"",
"+",
"this",
"+",
"\" to finish\"",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"log",
".",
"debug",
"(",
"\"BackgroundProcess.joinThread() \"",
"+",
"name",
"+",
"\" was not running, thread was null\"",
")",
";",
"}",
"}"
] |
Inactivively waits for the process to finish or until timeout occurs,
whichever is earlier. If the process was not running, returns immediatelly.
@param timeout
|
[
"Inactivively",
"waits",
"for",
"the",
"process",
"to",
"finish",
"or",
"until",
"timeout",
"occurs",
"whichever",
"is",
"earlier",
".",
"If",
"the",
"process",
"was",
"not",
"running",
"returns",
"immediatelly",
"."
] |
4293116b412b4a20ead99963b9b05a135812c501
|
https://github.com/workplacesystems/queuj/blob/4293116b412b4a20ead99963b9b05a135812c501/src/main/java/com/workplacesystems/queuj/utils/BackgroundProcess.java#L248-L289
|
149,466
|
Viascom/groundwork
|
foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/header/FoxHttpHeader.java
|
FoxHttpHeader.addHeader
|
public void addHeader(Map<String, String> entries) {
for (Map.Entry<String, String> entry : entries.entrySet()) {
headerEntries.add(new HeaderEntry(entry.getKey(), entry.getValue()));
}
}
|
java
|
public void addHeader(Map<String, String> entries) {
for (Map.Entry<String, String> entry : entries.entrySet()) {
headerEntries.add(new HeaderEntry(entry.getKey(), entry.getValue()));
}
}
|
[
"public",
"void",
"addHeader",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"entries",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"entries",
".",
"entrySet",
"(",
")",
")",
"{",
"headerEntries",
".",
"add",
"(",
"new",
"HeaderEntry",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Add a new map of header entries
@param entries map of header entries
|
[
"Add",
"a",
"new",
"map",
"of",
"header",
"entries"
] |
d3f7d0df65e2e75861fc7db938090683f2cdf919
|
https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/header/FoxHttpHeader.java#L51-L55
|
149,467
|
Viascom/groundwork
|
foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/header/FoxHttpHeader.java
|
FoxHttpHeader.getHeader
|
public HeaderEntry getHeader(String name) {
for (HeaderEntry headerField : getHeaderEntries()) {
if (headerField.getName().equals(name)) {
return headerField;
}
}
return null;
}
|
java
|
public HeaderEntry getHeader(String name) {
for (HeaderEntry headerField : getHeaderEntries()) {
if (headerField.getName().equals(name)) {
return headerField;
}
}
return null;
}
|
[
"public",
"HeaderEntry",
"getHeader",
"(",
"String",
"name",
")",
"{",
"for",
"(",
"HeaderEntry",
"headerField",
":",
"getHeaderEntries",
"(",
")",
")",
"{",
"if",
"(",
"headerField",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
")",
"{",
"return",
"headerField",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get a specific header based on its name
@param name name of the header
@return a specific header
|
[
"Get",
"a",
"specific",
"header",
"based",
"on",
"its",
"name"
] |
d3f7d0df65e2e75861fc7db938090683f2cdf919
|
https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/header/FoxHttpHeader.java#L72-L79
|
149,468
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java
|
MappingUtils.propertyDescriptors
|
public static PropertyDescriptor[] propertyDescriptors(Class<?> clazz) {
BeanInfo beanInfo = null;
try {
beanInfo = Introspector.getBeanInfo(clazz);
} catch (IntrospectionException ex) {
throw new IllegalArgumentException(
"Bean introspection failed: " + ex.getMessage());
}
return beanInfo.getPropertyDescriptors();
}
|
java
|
public static PropertyDescriptor[] propertyDescriptors(Class<?> clazz) {
BeanInfo beanInfo = null;
try {
beanInfo = Introspector.getBeanInfo(clazz);
} catch (IntrospectionException ex) {
throw new IllegalArgumentException(
"Bean introspection failed: " + ex.getMessage());
}
return beanInfo.getPropertyDescriptors();
}
|
[
"public",
"static",
"PropertyDescriptor",
"[",
"]",
"propertyDescriptors",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"BeanInfo",
"beanInfo",
"=",
"null",
";",
"try",
"{",
"beanInfo",
"=",
"Introspector",
".",
"getBeanInfo",
"(",
"clazz",
")",
";",
"}",
"catch",
"(",
"IntrospectionException",
"ex",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Bean introspection failed: \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"beanInfo",
".",
"getPropertyDescriptors",
"(",
")",
";",
"}"
] |
Reads property descriptors of class
@param clazz Class for which we are getting property descriptors
@return Array of Class PropertyDescriptors
|
[
"Reads",
"property",
"descriptors",
"of",
"class"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java#L80-L91
|
149,469
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java
|
MappingUtils.mapPropertyDescriptors
|
public static Map<String, PropertyDescriptor> mapPropertyDescriptors(Class<?> clazz) {
PropertyDescriptor[] properties = propertyDescriptors(clazz);
Map<String, PropertyDescriptor> mappedProperties = new HashMap<String, PropertyDescriptor>();
for (PropertyDescriptor property : properties) {
if ("class".equals(property.getName()) == false) {
mappedProperties.put(property.getName(), property);
}
}
return mappedProperties;
}
|
java
|
public static Map<String, PropertyDescriptor> mapPropertyDescriptors(Class<?> clazz) {
PropertyDescriptor[] properties = propertyDescriptors(clazz);
Map<String, PropertyDescriptor> mappedProperties = new HashMap<String, PropertyDescriptor>();
for (PropertyDescriptor property : properties) {
if ("class".equals(property.getName()) == false) {
mappedProperties.put(property.getName(), property);
}
}
return mappedProperties;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"PropertyDescriptor",
">",
"mapPropertyDescriptors",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"PropertyDescriptor",
"[",
"]",
"properties",
"=",
"propertyDescriptors",
"(",
"clazz",
")",
";",
"Map",
"<",
"String",
",",
"PropertyDescriptor",
">",
"mappedProperties",
"=",
"new",
"HashMap",
"<",
"String",
",",
"PropertyDescriptor",
">",
"(",
")",
";",
"for",
"(",
"PropertyDescriptor",
"property",
":",
"properties",
")",
"{",
"if",
"(",
"\"class\"",
".",
"equals",
"(",
"property",
".",
"getName",
"(",
")",
")",
"==",
"false",
")",
"{",
"mappedProperties",
".",
"put",
"(",
"property",
".",
"getName",
"(",
")",
",",
"property",
")",
";",
"}",
"}",
"return",
"mappedProperties",
";",
"}"
] |
Reads property descriptors of class and puts them into Map.
Key for map is read from property descriptor.
@param clazz Class for which Property Descriptors would be read
@return Map of Property Descriptors for specified class
|
[
"Reads",
"property",
"descriptors",
"of",
"class",
"and",
"puts",
"them",
"into",
"Map",
".",
"Key",
"for",
"map",
"is",
"read",
"from",
"property",
"descriptor",
"."
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java#L100-L111
|
149,470
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java
|
MappingUtils.callGetter
|
public static Object callGetter(Object target, PropertyDescriptor prop) {
Object result = null;
Method getter = prop.getReadMethod();
if (getter == null) {
throw new RuntimeException("No read method for bean property "
+ target.getClass() + " " + prop.getName());
}
try {
result = getter.invoke(target, new Object[0]);
} catch (InvocationTargetException e) {
throw new RuntimeException("Couldn't invoke method: " + getter,
e);
} catch (IllegalArgumentException e) {
throw new RuntimeException(
"Couldn't invoke method with 0 arguments: " + getter, e);
} catch (IllegalAccessException e) {
throw new RuntimeException("Couldn't invoke method: " + getter,
e);
}
return result;
}
|
java
|
public static Object callGetter(Object target, PropertyDescriptor prop) {
Object result = null;
Method getter = prop.getReadMethod();
if (getter == null) {
throw new RuntimeException("No read method for bean property "
+ target.getClass() + " " + prop.getName());
}
try {
result = getter.invoke(target, new Object[0]);
} catch (InvocationTargetException e) {
throw new RuntimeException("Couldn't invoke method: " + getter,
e);
} catch (IllegalArgumentException e) {
throw new RuntimeException(
"Couldn't invoke method with 0 arguments: " + getter, e);
} catch (IllegalAccessException e) {
throw new RuntimeException("Couldn't invoke method: " + getter,
e);
}
return result;
}
|
[
"public",
"static",
"Object",
"callGetter",
"(",
"Object",
"target",
",",
"PropertyDescriptor",
"prop",
")",
"{",
"Object",
"result",
"=",
"null",
";",
"Method",
"getter",
"=",
"prop",
".",
"getReadMethod",
"(",
")",
";",
"if",
"(",
"getter",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"No read method for bean property \"",
"+",
"target",
".",
"getClass",
"(",
")",
"+",
"\" \"",
"+",
"prop",
".",
"getName",
"(",
")",
")",
";",
"}",
"try",
"{",
"result",
"=",
"getter",
".",
"invoke",
"(",
"target",
",",
"new",
"Object",
"[",
"0",
"]",
")",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Couldn't invoke method: \"",
"+",
"getter",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Couldn't invoke method with 0 arguments: \"",
"+",
"getter",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Couldn't invoke method: \"",
"+",
"getter",
",",
"e",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Invokes Property Descriptor Getter and returns value returned by that function.
@param target Object Getter of which would be executed
@param prop Property Descriptor which would be used to invoke Getter
@return Value returned from Getter
|
[
"Invokes",
"Property",
"Descriptor",
"Getter",
"and",
"returns",
"value",
"returned",
"by",
"that",
"function",
"."
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java#L120-L143
|
149,471
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java
|
MappingUtils.convertResultSet
|
public static List<QueryParameters> convertResultSet(ResultSet rs) throws SQLException {
List<QueryParameters> result = new ArrayList<QueryParameters>();
String columnName = null;
while (rs.next() == true) {
QueryParameters params = new QueryParameters();
ResultSetMetaData rsmd = rs.getMetaData();
int cols = rsmd.getColumnCount();
for (int i = 1; i <= cols; i++) {
columnName = rsmd.getColumnLabel(i);
if (null == columnName || 0 == columnName.length()) {
columnName = rsmd.getColumnName(i);
}
params.set(columnName, rs.getObject(i));
params.updatePosition(columnName, i - 1);
}
result.add(params);
}
return result;
}
|
java
|
public static List<QueryParameters> convertResultSet(ResultSet rs) throws SQLException {
List<QueryParameters> result = new ArrayList<QueryParameters>();
String columnName = null;
while (rs.next() == true) {
QueryParameters params = new QueryParameters();
ResultSetMetaData rsmd = rs.getMetaData();
int cols = rsmd.getColumnCount();
for (int i = 1; i <= cols; i++) {
columnName = rsmd.getColumnLabel(i);
if (null == columnName || 0 == columnName.length()) {
columnName = rsmd.getColumnName(i);
}
params.set(columnName, rs.getObject(i));
params.updatePosition(columnName, i - 1);
}
result.add(params);
}
return result;
}
|
[
"public",
"static",
"List",
"<",
"QueryParameters",
">",
"convertResultSet",
"(",
"ResultSet",
"rs",
")",
"throws",
"SQLException",
"{",
"List",
"<",
"QueryParameters",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"QueryParameters",
">",
"(",
")",
";",
"String",
"columnName",
"=",
"null",
";",
"while",
"(",
"rs",
".",
"next",
"(",
")",
"==",
"true",
")",
"{",
"QueryParameters",
"params",
"=",
"new",
"QueryParameters",
"(",
")",
";",
"ResultSetMetaData",
"rsmd",
"=",
"rs",
".",
"getMetaData",
"(",
")",
";",
"int",
"cols",
"=",
"rsmd",
".",
"getColumnCount",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"cols",
";",
"i",
"++",
")",
"{",
"columnName",
"=",
"rsmd",
".",
"getColumnLabel",
"(",
"i",
")",
";",
"if",
"(",
"null",
"==",
"columnName",
"||",
"0",
"==",
"columnName",
".",
"length",
"(",
")",
")",
"{",
"columnName",
"=",
"rsmd",
".",
"getColumnName",
"(",
"i",
")",
";",
"}",
"params",
".",
"set",
"(",
"columnName",
",",
"rs",
".",
"getObject",
"(",
"i",
")",
")",
";",
"params",
".",
"updatePosition",
"(",
"columnName",
",",
"i",
"-",
"1",
")",
";",
"}",
"result",
".",
"add",
"(",
"params",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Converts java.sql.ResultSet into List of QueryParameters.
Used for caching purposes to allow ResultSet to be closed and disposed.
@param rs ResultSet values from which would be read
@return List of QueryParameters (one for each row)
@throws SQLException propagates SQLException sent from ResultSet
|
[
"Converts",
"java",
".",
"sql",
".",
"ResultSet",
"into",
"List",
"of",
"QueryParameters",
".",
"Used",
"for",
"caching",
"purposes",
"to",
"allow",
"ResultSet",
"to",
"be",
"closed",
"and",
"disposed",
"."
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java#L185-L209
|
149,472
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java
|
MappingUtils.newInstance
|
public static <T> T newInstance(Class<T> clazz) throws MjdbcException {
try {
return clazz.newInstance();
} catch (InstantiationException ex) {
throw new MjdbcException(
"Failed to create instance: " + clazz.getName() + " - " + ex.getMessage());
} catch (IllegalAccessException ex) {
throw new MjdbcException(
"Failed to create instance: " + clazz.getName() + " - " + ex.getMessage());
}
}
|
java
|
public static <T> T newInstance(Class<T> clazz) throws MjdbcException {
try {
return clazz.newInstance();
} catch (InstantiationException ex) {
throw new MjdbcException(
"Failed to create instance: " + clazz.getName() + " - " + ex.getMessage());
} catch (IllegalAccessException ex) {
throw new MjdbcException(
"Failed to create instance: " + clazz.getName() + " - " + ex.getMessage());
}
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"newInstance",
"(",
"Class",
"<",
"T",
">",
"clazz",
")",
"throws",
"MjdbcException",
"{",
"try",
"{",
"return",
"clazz",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"ex",
")",
"{",
"throw",
"new",
"MjdbcException",
"(",
"\"Failed to create instance: \"",
"+",
"clazz",
".",
"getName",
"(",
")",
"+",
"\" - \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"ex",
")",
"{",
"throw",
"new",
"MjdbcException",
"(",
"\"Failed to create instance: \"",
"+",
"clazz",
".",
"getName",
"(",
")",
"+",
"\" - \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Creates new Instance of class specified.
Default Constructor should be visible in order to create new Instance
@param clazz Class which should be instantiated
@return Empty Object
@throws SQLException in case of instantiation error
|
[
"Creates",
"new",
"Instance",
"of",
"class",
"specified",
".",
"Default",
"Constructor",
"should",
"be",
"visible",
"in",
"order",
"to",
"create",
"new",
"Instance"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java#L219-L231
|
149,473
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java
|
MappingUtils.hasFunction
|
public static boolean hasFunction(Object object, String functionName, Class[] parameters) {
boolean result = false;
try {
Method method = object.getClass().getMethod(functionName, parameters);
if (method != null) {
result = true;
}
} catch (NoSuchMethodException ex) {
result = false;
}
return result;
}
|
java
|
public static boolean hasFunction(Object object, String functionName, Class[] parameters) {
boolean result = false;
try {
Method method = object.getClass().getMethod(functionName, parameters);
if (method != null) {
result = true;
}
} catch (NoSuchMethodException ex) {
result = false;
}
return result;
}
|
[
"public",
"static",
"boolean",
"hasFunction",
"(",
"Object",
"object",
",",
"String",
"functionName",
",",
"Class",
"[",
"]",
"parameters",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"try",
"{",
"Method",
"method",
"=",
"object",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"functionName",
",",
"parameters",
")",
";",
"if",
"(",
"method",
"!=",
"null",
")",
"{",
"result",
"=",
"true",
";",
"}",
"}",
"catch",
"(",
"NoSuchMethodException",
"ex",
")",
"{",
"result",
"=",
"false",
";",
"}",
"return",
"result",
";",
"}"
] |
Checks if Instance has specified function
@param object Instance which function would be checked
@param functionName function name
@param parameters function parameters (array of Class)
@return true if function is present in Instance
|
[
"Checks",
"if",
"Instance",
"has",
"specified",
"function"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java#L307-L321
|
149,474
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java
|
MappingUtils.objectInstanceOf
|
public static boolean objectInstanceOf(Object object, String className) {
AssertUtils.assertNotNull(object);
boolean result = false;
Class clazz = object.getClass();
if (clazz.getName().equals(className) == true) {
result = true;
}
return result;
}
|
java
|
public static boolean objectInstanceOf(Object object, String className) {
AssertUtils.assertNotNull(object);
boolean result = false;
Class clazz = object.getClass();
if (clazz.getName().equals(className) == true) {
result = true;
}
return result;
}
|
[
"public",
"static",
"boolean",
"objectInstanceOf",
"(",
"Object",
"object",
",",
"String",
"className",
")",
"{",
"AssertUtils",
".",
"assertNotNull",
"(",
"object",
")",
";",
"boolean",
"result",
"=",
"false",
";",
"Class",
"clazz",
"=",
"object",
".",
"getClass",
"(",
")",
";",
"if",
"(",
"clazz",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"className",
")",
"==",
"true",
")",
"{",
"result",
"=",
"true",
";",
"}",
"return",
"result",
";",
"}"
] |
Checks if instance is of specified class
@param object Instance which would be checked
@param className Class name with which it would be checked
@return true if Instance is of specified class
|
[
"Checks",
"if",
"instance",
"is",
"of",
"specified",
"class"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java#L378-L390
|
149,475
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java
|
MappingUtils.objectAssignableTo
|
public static boolean objectAssignableTo(Object object, String className) throws MjdbcException {
AssertUtils.assertNotNull(object);
boolean result = false;
Class clazz = null;
try {
clazz = Class.forName(className);
} catch (ClassNotFoundException ex) {
throw new MjdbcException(ex);
}
result = clazz.isAssignableFrom(object.getClass());
return result;
}
|
java
|
public static boolean objectAssignableTo(Object object, String className) throws MjdbcException {
AssertUtils.assertNotNull(object);
boolean result = false;
Class clazz = null;
try {
clazz = Class.forName(className);
} catch (ClassNotFoundException ex) {
throw new MjdbcException(ex);
}
result = clazz.isAssignableFrom(object.getClass());
return result;
}
|
[
"public",
"static",
"boolean",
"objectAssignableTo",
"(",
"Object",
"object",
",",
"String",
"className",
")",
"throws",
"MjdbcException",
"{",
"AssertUtils",
".",
"assertNotNull",
"(",
"object",
")",
";",
"boolean",
"result",
"=",
"false",
";",
"Class",
"clazz",
"=",
"null",
";",
"try",
"{",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"className",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"ex",
")",
"{",
"throw",
"new",
"MjdbcException",
"(",
"ex",
")",
";",
"}",
"result",
"=",
"clazz",
".",
"isAssignableFrom",
"(",
"object",
".",
"getClass",
"(",
")",
")",
";",
"return",
"result",
";",
"}"
] |
Checks if instance can be cast to specified Class
@param object Instance which would be checked
@param className Class name with which it would be checked
@return true if Instance can be cast to specified class
@throws org.midao.jdbc.core.exception.MjdbcException
|
[
"Checks",
"if",
"instance",
"can",
"be",
"cast",
"to",
"specified",
"Class"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java#L400-L415
|
149,476
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java
|
MappingUtils.returnStaticField
|
public static Object returnStaticField(Class clazz, String fieldName) throws MjdbcException {
Object result = null;
Field field = null;
try {
field = clazz.getField(fieldName);
result = field.get(null);
} catch (NoSuchFieldException ex) {
throw new MjdbcException(ex);
} catch (IllegalAccessException ex) {
throw new MjdbcException(ex);
}
return result;
}
|
java
|
public static Object returnStaticField(Class clazz, String fieldName) throws MjdbcException {
Object result = null;
Field field = null;
try {
field = clazz.getField(fieldName);
result = field.get(null);
} catch (NoSuchFieldException ex) {
throw new MjdbcException(ex);
} catch (IllegalAccessException ex) {
throw new MjdbcException(ex);
}
return result;
}
|
[
"public",
"static",
"Object",
"returnStaticField",
"(",
"Class",
"clazz",
",",
"String",
"fieldName",
")",
"throws",
"MjdbcException",
"{",
"Object",
"result",
"=",
"null",
";",
"Field",
"field",
"=",
"null",
";",
"try",
"{",
"field",
"=",
"clazz",
".",
"getField",
"(",
"fieldName",
")",
";",
"result",
"=",
"field",
".",
"get",
"(",
"null",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"ex",
")",
"{",
"throw",
"new",
"MjdbcException",
"(",
"ex",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"ex",
")",
"{",
"throw",
"new",
"MjdbcException",
"(",
"ex",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Returns class static field value
Is used to return Constants
@param clazz Class static field of which would be returned
@param fieldName field name
@return field value
@throws org.midao.jdbc.core.exception.MjdbcException if field is not present or access is prohibited
|
[
"Returns",
"class",
"static",
"field",
"value",
"Is",
"used",
"to",
"return",
"Constants"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java#L426-L440
|
149,477
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java
|
MappingUtils.returnField
|
public static Object returnField(Object object, String fieldName) throws MjdbcException {
AssertUtils.assertNotNull(object);
Object result = null;
Field field = null;
try {
field = object.getClass().getField(fieldName);
result = field.get(object);
} catch (NoSuchFieldException ex) {
throw new MjdbcException(ex);
} catch (IllegalAccessException ex) {
throw new MjdbcException(ex);
}
return result;
}
|
java
|
public static Object returnField(Object object, String fieldName) throws MjdbcException {
AssertUtils.assertNotNull(object);
Object result = null;
Field field = null;
try {
field = object.getClass().getField(fieldName);
result = field.get(object);
} catch (NoSuchFieldException ex) {
throw new MjdbcException(ex);
} catch (IllegalAccessException ex) {
throw new MjdbcException(ex);
}
return result;
}
|
[
"public",
"static",
"Object",
"returnField",
"(",
"Object",
"object",
",",
"String",
"fieldName",
")",
"throws",
"MjdbcException",
"{",
"AssertUtils",
".",
"assertNotNull",
"(",
"object",
")",
";",
"Object",
"result",
"=",
"null",
";",
"Field",
"field",
"=",
"null",
";",
"try",
"{",
"field",
"=",
"object",
".",
"getClass",
"(",
")",
".",
"getField",
"(",
"fieldName",
")",
";",
"result",
"=",
"field",
".",
"get",
"(",
"object",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"ex",
")",
"{",
"throw",
"new",
"MjdbcException",
"(",
"ex",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"ex",
")",
"{",
"throw",
"new",
"MjdbcException",
"(",
"ex",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Returns class field value
Is used to return Constants
@param object Class field of which would be returned
@param fieldName field name
@return field value
@throws org.midao.jdbc.core.exception.MjdbcException if field is not present or access is prohibited
|
[
"Returns",
"class",
"field",
"value",
"Is",
"used",
"to",
"return",
"Constants"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java#L451-L467
|
149,478
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java
|
MappingUtils.isPrimitive
|
public static boolean isPrimitive(Object value) {
if (value == null) {
return true;
} else if (value.getClass().isPrimitive() == true) {
return true;
} else if (Integer.class.isInstance(value)) {
return true;
} else if (Long.class.isInstance(value)) {
return true;
} else if (Double.class.isInstance(value)) {
return true;
} else if (Float.class.isInstance(value)) {
return true;
} else if (Short.class.isInstance(value)) {
return true;
} else if (Byte.class.isInstance(value)) {
return true;
} else if (Character.class.isInstance(value)) {
return true;
} else if (Boolean.class.isInstance(value)) {
return true;
} else if (BigDecimal.class.isInstance(value)) {
return true;
} else if (BigInteger.class.isInstance(value)) {
return true;
}
return false;
}
|
java
|
public static boolean isPrimitive(Object value) {
if (value == null) {
return true;
} else if (value.getClass().isPrimitive() == true) {
return true;
} else if (Integer.class.isInstance(value)) {
return true;
} else if (Long.class.isInstance(value)) {
return true;
} else if (Double.class.isInstance(value)) {
return true;
} else if (Float.class.isInstance(value)) {
return true;
} else if (Short.class.isInstance(value)) {
return true;
} else if (Byte.class.isInstance(value)) {
return true;
} else if (Character.class.isInstance(value)) {
return true;
} else if (Boolean.class.isInstance(value)) {
return true;
} else if (BigDecimal.class.isInstance(value)) {
return true;
} else if (BigInteger.class.isInstance(value)) {
return true;
}
return false;
}
|
[
"public",
"static",
"boolean",
"isPrimitive",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"value",
".",
"getClass",
"(",
")",
".",
"isPrimitive",
"(",
")",
"==",
"true",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"Integer",
".",
"class",
".",
"isInstance",
"(",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"Long",
".",
"class",
".",
"isInstance",
"(",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"Double",
".",
"class",
".",
"isInstance",
"(",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"Float",
".",
"class",
".",
"isInstance",
"(",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"Short",
".",
"class",
".",
"isInstance",
"(",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"Byte",
".",
"class",
".",
"isInstance",
"(",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"Character",
".",
"class",
".",
"isInstance",
"(",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"Boolean",
".",
"class",
".",
"isInstance",
"(",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"BigDecimal",
".",
"class",
".",
"isInstance",
"(",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"BigInteger",
".",
"class",
".",
"isInstance",
"(",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks is value is of Primitive type
@param value value which would be checked
@return true - if value is primitive(or it's wrapper) type
|
[
"Checks",
"is",
"value",
"is",
"of",
"Primitive",
"type"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java#L475-L515
|
149,479
|
mike10004/common-helper
|
native-helper/src/main/java/com/github/mike10004/nativehelper/subprocess/Subprocess.java
|
Subprocess.running
|
public static Builder running(File executable) {
checkArgument(executable.isFile(), "file not found: %s", executable);
checkArgument(executable.canExecute(), "executable.canExecute");
return running(executable.getPath());
}
|
java
|
public static Builder running(File executable) {
checkArgument(executable.isFile(), "file not found: %s", executable);
checkArgument(executable.canExecute(), "executable.canExecute");
return running(executable.getPath());
}
|
[
"public",
"static",
"Builder",
"running",
"(",
"File",
"executable",
")",
"{",
"checkArgument",
"(",
"executable",
".",
"isFile",
"(",
")",
",",
"\"file not found: %s\"",
",",
"executable",
")",
";",
"checkArgument",
"(",
"executable",
".",
"canExecute",
"(",
")",
",",
"\"executable.canExecute\"",
")",
";",
"return",
"running",
"(",
"executable",
".",
"getPath",
"(",
")",
")",
";",
"}"
] |
Constructs a builder instance that will produce a program that
launches the given executable. Checks that a file exists at the given pathname
and that it is executable by the operating system.
@param executable the executable file
@return a builder instance
@throws IllegalArgumentException if {@link File#canExecute() } is false
|
[
"Constructs",
"a",
"builder",
"instance",
"that",
"will",
"produce",
"a",
"program",
"that",
"launches",
"the",
"given",
"executable",
".",
"Checks",
"that",
"a",
"file",
"exists",
"at",
"the",
"given",
"pathname",
"and",
"that",
"it",
"is",
"executable",
"by",
"the",
"operating",
"system",
"."
] |
744f82d9b0768a9ad9c63a57a37ab2c93bf408f4
|
https://github.com/mike10004/common-helper/blob/744f82d9b0768a9ad9c63a57a37ab2c93bf408f4/native-helper/src/main/java/com/github/mike10004/nativehelper/subprocess/Subprocess.java#L505-L509
|
149,480
|
Viascom/groundwork
|
foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/annotation/processor/FoxHttpAnnotationParser.java
|
FoxHttpAnnotationParser.parseInterface
|
@SuppressWarnings("unchecked")
public <T> T parseInterface(final Class<T> serviceInterface, FoxHttpClient foxHttpClient) throws FoxHttpException {
try {
Method[] methods = serviceInterface.getDeclaredMethods();
for (Method method : methods) {
FoxHttpMethodParser foxHttpMethodParser = new FoxHttpMethodParser();
foxHttpMethodParser.parseMethod(method, foxHttpClient);
FoxHttpRequestBuilder foxHttpRequestBuilder = new FoxHttpRequestBuilder(foxHttpMethodParser.getUrl(), foxHttpMethodParser.getRequestType(), foxHttpClient)
.setRequestHeader(foxHttpMethodParser.getHeaderFields())
.setSkipResponseBody(foxHttpMethodParser.isSkipResponseBody())
.setFollowRedirect(foxHttpMethodParser.isFollowRedirect());
requestCache.put(method, foxHttpRequestBuilder);
}
return (T) Proxy.newProxyInstance(serviceInterface.getClassLoader(),
new Class[]{serviceInterface}, new FoxHttpAnnotationInvocationHandler(requestCache, responseParsers));
} catch (FoxHttpException e) {
throw e;
} catch (Exception e) {
throw new FoxHttpRequestException(e);
}
}
|
java
|
@SuppressWarnings("unchecked")
public <T> T parseInterface(final Class<T> serviceInterface, FoxHttpClient foxHttpClient) throws FoxHttpException {
try {
Method[] methods = serviceInterface.getDeclaredMethods();
for (Method method : methods) {
FoxHttpMethodParser foxHttpMethodParser = new FoxHttpMethodParser();
foxHttpMethodParser.parseMethod(method, foxHttpClient);
FoxHttpRequestBuilder foxHttpRequestBuilder = new FoxHttpRequestBuilder(foxHttpMethodParser.getUrl(), foxHttpMethodParser.getRequestType(), foxHttpClient)
.setRequestHeader(foxHttpMethodParser.getHeaderFields())
.setSkipResponseBody(foxHttpMethodParser.isSkipResponseBody())
.setFollowRedirect(foxHttpMethodParser.isFollowRedirect());
requestCache.put(method, foxHttpRequestBuilder);
}
return (T) Proxy.newProxyInstance(serviceInterface.getClassLoader(),
new Class[]{serviceInterface}, new FoxHttpAnnotationInvocationHandler(requestCache, responseParsers));
} catch (FoxHttpException e) {
throw e;
} catch (Exception e) {
throw new FoxHttpRequestException(e);
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"parseInterface",
"(",
"final",
"Class",
"<",
"T",
">",
"serviceInterface",
",",
"FoxHttpClient",
"foxHttpClient",
")",
"throws",
"FoxHttpException",
"{",
"try",
"{",
"Method",
"[",
"]",
"methods",
"=",
"serviceInterface",
".",
"getDeclaredMethods",
"(",
")",
";",
"for",
"(",
"Method",
"method",
":",
"methods",
")",
"{",
"FoxHttpMethodParser",
"foxHttpMethodParser",
"=",
"new",
"FoxHttpMethodParser",
"(",
")",
";",
"foxHttpMethodParser",
".",
"parseMethod",
"(",
"method",
",",
"foxHttpClient",
")",
";",
"FoxHttpRequestBuilder",
"foxHttpRequestBuilder",
"=",
"new",
"FoxHttpRequestBuilder",
"(",
"foxHttpMethodParser",
".",
"getUrl",
"(",
")",
",",
"foxHttpMethodParser",
".",
"getRequestType",
"(",
")",
",",
"foxHttpClient",
")",
".",
"setRequestHeader",
"(",
"foxHttpMethodParser",
".",
"getHeaderFields",
"(",
")",
")",
".",
"setSkipResponseBody",
"(",
"foxHttpMethodParser",
".",
"isSkipResponseBody",
"(",
")",
")",
".",
"setFollowRedirect",
"(",
"foxHttpMethodParser",
".",
"isFollowRedirect",
"(",
")",
")",
";",
"requestCache",
".",
"put",
"(",
"method",
",",
"foxHttpRequestBuilder",
")",
";",
"}",
"return",
"(",
"T",
")",
"Proxy",
".",
"newProxyInstance",
"(",
"serviceInterface",
".",
"getClassLoader",
"(",
")",
",",
"new",
"Class",
"[",
"]",
"{",
"serviceInterface",
"}",
",",
"new",
"FoxHttpAnnotationInvocationHandler",
"(",
"requestCache",
",",
"responseParsers",
")",
")",
";",
"}",
"catch",
"(",
"FoxHttpException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"FoxHttpRequestException",
"(",
"e",
")",
";",
"}",
"}"
] |
Parse the given interface for the use of FoxHttp
@param serviceInterface interface to parse
@param foxHttpClient FoxHttpClient to use
@param <T> interface class to parse
@return Proxy of the interface
@throws FoxHttpRequestException
|
[
"Parse",
"the",
"given",
"interface",
"for",
"the",
"use",
"of",
"FoxHttp"
] |
d3f7d0df65e2e75861fc7db938090683f2cdf919
|
https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/annotation/processor/FoxHttpAnnotationParser.java#L41-L67
|
149,481
|
workplacesystems/queuj
|
src/main/java/com/workplacesystems/queuj/QueueBuilder.java
|
QueueBuilder.newQueue
|
public Queue<B> newQueue()
{
return new Queue<B>(parent_queue, queue_restriction, index, process_builder_class, process_server_class,
default_occurence, default_visibility, default_access, default_resilience, default_output, implementation_options);
}
|
java
|
public Queue<B> newQueue()
{
return new Queue<B>(parent_queue, queue_restriction, index, process_builder_class, process_server_class,
default_occurence, default_visibility, default_access, default_resilience, default_output, implementation_options);
}
|
[
"public",
"Queue",
"<",
"B",
">",
"newQueue",
"(",
")",
"{",
"return",
"new",
"Queue",
"<",
"B",
">",
"(",
"parent_queue",
",",
"queue_restriction",
",",
"index",
",",
"process_builder_class",
",",
"process_server_class",
",",
"default_occurence",
",",
"default_visibility",
",",
"default_access",
",",
"default_resilience",
",",
"default_output",
",",
"implementation_options",
")",
";",
"}"
] |
Create the new Queue using the currently set properties.
|
[
"Create",
"the",
"new",
"Queue",
"using",
"the",
"currently",
"set",
"properties",
"."
] |
4293116b412b4a20ead99963b9b05a135812c501
|
https://github.com/workplacesystems/queuj/blob/4293116b412b4a20ead99963b9b05a135812c501/src/main/java/com/workplacesystems/queuj/QueueBuilder.java#L152-L156
|
149,482
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/input/named/AbstractNamedInputHandler.java
|
AbstractNamedInputHandler.updateBean
|
protected T updateBean(T object, Map<String, Object> source) {
T clone = copyProperties(object);
updateProperties(clone, source);
return clone;
}
|
java
|
protected T updateBean(T object, Map<String, Object> source) {
T clone = copyProperties(object);
updateProperties(clone, source);
return clone;
}
|
[
"protected",
"T",
"updateBean",
"(",
"T",
"object",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"source",
")",
"{",
"T",
"clone",
"=",
"copyProperties",
"(",
"object",
")",
";",
"updateProperties",
"(",
"clone",
",",
"source",
")",
";",
"return",
"clone",
";",
"}"
] |
Updates bean with values from source.
@param object Bean object to update
@param source Map which would be read
@return cloned bean with updated values
|
[
"Updates",
"bean",
"with",
"values",
"from",
"source",
"."
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/input/named/AbstractNamedInputHandler.java#L88-L94
|
149,483
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/input/named/AbstractNamedInputHandler.java
|
AbstractNamedInputHandler.createEmpty
|
private T createEmpty(Class<?> clazz) {
T emptyInstance = null;
if (clazz.isInterface()) {
throw new IllegalArgumentException("Specified class is an interface: " + clazz.getName());
}
try {
emptyInstance = (T) clazz.newInstance();
} catch (InstantiationException ex) {
throw new IllegalArgumentException(clazz.getName() + ". Is it an abstract class?", ex);
} catch (IllegalAccessException ex) {
throw new IllegalArgumentException(clazz.getName() + "Is the constructor accessible?", ex);
}
return emptyInstance;
}
|
java
|
private T createEmpty(Class<?> clazz) {
T emptyInstance = null;
if (clazz.isInterface()) {
throw new IllegalArgumentException("Specified class is an interface: " + clazz.getName());
}
try {
emptyInstance = (T) clazz.newInstance();
} catch (InstantiationException ex) {
throw new IllegalArgumentException(clazz.getName() + ". Is it an abstract class?", ex);
} catch (IllegalAccessException ex) {
throw new IllegalArgumentException(clazz.getName() + "Is the constructor accessible?", ex);
}
return emptyInstance;
}
|
[
"private",
"T",
"createEmpty",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"T",
"emptyInstance",
"=",
"null",
";",
"if",
"(",
"clazz",
".",
"isInterface",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Specified class is an interface: \"",
"+",
"clazz",
".",
"getName",
"(",
")",
")",
";",
"}",
"try",
"{",
"emptyInstance",
"=",
"(",
"T",
")",
"clazz",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"ex",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"clazz",
".",
"getName",
"(",
")",
"+",
"\". Is it an abstract class?\"",
",",
"ex",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"ex",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"clazz",
".",
"getName",
"(",
")",
"+",
"\"Is the constructor accessible?\"",
",",
"ex",
")",
";",
"}",
"return",
"emptyInstance",
";",
"}"
] |
Creates new empty Bean instance
@param clazz Class description which would be instantiated
@return empty Bean instance
|
[
"Creates",
"new",
"empty",
"Bean",
"instance"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/input/named/AbstractNamedInputHandler.java#L144-L160
|
149,484
|
kikinteractive/ice
|
ice/src/main/java/com/kik/config/ice/ConfigSystem.java
|
ConfigSystem.configModuleWithOverrides
|
public static <C> Module configModuleWithOverrides(final Class<C> configInterface, OverrideConsumer<C> overrideConsumer)
{
checkNotNull(configInterface);
checkNotNull(overrideConsumer);
return configModuleWithOverrides(configInterface, Optional.empty(), Optional.ofNullable(overrideConsumer));
}
|
java
|
public static <C> Module configModuleWithOverrides(final Class<C> configInterface, OverrideConsumer<C> overrideConsumer)
{
checkNotNull(configInterface);
checkNotNull(overrideConsumer);
return configModuleWithOverrides(configInterface, Optional.empty(), Optional.ofNullable(overrideConsumer));
}
|
[
"public",
"static",
"<",
"C",
">",
"Module",
"configModuleWithOverrides",
"(",
"final",
"Class",
"<",
"C",
">",
"configInterface",
",",
"OverrideConsumer",
"<",
"C",
">",
"overrideConsumer",
")",
"{",
"checkNotNull",
"(",
"configInterface",
")",
";",
"checkNotNull",
"(",
"overrideConsumer",
")",
";",
"return",
"configModuleWithOverrides",
"(",
"configInterface",
",",
"Optional",
".",
"empty",
"(",
")",
",",
"Optional",
".",
"ofNullable",
"(",
"overrideConsumer",
")",
")",
";",
"}"
] |
Generates a Guice Module for use with Injector creation. THe generate Guice module binds a number of support
classes to service a dynamically generate implementation of the provided configuration interface.
This method further overrides the annotated defaults on the configuration class as per the code in
the given overrideConsumer
@param <C> The configuration interface type to be implemented
@param configInterface The configuration interface
@param overrideConsumer a lambda which is given an instance of {@link OverrideModule} which can be used to
build type-safe overrides for the default configuration of the config.
@return a module to install in your Guice Injector
|
[
"Generates",
"a",
"Guice",
"Module",
"for",
"use",
"with",
"Injector",
"creation",
".",
"THe",
"generate",
"Guice",
"module",
"binds",
"a",
"number",
"of",
"support",
"classes",
"to",
"service",
"a",
"dynamically",
"generate",
"implementation",
"of",
"the",
"provided",
"configuration",
"interface",
".",
"This",
"method",
"further",
"overrides",
"the",
"annotated",
"defaults",
"on",
"the",
"configuration",
"class",
"as",
"per",
"the",
"code",
"in",
"the",
"given",
"overrideConsumer"
] |
0c58d7bf2d9f6504892d0768d6022fcfa6df7514
|
https://github.com/kikinteractive/ice/blob/0c58d7bf2d9f6504892d0768d6022fcfa6df7514/ice/src/main/java/com/kik/config/ice/ConfigSystem.java#L107-L112
|
149,485
|
kikinteractive/ice
|
ice/src/main/java/com/kik/config/ice/ConfigSystem.java
|
ConfigSystem.configModuleWithOverrides
|
public static <C> Module configModuleWithOverrides(final Class<C> configInterface, Named name, OverrideConsumer<C> overrideConsumer)
{
checkNotNull(configInterface);
checkNotNull(name);
checkNotNull(overrideConsumer);
return configModuleWithOverrides(configInterface, Optional.ofNullable(name), Optional.ofNullable(overrideConsumer));
}
|
java
|
public static <C> Module configModuleWithOverrides(final Class<C> configInterface, Named name, OverrideConsumer<C> overrideConsumer)
{
checkNotNull(configInterface);
checkNotNull(name);
checkNotNull(overrideConsumer);
return configModuleWithOverrides(configInterface, Optional.ofNullable(name), Optional.ofNullable(overrideConsumer));
}
|
[
"public",
"static",
"<",
"C",
">",
"Module",
"configModuleWithOverrides",
"(",
"final",
"Class",
"<",
"C",
">",
"configInterface",
",",
"Named",
"name",
",",
"OverrideConsumer",
"<",
"C",
">",
"overrideConsumer",
")",
"{",
"checkNotNull",
"(",
"configInterface",
")",
";",
"checkNotNull",
"(",
"name",
")",
";",
"checkNotNull",
"(",
"overrideConsumer",
")",
";",
"return",
"configModuleWithOverrides",
"(",
"configInterface",
",",
"Optional",
".",
"ofNullable",
"(",
"name",
")",
",",
"Optional",
".",
"ofNullable",
"(",
"overrideConsumer",
")",
")",
";",
"}"
] |
Generates a Guice Module for use with Injector creation. The generate Guice module binds a number of support
classes to service a dynamically generate implementation of the provided configuration interface.
This method further overrides the annotated defaults on the configuration class as per the code in
the given overrideConsumer
@param <C> The configuration interface type to be implemented
@param configInterface The configuration interface
@param name Named annotation to provide an arbitrary scope to the configuration interface. Used when
there are multiple implementations of the config interface.
@param overrideConsumer a lambda which is given an instance of {@link OverrideModule} which can be used to
build type-safe overrides for the default configuration of the config.
@return a module to install in your Guice Injector
|
[
"Generates",
"a",
"Guice",
"Module",
"for",
"use",
"with",
"Injector",
"creation",
".",
"The",
"generate",
"Guice",
"module",
"binds",
"a",
"number",
"of",
"support",
"classes",
"to",
"service",
"a",
"dynamically",
"generate",
"implementation",
"of",
"the",
"provided",
"configuration",
"interface",
".",
"This",
"method",
"further",
"overrides",
"the",
"annotated",
"defaults",
"on",
"the",
"configuration",
"class",
"as",
"per",
"the",
"code",
"in",
"the",
"given",
"overrideConsumer"
] |
0c58d7bf2d9f6504892d0768d6022fcfa6df7514
|
https://github.com/kikinteractive/ice/blob/0c58d7bf2d9f6504892d0768d6022fcfa6df7514/ice/src/main/java/com/kik/config/ice/ConfigSystem.java#L128-L134
|
149,486
|
wb14123/bard
|
bard-core/src/main/java/com/bardframework/bard/core/Util.java
|
Util.getConfig
|
public static CompositeConfiguration getConfig() {
if (config == null) {
config = new CompositeConfiguration();
String configFile = "bard.properties";
if (Util.class.getClassLoader().getResource(configFile) == null) {
return config;
}
try {
config.addConfiguration(new PropertiesConfiguration("bard.properties"));
} catch (ConfigurationException e) {
logger.error("Load Bard configuration \"bard.properties\" error: {}", e);
}
}
return config;
}
|
java
|
public static CompositeConfiguration getConfig() {
if (config == null) {
config = new CompositeConfiguration();
String configFile = "bard.properties";
if (Util.class.getClassLoader().getResource(configFile) == null) {
return config;
}
try {
config.addConfiguration(new PropertiesConfiguration("bard.properties"));
} catch (ConfigurationException e) {
logger.error("Load Bard configuration \"bard.properties\" error: {}", e);
}
}
return config;
}
|
[
"public",
"static",
"CompositeConfiguration",
"getConfig",
"(",
")",
"{",
"if",
"(",
"config",
"==",
"null",
")",
"{",
"config",
"=",
"new",
"CompositeConfiguration",
"(",
")",
";",
"String",
"configFile",
"=",
"\"bard.properties\"",
";",
"if",
"(",
"Util",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"configFile",
")",
"==",
"null",
")",
"{",
"return",
"config",
";",
"}",
"try",
"{",
"config",
".",
"addConfiguration",
"(",
"new",
"PropertiesConfiguration",
"(",
"\"bard.properties\"",
")",
")",
";",
"}",
"catch",
"(",
"ConfigurationException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Load Bard configuration \\\"bard.properties\\\" error: {}\"",
",",
"e",
")",
";",
"}",
"}",
"return",
"config",
";",
"}"
] |
Get the Bard config object. The properties is set in "bard.properties".
@return The config object.
|
[
"Get",
"the",
"Bard",
"config",
"object",
".",
"The",
"properties",
"is",
"set",
"in",
"bard",
".",
"properties",
"."
] |
98618ae31fd80000c794661b4c130af1b1298d9b
|
https://github.com/wb14123/bard/blob/98618ae31fd80000c794661b4c130af1b1298d9b/bard-core/src/main/java/com/bardframework/bard/core/Util.java#L18-L34
|
149,487
|
wb14123/bard
|
bard-util/bard-user/src/main/java/com/bardframework/bard/util/user/PasswordEncrypter.java
|
PasswordEncrypter.encrypt
|
public static String[] encrypt(String password) {
SecureRandom random = new SecureRandom();
String salt = new BigInteger(130, random).toString(32);
String encryptPassword = encrypt(password, salt);
return new String[] {encryptPassword, salt};
}
|
java
|
public static String[] encrypt(String password) {
SecureRandom random = new SecureRandom();
String salt = new BigInteger(130, random).toString(32);
String encryptPassword = encrypt(password, salt);
return new String[] {encryptPassword, salt};
}
|
[
"public",
"static",
"String",
"[",
"]",
"encrypt",
"(",
"String",
"password",
")",
"{",
"SecureRandom",
"random",
"=",
"new",
"SecureRandom",
"(",
")",
";",
"String",
"salt",
"=",
"new",
"BigInteger",
"(",
"130",
",",
"random",
")",
".",
"toString",
"(",
"32",
")",
";",
"String",
"encryptPassword",
"=",
"encrypt",
"(",
"password",
",",
"salt",
")",
";",
"return",
"new",
"String",
"[",
"]",
"{",
"encryptPassword",
",",
"salt",
"}",
";",
"}"
] |
Encrypt a password string with a random generated salt.
@param password The origin password need to be encrypt.
@return An array with two elements: The first one is the encrypted password and the second one is the salt.
|
[
"Encrypt",
"a",
"password",
"string",
"with",
"a",
"random",
"generated",
"salt",
"."
] |
98618ae31fd80000c794661b4c130af1b1298d9b
|
https://github.com/wb14123/bard/blob/98618ae31fd80000c794661b4c130af1b1298d9b/bard-util/bard-user/src/main/java/com/bardframework/bard/util/user/PasswordEncrypter.java#L15-L20
|
149,488
|
wb14123/bard
|
bard-util/bard-user/src/main/java/com/bardframework/bard/util/user/PasswordEncrypter.java
|
PasswordEncrypter.encrypt
|
public static String encrypt(String password, String salt) {
String saltPassword = password + salt;
return DigestUtils.sha256Hex(saltPassword.getBytes());
}
|
java
|
public static String encrypt(String password, String salt) {
String saltPassword = password + salt;
return DigestUtils.sha256Hex(saltPassword.getBytes());
}
|
[
"public",
"static",
"String",
"encrypt",
"(",
"String",
"password",
",",
"String",
"salt",
")",
"{",
"String",
"saltPassword",
"=",
"password",
"+",
"salt",
";",
"return",
"DigestUtils",
".",
"sha256Hex",
"(",
"saltPassword",
".",
"getBytes",
"(",
")",
")",
";",
"}"
] |
Encrypt a password string with a given password.
@param password The origin password need to be encrypt.
@param salt The salt.
@return The encrypted password.
|
[
"Encrypt",
"a",
"password",
"string",
"with",
"a",
"given",
"password",
"."
] |
98618ae31fd80000c794661b4c130af1b1298d9b
|
https://github.com/wb14123/bard/blob/98618ae31fd80000c794661b4c130af1b1298d9b/bard-util/bard-user/src/main/java/com/bardframework/bard/util/user/PasswordEncrypter.java#L29-L32
|
149,489
|
greese/dasein-util
|
src/main/java/org/dasein/media/ImageIngester.java
|
ImageIngester.checkSwf
|
@SuppressWarnings("unused")
private boolean checkSwf() throws IOException {
//get rid of the last byte of the signature, the byte of the version and 4 bytes of the size
byte[] a = new byte[6];
if (read(a) != a.length) {
return false;
}
format = FORMAT_SWF;
int bitSize = (int)readUBits( 5 );
int minX = (int)readSBits( bitSize ); // unused, but necessary
int maxX = (int)readSBits( bitSize );
int minY = (int)readSBits( bitSize ); // unused, but necessary
int maxY = (int)readSBits( bitSize );
width = maxX/20; //cause we're in twips
height = maxY/20; //cause we're in twips
setPhysicalWidthDpi(72);
setPhysicalHeightDpi(72);
return (width > 0 && height > 0);
}
|
java
|
@SuppressWarnings("unused")
private boolean checkSwf() throws IOException {
//get rid of the last byte of the signature, the byte of the version and 4 bytes of the size
byte[] a = new byte[6];
if (read(a) != a.length) {
return false;
}
format = FORMAT_SWF;
int bitSize = (int)readUBits( 5 );
int minX = (int)readSBits( bitSize ); // unused, but necessary
int maxX = (int)readSBits( bitSize );
int minY = (int)readSBits( bitSize ); // unused, but necessary
int maxY = (int)readSBits( bitSize );
width = maxX/20; //cause we're in twips
height = maxY/20; //cause we're in twips
setPhysicalWidthDpi(72);
setPhysicalHeightDpi(72);
return (width > 0 && height > 0);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"private",
"boolean",
"checkSwf",
"(",
")",
"throws",
"IOException",
"{",
"//get rid of the last byte of the signature, the byte of the version and 4 bytes of the size",
"byte",
"[",
"]",
"a",
"=",
"new",
"byte",
"[",
"6",
"]",
";",
"if",
"(",
"read",
"(",
"a",
")",
"!=",
"a",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"format",
"=",
"FORMAT_SWF",
";",
"int",
"bitSize",
"=",
"(",
"int",
")",
"readUBits",
"(",
"5",
")",
";",
"int",
"minX",
"=",
"(",
"int",
")",
"readSBits",
"(",
"bitSize",
")",
";",
"// unused, but necessary",
"int",
"maxX",
"=",
"(",
"int",
")",
"readSBits",
"(",
"bitSize",
")",
";",
"int",
"minY",
"=",
"(",
"int",
")",
"readSBits",
"(",
"bitSize",
")",
";",
"// unused, but necessary",
"int",
"maxY",
"=",
"(",
"int",
")",
"readSBits",
"(",
"bitSize",
")",
";",
"width",
"=",
"maxX",
"/",
"20",
";",
"//cause we're in twips",
"height",
"=",
"maxY",
"/",
"20",
";",
"//cause we're in twips",
"setPhysicalWidthDpi",
"(",
"72",
")",
";",
"setPhysicalHeightDpi",
"(",
"72",
")",
";",
"return",
"(",
"width",
">",
"0",
"&&",
"height",
">",
"0",
")",
";",
"}"
] |
Written by Michael Aird.
|
[
"Written",
"by",
"Michael",
"Aird",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/media/ImageIngester.java#L704-L722
|
149,490
|
greese/dasein-util
|
src/main/java/org/dasein/media/ImageIngester.java
|
ImageIngester.getComment
|
public String getComment(int index) {
if (comments == null || index < 0 || index >= comments.size()) {
throw new IllegalArgumentException("Not a valid comment index: " + index);
}
return (String)comments.get(index);
}
|
java
|
public String getComment(int index) {
if (comments == null || index < 0 || index >= comments.size()) {
throw new IllegalArgumentException("Not a valid comment index: " + index);
}
return (String)comments.get(index);
}
|
[
"public",
"String",
"getComment",
"(",
"int",
"index",
")",
"{",
"if",
"(",
"comments",
"==",
"null",
"||",
"index",
"<",
"0",
"||",
"index",
">=",
"comments",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Not a valid comment index: \"",
"+",
"index",
")",
";",
"}",
"return",
"(",
"String",
")",
"comments",
".",
"get",
"(",
"index",
")",
";",
"}"
] |
Returns the index'th comment retrieved from the image.
@throws IllegalArgumentException if index is smaller than 0 or larger than or equal
to the number of comments retrieved
@see #getNumberOfComments
|
[
"Returns",
"the",
"index",
"th",
"comment",
"retrieved",
"from",
"the",
"image",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/media/ImageIngester.java#L748-L753
|
149,491
|
javagl/Common
|
src/main/java/de/javagl/common/xml/XmlUtils.java
|
XmlUtils.getDefaultDocument
|
public static synchronized Document getDefaultDocument()
{
if (defaultDocument == null)
{
DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = null;
try
{
documentBuilder = documentBuilderFactory.newDocumentBuilder();
}
catch (ParserConfigurationException e)
{
// Can not happen, since it's the default configuration
throw new XmlException("Could not create default document", e);
}
defaultDocument = documentBuilder.newDocument();
}
return defaultDocument;
}
|
java
|
public static synchronized Document getDefaultDocument()
{
if (defaultDocument == null)
{
DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = null;
try
{
documentBuilder = documentBuilderFactory.newDocumentBuilder();
}
catch (ParserConfigurationException e)
{
// Can not happen, since it's the default configuration
throw new XmlException("Could not create default document", e);
}
defaultDocument = documentBuilder.newDocument();
}
return defaultDocument;
}
|
[
"public",
"static",
"synchronized",
"Document",
"getDefaultDocument",
"(",
")",
"{",
"if",
"(",
"defaultDocument",
"==",
"null",
")",
"{",
"DocumentBuilderFactory",
"documentBuilderFactory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"DocumentBuilder",
"documentBuilder",
"=",
"null",
";",
"try",
"{",
"documentBuilder",
"=",
"documentBuilderFactory",
".",
"newDocumentBuilder",
"(",
")",
";",
"}",
"catch",
"(",
"ParserConfigurationException",
"e",
")",
"{",
"// Can not happen, since it's the default configuration\r",
"throw",
"new",
"XmlException",
"(",
"\"Could not create default document\"",
",",
"e",
")",
";",
"}",
"defaultDocument",
"=",
"documentBuilder",
".",
"newDocument",
"(",
")",
";",
"}",
"return",
"defaultDocument",
";",
"}"
] |
Returns a default XML document
@return The default XML document
|
[
"Returns",
"a",
"default",
"XML",
"document"
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/xml/XmlUtils.java#L72-L91
|
149,492
|
javagl/Common
|
src/main/java/de/javagl/common/xml/XmlUtils.java
|
XmlUtils.write
|
private static void write(
Node node, Writer writer, int indentation, boolean omitXmlDeclaration)
{
TransformerFactory transformerFactory =
TransformerFactory.newInstance();
if (indentation > 0)
{
transformerFactory.setAttribute("indent-number", indentation);
}
Transformer transformer = null;
try
{
transformer = transformerFactory.newTransformer();
}
catch (TransformerConfigurationException canNotHappen)
{
// Can not happen here
throw new XmlException(
"Could not create transformer", canNotHappen);
}
transformer.setOutputProperty(OutputKeys.STANDALONE, "yes");
transformer.setOutputProperty(
OutputKeys.INDENT,
propertyStringFor(indentation > 0));
transformer.setOutputProperty(
OutputKeys.OMIT_XML_DECLARATION,
propertyStringFor(omitXmlDeclaration));
DOMSource source = new DOMSource(node);
StreamResult xmlOutput = new StreamResult(writer);
try
{
transformer.transform(source, xmlOutput);
}
catch (TransformerException e)
{
throw new XmlException("Could not transform node", e);
}
}
|
java
|
private static void write(
Node node, Writer writer, int indentation, boolean omitXmlDeclaration)
{
TransformerFactory transformerFactory =
TransformerFactory.newInstance();
if (indentation > 0)
{
transformerFactory.setAttribute("indent-number", indentation);
}
Transformer transformer = null;
try
{
transformer = transformerFactory.newTransformer();
}
catch (TransformerConfigurationException canNotHappen)
{
// Can not happen here
throw new XmlException(
"Could not create transformer", canNotHappen);
}
transformer.setOutputProperty(OutputKeys.STANDALONE, "yes");
transformer.setOutputProperty(
OutputKeys.INDENT,
propertyStringFor(indentation > 0));
transformer.setOutputProperty(
OutputKeys.OMIT_XML_DECLARATION,
propertyStringFor(omitXmlDeclaration));
DOMSource source = new DOMSource(node);
StreamResult xmlOutput = new StreamResult(writer);
try
{
transformer.transform(source, xmlOutput);
}
catch (TransformerException e)
{
throw new XmlException("Could not transform node", e);
}
}
|
[
"private",
"static",
"void",
"write",
"(",
"Node",
"node",
",",
"Writer",
"writer",
",",
"int",
"indentation",
",",
"boolean",
"omitXmlDeclaration",
")",
"{",
"TransformerFactory",
"transformerFactory",
"=",
"TransformerFactory",
".",
"newInstance",
"(",
")",
";",
"if",
"(",
"indentation",
">",
"0",
")",
"{",
"transformerFactory",
".",
"setAttribute",
"(",
"\"indent-number\"",
",",
"indentation",
")",
";",
"}",
"Transformer",
"transformer",
"=",
"null",
";",
"try",
"{",
"transformer",
"=",
"transformerFactory",
".",
"newTransformer",
"(",
")",
";",
"}",
"catch",
"(",
"TransformerConfigurationException",
"canNotHappen",
")",
"{",
"// Can not happen here\r",
"throw",
"new",
"XmlException",
"(",
"\"Could not create transformer\"",
",",
"canNotHappen",
")",
";",
"}",
"transformer",
".",
"setOutputProperty",
"(",
"OutputKeys",
".",
"STANDALONE",
",",
"\"yes\"",
")",
";",
"transformer",
".",
"setOutputProperty",
"(",
"OutputKeys",
".",
"INDENT",
",",
"propertyStringFor",
"(",
"indentation",
">",
"0",
")",
")",
";",
"transformer",
".",
"setOutputProperty",
"(",
"OutputKeys",
".",
"OMIT_XML_DECLARATION",
",",
"propertyStringFor",
"(",
"omitXmlDeclaration",
")",
")",
";",
"DOMSource",
"source",
"=",
"new",
"DOMSource",
"(",
"node",
")",
";",
"StreamResult",
"xmlOutput",
"=",
"new",
"StreamResult",
"(",
"writer",
")",
";",
"try",
"{",
"transformer",
".",
"transform",
"(",
"source",
",",
"xmlOutput",
")",
";",
"}",
"catch",
"(",
"TransformerException",
"e",
")",
"{",
"throw",
"new",
"XmlException",
"(",
"\"Could not transform node\"",
",",
"e",
")",
";",
"}",
"}"
] |
Writes a formatted String representation of the given XML node
to the given writer.
@param node The node
@param writer The writer to write to
@param indentation The indentation. If this is not positive, then
no indentation will be performed
@param omitXmlDeclaration Whether the XML declaration should be omitted
@throws XmlException If there was an error while writing
|
[
"Writes",
"a",
"formatted",
"String",
"representation",
"of",
"the",
"given",
"XML",
"node",
"to",
"the",
"given",
"writer",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/xml/XmlUtils.java#L178-L216
|
149,493
|
javagl/Common
|
src/main/java/de/javagl/common/xml/XmlUtils.java
|
XmlUtils.read
|
public static Node read(InputStream inputStream) throws XmlException
{
try
{
DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder =
documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(inputStream);
Node node = document.getDocumentElement();
return node;
}
catch (ParserConfigurationException canNotHappen)
{
// Can not happen with a default configuration
throw new XmlException("Could not create parser", canNotHappen);
}
catch (SAXException e)
{
throw new XmlException("XML parsing error", e);
}
catch (IOException e)
{
throw new XmlException("IO error while reading XML", e);
}
}
|
java
|
public static Node read(InputStream inputStream) throws XmlException
{
try
{
DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder =
documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(inputStream);
Node node = document.getDocumentElement();
return node;
}
catch (ParserConfigurationException canNotHappen)
{
// Can not happen with a default configuration
throw new XmlException("Could not create parser", canNotHappen);
}
catch (SAXException e)
{
throw new XmlException("XML parsing error", e);
}
catch (IOException e)
{
throw new XmlException("IO error while reading XML", e);
}
}
|
[
"public",
"static",
"Node",
"read",
"(",
"InputStream",
"inputStream",
")",
"throws",
"XmlException",
"{",
"try",
"{",
"DocumentBuilderFactory",
"documentBuilderFactory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"DocumentBuilder",
"documentBuilder",
"=",
"documentBuilderFactory",
".",
"newDocumentBuilder",
"(",
")",
";",
"Document",
"document",
"=",
"documentBuilder",
".",
"parse",
"(",
"inputStream",
")",
";",
"Node",
"node",
"=",
"document",
".",
"getDocumentElement",
"(",
")",
";",
"return",
"node",
";",
"}",
"catch",
"(",
"ParserConfigurationException",
"canNotHappen",
")",
"{",
"// Can not happen with a default configuration\r",
"throw",
"new",
"XmlException",
"(",
"\"Could not create parser\"",
",",
"canNotHappen",
")",
";",
"}",
"catch",
"(",
"SAXException",
"e",
")",
"{",
"throw",
"new",
"XmlException",
"(",
"\"XML parsing error\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"XmlException",
"(",
"\"IO error while reading XML\"",
",",
"e",
")",
";",
"}",
"}"
] |
Creates an XML node by reading the contents of the given input stream.
@param inputStream The input stream to read from
@return The parsed node
@throws XmlException If there was an error while reading
|
[
"Creates",
"an",
"XML",
"node",
"by",
"reading",
"the",
"contents",
"of",
"the",
"given",
"input",
"stream",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/xml/XmlUtils.java#L236-L262
|
149,494
|
javagl/Common
|
src/main/java/de/javagl/common/xml/XmlUtils.java
|
XmlUtils.getAttributeValue
|
public static String getAttributeValue(
Node node, String attributeName, String defaultValue)
{
NamedNodeMap attributes = node.getAttributes();
Node attributeNode = attributes.getNamedItem(attributeName);
if (attributeNode == null)
{
return defaultValue;
}
String value = attributeNode.getNodeValue();
if (value == null)
{
return defaultValue;
}
return value;
}
|
java
|
public static String getAttributeValue(
Node node, String attributeName, String defaultValue)
{
NamedNodeMap attributes = node.getAttributes();
Node attributeNode = attributes.getNamedItem(attributeName);
if (attributeNode == null)
{
return defaultValue;
}
String value = attributeNode.getNodeValue();
if (value == null)
{
return defaultValue;
}
return value;
}
|
[
"public",
"static",
"String",
"getAttributeValue",
"(",
"Node",
"node",
",",
"String",
"attributeName",
",",
"String",
"defaultValue",
")",
"{",
"NamedNodeMap",
"attributes",
"=",
"node",
".",
"getAttributes",
"(",
")",
";",
"Node",
"attributeNode",
"=",
"attributes",
".",
"getNamedItem",
"(",
"attributeName",
")",
";",
"if",
"(",
"attributeNode",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"String",
"value",
"=",
"attributeNode",
".",
"getNodeValue",
"(",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"return",
"value",
";",
"}"
] |
Returns the attribute with the given name from the given node.
If the respective attribute could not be obtained, the given
default value will be returned
@param node The node to obtain the attribute from
@param attributeName The name of the attribute
@param defaultValue The default value to return when the specified
attribute could not be obtained
@return The value of the attribute, or the default value
|
[
"Returns",
"the",
"attribute",
"with",
"the",
"given",
"name",
"from",
"the",
"given",
"node",
".",
"If",
"the",
"respective",
"attribute",
"could",
"not",
"be",
"obtained",
"the",
"given",
"default",
"value",
"will",
"be",
"returned"
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/xml/XmlUtils.java#L295-L310
|
149,495
|
javagl/Common
|
src/main/java/de/javagl/common/xml/XmlUtils.java
|
XmlUtils.getRequiredAttributeValue
|
public static String getRequiredAttributeValue(
Node node, String attributeName)
{
NamedNodeMap attributes = node.getAttributes();
Node attributeNode = attributes.getNamedItem(attributeName);
if (attributeNode == null)
{
throw new XmlException(
"No attribute with name \""+attributeName+"\" found");
}
String value = attributeNode.getNodeValue();
if (value == null)
{
throw new XmlException(
"Attribute with name \""+attributeName+"\" has no value");
}
return value;
}
|
java
|
public static String getRequiredAttributeValue(
Node node, String attributeName)
{
NamedNodeMap attributes = node.getAttributes();
Node attributeNode = attributes.getNamedItem(attributeName);
if (attributeNode == null)
{
throw new XmlException(
"No attribute with name \""+attributeName+"\" found");
}
String value = attributeNode.getNodeValue();
if (value == null)
{
throw new XmlException(
"Attribute with name \""+attributeName+"\" has no value");
}
return value;
}
|
[
"public",
"static",
"String",
"getRequiredAttributeValue",
"(",
"Node",
"node",
",",
"String",
"attributeName",
")",
"{",
"NamedNodeMap",
"attributes",
"=",
"node",
".",
"getAttributes",
"(",
")",
";",
"Node",
"attributeNode",
"=",
"attributes",
".",
"getNamedItem",
"(",
"attributeName",
")",
";",
"if",
"(",
"attributeNode",
"==",
"null",
")",
"{",
"throw",
"new",
"XmlException",
"(",
"\"No attribute with name \\\"\"",
"+",
"attributeName",
"+",
"\"\\\" found\"",
")",
";",
"}",
"String",
"value",
"=",
"attributeNode",
".",
"getNodeValue",
"(",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"XmlException",
"(",
"\"Attribute with name \\\"\"",
"+",
"attributeName",
"+",
"\"\\\" has no value\"",
")",
";",
"}",
"return",
"value",
";",
"}"
] |
Returns the attribute with the given name from the given node.
@param node The node to obtain the attribute from
@param attributeName The name of the attribute
@return The value of the attribute
@throws XmlException If no value of the attribute with the given
name could be obtained.
|
[
"Returns",
"the",
"attribute",
"with",
"the",
"given",
"name",
"from",
"the",
"given",
"node",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/xml/XmlUtils.java#L322-L339
|
149,496
|
javagl/Common
|
src/main/java/de/javagl/common/xml/XmlUtils.java
|
XmlUtils.resolveAttributeFromMap
|
static <T> T resolveAttributeFromMap(
Node node, String attributeName, Map<String, ? extends T> map)
{
String id = XmlUtils.getAttributeValue(node, attributeName, null);
if (id == null)
{
throw new XmlException(
"No attribute \""+attributeName+"\" found");
}
T result = map.get(id);
if (result == null)
{
throw new XmlException(
"Could not resolve value with id \""+id+"\"");
}
return result;
}
|
java
|
static <T> T resolveAttributeFromMap(
Node node, String attributeName, Map<String, ? extends T> map)
{
String id = XmlUtils.getAttributeValue(node, attributeName, null);
if (id == null)
{
throw new XmlException(
"No attribute \""+attributeName+"\" found");
}
T result = map.get(id);
if (result == null)
{
throw new XmlException(
"Could not resolve value with id \""+id+"\"");
}
return result;
}
|
[
"static",
"<",
"T",
">",
"T",
"resolveAttributeFromMap",
"(",
"Node",
"node",
",",
"String",
"attributeName",
",",
"Map",
"<",
"String",
",",
"?",
"extends",
"T",
">",
"map",
")",
"{",
"String",
"id",
"=",
"XmlUtils",
".",
"getAttributeValue",
"(",
"node",
",",
"attributeName",
",",
"null",
")",
";",
"if",
"(",
"id",
"==",
"null",
")",
"{",
"throw",
"new",
"XmlException",
"(",
"\"No attribute \\\"\"",
"+",
"attributeName",
"+",
"\"\\\" found\"",
")",
";",
"}",
"T",
"result",
"=",
"map",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"throw",
"new",
"XmlException",
"(",
"\"Could not resolve value with id \\\"\"",
"+",
"id",
"+",
"\"\\\"\"",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Resolve the value in the given map whose key is the value of
the specified attribute.
@param <T> The type of the elements in the map
@param node The node
@param attributeName The name of the attribute
@param map The map
@return The value in the map whose key is the value of the
specified attribute
@throws XmlException If either the given node does not contain
an attribute with the given name, or the map does not contain
a value for the respective attribute value
|
[
"Resolve",
"the",
"value",
"in",
"the",
"given",
"map",
"whose",
"key",
"is",
"the",
"value",
"of",
"the",
"specified",
"attribute",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/xml/XmlUtils.java#L468-L484
|
149,497
|
javagl/Common
|
src/main/java/de/javagl/common/xml/XmlUtils.java
|
XmlUtils.readInt
|
static int readInt(Node node)
{
if (node == null)
{
throw new XmlException(
"Tried to read int value from null node");
}
String value = node.getFirstChild().getNodeValue();
if (value == null)
{
throw new XmlException(
"Tried to read int value from null value");
}
try
{
return Integer.parseInt(value);
}
catch (NumberFormatException e)
{
throw new XmlException(
"Expected int value, found \""+value+"\"", e);
}
}
|
java
|
static int readInt(Node node)
{
if (node == null)
{
throw new XmlException(
"Tried to read int value from null node");
}
String value = node.getFirstChild().getNodeValue();
if (value == null)
{
throw new XmlException(
"Tried to read int value from null value");
}
try
{
return Integer.parseInt(value);
}
catch (NumberFormatException e)
{
throw new XmlException(
"Expected int value, found \""+value+"\"", e);
}
}
|
[
"static",
"int",
"readInt",
"(",
"Node",
"node",
")",
"{",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"throw",
"new",
"XmlException",
"(",
"\"Tried to read int value from null node\"",
")",
";",
"}",
"String",
"value",
"=",
"node",
".",
"getFirstChild",
"(",
")",
".",
"getNodeValue",
"(",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"XmlException",
"(",
"\"Tried to read int value from null value\"",
")",
";",
"}",
"try",
"{",
"return",
"Integer",
".",
"parseInt",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"throw",
"new",
"XmlException",
"(",
"\"Expected int value, found \\\"\"",
"+",
"value",
"+",
"\"\\\"\"",
",",
"e",
")",
";",
"}",
"}"
] |
Parse an int value from the first child of the given node.
@param node The node
@return The int value
@throws XmlException If the given node was <code>null</code>, or no
int value could be parsed
|
[
"Parse",
"an",
"int",
"value",
"from",
"the",
"first",
"child",
"of",
"the",
"given",
"node",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/xml/XmlUtils.java#L495-L517
|
149,498
|
javagl/Common
|
src/main/java/de/javagl/common/xml/XmlUtils.java
|
XmlUtils.readDouble
|
static double readDouble(Node node)
{
if (node == null)
{
throw new XmlException(
"Tried to read double value from null node");
}
String value = node.getFirstChild().getNodeValue();
if (value == null)
{
throw new XmlException(
"Tried to read double value from null value");
}
try
{
return Double.parseDouble(value);
}
catch (NumberFormatException e)
{
throw new XmlException(
"Expected double value, found \""+value+"\"", e);
}
}
|
java
|
static double readDouble(Node node)
{
if (node == null)
{
throw new XmlException(
"Tried to read double value from null node");
}
String value = node.getFirstChild().getNodeValue();
if (value == null)
{
throw new XmlException(
"Tried to read double value from null value");
}
try
{
return Double.parseDouble(value);
}
catch (NumberFormatException e)
{
throw new XmlException(
"Expected double value, found \""+value+"\"", e);
}
}
|
[
"static",
"double",
"readDouble",
"(",
"Node",
"node",
")",
"{",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"throw",
"new",
"XmlException",
"(",
"\"Tried to read double value from null node\"",
")",
";",
"}",
"String",
"value",
"=",
"node",
".",
"getFirstChild",
"(",
")",
".",
"getNodeValue",
"(",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"XmlException",
"(",
"\"Tried to read double value from null value\"",
")",
";",
"}",
"try",
"{",
"return",
"Double",
".",
"parseDouble",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"throw",
"new",
"XmlException",
"(",
"\"Expected double value, found \\\"\"",
"+",
"value",
"+",
"\"\\\"\"",
",",
"e",
")",
";",
"}",
"}"
] |
Parse a double value from the first child of the given node.
@param node The node
@return The double value
@throws XmlException If the given node was <code>null</code>, or no
double value could be parsed
|
[
"Parse",
"a",
"double",
"value",
"from",
"the",
"first",
"child",
"of",
"the",
"given",
"node",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/xml/XmlUtils.java#L527-L549
|
149,499
|
javagl/Common
|
src/main/java/de/javagl/common/xml/XmlUtils.java
|
XmlUtils.readBoolean
|
static boolean readBoolean(Node node)
{
if (node == null)
{
throw new XmlException(
"Tried to read boolean value from null node");
}
String value = node.getFirstChild().getNodeValue();
return Boolean.parseBoolean(value);
}
|
java
|
static boolean readBoolean(Node node)
{
if (node == null)
{
throw new XmlException(
"Tried to read boolean value from null node");
}
String value = node.getFirstChild().getNodeValue();
return Boolean.parseBoolean(value);
}
|
[
"static",
"boolean",
"readBoolean",
"(",
"Node",
"node",
")",
"{",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"throw",
"new",
"XmlException",
"(",
"\"Tried to read boolean value from null node\"",
")",
";",
"}",
"String",
"value",
"=",
"node",
".",
"getFirstChild",
"(",
")",
".",
"getNodeValue",
"(",
")",
";",
"return",
"Boolean",
".",
"parseBoolean",
"(",
"value",
")",
";",
"}"
] |
Parse a boolean value from the first child of the given node.
@param node The node
@return The boolean value
@throws XmlException If the given node was <code>null</code>
|
[
"Parse",
"a",
"boolean",
"value",
"from",
"the",
"first",
"child",
"of",
"the",
"given",
"node",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/xml/XmlUtils.java#L558-L567
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.