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,300
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java
|
QueryParameters.getOrderList
|
public List<Integer> getOrderList(String key) {
List<Integer> result = new ArrayList<Integer>();
String processedKey = processKey(key);
String orderKey = null;
for (int i = 0; i < this.order.size(); i++) {
orderKey = this.order.get(i);
if (orderKey != null && orderKey.equals(processedKey) == true) {
result.add(i);
}
}
return result;
}
|
java
|
public List<Integer> getOrderList(String key) {
List<Integer> result = new ArrayList<Integer>();
String processedKey = processKey(key);
String orderKey = null;
for (int i = 0; i < this.order.size(); i++) {
orderKey = this.order.get(i);
if (orderKey != null && orderKey.equals(processedKey) == true) {
result.add(i);
}
}
return result;
}
|
[
"public",
"List",
"<",
"Integer",
">",
"getOrderList",
"(",
"String",
"key",
")",
"{",
"List",
"<",
"Integer",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
")",
";",
"String",
"processedKey",
"=",
"processKey",
"(",
"key",
")",
";",
"String",
"orderKey",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"order",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"orderKey",
"=",
"this",
".",
"order",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"orderKey",
"!=",
"null",
"&&",
"orderKey",
".",
"equals",
"(",
"processedKey",
")",
"==",
"true",
")",
"{",
"result",
".",
"add",
"(",
"i",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Returns list of positions of specified key
@param key Key
@return this instance of QueryParameters
|
[
"Returns",
"list",
"of",
"positions",
"of",
"specified",
"key"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java#L359-L373
|
149,301
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java
|
QueryParameters.isOutParameter
|
public boolean isOutParameter(String key) {
boolean isOut = false;
if (this.getDirection(processKey(key)) == Direction.INOUT || this.getDirection(processKey(key)) == Direction.OUT) {
isOut = true;
}
return isOut;
}
|
java
|
public boolean isOutParameter(String key) {
boolean isOut = false;
if (this.getDirection(processKey(key)) == Direction.INOUT || this.getDirection(processKey(key)) == Direction.OUT) {
isOut = true;
}
return isOut;
}
|
[
"public",
"boolean",
"isOutParameter",
"(",
"String",
"key",
")",
"{",
"boolean",
"isOut",
"=",
"false",
";",
"if",
"(",
"this",
".",
"getDirection",
"(",
"processKey",
"(",
"key",
")",
")",
"==",
"Direction",
".",
"INOUT",
"||",
"this",
".",
"getDirection",
"(",
"processKey",
"(",
"key",
")",
")",
"==",
"Direction",
".",
"OUT",
")",
"{",
"isOut",
"=",
"true",
";",
"}",
"return",
"isOut",
";",
"}"
] |
Checks is specified key is OUT parameter.
OUT and INOUT parameter would be considered as OUT parameter
@param key Key
@return true - if key is OUT parameter
|
[
"Checks",
"is",
"specified",
"key",
"is",
"OUT",
"parameter",
".",
"OUT",
"and",
"INOUT",
"parameter",
"would",
"be",
"considered",
"as",
"OUT",
"parameter"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java#L443-L451
|
149,302
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java
|
QueryParameters.isInParameter
|
public boolean isInParameter(String key) {
boolean isIn = false;
if (this.getDirection(processKey(key)) == Direction.INOUT || this.getDirection(processKey(key)) == Direction.IN) {
isIn = true;
}
return isIn;
}
|
java
|
public boolean isInParameter(String key) {
boolean isIn = false;
if (this.getDirection(processKey(key)) == Direction.INOUT || this.getDirection(processKey(key)) == Direction.IN) {
isIn = true;
}
return isIn;
}
|
[
"public",
"boolean",
"isInParameter",
"(",
"String",
"key",
")",
"{",
"boolean",
"isIn",
"=",
"false",
";",
"if",
"(",
"this",
".",
"getDirection",
"(",
"processKey",
"(",
"key",
")",
")",
"==",
"Direction",
".",
"INOUT",
"||",
"this",
".",
"getDirection",
"(",
"processKey",
"(",
"key",
")",
")",
"==",
"Direction",
".",
"IN",
")",
"{",
"isIn",
"=",
"true",
";",
"}",
"return",
"isIn",
";",
"}"
] |
Checks is specified key is IN parameter.
IN and INOUT parameter would be considered as IN parameter
@param key Key
@return true - if key is IN parameter
|
[
"Checks",
"is",
"specified",
"key",
"is",
"IN",
"parameter",
".",
"IN",
"and",
"INOUT",
"parameter",
"would",
"be",
"considered",
"as",
"IN",
"parameter"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java#L460-L468
|
149,303
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java
|
QueryParameters.getNameByPosition
|
public String getNameByPosition(Integer position) {
String name = null;
name = this.order.get(position);
return name;
}
|
java
|
public String getNameByPosition(Integer position) {
String name = null;
name = this.order.get(position);
return name;
}
|
[
"public",
"String",
"getNameByPosition",
"(",
"Integer",
"position",
")",
"{",
"String",
"name",
"=",
"null",
";",
"name",
"=",
"this",
".",
"order",
".",
"get",
"(",
"position",
")",
";",
"return",
"name",
";",
"}"
] |
Returns Key by searching key assigned to that position
@param position Position which would be searched
@return Key
|
[
"Returns",
"Key",
"by",
"searching",
"key",
"assigned",
"to",
"that",
"position"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java#L476-L482
|
149,304
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java
|
QueryParameters.getValueByPosition
|
public Object getValueByPosition(Integer position) throws NoSuchFieldException {
String name = null;
Object value = null;
name = this.getNameByPosition(position);
if (name != null) {
value = this.getValue(name);
} else {
throw new NoSuchFieldException();
}
return value;
}
|
java
|
public Object getValueByPosition(Integer position) throws NoSuchFieldException {
String name = null;
Object value = null;
name = this.getNameByPosition(position);
if (name != null) {
value = this.getValue(name);
} else {
throw new NoSuchFieldException();
}
return value;
}
|
[
"public",
"Object",
"getValueByPosition",
"(",
"Integer",
"position",
")",
"throws",
"NoSuchFieldException",
"{",
"String",
"name",
"=",
"null",
";",
"Object",
"value",
"=",
"null",
";",
"name",
"=",
"this",
".",
"getNameByPosition",
"(",
"position",
")",
";",
"if",
"(",
"name",
"!=",
"null",
")",
"{",
"value",
"=",
"this",
".",
"getValue",
"(",
"name",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"NoSuchFieldException",
"(",
")",
";",
"}",
"return",
"value",
";",
"}"
] |
Returns value by searching key assigned to that position
@param position Position which would be searched
@return Value
@throws NoSuchFieldException
|
[
"Returns",
"value",
"by",
"searching",
"key",
"assigned",
"to",
"that",
"position"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java#L491-L504
|
149,305
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java
|
QueryParameters.remove
|
public void remove(String key) {
String processedKey = processKey(key);
String orderKey = null;
// removing key set for all positions
for (int i = 0; i < this.order.size(); i++) {
orderKey = this.order.get(i);
if (orderKey != null && orderKey.equals(processedKey) == true) {
this.order.remove(i);
}
}
this.types.remove(processedKey);
this.direction.remove(processedKey);
this.values.remove(processedKey);
}
|
java
|
public void remove(String key) {
String processedKey = processKey(key);
String orderKey = null;
// removing key set for all positions
for (int i = 0; i < this.order.size(); i++) {
orderKey = this.order.get(i);
if (orderKey != null && orderKey.equals(processedKey) == true) {
this.order.remove(i);
}
}
this.types.remove(processedKey);
this.direction.remove(processedKey);
this.values.remove(processedKey);
}
|
[
"public",
"void",
"remove",
"(",
"String",
"key",
")",
"{",
"String",
"processedKey",
"=",
"processKey",
"(",
"key",
")",
";",
"String",
"orderKey",
"=",
"null",
";",
"// removing key set for all positions\r",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"order",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"orderKey",
"=",
"this",
".",
"order",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"orderKey",
"!=",
"null",
"&&",
"orderKey",
".",
"equals",
"(",
"processedKey",
")",
"==",
"true",
")",
"{",
"this",
".",
"order",
".",
"remove",
"(",
"i",
")",
";",
"}",
"}",
"this",
".",
"types",
".",
"remove",
"(",
"processedKey",
")",
";",
"this",
".",
"direction",
".",
"remove",
"(",
"processedKey",
")",
";",
"this",
".",
"values",
".",
"remove",
"(",
"processedKey",
")",
";",
"}"
] |
Removes specified key
@param key Key which would be removed
|
[
"Removes",
"specified",
"key"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java#L522-L538
|
149,306
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java
|
QueryParameters.getValuesArray
|
public Object[] getValuesArray() {
this.assertIncorrectOrder();
Object[] params = new Object[this.order.size()];
String parameterName = null;
for (int i = 0; i < this.order.size(); i++) {
parameterName = this.getNameByPosition(i);
params[i] = this.getValue(parameterName);
}
return params;
}
|
java
|
public Object[] getValuesArray() {
this.assertIncorrectOrder();
Object[] params = new Object[this.order.size()];
String parameterName = null;
for (int i = 0; i < this.order.size(); i++) {
parameterName = this.getNameByPosition(i);
params[i] = this.getValue(parameterName);
}
return params;
}
|
[
"public",
"Object",
"[",
"]",
"getValuesArray",
"(",
")",
"{",
"this",
".",
"assertIncorrectOrder",
"(",
")",
";",
"Object",
"[",
"]",
"params",
"=",
"new",
"Object",
"[",
"this",
".",
"order",
".",
"size",
"(",
")",
"]",
";",
"String",
"parameterName",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"order",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"parameterName",
"=",
"this",
".",
"getNameByPosition",
"(",
"i",
")",
";",
"params",
"[",
"i",
"]",
"=",
"this",
".",
"getValue",
"(",
"parameterName",
")",
";",
"}",
"return",
"params",
";",
"}"
] |
Utility function.
Returns array of values
@return array of values
|
[
"Utility",
"function",
".",
"Returns",
"array",
"of",
"values"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java#L698-L711
|
149,307
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java
|
QueryParameters.processKey
|
private String processKey(String key) {
AssertUtils.assertNotNull(key, "Key cannot be null");
String result = null;
if (this.isCaseSensitive() == false) {
result = key.toLowerCase(Locale.ENGLISH);
} else {
result = key;
}
return result;
}
|
java
|
private String processKey(String key) {
AssertUtils.assertNotNull(key, "Key cannot be null");
String result = null;
if (this.isCaseSensitive() == false) {
result = key.toLowerCase(Locale.ENGLISH);
} else {
result = key;
}
return result;
}
|
[
"private",
"String",
"processKey",
"(",
"String",
"key",
")",
"{",
"AssertUtils",
".",
"assertNotNull",
"(",
"key",
",",
"\"Key cannot be null\"",
")",
";",
"String",
"result",
"=",
"null",
";",
"if",
"(",
"this",
".",
"isCaseSensitive",
"(",
")",
"==",
"false",
")",
"{",
"result",
"=",
"key",
".",
"toLowerCase",
"(",
"Locale",
".",
"ENGLISH",
")",
";",
"}",
"else",
"{",
"result",
"=",
"key",
";",
"}",
"return",
"result",
";",
"}"
] |
Utility function.
Processes key and converts it's case if required
@param key Key
@return Processed Key
|
[
"Utility",
"function",
".",
"Processes",
"key",
"and",
"converts",
"it",
"s",
"case",
"if",
"required"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java#L787-L799
|
149,308
|
Viascom/groundwork
|
foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/query/FoxHttpRequestQuery.java
|
FoxHttpRequestQuery.parseObjectAsQueryMap
|
public void parseObjectAsQueryMap(List<String> params, Object o) throws FoxHttpRequestException {
try {
Class clazz = o.getClass();
HashMap<String, String> paramMap = new HashMap<>();
for (String param : params) {
Field field = clazz.getDeclaredField(param);
field.setAccessible(true);
String paramName = field.getName();
String value = String.valueOf(field.get(o));
if (field.get(o) != null && !value.isEmpty()) {
paramMap.put(paramName, value);
}
}
queryMap = paramMap;
} catch (Exception e) {
throw new FoxHttpRequestException(e);
}
}
|
java
|
public void parseObjectAsQueryMap(List<String> params, Object o) throws FoxHttpRequestException {
try {
Class clazz = o.getClass();
HashMap<String, String> paramMap = new HashMap<>();
for (String param : params) {
Field field = clazz.getDeclaredField(param);
field.setAccessible(true);
String paramName = field.getName();
String value = String.valueOf(field.get(o));
if (field.get(o) != null && !value.isEmpty()) {
paramMap.put(paramName, value);
}
}
queryMap = paramMap;
} catch (Exception e) {
throw new FoxHttpRequestException(e);
}
}
|
[
"public",
"void",
"parseObjectAsQueryMap",
"(",
"List",
"<",
"String",
">",
"params",
",",
"Object",
"o",
")",
"throws",
"FoxHttpRequestException",
"{",
"try",
"{",
"Class",
"clazz",
"=",
"o",
".",
"getClass",
"(",
")",
";",
"HashMap",
"<",
"String",
",",
"String",
">",
"paramMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"param",
":",
"params",
")",
"{",
"Field",
"field",
"=",
"clazz",
".",
"getDeclaredField",
"(",
"param",
")",
";",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"String",
"paramName",
"=",
"field",
".",
"getName",
"(",
")",
";",
"String",
"value",
"=",
"String",
".",
"valueOf",
"(",
"field",
".",
"get",
"(",
"o",
")",
")",
";",
"if",
"(",
"field",
".",
"get",
"(",
"o",
")",
"!=",
"null",
"&&",
"!",
"value",
".",
"isEmpty",
"(",
")",
")",
"{",
"paramMap",
".",
"put",
"(",
"paramName",
",",
"value",
")",
";",
"}",
"}",
"queryMap",
"=",
"paramMap",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"FoxHttpRequestException",
"(",
"e",
")",
";",
"}",
"}"
] |
Parse an object as query map
@param params list of attribute names which will be included
@param o object with the attributes
@throws FoxHttpRequestException can throw an exception if a field does not exist
|
[
"Parse",
"an",
"object",
"as",
"query",
"map"
] |
d3f7d0df65e2e75861fc7db938090683f2cdf919
|
https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/query/FoxHttpRequestQuery.java#L78-L95
|
149,309
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/output/MapOutputHandler.java
|
MapOutputHandler.handle
|
public Map<String, Object> handle(List<QueryParameters> outputList) throws MjdbcException {
return this.outputProcessor.toMap(outputList);
}
|
java
|
public Map<String, Object> handle(List<QueryParameters> outputList) throws MjdbcException {
return this.outputProcessor.toMap(outputList);
}
|
[
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"handle",
"(",
"List",
"<",
"QueryParameters",
">",
"outputList",
")",
"throws",
"MjdbcException",
"{",
"return",
"this",
".",
"outputProcessor",
".",
"toMap",
"(",
"outputList",
")",
";",
"}"
] |
Converts first row of query output into Map
@param outputList Query output
@return Map converted from first row of query output
@throws org.midao.jdbc.core.exception.MjdbcException
|
[
"Converts",
"first",
"row",
"of",
"query",
"output",
"into",
"Map"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/output/MapOutputHandler.java#L56-L58
|
149,310
|
geomajas/geomajas-project-graphics
|
graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java
|
SliderBar.onResize
|
public void onResize(int width, int height) {
// Center the line in the shell
int lineWidth = lineElement.getOffsetWidth();
lineLeftOffset = (width / 2) - (lineWidth / 2);
DOM.setStyleAttribute(lineElement, "left", lineLeftOffset + "px");
// Draw the other components
drawLabels();
drawTicks();
drawKnob();
}
|
java
|
public void onResize(int width, int height) {
// Center the line in the shell
int lineWidth = lineElement.getOffsetWidth();
lineLeftOffset = (width / 2) - (lineWidth / 2);
DOM.setStyleAttribute(lineElement, "left", lineLeftOffset + "px");
// Draw the other components
drawLabels();
drawTicks();
drawKnob();
}
|
[
"public",
"void",
"onResize",
"(",
"int",
"width",
",",
"int",
"height",
")",
"{",
"// Center the line in the shell\r",
"int",
"lineWidth",
"=",
"lineElement",
".",
"getOffsetWidth",
"(",
")",
";",
"lineLeftOffset",
"=",
"(",
"width",
"/",
"2",
")",
"-",
"(",
"lineWidth",
"/",
"2",
")",
";",
"DOM",
".",
"setStyleAttribute",
"(",
"lineElement",
",",
"\"left\"",
",",
"lineLeftOffset",
"+",
"\"px\"",
")",
";",
"// Draw the other components\r",
"drawLabels",
"(",
")",
";",
"drawTicks",
"(",
")",
";",
"drawKnob",
"(",
")",
";",
"}"
] |
This method is called when the dimensions of the parent element change. Subclasses should override this method as
needed.
@param width
the new client width of the element
@param height
the new client height of the element
|
[
"This",
"method",
"is",
"called",
"when",
"the",
"dimensions",
"of",
"the",
"parent",
"element",
"change",
".",
"Subclasses",
"should",
"override",
"this",
"method",
"as",
"needed",
"."
] |
1104196640e0ba455b8a619e774352a8e1e319ba
|
https://github.com/geomajas/geomajas-project-graphics/blob/1104196640e0ba455b8a619e774352a8e1e319ba/graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java#L520-L530
|
149,311
|
geomajas/geomajas-project-graphics
|
graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java
|
SliderBar.redraw
|
public void redraw() {
if (isAttached()) {
int width = getElement().getClientWidth();
int height = getElement().getClientHeight();
onResize(width, height);
}
}
|
java
|
public void redraw() {
if (isAttached()) {
int width = getElement().getClientWidth();
int height = getElement().getClientHeight();
onResize(width, height);
}
}
|
[
"public",
"void",
"redraw",
"(",
")",
"{",
"if",
"(",
"isAttached",
"(",
")",
")",
"{",
"int",
"width",
"=",
"getElement",
"(",
")",
".",
"getClientWidth",
"(",
")",
";",
"int",
"height",
"=",
"getElement",
"(",
")",
".",
"getClientHeight",
"(",
")",
";",
"onResize",
"(",
"width",
",",
"height",
")",
";",
"}",
"}"
] |
Redraw the progress bar when something changes the layout.
|
[
"Redraw",
"the",
"progress",
"bar",
"when",
"something",
"changes",
"the",
"layout",
"."
] |
1104196640e0ba455b8a619e774352a8e1e319ba
|
https://github.com/geomajas/geomajas-project-graphics/blob/1104196640e0ba455b8a619e774352a8e1e319ba/graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java#L535-L541
|
149,312
|
geomajas/geomajas-project-graphics
|
graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java
|
SliderBar.setCurrentValue
|
public void setCurrentValue(double curValue, boolean fireEvent) {
// Confine the value to the range
this.curValue = Math.max(minValue, Math.min(maxValue, curValue));
double remainder = (this.curValue - minValue) % stepSize;
this.curValue -= remainder;
// Go to next step if more than halfway there
if ((remainder > (stepSize / 2)) && ((this.curValue + stepSize) <= maxValue)) {
this.curValue += stepSize;
}
// Redraw the knob
drawKnob();
// Fire the ValueChangeEvent
if (fireEvent) {
ValueChangeEvent.fire(this, this.curValue);
}
}
|
java
|
public void setCurrentValue(double curValue, boolean fireEvent) {
// Confine the value to the range
this.curValue = Math.max(minValue, Math.min(maxValue, curValue));
double remainder = (this.curValue - minValue) % stepSize;
this.curValue -= remainder;
// Go to next step if more than halfway there
if ((remainder > (stepSize / 2)) && ((this.curValue + stepSize) <= maxValue)) {
this.curValue += stepSize;
}
// Redraw the knob
drawKnob();
// Fire the ValueChangeEvent
if (fireEvent) {
ValueChangeEvent.fire(this, this.curValue);
}
}
|
[
"public",
"void",
"setCurrentValue",
"(",
"double",
"curValue",
",",
"boolean",
"fireEvent",
")",
"{",
"// Confine the value to the range\r",
"this",
".",
"curValue",
"=",
"Math",
".",
"max",
"(",
"minValue",
",",
"Math",
".",
"min",
"(",
"maxValue",
",",
"curValue",
")",
")",
";",
"double",
"remainder",
"=",
"(",
"this",
".",
"curValue",
"-",
"minValue",
")",
"%",
"stepSize",
";",
"this",
".",
"curValue",
"-=",
"remainder",
";",
"// Go to next step if more than halfway there\r",
"if",
"(",
"(",
"remainder",
">",
"(",
"stepSize",
"/",
"2",
")",
")",
"&&",
"(",
"(",
"this",
".",
"curValue",
"+",
"stepSize",
")",
"<=",
"maxValue",
")",
")",
"{",
"this",
".",
"curValue",
"+=",
"stepSize",
";",
"}",
"// Redraw the knob\r",
"drawKnob",
"(",
")",
";",
"// Fire the ValueChangeEvent\r",
"if",
"(",
"fireEvent",
")",
"{",
"ValueChangeEvent",
".",
"fire",
"(",
"this",
",",
"this",
".",
"curValue",
")",
";",
"}",
"}"
] |
Set the current value and optionally fire the onValueChange event.
@param curValue
the current value
@param fireEvent
fire the onValue change event if true
|
[
"Set",
"the",
"current",
"value",
"and",
"optionally",
"fire",
"the",
"onValueChange",
"event",
"."
] |
1104196640e0ba455b8a619e774352a8e1e319ba
|
https://github.com/geomajas/geomajas-project-graphics/blob/1104196640e0ba455b8a619e774352a8e1e319ba/graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java#L561-L579
|
149,313
|
geomajas/geomajas-project-graphics
|
graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java
|
SliderBar.setEnabled
|
public void setEnabled(boolean enabled) {
this.enabled = enabled;
if (enabled) {
DOM.setElementProperty(lineElement, "className", SLIDER_LINE);
} else {
DOM.setElementProperty(lineElement, "className", SLIDER_LINE + " "
+ SLIDER_LINE_DISABLED);
}
redraw();
}
|
java
|
public void setEnabled(boolean enabled) {
this.enabled = enabled;
if (enabled) {
DOM.setElementProperty(lineElement, "className", SLIDER_LINE);
} else {
DOM.setElementProperty(lineElement, "className", SLIDER_LINE + " "
+ SLIDER_LINE_DISABLED);
}
redraw();
}
|
[
"public",
"void",
"setEnabled",
"(",
"boolean",
"enabled",
")",
"{",
"this",
".",
"enabled",
"=",
"enabled",
";",
"if",
"(",
"enabled",
")",
"{",
"DOM",
".",
"setElementProperty",
"(",
"lineElement",
",",
"\"className\"",
",",
"SLIDER_LINE",
")",
";",
"}",
"else",
"{",
"DOM",
".",
"setElementProperty",
"(",
"lineElement",
",",
"\"className\"",
",",
"SLIDER_LINE",
"+",
"\" \"",
"+",
"SLIDER_LINE_DISABLED",
")",
";",
"}",
"redraw",
"(",
")",
";",
"}"
] |
Sets whether this widget is enabled.
@param enabled
true to enable the widget, false to disable it
|
[
"Sets",
"whether",
"this",
"widget",
"is",
"enabled",
"."
] |
1104196640e0ba455b8a619e774352a8e1e319ba
|
https://github.com/geomajas/geomajas-project-graphics/blob/1104196640e0ba455b8a619e774352a8e1e319ba/graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java#L587-L596
|
149,314
|
geomajas/geomajas-project-graphics
|
graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java
|
SliderBar.getKnobPercent
|
protected double getKnobPercent() {
// If we have no range
if (maxValue <= minValue) {
return 0;
}
// Calculate the relative progress
double percent = (curValue - minValue) / (maxValue - minValue);
return Math.max(0.0, Math.min(1.0, percent));
}
|
java
|
protected double getKnobPercent() {
// If we have no range
if (maxValue <= minValue) {
return 0;
}
// Calculate the relative progress
double percent = (curValue - minValue) / (maxValue - minValue);
return Math.max(0.0, Math.min(1.0, percent));
}
|
[
"protected",
"double",
"getKnobPercent",
"(",
")",
"{",
"// If we have no range\r",
"if",
"(",
"maxValue",
"<=",
"minValue",
")",
"{",
"return",
"0",
";",
"}",
"// Calculate the relative progress\r",
"double",
"percent",
"=",
"(",
"curValue",
"-",
"minValue",
")",
"/",
"(",
"maxValue",
"-",
"minValue",
")",
";",
"return",
"Math",
".",
"max",
"(",
"0.0",
",",
"Math",
".",
"min",
"(",
"1.0",
",",
"percent",
")",
")",
";",
"}"
] |
Get the percentage of the knob's position relative to the size of the line. The return value will be between 0.0
and 1.0.
@return the current percent complete
|
[
"Get",
"the",
"percentage",
"of",
"the",
"knob",
"s",
"position",
"relative",
"to",
"the",
"size",
"of",
"the",
"line",
".",
"The",
"return",
"value",
"will",
"be",
"between",
"0",
".",
"0",
"and",
"1",
".",
"0",
"."
] |
1104196640e0ba455b8a619e774352a8e1e319ba
|
https://github.com/geomajas/geomajas-project-graphics/blob/1104196640e0ba455b8a619e774352a8e1e319ba/graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java#L736-L745
|
149,315
|
geomajas/geomajas-project-graphics
|
graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java
|
SliderBar.drawKnob
|
private void drawKnob() {
// Abort if not attached
if (!isAttached()) {
return;
}
// Move the knob to the correct position
Element knobElement = knobImage.getElement();
int lineWidth = lineElement.getOffsetWidth();
int knobWidth = knobElement.getOffsetWidth();
int knobLeftOffset = (int) (lineLeftOffset + (getKnobPercent() * lineWidth) - (knobWidth / 2));
knobLeftOffset = Math.min(knobLeftOffset, lineLeftOffset + lineWidth - (knobWidth / 2) - 1);
DOM.setStyleAttribute(knobElement, "left", knobLeftOffset + "px");
}
|
java
|
private void drawKnob() {
// Abort if not attached
if (!isAttached()) {
return;
}
// Move the knob to the correct position
Element knobElement = knobImage.getElement();
int lineWidth = lineElement.getOffsetWidth();
int knobWidth = knobElement.getOffsetWidth();
int knobLeftOffset = (int) (lineLeftOffset + (getKnobPercent() * lineWidth) - (knobWidth / 2));
knobLeftOffset = Math.min(knobLeftOffset, lineLeftOffset + lineWidth - (knobWidth / 2) - 1);
DOM.setStyleAttribute(knobElement, "left", knobLeftOffset + "px");
}
|
[
"private",
"void",
"drawKnob",
"(",
")",
"{",
"// Abort if not attached\r",
"if",
"(",
"!",
"isAttached",
"(",
")",
")",
"{",
"return",
";",
"}",
"// Move the knob to the correct position\r",
"Element",
"knobElement",
"=",
"knobImage",
".",
"getElement",
"(",
")",
";",
"int",
"lineWidth",
"=",
"lineElement",
".",
"getOffsetWidth",
"(",
")",
";",
"int",
"knobWidth",
"=",
"knobElement",
".",
"getOffsetWidth",
"(",
")",
";",
"int",
"knobLeftOffset",
"=",
"(",
"int",
")",
"(",
"lineLeftOffset",
"+",
"(",
"getKnobPercent",
"(",
")",
"*",
"lineWidth",
")",
"-",
"(",
"knobWidth",
"/",
"2",
")",
")",
";",
"knobLeftOffset",
"=",
"Math",
".",
"min",
"(",
"knobLeftOffset",
",",
"lineLeftOffset",
"+",
"lineWidth",
"-",
"(",
"knobWidth",
"/",
"2",
")",
"-",
"1",
")",
";",
"DOM",
".",
"setStyleAttribute",
"(",
"knobElement",
",",
"\"left\"",
",",
"knobLeftOffset",
"+",
"\"px\"",
")",
";",
"}"
] |
Draw the knob where it is supposed to be relative to the line.
|
[
"Draw",
"the",
"knob",
"where",
"it",
"is",
"supposed",
"to",
"be",
"relative",
"to",
"the",
"line",
"."
] |
1104196640e0ba455b8a619e774352a8e1e319ba
|
https://github.com/geomajas/geomajas-project-graphics/blob/1104196640e0ba455b8a619e774352a8e1e319ba/graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java#L763-L776
|
149,316
|
geomajas/geomajas-project-graphics
|
graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java
|
SliderBar.drawLabels
|
private void drawLabels() {
// Abort if not attached
if (!isAttached()) {
return;
}
// Draw the labels
int lineWidth = lineElement.getOffsetWidth();
if (numLabels > 0) {
// Create the labels or make them visible
for (int i = 0; i <= numLabels; i++) {
Element label = null;
if (i < labelElements.size()) {
label = labelElements.get(i);
} else { // Create the new label
label = DOM.createDiv();
DOM.setStyleAttribute(label, "position", "absolute");
DOM.setStyleAttribute(label, "display", "none");
if (enabled) {
DOM.setElementProperty(label, "className", "ks-SliderBar-label");
} else {
DOM.setElementProperty(label, "className", "ks-SliderBar-label-disabled");
}
DOM.appendChild(getElement(), label);
labelElements.add(label);
}
// Set the label text
double value = minValue + (getTotalRange() * i / numLabels);
DOM.setStyleAttribute(label, "visibility", "hidden");
DOM.setStyleAttribute(label, "display", "");
DOM.setElementProperty(label, "innerHTML", formatLabel(value));
// Move to the left so the label width is not clipped by the
// shell
DOM.setStyleAttribute(label, "left", "0px");
// Position the label and make it visible
int labelWidth = label.getOffsetWidth();
int labelLeftOffset = lineLeftOffset + (lineWidth * i / numLabels) - (labelWidth / 2);
// labelLeftOffset = Math.min(labelLeftOffset, lineLeftOffset + lineWidth - labelWidth);
// labelLeftOffset = Math.max(labelLeftOffset, lineLeftOffset);
DOM.setStyleAttribute(label, "left", labelLeftOffset + "px");
DOM.setStyleAttribute(label, "visibility", "visible");
}
// Hide unused labels
for (int i = (numLabels + 1); i < labelElements.size(); i++) {
DOM.setStyleAttribute(labelElements.get(i), "display", "none");
}
} else { // Hide all labels
for (Element elem : labelElements) {
DOM.setStyleAttribute(elem, "display", "none");
}
}
}
|
java
|
private void drawLabels() {
// Abort if not attached
if (!isAttached()) {
return;
}
// Draw the labels
int lineWidth = lineElement.getOffsetWidth();
if (numLabels > 0) {
// Create the labels or make them visible
for (int i = 0; i <= numLabels; i++) {
Element label = null;
if (i < labelElements.size()) {
label = labelElements.get(i);
} else { // Create the new label
label = DOM.createDiv();
DOM.setStyleAttribute(label, "position", "absolute");
DOM.setStyleAttribute(label, "display", "none");
if (enabled) {
DOM.setElementProperty(label, "className", "ks-SliderBar-label");
} else {
DOM.setElementProperty(label, "className", "ks-SliderBar-label-disabled");
}
DOM.appendChild(getElement(), label);
labelElements.add(label);
}
// Set the label text
double value = minValue + (getTotalRange() * i / numLabels);
DOM.setStyleAttribute(label, "visibility", "hidden");
DOM.setStyleAttribute(label, "display", "");
DOM.setElementProperty(label, "innerHTML", formatLabel(value));
// Move to the left so the label width is not clipped by the
// shell
DOM.setStyleAttribute(label, "left", "0px");
// Position the label and make it visible
int labelWidth = label.getOffsetWidth();
int labelLeftOffset = lineLeftOffset + (lineWidth * i / numLabels) - (labelWidth / 2);
// labelLeftOffset = Math.min(labelLeftOffset, lineLeftOffset + lineWidth - labelWidth);
// labelLeftOffset = Math.max(labelLeftOffset, lineLeftOffset);
DOM.setStyleAttribute(label, "left", labelLeftOffset + "px");
DOM.setStyleAttribute(label, "visibility", "visible");
}
// Hide unused labels
for (int i = (numLabels + 1); i < labelElements.size(); i++) {
DOM.setStyleAttribute(labelElements.get(i), "display", "none");
}
} else { // Hide all labels
for (Element elem : labelElements) {
DOM.setStyleAttribute(elem, "display", "none");
}
}
}
|
[
"private",
"void",
"drawLabels",
"(",
")",
"{",
"// Abort if not attached\r",
"if",
"(",
"!",
"isAttached",
"(",
")",
")",
"{",
"return",
";",
"}",
"// Draw the labels\r",
"int",
"lineWidth",
"=",
"lineElement",
".",
"getOffsetWidth",
"(",
")",
";",
"if",
"(",
"numLabels",
">",
"0",
")",
"{",
"// Create the labels or make them visible\r",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"numLabels",
";",
"i",
"++",
")",
"{",
"Element",
"label",
"=",
"null",
";",
"if",
"(",
"i",
"<",
"labelElements",
".",
"size",
"(",
")",
")",
"{",
"label",
"=",
"labelElements",
".",
"get",
"(",
"i",
")",
";",
"}",
"else",
"{",
"// Create the new label\r",
"label",
"=",
"DOM",
".",
"createDiv",
"(",
")",
";",
"DOM",
".",
"setStyleAttribute",
"(",
"label",
",",
"\"position\"",
",",
"\"absolute\"",
")",
";",
"DOM",
".",
"setStyleAttribute",
"(",
"label",
",",
"\"display\"",
",",
"\"none\"",
")",
";",
"if",
"(",
"enabled",
")",
"{",
"DOM",
".",
"setElementProperty",
"(",
"label",
",",
"\"className\"",
",",
"\"ks-SliderBar-label\"",
")",
";",
"}",
"else",
"{",
"DOM",
".",
"setElementProperty",
"(",
"label",
",",
"\"className\"",
",",
"\"ks-SliderBar-label-disabled\"",
")",
";",
"}",
"DOM",
".",
"appendChild",
"(",
"getElement",
"(",
")",
",",
"label",
")",
";",
"labelElements",
".",
"add",
"(",
"label",
")",
";",
"}",
"// Set the label text\r",
"double",
"value",
"=",
"minValue",
"+",
"(",
"getTotalRange",
"(",
")",
"*",
"i",
"/",
"numLabels",
")",
";",
"DOM",
".",
"setStyleAttribute",
"(",
"label",
",",
"\"visibility\"",
",",
"\"hidden\"",
")",
";",
"DOM",
".",
"setStyleAttribute",
"(",
"label",
",",
"\"display\"",
",",
"\"\"",
")",
";",
"DOM",
".",
"setElementProperty",
"(",
"label",
",",
"\"innerHTML\"",
",",
"formatLabel",
"(",
"value",
")",
")",
";",
"// Move to the left so the label width is not clipped by the\r",
"// shell\r",
"DOM",
".",
"setStyleAttribute",
"(",
"label",
",",
"\"left\"",
",",
"\"0px\"",
")",
";",
"// Position the label and make it visible\r",
"int",
"labelWidth",
"=",
"label",
".",
"getOffsetWidth",
"(",
")",
";",
"int",
"labelLeftOffset",
"=",
"lineLeftOffset",
"+",
"(",
"lineWidth",
"*",
"i",
"/",
"numLabels",
")",
"-",
"(",
"labelWidth",
"/",
"2",
")",
";",
"//\t\t\t\tlabelLeftOffset = Math.min(labelLeftOffset, lineLeftOffset + lineWidth - labelWidth);\r",
"//\t\t\t\tlabelLeftOffset = Math.max(labelLeftOffset, lineLeftOffset);\r",
"DOM",
".",
"setStyleAttribute",
"(",
"label",
",",
"\"left\"",
",",
"labelLeftOffset",
"+",
"\"px\"",
")",
";",
"DOM",
".",
"setStyleAttribute",
"(",
"label",
",",
"\"visibility\"",
",",
"\"visible\"",
")",
";",
"}",
"// Hide unused labels\r",
"for",
"(",
"int",
"i",
"=",
"(",
"numLabels",
"+",
"1",
")",
";",
"i",
"<",
"labelElements",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"DOM",
".",
"setStyleAttribute",
"(",
"labelElements",
".",
"get",
"(",
"i",
")",
",",
"\"display\"",
",",
"\"none\"",
")",
";",
"}",
"}",
"else",
"{",
"// Hide all labels\r",
"for",
"(",
"Element",
"elem",
":",
"labelElements",
")",
"{",
"DOM",
".",
"setStyleAttribute",
"(",
"elem",
",",
"\"display\"",
",",
"\"none\"",
")",
";",
"}",
"}",
"}"
] |
Draw the labels along the line. NOT USED IN KEYSTONE
|
[
"Draw",
"the",
"labels",
"along",
"the",
"line",
".",
"NOT",
"USED",
"IN",
"KEYSTONE"
] |
1104196640e0ba455b8a619e774352a8e1e319ba
|
https://github.com/geomajas/geomajas-project-graphics/blob/1104196640e0ba455b8a619e774352a8e1e319ba/graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java#L781-L836
|
149,317
|
geomajas/geomajas-project-graphics
|
graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java
|
SliderBar.drawTicks
|
private void drawTicks() {
// Abort if not attached
if (!isAttached()) {
return;
}
// Draw the ticks
int lineWidth = lineElement.getOffsetWidth();
if (numTicks > 0) {
// Create the ticks or make them visible
for (int i = 0; i <= numTicks; i++) {
Element tick = null;
if (i < tickElements.size()) {
tick = tickElements.get(i);
} else { // Create the new tick
tick = DOM.createDiv();
DOM.setStyleAttribute(tick, "position", "absolute");
DOM.setStyleAttribute(tick, "display", "none");
DOM.appendChild(getElement(), tick);
tickElements.add(tick);
}
if (enabled) {
DOM.setElementProperty(tick, "className", SLIDER_TICK);
} else {
DOM.setElementProperty(tick, "className", SLIDER_TICK + " "
+ SLIDER_TICK_SLIDING);
}
// Position the tick and make it visible
DOM.setStyleAttribute(tick, "visibility", "hidden");
DOM.setStyleAttribute(tick, "display", "");
int tickWidth = tick.getOffsetWidth();
int tickLeftOffset = lineLeftOffset + (lineWidth * i / numTicks) - (tickWidth / 2);
tickLeftOffset = Math.min(tickLeftOffset, lineLeftOffset + lineWidth - tickWidth);
DOM.setStyleAttribute(tick, "left", tickLeftOffset + "px");
DOM.setStyleAttribute(tick, "visibility", "visible");
}
// Hide unused ticks
for (int i = (numTicks + 1); i < tickElements.size(); i++) {
DOM.setStyleAttribute(tickElements.get(i), "display", "none");
}
} else { // Hide all ticks
for (Element elem : tickElements) {
DOM.setStyleAttribute(elem, "display", "none");
}
}
}
|
java
|
private void drawTicks() {
// Abort if not attached
if (!isAttached()) {
return;
}
// Draw the ticks
int lineWidth = lineElement.getOffsetWidth();
if (numTicks > 0) {
// Create the ticks or make them visible
for (int i = 0; i <= numTicks; i++) {
Element tick = null;
if (i < tickElements.size()) {
tick = tickElements.get(i);
} else { // Create the new tick
tick = DOM.createDiv();
DOM.setStyleAttribute(tick, "position", "absolute");
DOM.setStyleAttribute(tick, "display", "none");
DOM.appendChild(getElement(), tick);
tickElements.add(tick);
}
if (enabled) {
DOM.setElementProperty(tick, "className", SLIDER_TICK);
} else {
DOM.setElementProperty(tick, "className", SLIDER_TICK + " "
+ SLIDER_TICK_SLIDING);
}
// Position the tick and make it visible
DOM.setStyleAttribute(tick, "visibility", "hidden");
DOM.setStyleAttribute(tick, "display", "");
int tickWidth = tick.getOffsetWidth();
int tickLeftOffset = lineLeftOffset + (lineWidth * i / numTicks) - (tickWidth / 2);
tickLeftOffset = Math.min(tickLeftOffset, lineLeftOffset + lineWidth - tickWidth);
DOM.setStyleAttribute(tick, "left", tickLeftOffset + "px");
DOM.setStyleAttribute(tick, "visibility", "visible");
}
// Hide unused ticks
for (int i = (numTicks + 1); i < tickElements.size(); i++) {
DOM.setStyleAttribute(tickElements.get(i), "display", "none");
}
} else { // Hide all ticks
for (Element elem : tickElements) {
DOM.setStyleAttribute(elem, "display", "none");
}
}
}
|
[
"private",
"void",
"drawTicks",
"(",
")",
"{",
"// Abort if not attached\r",
"if",
"(",
"!",
"isAttached",
"(",
")",
")",
"{",
"return",
";",
"}",
"// Draw the ticks\r",
"int",
"lineWidth",
"=",
"lineElement",
".",
"getOffsetWidth",
"(",
")",
";",
"if",
"(",
"numTicks",
">",
"0",
")",
"{",
"// Create the ticks or make them visible\r",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"numTicks",
";",
"i",
"++",
")",
"{",
"Element",
"tick",
"=",
"null",
";",
"if",
"(",
"i",
"<",
"tickElements",
".",
"size",
"(",
")",
")",
"{",
"tick",
"=",
"tickElements",
".",
"get",
"(",
"i",
")",
";",
"}",
"else",
"{",
"// Create the new tick\r",
"tick",
"=",
"DOM",
".",
"createDiv",
"(",
")",
";",
"DOM",
".",
"setStyleAttribute",
"(",
"tick",
",",
"\"position\"",
",",
"\"absolute\"",
")",
";",
"DOM",
".",
"setStyleAttribute",
"(",
"tick",
",",
"\"display\"",
",",
"\"none\"",
")",
";",
"DOM",
".",
"appendChild",
"(",
"getElement",
"(",
")",
",",
"tick",
")",
";",
"tickElements",
".",
"add",
"(",
"tick",
")",
";",
"}",
"if",
"(",
"enabled",
")",
"{",
"DOM",
".",
"setElementProperty",
"(",
"tick",
",",
"\"className\"",
",",
"SLIDER_TICK",
")",
";",
"}",
"else",
"{",
"DOM",
".",
"setElementProperty",
"(",
"tick",
",",
"\"className\"",
",",
"SLIDER_TICK",
"+",
"\" \"",
"+",
"SLIDER_TICK_SLIDING",
")",
";",
"}",
"// Position the tick and make it visible\r",
"DOM",
".",
"setStyleAttribute",
"(",
"tick",
",",
"\"visibility\"",
",",
"\"hidden\"",
")",
";",
"DOM",
".",
"setStyleAttribute",
"(",
"tick",
",",
"\"display\"",
",",
"\"\"",
")",
";",
"int",
"tickWidth",
"=",
"tick",
".",
"getOffsetWidth",
"(",
")",
";",
"int",
"tickLeftOffset",
"=",
"lineLeftOffset",
"+",
"(",
"lineWidth",
"*",
"i",
"/",
"numTicks",
")",
"-",
"(",
"tickWidth",
"/",
"2",
")",
";",
"tickLeftOffset",
"=",
"Math",
".",
"min",
"(",
"tickLeftOffset",
",",
"lineLeftOffset",
"+",
"lineWidth",
"-",
"tickWidth",
")",
";",
"DOM",
".",
"setStyleAttribute",
"(",
"tick",
",",
"\"left\"",
",",
"tickLeftOffset",
"+",
"\"px\"",
")",
";",
"DOM",
".",
"setStyleAttribute",
"(",
"tick",
",",
"\"visibility\"",
",",
"\"visible\"",
")",
";",
"}",
"// Hide unused ticks\r",
"for",
"(",
"int",
"i",
"=",
"(",
"numTicks",
"+",
"1",
")",
";",
"i",
"<",
"tickElements",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"DOM",
".",
"setStyleAttribute",
"(",
"tickElements",
".",
"get",
"(",
"i",
")",
",",
"\"display\"",
",",
"\"none\"",
")",
";",
"}",
"}",
"else",
"{",
"// Hide all ticks\r",
"for",
"(",
"Element",
"elem",
":",
"tickElements",
")",
"{",
"DOM",
".",
"setStyleAttribute",
"(",
"elem",
",",
"\"display\"",
",",
"\"none\"",
")",
";",
"}",
"}",
"}"
] |
Draw the tick along the line.
|
[
"Draw",
"the",
"tick",
"along",
"the",
"line",
"."
] |
1104196640e0ba455b8a619e774352a8e1e319ba
|
https://github.com/geomajas/geomajas-project-graphics/blob/1104196640e0ba455b8a619e774352a8e1e319ba/graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java#L841-L887
|
149,318
|
geomajas/geomajas-project-graphics
|
graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java
|
SliderBar.slideKnob
|
private void slideKnob(Event event) {
int x = DOM.eventGetClientX(event);
if (x > 0) {
int lineWidth = lineElement.getOffsetWidth();
int lineLeft = lineElement.getAbsoluteLeft();
double percent = (double) (x - lineLeft) / lineWidth * 1.0;
setCurrentValue(getTotalRange() * percent + minValue, true);
}
}
|
java
|
private void slideKnob(Event event) {
int x = DOM.eventGetClientX(event);
if (x > 0) {
int lineWidth = lineElement.getOffsetWidth();
int lineLeft = lineElement.getAbsoluteLeft();
double percent = (double) (x - lineLeft) / lineWidth * 1.0;
setCurrentValue(getTotalRange() * percent + minValue, true);
}
}
|
[
"private",
"void",
"slideKnob",
"(",
"Event",
"event",
")",
"{",
"int",
"x",
"=",
"DOM",
".",
"eventGetClientX",
"(",
"event",
")",
";",
"if",
"(",
"x",
">",
"0",
")",
"{",
"int",
"lineWidth",
"=",
"lineElement",
".",
"getOffsetWidth",
"(",
")",
";",
"int",
"lineLeft",
"=",
"lineElement",
".",
"getAbsoluteLeft",
"(",
")",
";",
"double",
"percent",
"=",
"(",
"double",
")",
"(",
"x",
"-",
"lineLeft",
")",
"/",
"lineWidth",
"*",
"1.0",
";",
"setCurrentValue",
"(",
"getTotalRange",
"(",
")",
"*",
"percent",
"+",
"minValue",
",",
"true",
")",
";",
"}",
"}"
] |
Slide the knob to a new location.
@param event
the mouse event
|
[
"Slide",
"the",
"knob",
"to",
"a",
"new",
"location",
"."
] |
1104196640e0ba455b8a619e774352a8e1e319ba
|
https://github.com/geomajas/geomajas-project-graphics/blob/1104196640e0ba455b8a619e774352a8e1e319ba/graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java#L910-L918
|
149,319
|
geomajas/geomajas-project-graphics
|
graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java
|
SliderBar.startSliding
|
private void startSliding(boolean highlight, boolean fireEvent) {
if (highlight) {
DOM.setElementProperty(lineElement, "className", SLIDER_LINE + " "
+ SLIDER_LINE_SLIDING);
DOM.setElementProperty(knobImage.getElement(), "className", SLIDER_KNOB + " "
+ SLIDER_KNOB_SLIDING);
}
}
|
java
|
private void startSliding(boolean highlight, boolean fireEvent) {
if (highlight) {
DOM.setElementProperty(lineElement, "className", SLIDER_LINE + " "
+ SLIDER_LINE_SLIDING);
DOM.setElementProperty(knobImage.getElement(), "className", SLIDER_KNOB + " "
+ SLIDER_KNOB_SLIDING);
}
}
|
[
"private",
"void",
"startSliding",
"(",
"boolean",
"highlight",
",",
"boolean",
"fireEvent",
")",
"{",
"if",
"(",
"highlight",
")",
"{",
"DOM",
".",
"setElementProperty",
"(",
"lineElement",
",",
"\"className\"",
",",
"SLIDER_LINE",
"+",
"\" \"",
"+",
"SLIDER_LINE_SLIDING",
")",
";",
"DOM",
".",
"setElementProperty",
"(",
"knobImage",
".",
"getElement",
"(",
")",
",",
"\"className\"",
",",
"SLIDER_KNOB",
"+",
"\" \"",
"+",
"SLIDER_KNOB_SLIDING",
")",
";",
"}",
"}"
] |
Start sliding the knob.
@param highlight
true to change the style
@param fireEvent
true to fire the event
|
[
"Start",
"sliding",
"the",
"knob",
"."
] |
1104196640e0ba455b8a619e774352a8e1e319ba
|
https://github.com/geomajas/geomajas-project-graphics/blob/1104196640e0ba455b8a619e774352a8e1e319ba/graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java#L928-L935
|
149,320
|
geomajas/geomajas-project-graphics
|
graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java
|
SliderBar.stopSliding
|
private void stopSliding(boolean unhighlight, boolean fireEvent) {
if (unhighlight) {
DOM.setElementProperty(lineElement, "className", SLIDER_LINE);
DOM.setElementProperty(knobImage.getElement(), "className", SLIDER_KNOB);
}
}
|
java
|
private void stopSliding(boolean unhighlight, boolean fireEvent) {
if (unhighlight) {
DOM.setElementProperty(lineElement, "className", SLIDER_LINE);
DOM.setElementProperty(knobImage.getElement(), "className", SLIDER_KNOB);
}
}
|
[
"private",
"void",
"stopSliding",
"(",
"boolean",
"unhighlight",
",",
"boolean",
"fireEvent",
")",
"{",
"if",
"(",
"unhighlight",
")",
"{",
"DOM",
".",
"setElementProperty",
"(",
"lineElement",
",",
"\"className\"",
",",
"SLIDER_LINE",
")",
";",
"DOM",
".",
"setElementProperty",
"(",
"knobImage",
".",
"getElement",
"(",
")",
",",
"\"className\"",
",",
"SLIDER_KNOB",
")",
";",
"}",
"}"
] |
Stop sliding the knob.
@param unhighlight
true to change the style
@param fireEvent
true to fire the event
|
[
"Stop",
"sliding",
"the",
"knob",
"."
] |
1104196640e0ba455b8a619e774352a8e1e319ba
|
https://github.com/geomajas/geomajas-project-graphics/blob/1104196640e0ba455b8a619e774352a8e1e319ba/graphics/src/main/java/org/geomajas/graphics/client/widget/SliderBar.java#L945-L951
|
149,321
|
javagl/Common
|
src/main/java/de/javagl/common/iteration/Iterators.java
|
Iterators.toList
|
public static <T> List<T> toList(Iterator<T> iterator)
{
Objects.requireNonNull(iterator, "The iterator is null");
return Iterators.toCollection(iterator, new ArrayList<T>());
}
|
java
|
public static <T> List<T> toList(Iterator<T> iterator)
{
Objects.requireNonNull(iterator, "The iterator is null");
return Iterators.toCollection(iterator, new ArrayList<T>());
}
|
[
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"toList",
"(",
"Iterator",
"<",
"T",
">",
"iterator",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"iterator",
",",
"\"The iterator is null\"",
")",
";",
"return",
"Iterators",
".",
"toCollection",
"(",
"iterator",
",",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
")",
";",
"}"
] |
Drains all elements from the given iterator into a list
@param <T> The element type
@param iterator The iterator
@return The list
|
[
"Drains",
"all",
"elements",
"from",
"the",
"given",
"iterator",
"into",
"a",
"list"
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/iteration/Iterators.java#L54-L58
|
149,322
|
javagl/Common
|
src/main/java/de/javagl/common/iteration/Iterators.java
|
Iterators.toSet
|
public static <T> Set<T> toSet(Iterator<T> iterator)
{
Objects.requireNonNull(iterator, "The iterator is null");
return Iterators.toCollection(iterator, new LinkedHashSet<T>());
}
|
java
|
public static <T> Set<T> toSet(Iterator<T> iterator)
{
Objects.requireNonNull(iterator, "The iterator is null");
return Iterators.toCollection(iterator, new LinkedHashSet<T>());
}
|
[
"public",
"static",
"<",
"T",
">",
"Set",
"<",
"T",
">",
"toSet",
"(",
"Iterator",
"<",
"T",
">",
"iterator",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"iterator",
",",
"\"The iterator is null\"",
")",
";",
"return",
"Iterators",
".",
"toCollection",
"(",
"iterator",
",",
"new",
"LinkedHashSet",
"<",
"T",
">",
"(",
")",
")",
";",
"}"
] |
Drains all elements from the given iterator into a set
@param <T> The element type
@param iterator The iterator
@return The set
|
[
"Drains",
"all",
"elements",
"from",
"the",
"given",
"iterator",
"into",
"a",
"set"
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/iteration/Iterators.java#L67-L71
|
149,323
|
javagl/Common
|
src/main/java/de/javagl/common/iteration/Iterators.java
|
Iterators.toCollection
|
public static <T, C extends Collection<? super T>> C toCollection(
Iterator<T> iterator, C collection)
{
Objects.requireNonNull(iterator, "The iterator is null");
Objects.requireNonNull(iterator, "The collection is null");
while (iterator.hasNext())
{
collection.add(iterator.next());
}
return collection;
}
|
java
|
public static <T, C extends Collection<? super T>> C toCollection(
Iterator<T> iterator, C collection)
{
Objects.requireNonNull(iterator, "The iterator is null");
Objects.requireNonNull(iterator, "The collection is null");
while (iterator.hasNext())
{
collection.add(iterator.next());
}
return collection;
}
|
[
"public",
"static",
"<",
"T",
",",
"C",
"extends",
"Collection",
"<",
"?",
"super",
"T",
">",
">",
"C",
"toCollection",
"(",
"Iterator",
"<",
"T",
">",
"iterator",
",",
"C",
"collection",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"iterator",
",",
"\"The iterator is null\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"iterator",
",",
"\"The collection is null\"",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"collection",
".",
"add",
"(",
"iterator",
".",
"next",
"(",
")",
")",
";",
"}",
"return",
"collection",
";",
"}"
] |
Drains all elements that are provided by the given iterator
into the given collection
@param <T> The element type
@param <C> The collection type
@param iterator The iterator
@param collection The target collection
@return The given collection
|
[
"Drains",
"all",
"elements",
"that",
"are",
"provided",
"by",
"the",
"given",
"iterator",
"into",
"the",
"given",
"collection"
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/iteration/Iterators.java#L83-L93
|
149,324
|
javagl/Common
|
src/main/java/de/javagl/common/iteration/Iterators.java
|
Iterators.weakeningIterator
|
public static <T> Iterator<T> weakeningIterator(
final Iterator<? extends T> delegate)
{
Objects.requireNonNull(delegate, "The delegate is null");
return new Iterator<T>()
{
@Override
public boolean hasNext()
{
return delegate.hasNext();
}
@Override
public T next()
{
return delegate.next();
}
@Override
public void remove()
{
delegate.remove();
}
};
}
|
java
|
public static <T> Iterator<T> weakeningIterator(
final Iterator<? extends T> delegate)
{
Objects.requireNonNull(delegate, "The delegate is null");
return new Iterator<T>()
{
@Override
public boolean hasNext()
{
return delegate.hasNext();
}
@Override
public T next()
{
return delegate.next();
}
@Override
public void remove()
{
delegate.remove();
}
};
}
|
[
"public",
"static",
"<",
"T",
">",
"Iterator",
"<",
"T",
">",
"weakeningIterator",
"(",
"final",
"Iterator",
"<",
"?",
"extends",
"T",
">",
"delegate",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"delegate",
",",
"\"The delegate is null\"",
")",
";",
"return",
"new",
"Iterator",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"hasNext",
"(",
")",
"{",
"return",
"delegate",
".",
"hasNext",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"T",
"next",
"(",
")",
"{",
"return",
"delegate",
".",
"next",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"remove",
"(",
")",
"{",
"delegate",
".",
"remove",
"(",
")",
";",
"}",
"}",
";",
"}"
] |
Returns an iterator that removes the type bound
of another iterator
@param <T> The element type
@param delegate The delegate iterator
@return The new iterator
|
[
"Returns",
"an",
"iterator",
"that",
"removes",
"the",
"type",
"bound",
"of",
"another",
"iterator"
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/iteration/Iterators.java#L103-L127
|
149,325
|
javagl/Common
|
src/main/java/de/javagl/common/iteration/Iterators.java
|
Iterators.iteratorOverIterators
|
public static <T> Iterator<T> iteratorOverIterators(
Iterator<? extends T> iterator0, Iterator<? extends T> iterator1)
{
Objects.requireNonNull(iterator0, "The iterator0 is null");
Objects.requireNonNull(iterator1, "The iterator1 is null");
List<Iterator<? extends T>> iterators =
new ArrayList<Iterator<? extends T>>(2);
iterators.add(iterator0);
iterators.add(iterator1);
return Iterators.iteratorOverIterators(iterators.iterator());
}
|
java
|
public static <T> Iterator<T> iteratorOverIterators(
Iterator<? extends T> iterator0, Iterator<? extends T> iterator1)
{
Objects.requireNonNull(iterator0, "The iterator0 is null");
Objects.requireNonNull(iterator1, "The iterator1 is null");
List<Iterator<? extends T>> iterators =
new ArrayList<Iterator<? extends T>>(2);
iterators.add(iterator0);
iterators.add(iterator1);
return Iterators.iteratorOverIterators(iterators.iterator());
}
|
[
"public",
"static",
"<",
"T",
">",
"Iterator",
"<",
"T",
">",
"iteratorOverIterators",
"(",
"Iterator",
"<",
"?",
"extends",
"T",
">",
"iterator0",
",",
"Iterator",
"<",
"?",
"extends",
"T",
">",
"iterator1",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"iterator0",
",",
"\"The iterator0 is null\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"iterator1",
",",
"\"The iterator1 is null\"",
")",
";",
"List",
"<",
"Iterator",
"<",
"?",
"extends",
"T",
">",
">",
"iterators",
"=",
"new",
"ArrayList",
"<",
"Iterator",
"<",
"?",
"extends",
"T",
">",
">",
"(",
"2",
")",
";",
"iterators",
".",
"add",
"(",
"iterator0",
")",
";",
"iterators",
".",
"add",
"(",
"iterator1",
")",
";",
"return",
"Iterators",
".",
"iteratorOverIterators",
"(",
"iterators",
".",
"iterator",
"(",
")",
")",
";",
"}"
] |
Returns an iterator that combines the given iterators.
@param <T> The element type
@param iterator0 The first iterator
@param iterator1 The second iterator
@return The iterator
|
[
"Returns",
"an",
"iterator",
"that",
"combines",
"the",
"given",
"iterators",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/iteration/Iterators.java#L137-L147
|
149,326
|
javagl/Common
|
src/main/java/de/javagl/common/iteration/Iterators.java
|
Iterators.iteratorOverIterators
|
public static <S extends Iterator<? extends T>, T> Iterator<T>
iteratorOverIterators(Iterator<S> iteratorsIterator)
{
Objects.requireNonNull(iteratorsIterator,
"The iteratorsIterator is null");
return new CombiningIterator<T>(iteratorsIterator);
}
|
java
|
public static <S extends Iterator<? extends T>, T> Iterator<T>
iteratorOverIterators(Iterator<S> iteratorsIterator)
{
Objects.requireNonNull(iteratorsIterator,
"The iteratorsIterator is null");
return new CombiningIterator<T>(iteratorsIterator);
}
|
[
"public",
"static",
"<",
"S",
"extends",
"Iterator",
"<",
"?",
"extends",
"T",
">",
",",
"T",
">",
"Iterator",
"<",
"T",
">",
"iteratorOverIterators",
"(",
"Iterator",
"<",
"S",
">",
"iteratorsIterator",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"iteratorsIterator",
",",
"\"The iteratorsIterator is null\"",
")",
";",
"return",
"new",
"CombiningIterator",
"<",
"T",
">",
"(",
"iteratorsIterator",
")",
";",
"}"
] |
Returns an iterator that combines the iterators
that are returned by the given iterator.
@param <S> The iterator type
@param <T> The element type
@param iteratorsIterator The iterator iterator. May not provide
<code>null</code> iterators.
@return The iterator
|
[
"Returns",
"an",
"iterator",
"that",
"combines",
"the",
"iterators",
"that",
"are",
"returned",
"by",
"the",
"given",
"iterator",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/iteration/Iterators.java#L159-L165
|
149,327
|
javagl/Common
|
src/main/java/de/javagl/common/iteration/Iterators.java
|
Iterators.iteratorOverIterators
|
public static <S extends Iterator<? extends T>, T> Iterator<T>
iteratorOverIterators(Iterable<S> iteratorsIterable)
{
Objects.requireNonNull(iteratorsIterable,
"The iteratorsIterable is null");
return new CombiningIterator<T>(iteratorsIterable.iterator());
}
|
java
|
public static <S extends Iterator<? extends T>, T> Iterator<T>
iteratorOverIterators(Iterable<S> iteratorsIterable)
{
Objects.requireNonNull(iteratorsIterable,
"The iteratorsIterable is null");
return new CombiningIterator<T>(iteratorsIterable.iterator());
}
|
[
"public",
"static",
"<",
"S",
"extends",
"Iterator",
"<",
"?",
"extends",
"T",
">",
",",
"T",
">",
"Iterator",
"<",
"T",
">",
"iteratorOverIterators",
"(",
"Iterable",
"<",
"S",
">",
"iteratorsIterable",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"iteratorsIterable",
",",
"\"The iteratorsIterable is null\"",
")",
";",
"return",
"new",
"CombiningIterator",
"<",
"T",
">",
"(",
"iteratorsIterable",
".",
"iterator",
"(",
")",
")",
";",
"}"
] |
Returns an iterator that combines the iterators that
are returned by the iterator that is returned by the
given iterable.
@param <S> The iterator type
@param <T> The element type
@param iteratorsIterable The iterable for the iterators. May not
provide <code>null</code> iterators.
@return The iterator
|
[
"Returns",
"an",
"iterator",
"that",
"combines",
"the",
"iterators",
"that",
"are",
"returned",
"by",
"the",
"iterator",
"that",
"is",
"returned",
"by",
"the",
"given",
"iterable",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/iteration/Iterators.java#L178-L184
|
149,328
|
javagl/Common
|
src/main/java/de/javagl/common/iteration/Iterators.java
|
Iterators.iteratorOverIterables
|
public static <S extends Iterable<? extends T>, T> Iterator<T>
iteratorOverIterables(Iterator<S> iterablesIterator)
{
Objects.requireNonNull(iterablesIterator,
"The iterablesIterator is null");
TransformingIterator<S, Iterator<? extends T>> iteratorIterator =
new TransformingIterator<S, Iterator<? extends T>>(
iterablesIterator, iterable -> iterable.iterator());
return new CombiningIterator<T>(iteratorIterator);
}
|
java
|
public static <S extends Iterable<? extends T>, T> Iterator<T>
iteratorOverIterables(Iterator<S> iterablesIterator)
{
Objects.requireNonNull(iterablesIterator,
"The iterablesIterator is null");
TransformingIterator<S, Iterator<? extends T>> iteratorIterator =
new TransformingIterator<S, Iterator<? extends T>>(
iterablesIterator, iterable -> iterable.iterator());
return new CombiningIterator<T>(iteratorIterator);
}
|
[
"public",
"static",
"<",
"S",
"extends",
"Iterable",
"<",
"?",
"extends",
"T",
">",
",",
"T",
">",
"Iterator",
"<",
"T",
">",
"iteratorOverIterables",
"(",
"Iterator",
"<",
"S",
">",
"iterablesIterator",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"iterablesIterator",
",",
"\"The iterablesIterator is null\"",
")",
";",
"TransformingIterator",
"<",
"S",
",",
"Iterator",
"<",
"?",
"extends",
"T",
">",
">",
"iteratorIterator",
"=",
"new",
"TransformingIterator",
"<",
"S",
",",
"Iterator",
"<",
"?",
"extends",
"T",
">",
">",
"(",
"iterablesIterator",
",",
"iterable",
"->",
"iterable",
".",
"iterator",
"(",
")",
")",
";",
"return",
"new",
"CombiningIterator",
"<",
"T",
">",
"(",
"iteratorIterator",
")",
";",
"}"
] |
Returns an iterator that combines the iterators that are
returned by the iterables that are provided by the
given iterator
@param <S> The iterable type
@param <T> The element type
@param iterablesIterator The iterator over the iterables.
May not provide <code>null</code> iterables
@return The iterator
|
[
"Returns",
"an",
"iterator",
"that",
"combines",
"the",
"iterators",
"that",
"are",
"returned",
"by",
"the",
"iterables",
"that",
"are",
"provided",
"by",
"the",
"given",
"iterator"
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/iteration/Iterators.java#L197-L206
|
149,329
|
javagl/Common
|
src/main/java/de/javagl/common/iteration/Iterators.java
|
Iterators.iteratorOverIterables
|
public static <S extends Iterable<? extends T>, T> Iterator<T>
iteratorOverIterables(Iterable<S> iterablesIterable)
{
Objects.requireNonNull(iterablesIterable,
"The iterablesIterable is null");
return iteratorOverIterables(iterablesIterable.iterator());
}
|
java
|
public static <S extends Iterable<? extends T>, T> Iterator<T>
iteratorOverIterables(Iterable<S> iterablesIterable)
{
Objects.requireNonNull(iterablesIterable,
"The iterablesIterable is null");
return iteratorOverIterables(iterablesIterable.iterator());
}
|
[
"public",
"static",
"<",
"S",
"extends",
"Iterable",
"<",
"?",
"extends",
"T",
">",
",",
"T",
">",
"Iterator",
"<",
"T",
">",
"iteratorOverIterables",
"(",
"Iterable",
"<",
"S",
">",
"iterablesIterable",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"iterablesIterable",
",",
"\"The iterablesIterable is null\"",
")",
";",
"return",
"iteratorOverIterables",
"(",
"iterablesIterable",
".",
"iterator",
"(",
")",
")",
";",
"}"
] |
Returns an iterator that combines the iterators that are
returned by the iterables that are provided by the iterator
that is provided by the given iterable
@param <S> The iterable type
@param <T> The element type
@param iterablesIterable The iterable for the iterables. May not
provide <code>null</code> iterables.
@return The iterator
|
[
"Returns",
"an",
"iterator",
"that",
"combines",
"the",
"iterators",
"that",
"are",
"returned",
"by",
"the",
"iterables",
"that",
"are",
"provided",
"by",
"the",
"iterator",
"that",
"is",
"provided",
"by",
"the",
"given",
"iterable"
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/iteration/Iterators.java#L219-L225
|
149,330
|
javagl/Common
|
src/main/java/de/javagl/common/iteration/Iterators.java
|
Iterators.iteratorOverIterables
|
public static <T> Iterator<T> iteratorOverIterables(
Iterable<? extends T> iterable0, Iterable<? extends T> iterable1)
{
Objects.requireNonNull(iterable0, "The iterable0 is null");
Objects.requireNonNull(iterable1, "The iterable1 is null");
List<Iterable<? extends T>> iterables =
new ArrayList<Iterable<? extends T>>(2);
iterables.add(iterable0);
iterables.add(iterable1);
return iteratorOverIterables(iterables.iterator());
}
|
java
|
public static <T> Iterator<T> iteratorOverIterables(
Iterable<? extends T> iterable0, Iterable<? extends T> iterable1)
{
Objects.requireNonNull(iterable0, "The iterable0 is null");
Objects.requireNonNull(iterable1, "The iterable1 is null");
List<Iterable<? extends T>> iterables =
new ArrayList<Iterable<? extends T>>(2);
iterables.add(iterable0);
iterables.add(iterable1);
return iteratorOverIterables(iterables.iterator());
}
|
[
"public",
"static",
"<",
"T",
">",
"Iterator",
"<",
"T",
">",
"iteratorOverIterables",
"(",
"Iterable",
"<",
"?",
"extends",
"T",
">",
"iterable0",
",",
"Iterable",
"<",
"?",
"extends",
"T",
">",
"iterable1",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"iterable0",
",",
"\"The iterable0 is null\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"iterable1",
",",
"\"The iterable1 is null\"",
")",
";",
"List",
"<",
"Iterable",
"<",
"?",
"extends",
"T",
">",
">",
"iterables",
"=",
"new",
"ArrayList",
"<",
"Iterable",
"<",
"?",
"extends",
"T",
">",
">",
"(",
"2",
")",
";",
"iterables",
".",
"add",
"(",
"iterable0",
")",
";",
"iterables",
".",
"add",
"(",
"iterable1",
")",
";",
"return",
"iteratorOverIterables",
"(",
"iterables",
".",
"iterator",
"(",
")",
")",
";",
"}"
] |
Returns an iterator that combines the iterators that are
returned by the given iterables
@param <T> The element type
@param iterable0 The first iterable
@param iterable1 The second iterable
@return The iterator
|
[
"Returns",
"an",
"iterator",
"that",
"combines",
"the",
"iterators",
"that",
"are",
"returned",
"by",
"the",
"given",
"iterables"
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/iteration/Iterators.java#L236-L246
|
149,331
|
javagl/Common
|
src/main/java/de/javagl/common/iteration/Iterators.java
|
Iterators.transformingIterator
|
public static <S, T> Iterator<T> transformingIterator(
Iterator<? extends S> iterator,
Function<S, ? extends T> function)
{
Objects.requireNonNull(iterator, "The iterator is null");
Objects.requireNonNull(function, "The function is null");
return new TransformingIterator<S, T>(iterator, function);
}
|
java
|
public static <S, T> Iterator<T> transformingIterator(
Iterator<? extends S> iterator,
Function<S, ? extends T> function)
{
Objects.requireNonNull(iterator, "The iterator is null");
Objects.requireNonNull(function, "The function is null");
return new TransformingIterator<S, T>(iterator, function);
}
|
[
"public",
"static",
"<",
"S",
",",
"T",
">",
"Iterator",
"<",
"T",
">",
"transformingIterator",
"(",
"Iterator",
"<",
"?",
"extends",
"S",
">",
"iterator",
",",
"Function",
"<",
"S",
",",
"?",
"extends",
"T",
">",
"function",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"iterator",
",",
"\"The iterator is null\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"function",
",",
"\"The function is null\"",
")",
";",
"return",
"new",
"TransformingIterator",
"<",
"S",
",",
"T",
">",
"(",
"iterator",
",",
"function",
")",
";",
"}"
] |
Creates an iterator that passes the values that are provided
by the given delegate iterator to the given function, and
returns the resulting values
@param <S> The element type
@param <T> The value type
@param iterator The delegate iterator
@param function The function
@return The iterator
|
[
"Creates",
"an",
"iterator",
"that",
"passes",
"the",
"values",
"that",
"are",
"provided",
"by",
"the",
"given",
"delegate",
"iterator",
"to",
"the",
"given",
"function",
"and",
"returns",
"the",
"resulting",
"values"
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/iteration/Iterators.java#L259-L266
|
149,332
|
javagl/Common
|
src/main/java/de/javagl/common/iteration/Iterators.java
|
Iterators.filteringIterator
|
public static <T> Iterator<T> filteringIterator(
Iterator<? extends T> iterator,
Predicate<? super T> predicate)
{
Objects.requireNonNull(iterator, "The iterator is null");
Objects.requireNonNull(predicate, "The predicate is null");
return new FilteringIterator<T>(iterator, predicate);
}
|
java
|
public static <T> Iterator<T> filteringIterator(
Iterator<? extends T> iterator,
Predicate<? super T> predicate)
{
Objects.requireNonNull(iterator, "The iterator is null");
Objects.requireNonNull(predicate, "The predicate is null");
return new FilteringIterator<T>(iterator, predicate);
}
|
[
"public",
"static",
"<",
"T",
">",
"Iterator",
"<",
"T",
">",
"filteringIterator",
"(",
"Iterator",
"<",
"?",
"extends",
"T",
">",
"iterator",
",",
"Predicate",
"<",
"?",
"super",
"T",
">",
"predicate",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"iterator",
",",
"\"The iterator is null\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"predicate",
",",
"\"The predicate is null\"",
")",
";",
"return",
"new",
"FilteringIterator",
"<",
"T",
">",
"(",
"iterator",
",",
"predicate",
")",
";",
"}"
] |
Creates an iterator that only returns the elements from the
given iterator to which the given predicate applies.
@param <T> The element type
@param iterator The delegate iterator
@param predicate The predicate
@return The iterator
|
[
"Creates",
"an",
"iterator",
"that",
"only",
"returns",
"the",
"elements",
"from",
"the",
"given",
"iterator",
"to",
"which",
"the",
"given",
"predicate",
"applies",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/iteration/Iterators.java#L277-L284
|
149,333
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/StorageRef.java
|
StorageRef.getTables
|
public StorageRef getTables(OnTableSnapshot onTableSnapshot, OnError onError){
PostBodyBuilder pbb = new PostBodyBuilder(context);
Rest r = new Rest(context, RestType.LISTTABLES, pbb, null);
r.onError = onError;
r.onTableSnapshot = onTableSnapshot;
context.processRest(r);
return this;
}
|
java
|
public StorageRef getTables(OnTableSnapshot onTableSnapshot, OnError onError){
PostBodyBuilder pbb = new PostBodyBuilder(context);
Rest r = new Rest(context, RestType.LISTTABLES, pbb, null);
r.onError = onError;
r.onTableSnapshot = onTableSnapshot;
context.processRest(r);
return this;
}
|
[
"public",
"StorageRef",
"getTables",
"(",
"OnTableSnapshot",
"onTableSnapshot",
",",
"OnError",
"onError",
")",
"{",
"PostBodyBuilder",
"pbb",
"=",
"new",
"PostBodyBuilder",
"(",
"context",
")",
";",
"Rest",
"r",
"=",
"new",
"Rest",
"(",
"context",
",",
"RestType",
".",
"LISTTABLES",
",",
"pbb",
",",
"null",
")",
";",
"r",
".",
"onError",
"=",
"onError",
";",
"r",
".",
"onTableSnapshot",
"=",
"onTableSnapshot",
";",
"context",
".",
"processRest",
"(",
"r",
")",
";",
"return",
"this",
";",
"}"
] |
Retrieves a list of the names of all tables created by the user's subscription.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
storage.getTables(new OnTableSnapshot() {
@Override
public void run(TableSnapshot tableSnapshot) {
if(tableSnapshot != null) {
Log.d("StorageRef", "Table Name: " + tableSnapshot.val());
}
}
},new OnError() {
@Override
public void run(Integer integer, String errorMessage) {
Log.e("StorageRef","Error retrieving tables: " + errorMessage);
}
});
</pre>
@param onTableSnapshot
The callback to call once the values are available. The function will be called with a table snapshot as argument, as many times as the number of tables existent. 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 tables.
@param onError
The callback to call if an exception occurred
@return Current storage reference
|
[
"Retrieves",
"a",
"list",
"of",
"the",
"names",
"of",
"all",
"tables",
"created",
"by",
"the",
"user",
"s",
"subscription",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/StorageRef.java#L372-L379
|
149,334
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/StorageRef.java
|
StorageRef.isAuthenticated
|
public StorageRef isAuthenticated(String authenticationToken, OnBooleanResponse onBooleanResponse, OnError onError){
PostBodyBuilder pbb = new PostBodyBuilder(context);
Rest r = new Rest(context, RestType.ISAUTHENTICATED, pbb, null);
r.onError = onError;
r.onBooleanResponse = onBooleanResponse;
r.rawBody = "{\"applicationKey\":\""+context.applicationKey+"\", \"authenticationToken\":\""+authenticationToken+"\"}";
context.processRest(r);
return this;
}
|
java
|
public StorageRef isAuthenticated(String authenticationToken, OnBooleanResponse onBooleanResponse, OnError onError){
PostBodyBuilder pbb = new PostBodyBuilder(context);
Rest r = new Rest(context, RestType.ISAUTHENTICATED, pbb, null);
r.onError = onError;
r.onBooleanResponse = onBooleanResponse;
r.rawBody = "{\"applicationKey\":\""+context.applicationKey+"\", \"authenticationToken\":\""+authenticationToken+"\"}";
context.processRest(r);
return this;
}
|
[
"public",
"StorageRef",
"isAuthenticated",
"(",
"String",
"authenticationToken",
",",
"OnBooleanResponse",
"onBooleanResponse",
",",
"OnError",
"onError",
")",
"{",
"PostBodyBuilder",
"pbb",
"=",
"new",
"PostBodyBuilder",
"(",
"context",
")",
";",
"Rest",
"r",
"=",
"new",
"Rest",
"(",
"context",
",",
"RestType",
".",
"ISAUTHENTICATED",
",",
"pbb",
",",
"null",
")",
";",
"r",
".",
"onError",
"=",
"onError",
";",
"r",
".",
"onBooleanResponse",
"=",
"onBooleanResponse",
";",
"r",
".",
"rawBody",
"=",
"\"{\\\"applicationKey\\\":\\\"\"",
"+",
"context",
".",
"applicationKey",
"+",
"\"\\\", \\\"authenticationToken\\\":\\\"\"",
"+",
"authenticationToken",
"+",
"\"\\\"}\"",
";",
"context",
".",
"processRest",
"(",
"r",
")",
";",
"return",
"this",
";",
"}"
] |
Checks if a specified authentication token is authenticated.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
storage.isAuthenticated("authToken",new OnBooleanResponse() {
@Override
public void run(Boolean aBoolean) {
Log.d("StorageRef", "Is Authenticated? : " + aBoolean);
}
}, new OnError() {
@Override
public void run(Integer integer, String errorMessage) {
Log.e("StorageRef","Error checking authentication: " + errorMessage);
}
});
</pre>
@param authenticationToken
The token to verify.
@param onBooleanResponse
The callback to call when the operation is completed, with an argument as a result of verification.
@param onError
The callback to call if an exception occurred
@return Current storage reference
|
[
"Checks",
"if",
"a",
"specified",
"authentication",
"token",
"is",
"authenticated",
"."
] |
05816a6b7a6dcc83f9e7400ac3048494dadca302
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/StorageRef.java#L408-L416
|
149,335
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/ProcessedInput.java
|
ProcessedInput.setSqlParameterValues
|
public void setSqlParameterValues(List<Object> sqlParameterValues) {
if (sqlParameterValues != null) {
this.sqlParameterValues = new ArrayList<Object>(sqlParameterValues);
} else {
this.sqlParameterValues = null;
}
}
|
java
|
public void setSqlParameterValues(List<Object> sqlParameterValues) {
if (sqlParameterValues != null) {
this.sqlParameterValues = new ArrayList<Object>(sqlParameterValues);
} else {
this.sqlParameterValues = null;
}
}
|
[
"public",
"void",
"setSqlParameterValues",
"(",
"List",
"<",
"Object",
">",
"sqlParameterValues",
")",
"{",
"if",
"(",
"sqlParameterValues",
"!=",
"null",
")",
"{",
"this",
".",
"sqlParameterValues",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
"sqlParameterValues",
")",
";",
"}",
"else",
"{",
"this",
".",
"sqlParameterValues",
"=",
"null",
";",
"}",
"}"
] |
Sets list of parameter values
@param sqlParameterValues list of parameter values
|
[
"Sets",
"list",
"of",
"parameter",
"values"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/ProcessedInput.java#L230-L236
|
149,336
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/ProcessedInput.java
|
ProcessedInput.getParameterName
|
public String getParameterName(Integer position) {
String name = null;
if (this.sqlParameterNames != null) {
name = this.sqlParameterNames.get(position);
}
return name;
}
|
java
|
public String getParameterName(Integer position) {
String name = null;
if (this.sqlParameterNames != null) {
name = this.sqlParameterNames.get(position);
}
return name;
}
|
[
"public",
"String",
"getParameterName",
"(",
"Integer",
"position",
")",
"{",
"String",
"name",
"=",
"null",
";",
"if",
"(",
"this",
".",
"sqlParameterNames",
"!=",
"null",
")",
"{",
"name",
"=",
"this",
".",
"sqlParameterNames",
".",
"get",
"(",
"position",
")",
";",
"}",
"return",
"name",
";",
"}"
] |
Returns parameter name by specifying it's position
@param position position of parameter
@return name of parameter, null if list of names is empty
|
[
"Returns",
"parameter",
"name",
"by",
"specifying",
"it",
"s",
"position"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/ProcessedInput.java#L263-L271
|
149,337
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/ProcessedInput.java
|
ProcessedInput.getAmountOfParameters
|
public Integer getAmountOfParameters() {
Integer size = 0;
if (this.sqlParameterNames != null) {
size = this.sqlParameterNames.size();
}
return size;
}
|
java
|
public Integer getAmountOfParameters() {
Integer size = 0;
if (this.sqlParameterNames != null) {
size = this.sqlParameterNames.size();
}
return size;
}
|
[
"public",
"Integer",
"getAmountOfParameters",
"(",
")",
"{",
"Integer",
"size",
"=",
"0",
";",
"if",
"(",
"this",
".",
"sqlParameterNames",
"!=",
"null",
")",
"{",
"size",
"=",
"this",
".",
"sqlParameterNames",
".",
"size",
"(",
")",
";",
"}",
"return",
"size",
";",
"}"
] |
Returns amount of parameters specified in this instance of ProcessedInput
@return amount of parameters
|
[
"Returns",
"amount",
"of",
"parameters",
"specified",
"in",
"this",
"instance",
"of",
"ProcessedInput"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/ProcessedInput.java#L278-L285
|
149,338
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/ProcessedInput.java
|
ProcessedInput.fillParameterValues
|
public void fillParameterValues(Map<String, Object> valuesMap) {
AssertUtils.assertNotNull(valuesMap, "Value map cannot be null");
if (this.sqlParameterNames != null) {
String parameterName = null;
this.sqlParameterValues = new ArrayList<Object>();
// using for instead of iterator because this way I control position
// I am getting.
for (int i = 0; i < this.sqlParameterNames.size(); i++) {
parameterName = this.sqlParameterNames.get(i);
if (valuesMap.containsKey(parameterName) == true) {
this.sqlParameterValues.add(valuesMap.get(parameterName));
} else {
throw new IllegalArgumentException(String.format(HandlersConstants.ERROR_PARAMETER_NOT_FOUND, parameterName));
}
}
}
}
|
java
|
public void fillParameterValues(Map<String, Object> valuesMap) {
AssertUtils.assertNotNull(valuesMap, "Value map cannot be null");
if (this.sqlParameterNames != null) {
String parameterName = null;
this.sqlParameterValues = new ArrayList<Object>();
// using for instead of iterator because this way I control position
// I am getting.
for (int i = 0; i < this.sqlParameterNames.size(); i++) {
parameterName = this.sqlParameterNames.get(i);
if (valuesMap.containsKey(parameterName) == true) {
this.sqlParameterValues.add(valuesMap.get(parameterName));
} else {
throw new IllegalArgumentException(String.format(HandlersConstants.ERROR_PARAMETER_NOT_FOUND, parameterName));
}
}
}
}
|
[
"public",
"void",
"fillParameterValues",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"valuesMap",
")",
"{",
"AssertUtils",
".",
"assertNotNull",
"(",
"valuesMap",
",",
"\"Value map cannot be null\"",
")",
";",
"if",
"(",
"this",
".",
"sqlParameterNames",
"!=",
"null",
")",
"{",
"String",
"parameterName",
"=",
"null",
";",
"this",
".",
"sqlParameterValues",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
")",
";",
"// using for instead of iterator because this way I control position\r",
"// I am getting.\r",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"sqlParameterNames",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"parameterName",
"=",
"this",
".",
"sqlParameterNames",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"valuesMap",
".",
"containsKey",
"(",
"parameterName",
")",
"==",
"true",
")",
"{",
"this",
".",
"sqlParameterValues",
".",
"add",
"(",
"valuesMap",
".",
"get",
"(",
"parameterName",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"HandlersConstants",
".",
"ERROR_PARAMETER_NOT_FOUND",
",",
"parameterName",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Utility function.
Fills this ProcessedInput with values.
This function iterates over parameter names list and loads corresponding value from MAp
@param valuesMap Map of values which would be loaded
|
[
"Utility",
"function",
".",
"Fills",
"this",
"ProcessedInput",
"with",
"values",
".",
"This",
"function",
"iterates",
"over",
"parameter",
"names",
"list",
"and",
"loads",
"corresponding",
"value",
"from",
"MAp"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/ProcessedInput.java#L316-L336
|
149,339
|
wb14123/bard
|
bard-util/bard-user/src/main/java/com/bardframework/bard/util/user/TokenStorage.java
|
TokenStorage.put
|
public static String put(String username, final int seconds) {
String key = UUID.randomUUID().toString();
cache.setex(key, seconds, username);
return key;
}
|
java
|
public static String put(String username, final int seconds) {
String key = UUID.randomUUID().toString();
cache.setex(key, seconds, username);
return key;
}
|
[
"public",
"static",
"String",
"put",
"(",
"String",
"username",
",",
"final",
"int",
"seconds",
")",
"{",
"String",
"key",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"cache",
".",
"setex",
"(",
"key",
",",
"seconds",
",",
"username",
")",
";",
"return",
"key",
";",
"}"
] |
Put username into the token storage with an expire time.
@param username The username.
@param seconds The expire time in second.
@return Then generated token.
|
[
"Put",
"username",
"into",
"the",
"token",
"storage",
"with",
"an",
"expire",
"time",
"."
] |
98618ae31fd80000c794661b4c130af1b1298d9b
|
https://github.com/wb14123/bard/blob/98618ae31fd80000c794661b4c130af1b1298d9b/bard-util/bard-user/src/main/java/com/bardframework/bard/util/user/TokenStorage.java#L21-L25
|
149,340
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/xml/XmlInputOutputHandler.java
|
XmlInputOutputHandler.primitiveAmount
|
private int primitiveAmount(Object... values) {
int result = 0;
for (int i = 0; i < values.length; i++) {
if (MappingUtils.isPrimitive(values[i]) == true) {
result++;
}
}
return result;
}
|
java
|
private int primitiveAmount(Object... values) {
int result = 0;
for (int i = 0; i < values.length; i++) {
if (MappingUtils.isPrimitive(values[i]) == true) {
result++;
}
}
return result;
}
|
[
"private",
"int",
"primitiveAmount",
"(",
"Object",
"...",
"values",
")",
"{",
"int",
"result",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"MappingUtils",
".",
"isPrimitive",
"(",
"values",
"[",
"i",
"]",
")",
"==",
"true",
")",
"{",
"result",
"++",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Iterates over values and returns amount of primitive values in it.
Used to check if values supplied via constructors aren't mixed, as only primitive or complex types are allows
@param values values which should be counted
@return amount of primitive values
|
[
"Iterates",
"over",
"values",
"and",
"returns",
"amount",
"of",
"primitive",
"values",
"in",
"it",
".",
"Used",
"to",
"check",
"if",
"values",
"supplied",
"via",
"constructors",
"aren",
"t",
"mixed",
"as",
"only",
"primitive",
"or",
"complex",
"types",
"are",
"allows"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/xml/XmlInputOutputHandler.java#L243-L253
|
149,341
|
Viascom/groundwork
|
foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/FoxHttpResponse.java
|
FoxHttpResponse.getStringBody
|
public String getStringBody(Charset charset) throws IOException {
BufferedReader rd = new BufferedReader(new InputStreamReader(getInputStreamBody(), charset));
String line;
StringBuilder response = new StringBuilder();
while ((line = rd.readLine()) != null) {
if (response.length() != 0) {
response.append('\n');
}
response.append(line);
}
rd.close();
return response.toString();
}
|
java
|
public String getStringBody(Charset charset) throws IOException {
BufferedReader rd = new BufferedReader(new InputStreamReader(getInputStreamBody(), charset));
String line;
StringBuilder response = new StringBuilder();
while ((line = rd.readLine()) != null) {
if (response.length() != 0) {
response.append('\n');
}
response.append(line);
}
rd.close();
return response.toString();
}
|
[
"public",
"String",
"getStringBody",
"(",
"Charset",
"charset",
")",
"throws",
"IOException",
"{",
"BufferedReader",
"rd",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"getInputStreamBody",
"(",
")",
",",
"charset",
")",
")",
";",
"String",
"line",
";",
"StringBuilder",
"response",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"while",
"(",
"(",
"line",
"=",
"rd",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"response",
".",
"length",
"(",
")",
"!=",
"0",
")",
"{",
"response",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"response",
".",
"append",
"(",
"line",
")",
";",
"}",
"rd",
".",
"close",
"(",
")",
";",
"return",
"response",
".",
"toString",
"(",
")",
";",
"}"
] |
Get the response body as string
@param charset charset for the byte to String conversion
@return body as string
@throws IOException if the stream is not accessible
|
[
"Get",
"the",
"response",
"body",
"as",
"string"
] |
d3f7d0df65e2e75861fc7db938090683f2cdf919
|
https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/FoxHttpResponse.java#L86-L98
|
149,342
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/output/BeanMapOutputHandler.java
|
BeanMapOutputHandler.createRow
|
@Override
protected V createRow(QueryParameters params) throws MjdbcException {
return this.outputProcessor.toBean(params, type);
}
|
java
|
@Override
protected V createRow(QueryParameters params) throws MjdbcException {
return this.outputProcessor.toBean(params, type);
}
|
[
"@",
"Override",
"protected",
"V",
"createRow",
"(",
"QueryParameters",
"params",
")",
"throws",
"MjdbcException",
"{",
"return",
"this",
".",
"outputProcessor",
".",
"toBean",
"(",
"params",
",",
"type",
")",
";",
"}"
] |
Converts query output into Map of Beans.
@param params query output row
@return Map of Beans converted from query output
@throws org.midao.jdbc.core.exception.MjdbcException
|
[
"Converts",
"query",
"output",
"into",
"Map",
"of",
"Beans",
"."
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/output/BeanMapOutputHandler.java#L110-L113
|
149,343
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/metadata/BaseMetadataHandler.java
|
BaseMetadataHandler.updateCache
|
public int updateCache(DatabaseMetaData metaData, String catalogName, String schemaName, String procedureName) throws SQLException {
String dbProductName = MetadataUtils.processDatabaseProductName(metaData.getDatabaseProductName());
ResultSet procedures = null;
ResultSet procedureParameters = null;
List<String> proceduresList = new ArrayList<String>();
String procedureCatalog = null;
String procedureSchema = null;
String procedureNameFull = null;
String procedureParameterName = null;
Integer procedureParameterDirection = null;
Integer procedureParameterType = null;
QueryParameters.Direction direction = null;
QueryParameters procedureParams = null;
StoredProcedure procedurePath = null;
procedures = metaData.getProcedures(catalogName, schemaName, procedureName);
while (procedures.next() == true) {
procedureCatalog = procedures.getString("PROCEDURE_CAT");
procedureSchema = procedures.getString("PROCEDURE_SCHEM");
procedureNameFull = processProcedureName(dbProductName, procedures.getString("PROCEDURE_NAME"));
procedurePath = new StoredProcedure(procedureCatalog, procedureSchema, procedureNameFull);
procedureParameters = metaData.getProcedureColumns(procedureCatalog, procedureSchema, procedureNameFull, null);
proceduresList.add(procedureCatalog + "." + procedureSchema + "." + procedureNameFull);
procedureParams = new QueryParameters();
//procedureParameters = metaData.getProcedureColumns(null, procedureSchema, "%", "%");
//procedureParameters = metaData.getProcedureColumns(procedureCatalog, procedureSchema, "%" + procedureNameFull + "%", "%");
while (procedureParameters.next() == true) {
//procedureCatalog = procedureParameters.getString("PROCEDURE_CAT");
//procedureSchema = procedureParameters.getString("PROCEDURE_SCHEM");
//procedureNameFull = procedureParameters.getString("PROCEDURE_NAME");
//System.out.println(procedureCatalog + "." + procedureSchema + "." + procedureNameFull);
procedureParameterName = procedureParameters.getString("COLUMN_NAME");
procedureParameterDirection = procedureParameters.getInt("COLUMN_TYPE");
procedureParameterType = procedureParameters.getInt("DATA_TYPE");
if (procedureParameterName == null && (procedureParameterDirection == DatabaseMetaData.procedureColumnIn || procedureParameterDirection == DatabaseMetaData.procedureColumnInOut || procedureParameterDirection == DatabaseMetaData.procedureColumnOut)) {
// according to Spring - it is probably a member of a collection
} else {
direction = convertToDirection(procedureParameterDirection);
procedureParams.set(procedureParameterName, null, procedureParameterType, direction, procedureParams.orderSize());
}
}
MjdbcUtils.closeQuietly(procedureParameters);
this.procedureParameters.put(procedurePath, procedureParams);
}
MjdbcUtils.closeQuietly(procedures);
return proceduresList.size();
}
|
java
|
public int updateCache(DatabaseMetaData metaData, String catalogName, String schemaName, String procedureName) throws SQLException {
String dbProductName = MetadataUtils.processDatabaseProductName(metaData.getDatabaseProductName());
ResultSet procedures = null;
ResultSet procedureParameters = null;
List<String> proceduresList = new ArrayList<String>();
String procedureCatalog = null;
String procedureSchema = null;
String procedureNameFull = null;
String procedureParameterName = null;
Integer procedureParameterDirection = null;
Integer procedureParameterType = null;
QueryParameters.Direction direction = null;
QueryParameters procedureParams = null;
StoredProcedure procedurePath = null;
procedures = metaData.getProcedures(catalogName, schemaName, procedureName);
while (procedures.next() == true) {
procedureCatalog = procedures.getString("PROCEDURE_CAT");
procedureSchema = procedures.getString("PROCEDURE_SCHEM");
procedureNameFull = processProcedureName(dbProductName, procedures.getString("PROCEDURE_NAME"));
procedurePath = new StoredProcedure(procedureCatalog, procedureSchema, procedureNameFull);
procedureParameters = metaData.getProcedureColumns(procedureCatalog, procedureSchema, procedureNameFull, null);
proceduresList.add(procedureCatalog + "." + procedureSchema + "." + procedureNameFull);
procedureParams = new QueryParameters();
//procedureParameters = metaData.getProcedureColumns(null, procedureSchema, "%", "%");
//procedureParameters = metaData.getProcedureColumns(procedureCatalog, procedureSchema, "%" + procedureNameFull + "%", "%");
while (procedureParameters.next() == true) {
//procedureCatalog = procedureParameters.getString("PROCEDURE_CAT");
//procedureSchema = procedureParameters.getString("PROCEDURE_SCHEM");
//procedureNameFull = procedureParameters.getString("PROCEDURE_NAME");
//System.out.println(procedureCatalog + "." + procedureSchema + "." + procedureNameFull);
procedureParameterName = procedureParameters.getString("COLUMN_NAME");
procedureParameterDirection = procedureParameters.getInt("COLUMN_TYPE");
procedureParameterType = procedureParameters.getInt("DATA_TYPE");
if (procedureParameterName == null && (procedureParameterDirection == DatabaseMetaData.procedureColumnIn || procedureParameterDirection == DatabaseMetaData.procedureColumnInOut || procedureParameterDirection == DatabaseMetaData.procedureColumnOut)) {
// according to Spring - it is probably a member of a collection
} else {
direction = convertToDirection(procedureParameterDirection);
procedureParams.set(procedureParameterName, null, procedureParameterType, direction, procedureParams.orderSize());
}
}
MjdbcUtils.closeQuietly(procedureParameters);
this.procedureParameters.put(procedurePath, procedureParams);
}
MjdbcUtils.closeQuietly(procedures);
return proceduresList.size();
}
|
[
"public",
"int",
"updateCache",
"(",
"DatabaseMetaData",
"metaData",
",",
"String",
"catalogName",
",",
"String",
"schemaName",
",",
"String",
"procedureName",
")",
"throws",
"SQLException",
"{",
"String",
"dbProductName",
"=",
"MetadataUtils",
".",
"processDatabaseProductName",
"(",
"metaData",
".",
"getDatabaseProductName",
"(",
")",
")",
";",
"ResultSet",
"procedures",
"=",
"null",
";",
"ResultSet",
"procedureParameters",
"=",
"null",
";",
"List",
"<",
"String",
">",
"proceduresList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"String",
"procedureCatalog",
"=",
"null",
";",
"String",
"procedureSchema",
"=",
"null",
";",
"String",
"procedureNameFull",
"=",
"null",
";",
"String",
"procedureParameterName",
"=",
"null",
";",
"Integer",
"procedureParameterDirection",
"=",
"null",
";",
"Integer",
"procedureParameterType",
"=",
"null",
";",
"QueryParameters",
".",
"Direction",
"direction",
"=",
"null",
";",
"QueryParameters",
"procedureParams",
"=",
"null",
";",
"StoredProcedure",
"procedurePath",
"=",
"null",
";",
"procedures",
"=",
"metaData",
".",
"getProcedures",
"(",
"catalogName",
",",
"schemaName",
",",
"procedureName",
")",
";",
"while",
"(",
"procedures",
".",
"next",
"(",
")",
"==",
"true",
")",
"{",
"procedureCatalog",
"=",
"procedures",
".",
"getString",
"(",
"\"PROCEDURE_CAT\"",
")",
";",
"procedureSchema",
"=",
"procedures",
".",
"getString",
"(",
"\"PROCEDURE_SCHEM\"",
")",
";",
"procedureNameFull",
"=",
"processProcedureName",
"(",
"dbProductName",
",",
"procedures",
".",
"getString",
"(",
"\"PROCEDURE_NAME\"",
")",
")",
";",
"procedurePath",
"=",
"new",
"StoredProcedure",
"(",
"procedureCatalog",
",",
"procedureSchema",
",",
"procedureNameFull",
")",
";",
"procedureParameters",
"=",
"metaData",
".",
"getProcedureColumns",
"(",
"procedureCatalog",
",",
"procedureSchema",
",",
"procedureNameFull",
",",
"null",
")",
";",
"proceduresList",
".",
"add",
"(",
"procedureCatalog",
"+",
"\".\"",
"+",
"procedureSchema",
"+",
"\".\"",
"+",
"procedureNameFull",
")",
";",
"procedureParams",
"=",
"new",
"QueryParameters",
"(",
")",
";",
"//procedureParameters = metaData.getProcedureColumns(null, procedureSchema, \"%\", \"%\");\r",
"//procedureParameters = metaData.getProcedureColumns(procedureCatalog, procedureSchema, \"%\" + procedureNameFull + \"%\", \"%\");\r",
"while",
"(",
"procedureParameters",
".",
"next",
"(",
")",
"==",
"true",
")",
"{",
"//procedureCatalog = procedureParameters.getString(\"PROCEDURE_CAT\");\r",
"//procedureSchema = procedureParameters.getString(\"PROCEDURE_SCHEM\");\r",
"//procedureNameFull = procedureParameters.getString(\"PROCEDURE_NAME\");\r",
"//System.out.println(procedureCatalog + \".\" + procedureSchema + \".\" + procedureNameFull);\r",
"procedureParameterName",
"=",
"procedureParameters",
".",
"getString",
"(",
"\"COLUMN_NAME\"",
")",
";",
"procedureParameterDirection",
"=",
"procedureParameters",
".",
"getInt",
"(",
"\"COLUMN_TYPE\"",
")",
";",
"procedureParameterType",
"=",
"procedureParameters",
".",
"getInt",
"(",
"\"DATA_TYPE\"",
")",
";",
"if",
"(",
"procedureParameterName",
"==",
"null",
"&&",
"(",
"procedureParameterDirection",
"==",
"DatabaseMetaData",
".",
"procedureColumnIn",
"||",
"procedureParameterDirection",
"==",
"DatabaseMetaData",
".",
"procedureColumnInOut",
"||",
"procedureParameterDirection",
"==",
"DatabaseMetaData",
".",
"procedureColumnOut",
")",
")",
"{",
"// according to Spring - it is probably a member of a collection\r",
"}",
"else",
"{",
"direction",
"=",
"convertToDirection",
"(",
"procedureParameterDirection",
")",
";",
"procedureParams",
".",
"set",
"(",
"procedureParameterName",
",",
"null",
",",
"procedureParameterType",
",",
"direction",
",",
"procedureParams",
".",
"orderSize",
"(",
")",
")",
";",
"}",
"}",
"MjdbcUtils",
".",
"closeQuietly",
"(",
"procedureParameters",
")",
";",
"this",
".",
"procedureParameters",
".",
"put",
"(",
"procedurePath",
",",
"procedureParams",
")",
";",
"}",
"MjdbcUtils",
".",
"closeQuietly",
"(",
"procedures",
")",
";",
"return",
"proceduresList",
".",
"size",
"(",
")",
";",
"}"
] |
Function which is responsible for retrieving Stored Procedure parameters and storage it into cache.
This function doesn't perform cache read - only cache update.
@param metaData Database Metadata description class
@param catalogName Database Catalog
@param schemaName Database Schema
@param procedureName Procedure/Function name
@return amount of elements put into cache
@throws SQLException
|
[
"Function",
"which",
"is",
"responsible",
"for",
"retrieving",
"Stored",
"Procedure",
"parameters",
"and",
"storage",
"it",
"into",
"cache",
".",
"This",
"function",
"doesn",
"t",
"perform",
"cache",
"read",
"-",
"only",
"cache",
"update",
"."
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/metadata/BaseMetadataHandler.java#L91-L154
|
149,344
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/metadata/BaseMetadataHandler.java
|
BaseMetadataHandler.processCatalogName
|
private String processCatalogName(String dbProvideName, String userName, String catalogName) {
String result = null;
if (catalogName != null) {
result = catalogName.toUpperCase();
} else {
if ("Oracle".equals(dbProvideName) == true) {
// SPRING: Oracle uses catalog name for package name or an empty string if no package
result = "";
}
}
return result;
}
|
java
|
private String processCatalogName(String dbProvideName, String userName, String catalogName) {
String result = null;
if (catalogName != null) {
result = catalogName.toUpperCase();
} else {
if ("Oracle".equals(dbProvideName) == true) {
// SPRING: Oracle uses catalog name for package name or an empty string if no package
result = "";
}
}
return result;
}
|
[
"private",
"String",
"processCatalogName",
"(",
"String",
"dbProvideName",
",",
"String",
"userName",
",",
"String",
"catalogName",
")",
"{",
"String",
"result",
"=",
"null",
";",
"if",
"(",
"catalogName",
"!=",
"null",
")",
"{",
"result",
"=",
"catalogName",
".",
"toUpperCase",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"\"Oracle\"",
".",
"equals",
"(",
"dbProvideName",
")",
"==",
"true",
")",
"{",
"// SPRING: Oracle uses catalog name for package name or an empty string if no package\r",
"result",
"=",
"\"\"",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Processes Catalog name so it would be compatible with database
@param dbProvideName short database name
@param userName user name
@param catalogName catalog name which would be processed
@return processed catalog name
|
[
"Processes",
"Catalog",
"name",
"so",
"it",
"would",
"be",
"compatible",
"with",
"database"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/metadata/BaseMetadataHandler.java#L229-L242
|
149,345
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/metadata/BaseMetadataHandler.java
|
BaseMetadataHandler.processSchemaName
|
private String processSchemaName(String dbProductName, String userName, String schemaName) {
String result = null;
if (schemaName != null) {
result = schemaName.toUpperCase();
} else {
if ("DB2".equals(dbProductName) == true || "Apache Derby".equals(dbProductName) == true || "Oracle".equals(dbProductName) == true) {
if (userName != null) {
result = userName.toUpperCase();
}
} else if ("PostgreSQL".equals(dbProductName) == true) {
// for PostgreSQL - if no schema specified - public should be used
result = "public";
}
}
return result;
}
|
java
|
private String processSchemaName(String dbProductName, String userName, String schemaName) {
String result = null;
if (schemaName != null) {
result = schemaName.toUpperCase();
} else {
if ("DB2".equals(dbProductName) == true || "Apache Derby".equals(dbProductName) == true || "Oracle".equals(dbProductName) == true) {
if (userName != null) {
result = userName.toUpperCase();
}
} else if ("PostgreSQL".equals(dbProductName) == true) {
// for PostgreSQL - if no schema specified - public should be used
result = "public";
}
}
return result;
}
|
[
"private",
"String",
"processSchemaName",
"(",
"String",
"dbProductName",
",",
"String",
"userName",
",",
"String",
"schemaName",
")",
"{",
"String",
"result",
"=",
"null",
";",
"if",
"(",
"schemaName",
"!=",
"null",
")",
"{",
"result",
"=",
"schemaName",
".",
"toUpperCase",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"\"DB2\"",
".",
"equals",
"(",
"dbProductName",
")",
"==",
"true",
"||",
"\"Apache Derby\"",
".",
"equals",
"(",
"dbProductName",
")",
"==",
"true",
"||",
"\"Oracle\"",
".",
"equals",
"(",
"dbProductName",
")",
"==",
"true",
")",
"{",
"if",
"(",
"userName",
"!=",
"null",
")",
"{",
"result",
"=",
"userName",
".",
"toUpperCase",
"(",
")",
";",
"}",
"}",
"else",
"if",
"(",
"\"PostgreSQL\"",
".",
"equals",
"(",
"dbProductName",
")",
"==",
"true",
")",
"{",
"// for PostgreSQL - if no schema specified - public should be used\r",
"result",
"=",
"\"public\"",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Processes Schema name so it would be compatible with database
@param dbProductName short database name
@param userName user name
@param schemaName schema name which would be processed
@return processed schema name
|
[
"Processes",
"Schema",
"name",
"so",
"it",
"would",
"be",
"compatible",
"with",
"database"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/metadata/BaseMetadataHandler.java#L252-L269
|
149,346
|
jiaqi/caff
|
src/main/java/org/cyclopsgroup/caff/ref/ValueReferenceScanner.java
|
ValueReferenceScanner.scanForAnnotation
|
public <H extends Annotation> void scanForAnnotation(
Class<H> expectedAnnotation, Listener<T, H> listener) {
BeanInfo beanInfo;
try {
beanInfo = Introspector.getBeanInfo(beanType);
} catch (IntrospectionException e) {
throw new RuntimeException("Can't get bean info of " + beanType);
}
for (PropertyDescriptor desc : beanInfo.getPropertyDescriptors()) {
AccessibleObject access = findAnnotatedAccess(desc, expectedAnnotation);
if (access == null) {
continue;
}
ValueReference<T> reference;
if (access instanceof Field) {
reference = ValueReference.instanceOf((Field) access);
} else {
reference = ValueReference.instanceOf(desc);
}
listener.handleReference(reference, access.getAnnotation(expectedAnnotation), access);
}
for (Field field : beanType.getFields()) {
H annotation = field.getAnnotation(expectedAnnotation);
if (annotation == null) {
continue;
}
ValueReference<T> reference = ValueReference.instanceOf(field);
listener.handleReference(reference, annotation, field);
}
}
|
java
|
public <H extends Annotation> void scanForAnnotation(
Class<H> expectedAnnotation, Listener<T, H> listener) {
BeanInfo beanInfo;
try {
beanInfo = Introspector.getBeanInfo(beanType);
} catch (IntrospectionException e) {
throw new RuntimeException("Can't get bean info of " + beanType);
}
for (PropertyDescriptor desc : beanInfo.getPropertyDescriptors()) {
AccessibleObject access = findAnnotatedAccess(desc, expectedAnnotation);
if (access == null) {
continue;
}
ValueReference<T> reference;
if (access instanceof Field) {
reference = ValueReference.instanceOf((Field) access);
} else {
reference = ValueReference.instanceOf(desc);
}
listener.handleReference(reference, access.getAnnotation(expectedAnnotation), access);
}
for (Field field : beanType.getFields()) {
H annotation = field.getAnnotation(expectedAnnotation);
if (annotation == null) {
continue;
}
ValueReference<T> reference = ValueReference.instanceOf(field);
listener.handleReference(reference, annotation, field);
}
}
|
[
"public",
"<",
"H",
"extends",
"Annotation",
">",
"void",
"scanForAnnotation",
"(",
"Class",
"<",
"H",
">",
"expectedAnnotation",
",",
"Listener",
"<",
"T",
",",
"H",
">",
"listener",
")",
"{",
"BeanInfo",
"beanInfo",
";",
"try",
"{",
"beanInfo",
"=",
"Introspector",
".",
"getBeanInfo",
"(",
"beanType",
")",
";",
"}",
"catch",
"(",
"IntrospectionException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Can't get bean info of \"",
"+",
"beanType",
")",
";",
"}",
"for",
"(",
"PropertyDescriptor",
"desc",
":",
"beanInfo",
".",
"getPropertyDescriptors",
"(",
")",
")",
"{",
"AccessibleObject",
"access",
"=",
"findAnnotatedAccess",
"(",
"desc",
",",
"expectedAnnotation",
")",
";",
"if",
"(",
"access",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"ValueReference",
"<",
"T",
">",
"reference",
";",
"if",
"(",
"access",
"instanceof",
"Field",
")",
"{",
"reference",
"=",
"ValueReference",
".",
"instanceOf",
"(",
"(",
"Field",
")",
"access",
")",
";",
"}",
"else",
"{",
"reference",
"=",
"ValueReference",
".",
"instanceOf",
"(",
"desc",
")",
";",
"}",
"listener",
".",
"handleReference",
"(",
"reference",
",",
"access",
".",
"getAnnotation",
"(",
"expectedAnnotation",
")",
",",
"access",
")",
";",
"}",
"for",
"(",
"Field",
"field",
":",
"beanType",
".",
"getFields",
"(",
")",
")",
"{",
"H",
"annotation",
"=",
"field",
".",
"getAnnotation",
"(",
"expectedAnnotation",
")",
";",
"if",
"(",
"annotation",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"ValueReference",
"<",
"T",
">",
"reference",
"=",
"ValueReference",
".",
"instanceOf",
"(",
"field",
")",
";",
"listener",
".",
"handleReference",
"(",
"reference",
",",
"annotation",
",",
"field",
")",
";",
"}",
"}"
] |
Scan given class and look for possible references annotated by given annotation
@param <H> Only field or method annotated with this annotation is inspected
@param expectedAnnotation Only field or method annotated with this annotation is inspected
@param listener Listener to handle found references
|
[
"Scan",
"given",
"class",
"and",
"look",
"for",
"possible",
"references",
"annotated",
"by",
"given",
"annotation"
] |
dba4b937a0afc844eb37ccf74dd04dd78f0c1314
|
https://github.com/jiaqi/caff/blob/dba4b937a0afc844eb37ccf74dd04dd78f0c1314/src/main/java/org/cyclopsgroup/caff/ref/ValueReferenceScanner.java#L71-L100
|
149,347
|
greese/dasein-util
|
src/main/java/org/dasein/util/ConcurrentMultiCache.java
|
ConcurrentMultiCache.cache
|
public T cache(T item) {
HashMap<String,Object> keys;
if( item == null ) {
throw new NullPointerException("Multi caches may not have null values.");
}
keys = getKeys(item);
synchronized( this ) {
item = getCurrent(item);
for( String key : caches.keySet() ) {
ConcurrentCache<Object,T> cache = caches.get(key);
cache.put(keys.get(key), item);
}
return item;
}
}
|
java
|
public T cache(T item) {
HashMap<String,Object> keys;
if( item == null ) {
throw new NullPointerException("Multi caches may not have null values.");
}
keys = getKeys(item);
synchronized( this ) {
item = getCurrent(item);
for( String key : caches.keySet() ) {
ConcurrentCache<Object,T> cache = caches.get(key);
cache.put(keys.get(key), item);
}
return item;
}
}
|
[
"public",
"T",
"cache",
"(",
"T",
"item",
")",
"{",
"HashMap",
"<",
"String",
",",
"Object",
">",
"keys",
";",
"if",
"(",
"item",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Multi caches may not have null values.\"",
")",
";",
"}",
"keys",
"=",
"getKeys",
"(",
"item",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"item",
"=",
"getCurrent",
"(",
"item",
")",
";",
"for",
"(",
"String",
"key",
":",
"caches",
".",
"keySet",
"(",
")",
")",
"{",
"ConcurrentCache",
"<",
"Object",
",",
"T",
">",
"cache",
"=",
"caches",
".",
"get",
"(",
"key",
")",
";",
"cache",
".",
"put",
"(",
"keys",
".",
"get",
"(",
"key",
")",
",",
"item",
")",
";",
"}",
"return",
"item",
";",
"}",
"}"
] |
Places the specified item in the cache. It will not replace an existing
item in the cache. Instead, if an item already exists in the cache, it
will make sure that item is cached across all identifiers and then return
the cached item.
@param item the item to be cached
@return whatever item is in the cache after this operation
|
[
"Places",
"the",
"specified",
"item",
"in",
"the",
"cache",
".",
"It",
"will",
"not",
"replace",
"an",
"existing",
"item",
"in",
"the",
"cache",
".",
"Instead",
"if",
"an",
"item",
"already",
"exists",
"in",
"the",
"cache",
"it",
"will",
"make",
"sure",
"that",
"item",
"is",
"cached",
"across",
"all",
"identifiers",
"and",
"then",
"return",
"the",
"cached",
"item",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/ConcurrentMultiCache.java#L149-L165
|
149,348
|
greese/dasein-util
|
src/main/java/org/dasein/util/ConcurrentMultiCache.java
|
ConcurrentMultiCache.find
|
public T find(Map<String,Object> vals) {
String key = order.get(0);
Object val = vals.get(key);
CacheLoader<T> loader;
if( val == null ) {
throw new CacheManagementException("No value specified for key: " + key);
}
loader = new MapLoader<T>(target);
return find(key, val, loader, vals);
}
|
java
|
public T find(Map<String,Object> vals) {
String key = order.get(0);
Object val = vals.get(key);
CacheLoader<T> loader;
if( val == null ) {
throw new CacheManagementException("No value specified for key: " + key);
}
loader = new MapLoader<T>(target);
return find(key, val, loader, vals);
}
|
[
"public",
"T",
"find",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"vals",
")",
"{",
"String",
"key",
"=",
"order",
".",
"get",
"(",
"0",
")",
";",
"Object",
"val",
"=",
"vals",
".",
"get",
"(",
"key",
")",
";",
"CacheLoader",
"<",
"T",
">",
"loader",
";",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"throw",
"new",
"CacheManagementException",
"(",
"\"No value specified for key: \"",
"+",
"key",
")",
";",
"}",
"loader",
"=",
"new",
"MapLoader",
"<",
"T",
">",
"(",
"target",
")",
";",
"return",
"find",
"(",
"key",
",",
"val",
",",
"loader",
",",
"vals",
")",
";",
"}"
] |
Finds the object in the cache matching the values in the specified value map.
If a matching argument is not in the cache, this method will instantiate an
instance of the object and assign the mapping values to that instantiated
object. In order for this to work, the keys in this mapping must have the same
names as the attributes for the instantiated object
@param vals the mapping that includes the attribute/value pairs
@return an object matching those values in the cache
|
[
"Finds",
"the",
"object",
"in",
"the",
"cache",
"matching",
"the",
"values",
"in",
"the",
"specified",
"value",
"map",
".",
"If",
"a",
"matching",
"argument",
"is",
"not",
"in",
"the",
"cache",
"this",
"method",
"will",
"instantiate",
"an",
"instance",
"of",
"the",
"object",
"and",
"assign",
"the",
"mapping",
"values",
"to",
"that",
"instantiated",
"object",
".",
"In",
"order",
"for",
"this",
"to",
"work",
"the",
"keys",
"in",
"this",
"mapping",
"must",
"have",
"the",
"same",
"names",
"as",
"the",
"attributes",
"for",
"the",
"instantiated",
"object"
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/ConcurrentMultiCache.java#L189-L199
|
149,349
|
greese/dasein-util
|
src/main/java/org/dasein/util/ConcurrentMultiCache.java
|
ConcurrentMultiCache.find
|
public T find(String key, Object val, CacheLoader<T> loader, Object ... args) {
ConcurrentCache<Object,T> cache = caches.get(key);
T item;
if( val instanceof BigDecimal ) {
val = ((BigDecimal)val).longValue();
}
item = cache.get(val);
if( item == null && loader != null ) {
item = loader.load(args);
if( item == null ) {
return null;
}
synchronized( this ) {
item = getCurrent(item);
put(item);
}
}
return item;
}
|
java
|
public T find(String key, Object val, CacheLoader<T> loader, Object ... args) {
ConcurrentCache<Object,T> cache = caches.get(key);
T item;
if( val instanceof BigDecimal ) {
val = ((BigDecimal)val).longValue();
}
item = cache.get(val);
if( item == null && loader != null ) {
item = loader.load(args);
if( item == null ) {
return null;
}
synchronized( this ) {
item = getCurrent(item);
put(item);
}
}
return item;
}
|
[
"public",
"T",
"find",
"(",
"String",
"key",
",",
"Object",
"val",
",",
"CacheLoader",
"<",
"T",
">",
"loader",
",",
"Object",
"...",
"args",
")",
"{",
"ConcurrentCache",
"<",
"Object",
",",
"T",
">",
"cache",
"=",
"caches",
".",
"get",
"(",
"key",
")",
";",
"T",
"item",
";",
"if",
"(",
"val",
"instanceof",
"BigDecimal",
")",
"{",
"val",
"=",
"(",
"(",
"BigDecimal",
")",
"val",
")",
".",
"longValue",
"(",
")",
";",
"}",
"item",
"=",
"cache",
".",
"get",
"(",
"val",
")",
";",
"if",
"(",
"item",
"==",
"null",
"&&",
"loader",
"!=",
"null",
")",
"{",
"item",
"=",
"loader",
".",
"load",
"(",
"args",
")",
";",
"if",
"(",
"item",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"synchronized",
"(",
"this",
")",
"{",
"item",
"=",
"getCurrent",
"(",
"item",
")",
";",
"put",
"(",
"item",
")",
";",
"}",
"}",
"return",
"item",
";",
"}"
] |
Seeks the item from the cache that is identified by the specified key having
the specified value. If no match is found, the specified loader will be called
with the specified arguments in order to place an instantiated item into the cache.
@param key the name of the unique identifier attribute whose value you have
@param val the value of the unique identifier that identifiers the desired item
@param loader a loader to load the desired object from the persistence store if it
is not in memory
@param args any arguments to pass to the loader
@return the object that matches the specified key/value
|
[
"Seeks",
"the",
"item",
"from",
"the",
"cache",
"that",
"is",
"identified",
"by",
"the",
"specified",
"key",
"having",
"the",
"specified",
"value",
".",
"If",
"no",
"match",
"is",
"found",
"the",
"specified",
"loader",
"will",
"be",
"called",
"with",
"the",
"specified",
"arguments",
"in",
"order",
"to",
"place",
"an",
"instantiated",
"item",
"into",
"the",
"cache",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/ConcurrentMultiCache.java#L256-L275
|
149,350
|
greese/dasein-util
|
src/main/java/org/dasein/util/ConcurrentMultiCache.java
|
ConcurrentMultiCache.getCurrent
|
private T getCurrent(T item) {
for( String key: order ) {
ConcurrentCache<Object,T> cache = caches.get(key);
Object val = getValue(key, item);
T tmp;
if( val instanceof BigDecimal ) {
val = ((BigDecimal)val).longValue();
}
tmp = cache.get(val);
if( tmp != null ) {
if( tmp instanceof CachedItem ) {
if( ((CachedItem)tmp).isValidForCache() ) {
return tmp;
}
}
else {
return tmp;
}
}
}
return item;
}
|
java
|
private T getCurrent(T item) {
for( String key: order ) {
ConcurrentCache<Object,T> cache = caches.get(key);
Object val = getValue(key, item);
T tmp;
if( val instanceof BigDecimal ) {
val = ((BigDecimal)val).longValue();
}
tmp = cache.get(val);
if( tmp != null ) {
if( tmp instanceof CachedItem ) {
if( ((CachedItem)tmp).isValidForCache() ) {
return tmp;
}
}
else {
return tmp;
}
}
}
return item;
}
|
[
"private",
"T",
"getCurrent",
"(",
"T",
"item",
")",
"{",
"for",
"(",
"String",
"key",
":",
"order",
")",
"{",
"ConcurrentCache",
"<",
"Object",
",",
"T",
">",
"cache",
"=",
"caches",
".",
"get",
"(",
"key",
")",
";",
"Object",
"val",
"=",
"getValue",
"(",
"key",
",",
"item",
")",
";",
"T",
"tmp",
";",
"if",
"(",
"val",
"instanceof",
"BigDecimal",
")",
"{",
"val",
"=",
"(",
"(",
"BigDecimal",
")",
"val",
")",
".",
"longValue",
"(",
")",
";",
"}",
"tmp",
"=",
"cache",
".",
"get",
"(",
"val",
")",
";",
"if",
"(",
"tmp",
"!=",
"null",
")",
"{",
"if",
"(",
"tmp",
"instanceof",
"CachedItem",
")",
"{",
"if",
"(",
"(",
"(",
"CachedItem",
")",
"tmp",
")",
".",
"isValidForCache",
"(",
")",
")",
"{",
"return",
"tmp",
";",
"}",
"}",
"else",
"{",
"return",
"tmp",
";",
"}",
"}",
"}",
"return",
"item",
";",
"}"
] |
Provides the current version of the specified item stored in the cache.
If no item matches the passed in item, then the passed in item is returned
but not cached. This better be called from a synchronized block!
@param item the item being sought
@return the currently cached object that is equivalent to the passed in object
|
[
"Provides",
"the",
"current",
"version",
"of",
"the",
"specified",
"item",
"stored",
"in",
"the",
"cache",
".",
"If",
"no",
"item",
"matches",
"the",
"passed",
"in",
"item",
"then",
"the",
"passed",
"in",
"item",
"is",
"returned",
"but",
"not",
"cached",
".",
"This",
"better",
"be",
"called",
"from",
"a",
"synchronized",
"block!"
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/ConcurrentMultiCache.java#L284-L306
|
149,351
|
greese/dasein-util
|
src/main/java/org/dasein/util/ConcurrentMultiCache.java
|
ConcurrentMultiCache.getKeys
|
public HashMap<String,Object> getKeys(T item) {
HashMap<String,Object> keys = new HashMap<String,Object>();
for( String key: caches.keySet() ) {
keys.put(key, getValue(key, item));
}
return keys;
}
|
java
|
public HashMap<String,Object> getKeys(T item) {
HashMap<String,Object> keys = new HashMap<String,Object>();
for( String key: caches.keySet() ) {
keys.put(key, getValue(key, item));
}
return keys;
}
|
[
"public",
"HashMap",
"<",
"String",
",",
"Object",
">",
"getKeys",
"(",
"T",
"item",
")",
"{",
"HashMap",
"<",
"String",
",",
"Object",
">",
"keys",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"for",
"(",
"String",
"key",
":",
"caches",
".",
"keySet",
"(",
")",
")",
"{",
"keys",
".",
"put",
"(",
"key",
",",
"getValue",
"(",
"key",
",",
"item",
")",
")",
";",
"}",
"return",
"keys",
";",
"}"
] |
Provides the values for all of the unique identifiers managed by the cache.
@param item the item whose key values are being sought
@return a mapping of key names to item values
|
[
"Provides",
"the",
"values",
"for",
"all",
"of",
"the",
"unique",
"identifiers",
"managed",
"by",
"the",
"cache",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/ConcurrentMultiCache.java#L313-L320
|
149,352
|
greese/dasein-util
|
src/main/java/org/dasein/util/ConcurrentMultiCache.java
|
ConcurrentMultiCache.getValue
|
private Object getValue(String key, T item) {
Class cls = item.getClass();
while( true ) {
try {
Field f = cls.getDeclaredField(key);
int m = f.getModifiers();
if( Modifier.isTransient(m) || Modifier.isStatic(m) ) {
return null;
}
f.setAccessible(true);
return f.get(item);
}
catch( Exception e ) {
Class[] params = new Class[0];
String mname;
mname = "get" + key.substring(0,1).toUpperCase() + key.substring(1);
try {
Method method = cls.getDeclaredMethod(mname, params);
Object[] args = new Object[0];
return method.invoke(item, args);
}
catch( IllegalAccessException e2 ) {
// ignore
}
catch( SecurityException e2 ) {
// ignore
}
catch( NoSuchMethodException e2 ) {
// ignore
}
catch( IllegalArgumentException e2 ) {
// ignore
}
catch( InvocationTargetException e2 ) {
// ignore
}
cls = cls.getSuperclass();
if( cls == null || cls.getName().getClass().equals(Object.class.getName()) ) {
throw new CacheManagementException("No such property: " + key);
}
}
}
}
|
java
|
private Object getValue(String key, T item) {
Class cls = item.getClass();
while( true ) {
try {
Field f = cls.getDeclaredField(key);
int m = f.getModifiers();
if( Modifier.isTransient(m) || Modifier.isStatic(m) ) {
return null;
}
f.setAccessible(true);
return f.get(item);
}
catch( Exception e ) {
Class[] params = new Class[0];
String mname;
mname = "get" + key.substring(0,1).toUpperCase() + key.substring(1);
try {
Method method = cls.getDeclaredMethod(mname, params);
Object[] args = new Object[0];
return method.invoke(item, args);
}
catch( IllegalAccessException e2 ) {
// ignore
}
catch( SecurityException e2 ) {
// ignore
}
catch( NoSuchMethodException e2 ) {
// ignore
}
catch( IllegalArgumentException e2 ) {
// ignore
}
catch( InvocationTargetException e2 ) {
// ignore
}
cls = cls.getSuperclass();
if( cls == null || cls.getName().getClass().equals(Object.class.getName()) ) {
throw new CacheManagementException("No such property: " + key);
}
}
}
}
|
[
"private",
"Object",
"getValue",
"(",
"String",
"key",
",",
"T",
"item",
")",
"{",
"Class",
"cls",
"=",
"item",
".",
"getClass",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"Field",
"f",
"=",
"cls",
".",
"getDeclaredField",
"(",
"key",
")",
";",
"int",
"m",
"=",
"f",
".",
"getModifiers",
"(",
")",
";",
"if",
"(",
"Modifier",
".",
"isTransient",
"(",
"m",
")",
"||",
"Modifier",
".",
"isStatic",
"(",
"m",
")",
")",
"{",
"return",
"null",
";",
"}",
"f",
".",
"setAccessible",
"(",
"true",
")",
";",
"return",
"f",
".",
"get",
"(",
"item",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Class",
"[",
"]",
"params",
"=",
"new",
"Class",
"[",
"0",
"]",
";",
"String",
"mname",
";",
"mname",
"=",
"\"get\"",
"+",
"key",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
")",
"+",
"key",
".",
"substring",
"(",
"1",
")",
";",
"try",
"{",
"Method",
"method",
"=",
"cls",
".",
"getDeclaredMethod",
"(",
"mname",
",",
"params",
")",
";",
"Object",
"[",
"]",
"args",
"=",
"new",
"Object",
"[",
"0",
"]",
";",
"return",
"method",
".",
"invoke",
"(",
"item",
",",
"args",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e2",
")",
"{",
"// ignore",
"}",
"catch",
"(",
"SecurityException",
"e2",
")",
"{",
"// ignore",
"}",
"catch",
"(",
"NoSuchMethodException",
"e2",
")",
"{",
"// ignore",
"}",
"catch",
"(",
"IllegalArgumentException",
"e2",
")",
"{",
"// ignore",
"}",
"catch",
"(",
"InvocationTargetException",
"e2",
")",
"{",
"// ignore",
"}",
"cls",
"=",
"cls",
".",
"getSuperclass",
"(",
")",
";",
"if",
"(",
"cls",
"==",
"null",
"||",
"cls",
".",
"getName",
"(",
")",
".",
"getClass",
"(",
")",
".",
"equals",
"(",
"Object",
".",
"class",
".",
"getName",
"(",
")",
")",
")",
"{",
"throw",
"new",
"CacheManagementException",
"(",
"\"No such property: \"",
"+",
"key",
")",
";",
"}",
"}",
"}",
"}"
] |
Provides the actual value for the specified unique ID key for the specified object.
@param key the name of the unique identifier
@param item the object who's unique identifier value is sought
@return the unique identifier for the object's attribute matching the key
|
[
"Provides",
"the",
"actual",
"value",
"for",
"the",
"specified",
"unique",
"ID",
"key",
"for",
"the",
"specified",
"object",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/ConcurrentMultiCache.java#L332-L378
|
149,353
|
greese/dasein-util
|
src/main/java/org/dasein/util/ConcurrentMultiCache.java
|
ConcurrentMultiCache.put
|
private void put(T item) {
HashMap<String,Object> keys;
if( item == null ) {
throw new NullPointerException("Multi caches may not have null values.");
}
keys = getKeys(item);
synchronized( this ) {
for( String key : caches.keySet() ) {
ConcurrentCache<Object,T> cache = caches.get(key);
Object ob = keys.get(key);
if( ob instanceof BigDecimal ) {
ob = ((BigDecimal)ob).longValue();
}
cache.put(ob, item);
}
}
}
|
java
|
private void put(T item) {
HashMap<String,Object> keys;
if( item == null ) {
throw new NullPointerException("Multi caches may not have null values.");
}
keys = getKeys(item);
synchronized( this ) {
for( String key : caches.keySet() ) {
ConcurrentCache<Object,T> cache = caches.get(key);
Object ob = keys.get(key);
if( ob instanceof BigDecimal ) {
ob = ((BigDecimal)ob).longValue();
}
cache.put(ob, item);
}
}
}
|
[
"private",
"void",
"put",
"(",
"T",
"item",
")",
"{",
"HashMap",
"<",
"String",
",",
"Object",
">",
"keys",
";",
"if",
"(",
"item",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Multi caches may not have null values.\"",
")",
";",
"}",
"keys",
"=",
"getKeys",
"(",
"item",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"for",
"(",
"String",
"key",
":",
"caches",
".",
"keySet",
"(",
")",
")",
"{",
"ConcurrentCache",
"<",
"Object",
",",
"T",
">",
"cache",
"=",
"caches",
".",
"get",
"(",
"key",
")",
";",
"Object",
"ob",
"=",
"keys",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"ob",
"instanceof",
"BigDecimal",
")",
"{",
"ob",
"=",
"(",
"(",
"BigDecimal",
")",
"ob",
")",
".",
"longValue",
"(",
")",
";",
"}",
"cache",
".",
"put",
"(",
"ob",
",",
"item",
")",
";",
"}",
"}",
"}"
] |
Places the specified item into the cache regardless of current cache state.
@param item the item being placed into the cache
|
[
"Places",
"the",
"specified",
"item",
"into",
"the",
"cache",
"regardless",
"of",
"current",
"cache",
"state",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/ConcurrentMultiCache.java#L384-L402
|
149,354
|
greese/dasein-util
|
src/main/java/org/dasein/util/Cache.java
|
Cache.cache
|
public void cache(Object key, T val) {
cache.put(key, new SoftReference<T>(val));
}
|
java
|
public void cache(Object key, T val) {
cache.put(key, new SoftReference<T>(val));
}
|
[
"public",
"void",
"cache",
"(",
"Object",
"key",
",",
"T",
"val",
")",
"{",
"cache",
".",
"put",
"(",
"key",
",",
"new",
"SoftReference",
"<",
"T",
">",
"(",
"val",
")",
")",
";",
"}"
] |
Caches the specified object identified by the specified key.
@param key a unique key for this object
@param val the object to be cached
|
[
"Caches",
"the",
"specified",
"object",
"identified",
"by",
"the",
"specified",
"key",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/Cache.java#L90-L92
|
149,355
|
greese/dasein-util
|
src/main/java/org/dasein/util/Cache.java
|
Cache.containsAll
|
public boolean containsAll(Collection<?> coll) {
for( Object item : coll ) {
if( !contains(item) ) {
return false;
}
}
return true;
}
|
java
|
public boolean containsAll(Collection<?> coll) {
for( Object item : coll ) {
if( !contains(item) ) {
return false;
}
}
return true;
}
|
[
"public",
"boolean",
"containsAll",
"(",
"Collection",
"<",
"?",
">",
"coll",
")",
"{",
"for",
"(",
"Object",
"item",
":",
"coll",
")",
"{",
"if",
"(",
"!",
"contains",
"(",
"item",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Checks the passed in collection and determines if all elements
of that collection are contained within this cache. Care should
be taken in reading too much into a failure. If one of the elements
was once in this cache but has expired due to inactivity, this
method will return false.
@param coll the collection to test
@return true if all elements of the tested collection are in the cache
|
[
"Checks",
"the",
"passed",
"in",
"collection",
"and",
"determines",
"if",
"all",
"elements",
"of",
"that",
"collection",
"are",
"contained",
"within",
"this",
"cache",
".",
"Care",
"should",
"be",
"taken",
"in",
"reading",
"too",
"much",
"into",
"a",
"failure",
".",
"If",
"one",
"of",
"the",
"elements",
"was",
"once",
"in",
"this",
"cache",
"but",
"has",
"expired",
"due",
"to",
"inactivity",
"this",
"method",
"will",
"return",
"false",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/Cache.java#L134-L141
|
149,356
|
greese/dasein-util
|
src/main/java/org/dasein/util/Cache.java
|
Cache.containsKey
|
public boolean containsKey(Object key) {
if( !cache.containsKey(key) ) {
return false;
}
else {
SoftReference<T> ref = cache.get(key);
T ob = ref.get();
if( ob == null ) {
release(key);
return false;
}
if( ob instanceof CachedItem ) {
if( !((CachedItem)ob).isValidForCache() ) {
release(key);
return false;
}
}
return true;
}
}
|
java
|
public boolean containsKey(Object key) {
if( !cache.containsKey(key) ) {
return false;
}
else {
SoftReference<T> ref = cache.get(key);
T ob = ref.get();
if( ob == null ) {
release(key);
return false;
}
if( ob instanceof CachedItem ) {
if( !((CachedItem)ob).isValidForCache() ) {
release(key);
return false;
}
}
return true;
}
}
|
[
"public",
"boolean",
"containsKey",
"(",
"Object",
"key",
")",
"{",
"if",
"(",
"!",
"cache",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"SoftReference",
"<",
"T",
">",
"ref",
"=",
"cache",
".",
"get",
"(",
"key",
")",
";",
"T",
"ob",
"=",
"ref",
".",
"get",
"(",
")",
";",
"if",
"(",
"ob",
"==",
"null",
")",
"{",
"release",
"(",
"key",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"ob",
"instanceof",
"CachedItem",
")",
"{",
"if",
"(",
"!",
"(",
"(",
"CachedItem",
")",
"ob",
")",
".",
"isValidForCache",
"(",
")",
")",
"{",
"release",
"(",
"key",
")",
";",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
"}"
] |
Checks if an object with the specified key is in the cache.
@param key the object's identifier
@return true if the object is in the cache
|
[
"Checks",
"if",
"an",
"object",
"with",
"the",
"specified",
"key",
"is",
"in",
"the",
"cache",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/Cache.java#L148-L168
|
149,357
|
workplacesystems/queuj
|
src/main/java/com/workplacesystems/queuj/ProcessBuilder.java
|
ProcessBuilder.newProcess
|
public <K extends Serializable & Comparable> Process<K> newProcess()
{
final String queueOwner = partition == null ? null : partition.getQueueOwnerKey();
Callback<ProcessWrapper<K>> callback = new Callback<ProcessWrapper<K>>() {
@Override
protected void doAction() {
ProcessWrapper<K> process = ProcessWrapper.getNewInstance(
queueOwner, is_persistent, implementation_options);
ProcessPersistence<ProcessEntity<K>,K> processHome =
process.setDetails(process_name, queue, process_description, user,
occurrence, visibility, access, resilience, output,
pre_processes, post_processes, keep_completed,
process_listeners, locale, implementation_options);
if (report_type != null)
process.setReportType(report_type);
if(source_name != null)
process.setSourceName(source_name);
setupProcess(new Process(process));
preSubmitBatchJobProcessing();
if (is_persistent) processHome.persist();
process.getContainingServer().submitProcess(process);
_return(process);
}
};
QueujTransaction<K> transaction = (QueujTransaction<K>)QueujFactory.getTransaction();
return new Process<K>(transaction.doTransaction(queueOwner, is_persistent, callback, true));
}
|
java
|
public <K extends Serializable & Comparable> Process<K> newProcess()
{
final String queueOwner = partition == null ? null : partition.getQueueOwnerKey();
Callback<ProcessWrapper<K>> callback = new Callback<ProcessWrapper<K>>() {
@Override
protected void doAction() {
ProcessWrapper<K> process = ProcessWrapper.getNewInstance(
queueOwner, is_persistent, implementation_options);
ProcessPersistence<ProcessEntity<K>,K> processHome =
process.setDetails(process_name, queue, process_description, user,
occurrence, visibility, access, resilience, output,
pre_processes, post_processes, keep_completed,
process_listeners, locale, implementation_options);
if (report_type != null)
process.setReportType(report_type);
if(source_name != null)
process.setSourceName(source_name);
setupProcess(new Process(process));
preSubmitBatchJobProcessing();
if (is_persistent) processHome.persist();
process.getContainingServer().submitProcess(process);
_return(process);
}
};
QueujTransaction<K> transaction = (QueujTransaction<K>)QueujFactory.getTransaction();
return new Process<K>(transaction.doTransaction(queueOwner, is_persistent, callback, true));
}
|
[
"public",
"<",
"K",
"extends",
"Serializable",
"&",
"Comparable",
">",
"Process",
"<",
"K",
">",
"newProcess",
"(",
")",
"{",
"final",
"String",
"queueOwner",
"=",
"partition",
"==",
"null",
"?",
"null",
":",
"partition",
".",
"getQueueOwnerKey",
"(",
")",
";",
"Callback",
"<",
"ProcessWrapper",
"<",
"K",
">",
">",
"callback",
"=",
"new",
"Callback",
"<",
"ProcessWrapper",
"<",
"K",
">",
">",
"(",
")",
"{",
"@",
"Override",
"protected",
"void",
"doAction",
"(",
")",
"{",
"ProcessWrapper",
"<",
"K",
">",
"process",
"=",
"ProcessWrapper",
".",
"getNewInstance",
"(",
"queueOwner",
",",
"is_persistent",
",",
"implementation_options",
")",
";",
"ProcessPersistence",
"<",
"ProcessEntity",
"<",
"K",
">",
",",
"K",
">",
"processHome",
"=",
"process",
".",
"setDetails",
"(",
"process_name",
",",
"queue",
",",
"process_description",
",",
"user",
",",
"occurrence",
",",
"visibility",
",",
"access",
",",
"resilience",
",",
"output",
",",
"pre_processes",
",",
"post_processes",
",",
"keep_completed",
",",
"process_listeners",
",",
"locale",
",",
"implementation_options",
")",
";",
"if",
"(",
"report_type",
"!=",
"null",
")",
"process",
".",
"setReportType",
"(",
"report_type",
")",
";",
"if",
"(",
"source_name",
"!=",
"null",
")",
"process",
".",
"setSourceName",
"(",
"source_name",
")",
";",
"setupProcess",
"(",
"new",
"Process",
"(",
"process",
")",
")",
";",
"preSubmitBatchJobProcessing",
"(",
")",
";",
"if",
"(",
"is_persistent",
")",
"processHome",
".",
"persist",
"(",
")",
";",
"process",
".",
"getContainingServer",
"(",
")",
".",
"submitProcess",
"(",
"process",
")",
";",
"_return",
"(",
"process",
")",
";",
"}",
"}",
";",
"QueujTransaction",
"<",
"K",
">",
"transaction",
"=",
"(",
"QueujTransaction",
"<",
"K",
">",
")",
"QueujFactory",
".",
"getTransaction",
"(",
")",
";",
"return",
"new",
"Process",
"<",
"K",
">",
"(",
"transaction",
".",
"doTransaction",
"(",
"queueOwner",
",",
"is_persistent",
",",
"callback",
",",
"true",
")",
")",
";",
"}"
] |
Creates the Process using the parameters that have been set.
|
[
"Creates",
"the",
"Process",
"using",
"the",
"parameters",
"that",
"have",
"been",
"set",
"."
] |
4293116b412b4a20ead99963b9b05a135812c501
|
https://github.com/workplacesystems/queuj/blob/4293116b412b4a20ead99963b9b05a135812c501/src/main/java/com/workplacesystems/queuj/ProcessBuilder.java#L341-L378
|
149,358
|
jiaqi/caff
|
src/main/java/org/cyclopsgroup/caff/format/FixLengthImpl.java
|
FixLengthImpl.print
|
char[] print(T bean) {
char[] output = new char[type.length()];
Arrays.fill(output, type.fill());
for (Slot slot : slots.values()) {
if (!slot.reference.isReadable()) {
continue;
}
Object value = slot.reference.readValue(bean);
CharSequence content = slot.converter.toCharacters(value);
if (content.length() > slot.field.length()) {
content = slot.field.trim().trim(content, slot.field.length(), slot.field.align());
}
slot.field.align().fill(content, output, slot.field.start(), slot.field.length(), slot.fill);
}
return output;
}
|
java
|
char[] print(T bean) {
char[] output = new char[type.length()];
Arrays.fill(output, type.fill());
for (Slot slot : slots.values()) {
if (!slot.reference.isReadable()) {
continue;
}
Object value = slot.reference.readValue(bean);
CharSequence content = slot.converter.toCharacters(value);
if (content.length() > slot.field.length()) {
content = slot.field.trim().trim(content, slot.field.length(), slot.field.align());
}
slot.field.align().fill(content, output, slot.field.start(), slot.field.length(), slot.fill);
}
return output;
}
|
[
"char",
"[",
"]",
"print",
"(",
"T",
"bean",
")",
"{",
"char",
"[",
"]",
"output",
"=",
"new",
"char",
"[",
"type",
".",
"length",
"(",
")",
"]",
";",
"Arrays",
".",
"fill",
"(",
"output",
",",
"type",
".",
"fill",
"(",
")",
")",
";",
"for",
"(",
"Slot",
"slot",
":",
"slots",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"!",
"slot",
".",
"reference",
".",
"isReadable",
"(",
")",
")",
"{",
"continue",
";",
"}",
"Object",
"value",
"=",
"slot",
".",
"reference",
".",
"readValue",
"(",
"bean",
")",
";",
"CharSequence",
"content",
"=",
"slot",
".",
"converter",
".",
"toCharacters",
"(",
"value",
")",
";",
"if",
"(",
"content",
".",
"length",
"(",
")",
">",
"slot",
".",
"field",
".",
"length",
"(",
")",
")",
"{",
"content",
"=",
"slot",
".",
"field",
".",
"trim",
"(",
")",
".",
"trim",
"(",
"content",
",",
"slot",
".",
"field",
".",
"length",
"(",
")",
",",
"slot",
".",
"field",
".",
"align",
"(",
")",
")",
";",
"}",
"slot",
".",
"field",
".",
"align",
"(",
")",
".",
"fill",
"(",
"content",
",",
"output",
",",
"slot",
".",
"field",
".",
"start",
"(",
")",
",",
"slot",
".",
"field",
".",
"length",
"(",
")",
",",
"slot",
".",
"fill",
")",
";",
"}",
"return",
"output",
";",
"}"
] |
Print bean into given char array FIXME It's not completely working yet
@param bean Bean to print
@return Char array of result
|
[
"Print",
"bean",
"into",
"given",
"char",
"array",
"FIXME",
"It",
"s",
"not",
"completely",
"working",
"yet"
] |
dba4b937a0afc844eb37ccf74dd04dd78f0c1314
|
https://github.com/jiaqi/caff/blob/dba4b937a0afc844eb37ccf74dd04dd78f0c1314/src/main/java/org/cyclopsgroup/caff/format/FixLengthImpl.java#L99-L114
|
149,359
|
progolden/vraptor-boilerplate
|
vraptor-boilerplate-utils/src/main/java/br/com/caelum/vraptor/boilerplate/i18n/MessageBundle.java
|
MessageBundle.formatMessage
|
public String formatMessage(String key, Object[] args) {
try {
String raw = this.getMessage(key);
return MessageFormat.format(raw, args);
} catch (MissingResourceException ex) {
return "???!"+key+"!???";
}
}
|
java
|
public String formatMessage(String key, Object[] args) {
try {
String raw = this.getMessage(key);
return MessageFormat.format(raw, args);
} catch (MissingResourceException ex) {
return "???!"+key+"!???";
}
}
|
[
"public",
"String",
"formatMessage",
"(",
"String",
"key",
",",
"Object",
"[",
"]",
"args",
")",
"{",
"try",
"{",
"String",
"raw",
"=",
"this",
".",
"getMessage",
"(",
"key",
")",
";",
"return",
"MessageFormat",
".",
"format",
"(",
"raw",
",",
"args",
")",
";",
"}",
"catch",
"(",
"MissingResourceException",
"ex",
")",
"{",
"return",
"\"???!\"",
"+",
"key",
"+",
"\"!???\"",
";",
"}",
"}"
] |
Retorna uma mensagem formatada utilizando o MessageFormat.
@param key Chave da mesnagem.
@param args Parametros a serem inseridos na mensagem.
@return Mensagem formatada inserindo os argumentos no template estático obtivdo do arquivo de propriedades.
|
[
"Retorna",
"uma",
"mensagem",
"formatada",
"utilizando",
"o",
"MessageFormat",
"."
] |
3edf45cc0dc5aec61b16ca326b4d72c82d1d3e07
|
https://github.com/progolden/vraptor-boilerplate/blob/3edf45cc0dc5aec61b16ca326b4d72c82d1d3e07/vraptor-boilerplate-utils/src/main/java/br/com/caelum/vraptor/boilerplate/i18n/MessageBundle.java#L80-L87
|
149,360
|
Viascom/groundwork
|
foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/body/request/RequestMultipartBody.java
|
RequestMultipartBody.addFilePart
|
public void addFilePart(String fieldName, File uploadFile) throws FileNotFoundException {
stream.put(fieldName, new NamedInputStream(uploadFile.getName(), new FileInputStream(uploadFile), "binary", URLConnection.guessContentTypeFromName(uploadFile.getName())));
}
|
java
|
public void addFilePart(String fieldName, File uploadFile) throws FileNotFoundException {
stream.put(fieldName, new NamedInputStream(uploadFile.getName(), new FileInputStream(uploadFile), "binary", URLConnection.guessContentTypeFromName(uploadFile.getName())));
}
|
[
"public",
"void",
"addFilePart",
"(",
"String",
"fieldName",
",",
"File",
"uploadFile",
")",
"throws",
"FileNotFoundException",
"{",
"stream",
".",
"put",
"(",
"fieldName",
",",
"new",
"NamedInputStream",
"(",
"uploadFile",
".",
"getName",
"(",
")",
",",
"new",
"FileInputStream",
"(",
"uploadFile",
")",
",",
"\"binary\"",
",",
"URLConnection",
".",
"guessContentTypeFromName",
"(",
"uploadFile",
".",
"getName",
"(",
")",
")",
")",
")",
";",
"}"
] |
Adds a file to the request
@param fieldName name attribute
@param uploadFile a File to be uploaded
@throws FileNotFoundException
|
[
"Adds",
"a",
"file",
"to",
"the",
"request"
] |
d3f7d0df65e2e75861fc7db938090683f2cdf919
|
https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/body/request/RequestMultipartBody.java#L141-L143
|
149,361
|
Viascom/groundwork
|
foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/body/request/RequestMultipartBody.java
|
RequestMultipartBody.addInputStreamPart
|
public void addInputStreamPart(String name, String inputStreamName, InputStream inputStream, String contentTransferEncoding, String contentType) {
stream.put(name, new NamedInputStream(inputStreamName, inputStream, contentTransferEncoding, contentType));
}
|
java
|
public void addInputStreamPart(String name, String inputStreamName, InputStream inputStream, String contentTransferEncoding, String contentType) {
stream.put(name, new NamedInputStream(inputStreamName, inputStream, contentTransferEncoding, contentType));
}
|
[
"public",
"void",
"addInputStreamPart",
"(",
"String",
"name",
",",
"String",
"inputStreamName",
",",
"InputStream",
"inputStream",
",",
"String",
"contentTransferEncoding",
",",
"String",
"contentType",
")",
"{",
"stream",
".",
"put",
"(",
"name",
",",
"new",
"NamedInputStream",
"(",
"inputStreamName",
",",
"inputStream",
",",
"contentTransferEncoding",
",",
"contentType",
")",
")",
";",
"}"
] |
Adds an inputstream to te request
@param name
@param inputStreamName
@param inputStream
@param contentTransferEncoding usually binary
@param contentType
|
[
"Adds",
"an",
"inputstream",
"to",
"te",
"request"
] |
d3f7d0df65e2e75861fc7db938090683f2cdf919
|
https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/body/request/RequestMultipartBody.java#L154-L156
|
149,362
|
yangjm/winlet
|
utils/src/main/java/com/aggrepoint/utils/CollectionUtils.java
|
CollectionUtils.toHashMap
|
public static <T, K> HashMap<K, T> toHashMap(Collection<T> entities,
Function<T, K> keyMapper) {
return toMap(entities, keyMapper, HashMap<K, T>::new);
}
|
java
|
public static <T, K> HashMap<K, T> toHashMap(Collection<T> entities,
Function<T, K> keyMapper) {
return toMap(entities, keyMapper, HashMap<K, T>::new);
}
|
[
"public",
"static",
"<",
"T",
",",
"K",
">",
"HashMap",
"<",
"K",
",",
"T",
">",
"toHashMap",
"(",
"Collection",
"<",
"T",
">",
"entities",
",",
"Function",
"<",
"T",
",",
"K",
">",
"keyMapper",
")",
"{",
"return",
"toMap",
"(",
"entities",
",",
"keyMapper",
",",
"HashMap",
"<",
"K",
",",
"T",
">",
"::",
"new",
")",
";",
"}"
] |
Convert a collection to HashMap, The key is decided by keyMapper, value
is the object in collection
@param entities
@param keyMapper
@return
|
[
"Convert",
"a",
"collection",
"to",
"HashMap",
"The",
"key",
"is",
"decided",
"by",
"keyMapper",
"value",
"is",
"the",
"object",
"in",
"collection"
] |
2126236f56858e283fa6ad69fe9279ee30f47b67
|
https://github.com/yangjm/winlet/blob/2126236f56858e283fa6ad69fe9279ee30f47b67/utils/src/main/java/com/aggrepoint/utils/CollectionUtils.java#L98-L101
|
149,363
|
yangjm/winlet
|
utils/src/main/java/com/aggrepoint/utils/CollectionUtils.java
|
CollectionUtils.toHashtable
|
public static <T, K> Hashtable<K, T> toHashtable(Collection<T> entities,
Function<T, K> keyMapper) {
return toMap(entities, keyMapper, Hashtable<K, T>::new);
}
|
java
|
public static <T, K> Hashtable<K, T> toHashtable(Collection<T> entities,
Function<T, K> keyMapper) {
return toMap(entities, keyMapper, Hashtable<K, T>::new);
}
|
[
"public",
"static",
"<",
"T",
",",
"K",
">",
"Hashtable",
"<",
"K",
",",
"T",
">",
"toHashtable",
"(",
"Collection",
"<",
"T",
">",
"entities",
",",
"Function",
"<",
"T",
",",
"K",
">",
"keyMapper",
")",
"{",
"return",
"toMap",
"(",
"entities",
",",
"keyMapper",
",",
"Hashtable",
"<",
"K",
",",
"T",
">",
"::",
"new",
")",
";",
"}"
] |
Convert a collection to Hashtable. The key is decided by keyMapper, value
is the object in collection
@param entities
@param keyMapper
@return
|
[
"Convert",
"a",
"collection",
"to",
"Hashtable",
".",
"The",
"key",
"is",
"decided",
"by",
"keyMapper",
"value",
"is",
"the",
"object",
"in",
"collection"
] |
2126236f56858e283fa6ad69fe9279ee30f47b67
|
https://github.com/yangjm/winlet/blob/2126236f56858e283fa6ad69fe9279ee30f47b67/utils/src/main/java/com/aggrepoint/utils/CollectionUtils.java#L126-L129
|
149,364
|
yangjm/winlet
|
utils/src/main/java/com/aggrepoint/utils/CollectionUtils.java
|
CollectionUtils.groupTwice
|
public static <T, K, V, P, C extends Collection<V>> HashMap<K, HashMap<P, C>> groupTwice(
Collection<T> entities, Function<T, K> keyMapper1,
Function<T, P> keyMapper2, Function<T, V> valueMapper,
Supplier<C> collectionFactory) {
if (entities == null)
return null;
return entities.stream().collect(
Collectors.groupingBy(keyMapper1, HashMap::new, Collectors
.groupingBy(keyMapper2, HashMap::new, Collectors
.mapping(valueMapper, Collectors
.toCollection(collectionFactory)))));
}
|
java
|
public static <T, K, V, P, C extends Collection<V>> HashMap<K, HashMap<P, C>> groupTwice(
Collection<T> entities, Function<T, K> keyMapper1,
Function<T, P> keyMapper2, Function<T, V> valueMapper,
Supplier<C> collectionFactory) {
if (entities == null)
return null;
return entities.stream().collect(
Collectors.groupingBy(keyMapper1, HashMap::new, Collectors
.groupingBy(keyMapper2, HashMap::new, Collectors
.mapping(valueMapper, Collectors
.toCollection(collectionFactory)))));
}
|
[
"public",
"static",
"<",
"T",
",",
"K",
",",
"V",
",",
"P",
",",
"C",
"extends",
"Collection",
"<",
"V",
">",
">",
"HashMap",
"<",
"K",
",",
"HashMap",
"<",
"P",
",",
"C",
">",
">",
"groupTwice",
"(",
"Collection",
"<",
"T",
">",
"entities",
",",
"Function",
"<",
"T",
",",
"K",
">",
"keyMapper1",
",",
"Function",
"<",
"T",
",",
"P",
">",
"keyMapper2",
",",
"Function",
"<",
"T",
",",
"V",
">",
"valueMapper",
",",
"Supplier",
"<",
"C",
">",
"collectionFactory",
")",
"{",
"if",
"(",
"entities",
"==",
"null",
")",
"return",
"null",
";",
"return",
"entities",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"groupingBy",
"(",
"keyMapper1",
",",
"HashMap",
"::",
"new",
",",
"Collectors",
".",
"groupingBy",
"(",
"keyMapper2",
",",
"HashMap",
"::",
"new",
",",
"Collectors",
".",
"mapping",
"(",
"valueMapper",
",",
"Collectors",
".",
"toCollection",
"(",
"collectionFactory",
")",
")",
")",
")",
")",
";",
"}"
] |
Grouping into 2 levels
@param entities
@param keyMapper1
@param keyMapper2
@param valueMapper
@param collectionFactory
@return
|
[
"Grouping",
"into",
"2",
"levels"
] |
2126236f56858e283fa6ad69fe9279ee30f47b67
|
https://github.com/yangjm/winlet/blob/2126236f56858e283fa6ad69fe9279ee30f47b67/utils/src/main/java/com/aggrepoint/utils/CollectionUtils.java#L204-L215
|
149,365
|
yangjm/winlet
|
utils/src/main/java/com/aggrepoint/utils/CollectionUtils.java
|
CollectionUtils.matrix
|
public static <T, K, V, P> HashMap<K, HashMap<P, V>> matrix(
Collection<T> entities, Function<T, K> keyMapper1,
Function<T, P> keyMapper2, Function<T, V> valueMapper) {
if (entities == null)
return null;
return entities.stream().collect(
Collectors.groupingBy(keyMapper1, HashMap::new, Collectors
.toMap(keyMapper2, valueMapper, (a, b) -> a,
HashMap::new)));
}
|
java
|
public static <T, K, V, P> HashMap<K, HashMap<P, V>> matrix(
Collection<T> entities, Function<T, K> keyMapper1,
Function<T, P> keyMapper2, Function<T, V> valueMapper) {
if (entities == null)
return null;
return entities.stream().collect(
Collectors.groupingBy(keyMapper1, HashMap::new, Collectors
.toMap(keyMapper2, valueMapper, (a, b) -> a,
HashMap::new)));
}
|
[
"public",
"static",
"<",
"T",
",",
"K",
",",
"V",
",",
"P",
">",
"HashMap",
"<",
"K",
",",
"HashMap",
"<",
"P",
",",
"V",
">",
">",
"matrix",
"(",
"Collection",
"<",
"T",
">",
"entities",
",",
"Function",
"<",
"T",
",",
"K",
">",
"keyMapper1",
",",
"Function",
"<",
"T",
",",
"P",
">",
"keyMapper2",
",",
"Function",
"<",
"T",
",",
"V",
">",
"valueMapper",
")",
"{",
"if",
"(",
"entities",
"==",
"null",
")",
"return",
"null",
";",
"return",
"entities",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"groupingBy",
"(",
"keyMapper1",
",",
"HashMap",
"::",
"new",
",",
"Collectors",
".",
"toMap",
"(",
"keyMapper2",
",",
"valueMapper",
",",
"(",
"a",
",",
"b",
")",
"->",
"a",
",",
"HashMap",
"::",
"new",
")",
")",
")",
";",
"}"
] |
Similar to grouping into 2 levels except each unit is not a Collection
but a single object
@param entities
@param keyMapper1
@param keyMapper2
@param valueMapper
@return
|
[
"Similar",
"to",
"grouping",
"into",
"2",
"levels",
"except",
"each",
"unit",
"is",
"not",
"a",
"Collection",
"but",
"a",
"single",
"object"
] |
2126236f56858e283fa6ad69fe9279ee30f47b67
|
https://github.com/yangjm/winlet/blob/2126236f56858e283fa6ad69fe9279ee30f47b67/utils/src/main/java/com/aggrepoint/utils/CollectionUtils.java#L227-L236
|
149,366
|
yangjm/winlet
|
utils/src/main/java/com/aggrepoint/utils/CollectionUtils.java
|
CollectionUtils.toArray
|
public static <T, K> K[] toArray(Collection<T> entities,
Function<T, K> keyMapper, K[] arr) {
if (entities == null)
return null;
return entities.stream().map(keyMapper).toArray(size -> arr);
}
|
java
|
public static <T, K> K[] toArray(Collection<T> entities,
Function<T, K> keyMapper, K[] arr) {
if (entities == null)
return null;
return entities.stream().map(keyMapper).toArray(size -> arr);
}
|
[
"public",
"static",
"<",
"T",
",",
"K",
">",
"K",
"[",
"]",
"toArray",
"(",
"Collection",
"<",
"T",
">",
"entities",
",",
"Function",
"<",
"T",
",",
"K",
">",
"keyMapper",
",",
"K",
"[",
"]",
"arr",
")",
"{",
"if",
"(",
"entities",
"==",
"null",
")",
"return",
"null",
";",
"return",
"entities",
".",
"stream",
"(",
")",
".",
"map",
"(",
"keyMapper",
")",
".",
"toArray",
"(",
"size",
"->",
"arr",
")",
";",
"}"
] |
Extract attribute from objects in collection and store them in array and
return.
@param entities
@param keyMapper
@param arr
@return
|
[
"Extract",
"attribute",
"from",
"objects",
"in",
"collection",
"and",
"store",
"them",
"in",
"array",
"and",
"return",
"."
] |
2126236f56858e283fa6ad69fe9279ee30f47b67
|
https://github.com/yangjm/winlet/blob/2126236f56858e283fa6ad69fe9279ee30f47b67/utils/src/main/java/com/aggrepoint/utils/CollectionUtils.java#L247-L252
|
149,367
|
yangjm/winlet
|
utils/src/main/java/com/aggrepoint/utils/CollectionUtils.java
|
CollectionUtils.moveUp
|
public static <T, K> boolean moveUp(List<T> list, K key,
Function<T, K> keyMapper, int n) {
if (list == null)
return false;
ArrayList<T> newList = new ArrayList<T>();
boolean changed = false;
for (int i = 0; i < list.size(); i++) {
T item = list.get(i);
if (i > 0 && key.equals(keyMapper.apply(item))) {
int posi = i - n;
if (posi < 0)
posi = 0;
newList.add(posi, item);
changed = true;
} else
newList.add(item);
}
if (changed) {
list.clear();
list.addAll(newList);
return true;
}
return false;
}
|
java
|
public static <T, K> boolean moveUp(List<T> list, K key,
Function<T, K> keyMapper, int n) {
if (list == null)
return false;
ArrayList<T> newList = new ArrayList<T>();
boolean changed = false;
for (int i = 0; i < list.size(); i++) {
T item = list.get(i);
if (i > 0 && key.equals(keyMapper.apply(item))) {
int posi = i - n;
if (posi < 0)
posi = 0;
newList.add(posi, item);
changed = true;
} else
newList.add(item);
}
if (changed) {
list.clear();
list.addAll(newList);
return true;
}
return false;
}
|
[
"public",
"static",
"<",
"T",
",",
"K",
">",
"boolean",
"moveUp",
"(",
"List",
"<",
"T",
">",
"list",
",",
"K",
"key",
",",
"Function",
"<",
"T",
",",
"K",
">",
"keyMapper",
",",
"int",
"n",
")",
"{",
"if",
"(",
"list",
"==",
"null",
")",
"return",
"false",
";",
"ArrayList",
"<",
"T",
">",
"newList",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"boolean",
"changed",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"T",
"item",
"=",
"list",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"i",
">",
"0",
"&&",
"key",
".",
"equals",
"(",
"keyMapper",
".",
"apply",
"(",
"item",
")",
")",
")",
"{",
"int",
"posi",
"=",
"i",
"-",
"n",
";",
"if",
"(",
"posi",
"<",
"0",
")",
"posi",
"=",
"0",
";",
"newList",
".",
"add",
"(",
"posi",
",",
"item",
")",
";",
"changed",
"=",
"true",
";",
"}",
"else",
"newList",
".",
"add",
"(",
"item",
")",
";",
"}",
"if",
"(",
"changed",
")",
"{",
"list",
".",
"clear",
"(",
")",
";",
"list",
".",
"addAll",
"(",
"newList",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Move an object in List up
@param list
@param key
@param keyMapper
@return
|
[
"Move",
"an",
"object",
"in",
"List",
"up"
] |
2126236f56858e283fa6ad69fe9279ee30f47b67
|
https://github.com/yangjm/winlet/blob/2126236f56858e283fa6ad69fe9279ee30f47b67/utils/src/main/java/com/aggrepoint/utils/CollectionUtils.java#L262-L287
|
149,368
|
geomajas/geomajas-project-graphics
|
graphics/src/main/java/org/geomajas/graphics/client/widget/CreateIconChoicePopup.java
|
CreateIconChoicePopup.translateMarker
|
private ClickableMarkerShape translateMarker(ClickableMarkerShape shape, int amountOfMarkers) {
if (amountOfMarkers % imagePerRow != 0) {
int size = choiceListImageSize + 6;
shape.setTranslation(size * (amountOfMarkers % imagePerRow), size * (amountOfMarkers / imagePerRow));
}
return shape;
}
|
java
|
private ClickableMarkerShape translateMarker(ClickableMarkerShape shape, int amountOfMarkers) {
if (amountOfMarkers % imagePerRow != 0) {
int size = choiceListImageSize + 6;
shape.setTranslation(size * (amountOfMarkers % imagePerRow), size * (amountOfMarkers / imagePerRow));
}
return shape;
}
|
[
"private",
"ClickableMarkerShape",
"translateMarker",
"(",
"ClickableMarkerShape",
"shape",
",",
"int",
"amountOfMarkers",
")",
"{",
"if",
"(",
"amountOfMarkers",
"%",
"imagePerRow",
"!=",
"0",
")",
"{",
"int",
"size",
"=",
"choiceListImageSize",
"+",
"6",
";",
"shape",
".",
"setTranslation",
"(",
"size",
"*",
"(",
"amountOfMarkers",
"%",
"imagePerRow",
")",
",",
"size",
"*",
"(",
"amountOfMarkers",
"/",
"imagePerRow",
")",
")",
";",
"}",
"return",
"shape",
";",
"}"
] |
used for displaying marker SVG elements in a drawing area.
@param shape
@param amountOfMarkers
@return
|
[
"used",
"for",
"displaying",
"marker",
"SVG",
"elements",
"in",
"a",
"drawing",
"area",
"."
] |
1104196640e0ba455b8a619e774352a8e1e319ba
|
https://github.com/geomajas/geomajas-project-graphics/blob/1104196640e0ba455b8a619e774352a8e1e319ba/graphics/src/main/java/org/geomajas/graphics/client/widget/CreateIconChoicePopup.java#L351-L357
|
149,369
|
jiaqi/caff
|
src/main/java/org/cyclopsgroup/caff/util/ByteUtils.java
|
ByteUtils.writeLong
|
public static void writeLong(long value, byte[] dest, int offset)
throws IllegalArgumentException {
if (dest.length < offset + 8) {
throw new IllegalArgumentException(
"Destination byte array does not have enough space to write long from offset " + offset);
}
long t = value;
for (int i = offset; i < offset + 8; i++) {
dest[i] = (byte) (t & 0xff);
t = t >> 8;
}
}
|
java
|
public static void writeLong(long value, byte[] dest, int offset)
throws IllegalArgumentException {
if (dest.length < offset + 8) {
throw new IllegalArgumentException(
"Destination byte array does not have enough space to write long from offset " + offset);
}
long t = value;
for (int i = offset; i < offset + 8; i++) {
dest[i] = (byte) (t & 0xff);
t = t >> 8;
}
}
|
[
"public",
"static",
"void",
"writeLong",
"(",
"long",
"value",
",",
"byte",
"[",
"]",
"dest",
",",
"int",
"offset",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"dest",
".",
"length",
"<",
"offset",
"+",
"8",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Destination byte array does not have enough space to write long from offset \"",
"+",
"offset",
")",
";",
"}",
"long",
"t",
"=",
"value",
";",
"for",
"(",
"int",
"i",
"=",
"offset",
";",
"i",
"<",
"offset",
"+",
"8",
";",
"i",
"++",
")",
"{",
"dest",
"[",
"i",
"]",
"=",
"(",
"byte",
")",
"(",
"t",
"&",
"0xff",
")",
";",
"t",
"=",
"t",
">>",
"8",
";",
"}",
"}"
] |
Write long value to given byte array
@param value Value to write, it can be any long value
@param dest Destination byte array value is written to
@param offset The starting point of where the value is written
@throws IllegalArgumentException When input byte array doesn't have enough space to write a
long
|
[
"Write",
"long",
"value",
"to",
"given",
"byte",
"array"
] |
dba4b937a0afc844eb37ccf74dd04dd78f0c1314
|
https://github.com/jiaqi/caff/blob/dba4b937a0afc844eb37ccf74dd04dd78f0c1314/src/main/java/org/cyclopsgroup/caff/util/ByteUtils.java#L20-L31
|
149,370
|
jiaqi/caff
|
src/main/java/org/cyclopsgroup/caff/util/ByteUtils.java
|
ByteUtils.readLong
|
public static long readLong(byte[] src, int offset) throws IllegalArgumentException {
if (src.length < offset) {
throw new IllegalArgumentException("There's nothing to read in src from offset " + offset);
}
long r = 0;
for (int i = offset, j = 0; i < src.length && j < 64; i++, j += 8) {
r += ((long) src[i] & 0xff) << j;
}
return r;
}
|
java
|
public static long readLong(byte[] src, int offset) throws IllegalArgumentException {
if (src.length < offset) {
throw new IllegalArgumentException("There's nothing to read in src from offset " + offset);
}
long r = 0;
for (int i = offset, j = 0; i < src.length && j < 64; i++, j += 8) {
r += ((long) src[i] & 0xff) << j;
}
return r;
}
|
[
"public",
"static",
"long",
"readLong",
"(",
"byte",
"[",
"]",
"src",
",",
"int",
"offset",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"src",
".",
"length",
"<",
"offset",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"There's nothing to read in src from offset \"",
"+",
"offset",
")",
";",
"}",
"long",
"r",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"offset",
",",
"j",
"=",
"0",
";",
"i",
"<",
"src",
".",
"length",
"&&",
"j",
"<",
"64",
";",
"i",
"++",
",",
"j",
"+=",
"8",
")",
"{",
"r",
"+=",
"(",
"(",
"long",
")",
"src",
"[",
"i",
"]",
"&",
"0xff",
")",
"<<",
"j",
";",
"}",
"return",
"r",
";",
"}"
] |
Read long value from given source byte array
@param src Source byte array value is read from
@param offset The starting point where value is read from
@return The long value
@throws IllegalArgumentException When the length of input byte array conflicts offset
|
[
"Read",
"long",
"value",
"from",
"given",
"source",
"byte",
"array"
] |
dba4b937a0afc844eb37ccf74dd04dd78f0c1314
|
https://github.com/jiaqi/caff/blob/dba4b937a0afc844eb37ccf74dd04dd78f0c1314/src/main/java/org/cyclopsgroup/caff/util/ByteUtils.java#L41-L51
|
149,371
|
progolden/vraptor-boilerplate
|
vraptor-boilerplate-utils/src/main/java/br/com/caelum/vraptor/boilerplate/util/GeneralUtils.java
|
GeneralUtils.getGMTTimeString
|
public static String getGMTTimeString(long milliSeconds) {
SimpleDateFormat sdf = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss 'GMT'", Locale.ENGLISH);
return sdf.format(new Date(milliSeconds));
}
|
java
|
public static String getGMTTimeString(long milliSeconds) {
SimpleDateFormat sdf = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss 'GMT'", Locale.ENGLISH);
return sdf.format(new Date(milliSeconds));
}
|
[
"public",
"static",
"String",
"getGMTTimeString",
"(",
"long",
"milliSeconds",
")",
"{",
"SimpleDateFormat",
"sdf",
"=",
"new",
"SimpleDateFormat",
"(",
"\"E, d MMM yyyy HH:mm:ss 'GMT'\"",
",",
"Locale",
".",
"ENGLISH",
")",
";",
"return",
"sdf",
".",
"format",
"(",
"new",
"Date",
"(",
"milliSeconds",
")",
")",
";",
"}"
] |
Retorna uma data em GMT.
@param milliSeconds
@return
|
[
"Retorna",
"uma",
"data",
"em",
"GMT",
"."
] |
3edf45cc0dc5aec61b16ca326b4d72c82d1d3e07
|
https://github.com/progolden/vraptor-boilerplate/blob/3edf45cc0dc5aec61b16ca326b4d72c82d1d3e07/vraptor-boilerplate-utils/src/main/java/br/com/caelum/vraptor/boilerplate/util/GeneralUtils.java#L70-L73
|
149,372
|
progolden/vraptor-boilerplate
|
vraptor-boilerplate-utils/src/main/java/br/com/caelum/vraptor/boilerplate/util/GeneralUtils.java
|
GeneralUtils.toTitleCase
|
public static String toTitleCase(String text) {
StringBuilder str = new StringBuilder();
String[] words = text.trim().split("\\s");
for (int i = 0; i < words.length; i++) {
if (words[i].length() > 0) {
if (i > 0) {
str.append(" ");
}
String lower = words[i].toLowerCase(Locale.getDefault());
if (words[i].length() == 1) {
str.append(lower);
} else if (words[i].length() == 2) {
if (lower.equals("da") || lower.equals("de") || lower.equals("do") || lower.equals("di"))
str.append(lower);
else
str.append(StringUtils.capitalize(lower));
} else {
str.append(StringUtils.capitalize(lower));
}
}
}
return str.toString();
}
|
java
|
public static String toTitleCase(String text) {
StringBuilder str = new StringBuilder();
String[] words = text.trim().split("\\s");
for (int i = 0; i < words.length; i++) {
if (words[i].length() > 0) {
if (i > 0) {
str.append(" ");
}
String lower = words[i].toLowerCase(Locale.getDefault());
if (words[i].length() == 1) {
str.append(lower);
} else if (words[i].length() == 2) {
if (lower.equals("da") || lower.equals("de") || lower.equals("do") || lower.equals("di"))
str.append(lower);
else
str.append(StringUtils.capitalize(lower));
} else {
str.append(StringUtils.capitalize(lower));
}
}
}
return str.toString();
}
|
[
"public",
"static",
"String",
"toTitleCase",
"(",
"String",
"text",
")",
"{",
"StringBuilder",
"str",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"[",
"]",
"words",
"=",
"text",
".",
"trim",
"(",
")",
".",
"split",
"(",
"\"\\\\s\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"words",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"words",
"[",
"i",
"]",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"if",
"(",
"i",
">",
"0",
")",
"{",
"str",
".",
"append",
"(",
"\" \"",
")",
";",
"}",
"String",
"lower",
"=",
"words",
"[",
"i",
"]",
".",
"toLowerCase",
"(",
"Locale",
".",
"getDefault",
"(",
")",
")",
";",
"if",
"(",
"words",
"[",
"i",
"]",
".",
"length",
"(",
")",
"==",
"1",
")",
"{",
"str",
".",
"append",
"(",
"lower",
")",
";",
"}",
"else",
"if",
"(",
"words",
"[",
"i",
"]",
".",
"length",
"(",
")",
"==",
"2",
")",
"{",
"if",
"(",
"lower",
".",
"equals",
"(",
"\"da\"",
")",
"||",
"lower",
".",
"equals",
"(",
"\"de\"",
")",
"||",
"lower",
".",
"equals",
"(",
"\"do\"",
")",
"||",
"lower",
".",
"equals",
"(",
"\"di\"",
")",
")",
"str",
".",
"append",
"(",
"lower",
")",
";",
"else",
"str",
".",
"append",
"(",
"StringUtils",
".",
"capitalize",
"(",
"lower",
")",
")",
";",
"}",
"else",
"{",
"str",
".",
"append",
"(",
"StringUtils",
".",
"capitalize",
"(",
"lower",
")",
")",
";",
"}",
"}",
"}",
"return",
"str",
".",
"toString",
"(",
")",
";",
"}"
] |
Converte string para title case.
@param text
Texto a ser convertido.
@return Texto equivalente em title case.
|
[
"Converte",
"string",
"para",
"title",
"case",
"."
] |
3edf45cc0dc5aec61b16ca326b4d72c82d1d3e07
|
https://github.com/progolden/vraptor-boilerplate/blob/3edf45cc0dc5aec61b16ca326b4d72c82d1d3e07/vraptor-boilerplate-utils/src/main/java/br/com/caelum/vraptor/boilerplate/util/GeneralUtils.java#L180-L202
|
149,373
|
uniform-java/uniform
|
src/main/java/net/uniform/impl/utils/UniformUtils.java
|
UniformUtils.firstValue
|
public static <T> T firstValue(List<T> list) {
if (list != null && !list.isEmpty()) {
return list.get(0);
}
return null;
}
|
java
|
public static <T> T firstValue(List<T> list) {
if (list != null && !list.isEmpty()) {
return list.get(0);
}
return null;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"firstValue",
"(",
"List",
"<",
"T",
">",
"list",
")",
"{",
"if",
"(",
"list",
"!=",
"null",
"&&",
"!",
"list",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"list",
".",
"get",
"(",
"0",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the first value of a list, or null if the list is empty.
@param <T> List type
@param list Input list
@return First value or null
|
[
"Returns",
"the",
"first",
"value",
"of",
"a",
"list",
"or",
"null",
"if",
"the",
"list",
"is",
"empty",
"."
] |
0b84f0db562253165bc06c69f631e464dca0cb48
|
https://github.com/uniform-java/uniform/blob/0b84f0db562253165bc06c69f631e464dca0cb48/src/main/java/net/uniform/impl/utils/UniformUtils.java#L50-L55
|
149,374
|
uniform-java/uniform
|
src/main/java/net/uniform/impl/utils/UniformUtils.java
|
UniformUtils.getBeanProperties
|
public static Map<String, Object> getBeanProperties(Object bean) {
Map<String, Object> props = new HashMap<>();
if (bean == null) {
return props;
}
Class<?> clazz = bean.getClass();
try {
//Public fields:
Field[] fields = clazz.getFields();
for (Field field : fields) {
String name = field.getName();
if (!name.equals("class")) {
props.put(field.getName(), field.get(bean));
}
}
//Getters:
BeanInfo info = Introspector.getBeanInfo(clazz);
for (PropertyDescriptor desc : info.getPropertyDescriptors()) {
Method readMethod = desc.getReadMethod();
String name = desc.getName();
if (readMethod != null && !name.equals("class")) {
props.put(desc.getName(), readMethod.invoke(bean));
}
}
return props;
} catch (IntrospectionException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
throw new UniformException("Error while getting bean object properties of class" + clazz.getName(), ex);
}
}
|
java
|
public static Map<String, Object> getBeanProperties(Object bean) {
Map<String, Object> props = new HashMap<>();
if (bean == null) {
return props;
}
Class<?> clazz = bean.getClass();
try {
//Public fields:
Field[] fields = clazz.getFields();
for (Field field : fields) {
String name = field.getName();
if (!name.equals("class")) {
props.put(field.getName(), field.get(bean));
}
}
//Getters:
BeanInfo info = Introspector.getBeanInfo(clazz);
for (PropertyDescriptor desc : info.getPropertyDescriptors()) {
Method readMethod = desc.getReadMethod();
String name = desc.getName();
if (readMethod != null && !name.equals("class")) {
props.put(desc.getName(), readMethod.invoke(bean));
}
}
return props;
} catch (IntrospectionException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
throw new UniformException("Error while getting bean object properties of class" + clazz.getName(), ex);
}
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"getBeanProperties",
"(",
"Object",
"bean",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"props",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"bean",
"==",
"null",
")",
"{",
"return",
"props",
";",
"}",
"Class",
"<",
"?",
">",
"clazz",
"=",
"bean",
".",
"getClass",
"(",
")",
";",
"try",
"{",
"//Public fields:\r",
"Field",
"[",
"]",
"fields",
"=",
"clazz",
".",
"getFields",
"(",
")",
";",
"for",
"(",
"Field",
"field",
":",
"fields",
")",
"{",
"String",
"name",
"=",
"field",
".",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"name",
".",
"equals",
"(",
"\"class\"",
")",
")",
"{",
"props",
".",
"put",
"(",
"field",
".",
"getName",
"(",
")",
",",
"field",
".",
"get",
"(",
"bean",
")",
")",
";",
"}",
"}",
"//Getters:\r",
"BeanInfo",
"info",
"=",
"Introspector",
".",
"getBeanInfo",
"(",
"clazz",
")",
";",
"for",
"(",
"PropertyDescriptor",
"desc",
":",
"info",
".",
"getPropertyDescriptors",
"(",
")",
")",
"{",
"Method",
"readMethod",
"=",
"desc",
".",
"getReadMethod",
"(",
")",
";",
"String",
"name",
"=",
"desc",
".",
"getName",
"(",
")",
";",
"if",
"(",
"readMethod",
"!=",
"null",
"&&",
"!",
"name",
".",
"equals",
"(",
"\"class\"",
")",
")",
"{",
"props",
".",
"put",
"(",
"desc",
".",
"getName",
"(",
")",
",",
"readMethod",
".",
"invoke",
"(",
"bean",
")",
")",
";",
"}",
"}",
"return",
"props",
";",
"}",
"catch",
"(",
"IntrospectionException",
"|",
"IllegalAccessException",
"|",
"IllegalArgumentException",
"|",
"InvocationTargetException",
"ex",
")",
"{",
"throw",
"new",
"UniformException",
"(",
"\"Error while getting bean object properties of class\"",
"+",
"clazz",
".",
"getName",
"(",
")",
",",
"ex",
")",
";",
"}",
"}"
] |
Returns an index of all the accessible properties of a Java bean object.
@param bean Input object
@return Index of properties, never null
|
[
"Returns",
"an",
"index",
"of",
"all",
"the",
"accessible",
"properties",
"of",
"a",
"Java",
"bean",
"object",
"."
] |
0b84f0db562253165bc06c69f631e464dca0cb48
|
https://github.com/uniform-java/uniform/blob/0b84f0db562253165bc06c69f631e464dca0cb48/src/main/java/net/uniform/impl/utils/UniformUtils.java#L89-L121
|
149,375
|
mike10004/common-helper
|
ormlite-helper/src/main/java/com/github/mike10004/common/dbhelp/DefaultDatabaseContext.java
|
DefaultDatabaseContext.getDao
|
@Override
public <T> Dao<T, ?> getDao(Class<T> clz) throws SQLException {
return DaoManager.createDao(getConnectionSource(), clz);
}
|
java
|
@Override
public <T> Dao<T, ?> getDao(Class<T> clz) throws SQLException {
return DaoManager.createDao(getConnectionSource(), clz);
}
|
[
"@",
"Override",
"public",
"<",
"T",
">",
"Dao",
"<",
"T",
",",
"?",
">",
"getDao",
"(",
"Class",
"<",
"T",
">",
"clz",
")",
"throws",
"SQLException",
"{",
"return",
"DaoManager",
".",
"createDao",
"(",
"getConnectionSource",
"(",
")",
",",
"clz",
")",
";",
"}"
] |
Gets the data access object for an entity class that has an integer
primary key data type. Dao caching is performed by
the ORM library, so you don't need to take pains to hold on to this
reference.
@param <T> the entity class type
@param clz the entity class
@return the dao
@throws java.sql.SQLException if
{@link #getDao(java.lang.Class, java.lang.Class) } throws one
|
[
"Gets",
"the",
"data",
"access",
"object",
"for",
"an",
"entity",
"class",
"that",
"has",
"an",
"integer",
"primary",
"key",
"data",
"type",
".",
"Dao",
"caching",
"is",
"performed",
"by",
"the",
"ORM",
"library",
"so",
"you",
"don",
"t",
"need",
"to",
"take",
"pains",
"to",
"hold",
"on",
"to",
"this",
"reference",
"."
] |
744f82d9b0768a9ad9c63a57a37ab2c93bf408f4
|
https://github.com/mike10004/common-helper/blob/744f82d9b0768a9ad9c63a57a37ab2c93bf408f4/ormlite-helper/src/main/java/com/github/mike10004/common/dbhelp/DefaultDatabaseContext.java#L110-L113
|
149,376
|
mike10004/common-helper
|
ormlite-helper/src/main/java/com/github/mike10004/common/dbhelp/DefaultDatabaseContext.java
|
DefaultDatabaseContext.getDao
|
@Override
public <T, K> Dao<T, K> getDao(Class<T> clazz, Class<K> keyType) throws SQLException {
return DaoManager.createDao(getConnectionSource(), clazz);
}
|
java
|
@Override
public <T, K> Dao<T, K> getDao(Class<T> clazz, Class<K> keyType) throws SQLException {
return DaoManager.createDao(getConnectionSource(), clazz);
}
|
[
"@",
"Override",
"public",
"<",
"T",
",",
"K",
">",
"Dao",
"<",
"T",
",",
"K",
">",
"getDao",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"Class",
"<",
"K",
">",
"keyType",
")",
"throws",
"SQLException",
"{",
"return",
"DaoManager",
".",
"createDao",
"(",
"getConnectionSource",
"(",
")",
",",
"clazz",
")",
";",
"}"
] |
Gets the data access object for an entity class with a given key type.
Dao caching is performed by the ORM library, so you don't need to take
pains to hold on to this reference.
@param <T> the entity class type
@param <K> the key type
@param clazz the entity class
@param keyType the primary key type
@return the dao
@throws SQLException if
{@link DaoManager#createDao(com.j256.ormlite.support.ConnectionSource, java.lang.Class) }
throws one
|
[
"Gets",
"the",
"data",
"access",
"object",
"for",
"an",
"entity",
"class",
"with",
"a",
"given",
"key",
"type",
".",
"Dao",
"caching",
"is",
"performed",
"by",
"the",
"ORM",
"library",
"so",
"you",
"don",
"t",
"need",
"to",
"take",
"pains",
"to",
"hold",
"on",
"to",
"this",
"reference",
"."
] |
744f82d9b0768a9ad9c63a57a37ab2c93bf408f4
|
https://github.com/mike10004/common-helper/blob/744f82d9b0768a9ad9c63a57a37ab2c93bf408f4/ormlite-helper/src/main/java/com/github/mike10004/common/dbhelp/DefaultDatabaseContext.java#L128-L131
|
149,377
|
javagl/Common
|
src/main/java/de/javagl/common/concurrent/ExecutorServices.java
|
ExecutorServices.createFixedTimeoutExecutorService
|
public static ExecutorService createFixedTimeoutExecutorService(
int poolSize, long keepAliveTime, TimeUnit timeUnit)
{
ThreadPoolExecutor e =
new ThreadPoolExecutor(poolSize, poolSize,
keepAliveTime, timeUnit, new LinkedBlockingQueue<Runnable>());
e.allowCoreThreadTimeOut(true);
return e;
}
|
java
|
public static ExecutorService createFixedTimeoutExecutorService(
int poolSize, long keepAliveTime, TimeUnit timeUnit)
{
ThreadPoolExecutor e =
new ThreadPoolExecutor(poolSize, poolSize,
keepAliveTime, timeUnit, new LinkedBlockingQueue<Runnable>());
e.allowCoreThreadTimeOut(true);
return e;
}
|
[
"public",
"static",
"ExecutorService",
"createFixedTimeoutExecutorService",
"(",
"int",
"poolSize",
",",
"long",
"keepAliveTime",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"ThreadPoolExecutor",
"e",
"=",
"new",
"ThreadPoolExecutor",
"(",
"poolSize",
",",
"poolSize",
",",
"keepAliveTime",
",",
"timeUnit",
",",
"new",
"LinkedBlockingQueue",
"<",
"Runnable",
">",
"(",
")",
")",
";",
"e",
".",
"allowCoreThreadTimeOut",
"(",
"true",
")",
";",
"return",
"e",
";",
"}"
] |
Creates an executor service with a fixed pool size, that will time
out after a certain period of inactivity.
@param poolSize The core- and maximum pool size
@param keepAliveTime The keep alive time
@param timeUnit The time unit
@return The executor service
|
[
"Creates",
"an",
"executor",
"service",
"with",
"a",
"fixed",
"pool",
"size",
"that",
"will",
"time",
"out",
"after",
"a",
"certain",
"period",
"of",
"inactivity",
"."
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/concurrent/ExecutorServices.java#L115-L123
|
149,378
|
matthewhorridge/binaryowl
|
src/main/java/org/semanticweb/binaryowl/stream/PassThroughSetTransformer.java
|
PassThroughSetTransformer.transform
|
@Override
public <O extends Comparable> Set<O> transform(Set<O> set) {
return checkNotNull(set);
}
|
java
|
@Override
public <O extends Comparable> Set<O> transform(Set<O> set) {
return checkNotNull(set);
}
|
[
"@",
"Override",
"public",
"<",
"O",
"extends",
"Comparable",
">",
"Set",
"<",
"O",
">",
"transform",
"(",
"Set",
"<",
"O",
">",
"set",
")",
"{",
"return",
"checkNotNull",
"(",
"set",
")",
";",
"}"
] |
A set transformer that returns the supplied set.
@param set The set to be transformed. Not {@code null}.
@param <O> The type of elements contained within the set.
@return The same set that was supplied.
|
[
"A",
"set",
"transformer",
"that",
"returns",
"the",
"supplied",
"set",
"."
] |
7fccfe804120f86b38ca855ddbb569a81a042257
|
https://github.com/matthewhorridge/binaryowl/blob/7fccfe804120f86b38ca855ddbb569a81a042257/src/main/java/org/semanticweb/binaryowl/stream/PassThroughSetTransformer.java#L18-L21
|
149,379
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/wrappers/ConnectionProxy.java
|
ConnectionProxy.newInstance
|
public static Connection newInstance(Connection conn) {
return (Connection) java.lang.reflect.Proxy.newProxyInstance(Connection.class.getClassLoader(), new Class[]{Connection.class},
new ConnectionProxy(conn));
/*
return (Connection) java.lang.reflect.Proxy.newProxyInstance(conn.getClass().getClassLoader(), conn.getClass().getInterfaces(),
new ConnectionProxy(conn));
*/
}
|
java
|
public static Connection newInstance(Connection conn) {
return (Connection) java.lang.reflect.Proxy.newProxyInstance(Connection.class.getClassLoader(), new Class[]{Connection.class},
new ConnectionProxy(conn));
/*
return (Connection) java.lang.reflect.Proxy.newProxyInstance(conn.getClass().getClassLoader(), conn.getClass().getInterfaces(),
new ConnectionProxy(conn));
*/
}
|
[
"public",
"static",
"Connection",
"newInstance",
"(",
"Connection",
"conn",
")",
"{",
"return",
"(",
"Connection",
")",
"java",
".",
"lang",
".",
"reflect",
".",
"Proxy",
".",
"newProxyInstance",
"(",
"Connection",
".",
"class",
".",
"getClassLoader",
"(",
")",
",",
"new",
"Class",
"[",
"]",
"{",
"Connection",
".",
"class",
"}",
",",
"new",
"ConnectionProxy",
"(",
"conn",
")",
")",
";",
"/*\n return (Connection) java.lang.reflect.Proxy.newProxyInstance(conn.getClass().getClassLoader(), conn.getClass().getInterfaces(),\n new ConnectionProxy(conn));\n */",
"}"
] |
Creates new SQL Connection Proxy instance
@param conn SQL Connection
@return Proxy SQL Connection
|
[
"Creates",
"new",
"SQL",
"Connection",
"Proxy",
"instance"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/wrappers/ConnectionProxy.java#L41-L48
|
149,380
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/Overrider.java
|
Overrider.removeOverride
|
public void removeOverride(String operation) {
if (this.overrideOnce.containsKey(operation) == true) {
this.overrideOnce.remove(operation);
}
if (this.override.containsKey(operation) == true) {
this.override.remove(operation);
}
}
|
java
|
public void removeOverride(String operation) {
if (this.overrideOnce.containsKey(operation) == true) {
this.overrideOnce.remove(operation);
}
if (this.override.containsKey(operation) == true) {
this.override.remove(operation);
}
}
|
[
"public",
"void",
"removeOverride",
"(",
"String",
"operation",
")",
"{",
"if",
"(",
"this",
".",
"overrideOnce",
".",
"containsKey",
"(",
"operation",
")",
"==",
"true",
")",
"{",
"this",
".",
"overrideOnce",
".",
"remove",
"(",
"operation",
")",
";",
"}",
"if",
"(",
"this",
".",
"override",
".",
"containsKey",
"(",
"operation",
")",
"==",
"true",
")",
"{",
"this",
".",
"override",
".",
"remove",
"(",
"operation",
")",
";",
"}",
"}"
] |
Removes override.
@param operation name of the operation
|
[
"Removes",
"override",
"."
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/Overrider.java#L74-L82
|
149,381
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/Overrider.java
|
Overrider.hasOverride
|
public boolean hasOverride(String operation) {
boolean result = false;
if (this.overrideOnce.containsKey(operation) == true || this.override.containsKey(operation) == true) {
result = true;
}
return result;
}
|
java
|
public boolean hasOverride(String operation) {
boolean result = false;
if (this.overrideOnce.containsKey(operation) == true || this.override.containsKey(operation) == true) {
result = true;
}
return result;
}
|
[
"public",
"boolean",
"hasOverride",
"(",
"String",
"operation",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"if",
"(",
"this",
".",
"overrideOnce",
".",
"containsKey",
"(",
"operation",
")",
"==",
"true",
"||",
"this",
".",
"override",
".",
"containsKey",
"(",
"operation",
")",
"==",
"true",
")",
"{",
"result",
"=",
"true",
";",
"}",
"return",
"result",
";",
"}"
] |
Checks if override is present, but it won't be actually read
@param operation name of the operation
@return true if override is present
|
[
"Checks",
"if",
"override",
"is",
"present",
"but",
"it",
"won",
"t",
"be",
"actually",
"read"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/Overrider.java#L90-L98
|
149,382
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/Overrider.java
|
Overrider.getOverride
|
public Object getOverride(String operation) {
Object result = null;
if (this.overrideOnce.containsKey(operation) == true) {
result = this.overrideOnce.get(operation);
this.overrideOnce.remove(operation);
} else if (this.override.containsKey(operation) == true) {
result = this.override.get(operation);
}
return result;
}
|
java
|
public Object getOverride(String operation) {
Object result = null;
if (this.overrideOnce.containsKey(operation) == true) {
result = this.overrideOnce.get(operation);
this.overrideOnce.remove(operation);
} else if (this.override.containsKey(operation) == true) {
result = this.override.get(operation);
}
return result;
}
|
[
"public",
"Object",
"getOverride",
"(",
"String",
"operation",
")",
"{",
"Object",
"result",
"=",
"null",
";",
"if",
"(",
"this",
".",
"overrideOnce",
".",
"containsKey",
"(",
"operation",
")",
"==",
"true",
")",
"{",
"result",
"=",
"this",
".",
"overrideOnce",
".",
"get",
"(",
"operation",
")",
";",
"this",
".",
"overrideOnce",
".",
"remove",
"(",
"operation",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"override",
".",
"containsKey",
"(",
"operation",
")",
"==",
"true",
")",
"{",
"result",
"=",
"this",
".",
"override",
".",
"get",
"(",
"operation",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Return override value
@param operation name of the operation
@return override value
|
[
"Return",
"override",
"value"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/Overrider.java#L106-L117
|
149,383
|
greese/dasein-util
|
src/main/java/org/dasein/util/BrowseIterator.java
|
BrowseIterator.lastPage
|
public void lastPage() {
int idx = pages.size()-1;
if( idx < 0 ) {
idx = 0;
}
if( pageIndex != idx ) {
pageIndex = idx;
currentPage = null;
}
}
|
java
|
public void lastPage() {
int idx = pages.size()-1;
if( idx < 0 ) {
idx = 0;
}
if( pageIndex != idx ) {
pageIndex = idx;
currentPage = null;
}
}
|
[
"public",
"void",
"lastPage",
"(",
")",
"{",
"int",
"idx",
"=",
"pages",
".",
"size",
"(",
")",
"-",
"1",
";",
"if",
"(",
"idx",
"<",
"0",
")",
"{",
"idx",
"=",
"0",
";",
"}",
"if",
"(",
"pageIndex",
"!=",
"idx",
")",
"{",
"pageIndex",
"=",
"idx",
";",
"currentPage",
"=",
"null",
";",
"}",
"}"
] |
Navigates to the last page in the iterator.
|
[
"Navigates",
"to",
"the",
"last",
"page",
"in",
"the",
"iterator",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/BrowseIterator.java#L280-L290
|
149,384
|
greese/dasein-util
|
src/main/java/org/dasein/util/BrowseIterator.java
|
BrowseIterator.loadPage
|
private boolean loadPage() {
Collection<T> list;
if( pages.size() <= pageIndex ) {
return false;
}
list = pages.get(pageIndex);
currentPage = list.iterator();
return true;
}
|
java
|
private boolean loadPage() {
Collection<T> list;
if( pages.size() <= pageIndex ) {
return false;
}
list = pages.get(pageIndex);
currentPage = list.iterator();
return true;
}
|
[
"private",
"boolean",
"loadPage",
"(",
")",
"{",
"Collection",
"<",
"T",
">",
"list",
";",
"if",
"(",
"pages",
".",
"size",
"(",
")",
"<=",
"pageIndex",
")",
"{",
"return",
"false",
";",
"}",
"list",
"=",
"pages",
".",
"get",
"(",
"pageIndex",
")",
";",
"currentPage",
"=",
"list",
".",
"iterator",
"(",
")",
";",
"return",
"true",
";",
"}"
] |
Loads the next page
@return false if there are no more pages to load
|
[
"Loads",
"the",
"next",
"page"
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/BrowseIterator.java#L296-L305
|
149,385
|
greese/dasein-util
|
src/main/java/org/dasein/util/BrowseIterator.java
|
BrowseIterator.setPage
|
public boolean setPage(int p) {
p--;
if( p < 0 ) {
return false;
}
if( p >= pages.size() ) {
return false;
}
pageIndex = p;
currentPage = null;
return true;
}
|
java
|
public boolean setPage(int p) {
p--;
if( p < 0 ) {
return false;
}
if( p >= pages.size() ) {
return false;
}
pageIndex = p;
currentPage = null;
return true;
}
|
[
"public",
"boolean",
"setPage",
"(",
"int",
"p",
")",
"{",
"p",
"--",
";",
"if",
"(",
"p",
"<",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"p",
">=",
"pages",
".",
"size",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"pageIndex",
"=",
"p",
";",
"currentPage",
"=",
"null",
";",
"return",
"true",
";",
"}"
] |
Navigates to the specified page number with 0 being the first page.
@param p the page number to navigate to
@return true if the page was successfully navigated to
|
[
"Navigates",
"to",
"the",
"specified",
"page",
"number",
"with",
"0",
"being",
"the",
"first",
"page",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/BrowseIterator.java#L366-L377
|
149,386
|
greese/dasein-util
|
src/main/java/org/dasein/util/BrowseIterator.java
|
BrowseIterator.setPageSize
|
public void setPageSize(int ps) {
ArrayList<T> tmp = new ArrayList<T>();
for( Collection<T> page : pages ) {
for( T item : page ) {
tmp.add(item);
}
}
setup(tmp, ps, sorter);
}
|
java
|
public void setPageSize(int ps) {
ArrayList<T> tmp = new ArrayList<T>();
for( Collection<T> page : pages ) {
for( T item : page ) {
tmp.add(item);
}
}
setup(tmp, ps, sorter);
}
|
[
"public",
"void",
"setPageSize",
"(",
"int",
"ps",
")",
"{",
"ArrayList",
"<",
"T",
">",
"tmp",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"for",
"(",
"Collection",
"<",
"T",
">",
"page",
":",
"pages",
")",
"{",
"for",
"(",
"T",
"item",
":",
"page",
")",
"{",
"tmp",
".",
"add",
"(",
"item",
")",
";",
"}",
"}",
"setup",
"(",
"tmp",
",",
"ps",
",",
"sorter",
")",
";",
"}"
] |
Changes the page size of the list and reforms the list. May cause unexpected
behavior in terms of what is considered the "current page" after resizing.
@param ps the new page size
|
[
"Changes",
"the",
"page",
"size",
"of",
"the",
"list",
"and",
"reforms",
"the",
"list",
".",
"May",
"cause",
"unexpected",
"behavior",
"in",
"terms",
"of",
"what",
"is",
"considered",
"the",
"current",
"page",
"after",
"resizing",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/BrowseIterator.java#L384-L393
|
149,387
|
greese/dasein-util
|
src/main/java/org/dasein/util/BrowseIterator.java
|
BrowseIterator.setup
|
private void setup(Collection<T> items, int ps, Comparator<T> sort) {
Collection<T> list;
Iterator<T> it;
if( sort == null ) {
list = items;
}
else {
list = new TreeSet<T>(sort);
list.addAll(items);
}
sorter = sort;
pageSize = ps;
pages = new ArrayList<Collection<T>>();
it = list.iterator();
while( it.hasNext() ) {
ArrayList<T> page = new ArrayList<T>();
pages.add(page);
for(int i=0; i<ps; i++ ) {
T ob;
if( !it.hasNext() ) {
break;
}
ob = it.next();
page.add(ob);
}
}
}
|
java
|
private void setup(Collection<T> items, int ps, Comparator<T> sort) {
Collection<T> list;
Iterator<T> it;
if( sort == null ) {
list = items;
}
else {
list = new TreeSet<T>(sort);
list.addAll(items);
}
sorter = sort;
pageSize = ps;
pages = new ArrayList<Collection<T>>();
it = list.iterator();
while( it.hasNext() ) {
ArrayList<T> page = new ArrayList<T>();
pages.add(page);
for(int i=0; i<ps; i++ ) {
T ob;
if( !it.hasNext() ) {
break;
}
ob = it.next();
page.add(ob);
}
}
}
|
[
"private",
"void",
"setup",
"(",
"Collection",
"<",
"T",
">",
"items",
",",
"int",
"ps",
",",
"Comparator",
"<",
"T",
">",
"sort",
")",
"{",
"Collection",
"<",
"T",
">",
"list",
";",
"Iterator",
"<",
"T",
">",
"it",
";",
"if",
"(",
"sort",
"==",
"null",
")",
"{",
"list",
"=",
"items",
";",
"}",
"else",
"{",
"list",
"=",
"new",
"TreeSet",
"<",
"T",
">",
"(",
"sort",
")",
";",
"list",
".",
"addAll",
"(",
"items",
")",
";",
"}",
"sorter",
"=",
"sort",
";",
"pageSize",
"=",
"ps",
";",
"pages",
"=",
"new",
"ArrayList",
"<",
"Collection",
"<",
"T",
">",
">",
"(",
")",
";",
"it",
"=",
"list",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"ArrayList",
"<",
"T",
">",
"page",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"pages",
".",
"add",
"(",
"page",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ps",
";",
"i",
"++",
")",
"{",
"T",
"ob",
";",
"if",
"(",
"!",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"break",
";",
"}",
"ob",
"=",
"it",
".",
"next",
"(",
")",
";",
"page",
".",
"add",
"(",
"ob",
")",
";",
"}",
"}",
"}"
] |
Sets the collection up using the specified parameters.
@param items the items in the iterator
@param ps the page size for the structure
@param sort the sorter, if any, to use for sorting
|
[
"Sets",
"the",
"collection",
"up",
"using",
"the",
"specified",
"parameters",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/BrowseIterator.java#L401-L430
|
149,388
|
greese/dasein-util
|
src/main/java/org/dasein/util/BrowseIterator.java
|
BrowseIterator.sort
|
public void sort(Comparator<T> sort) {
ArrayList<T> tmp = new ArrayList<T>();
for( Collection<T> page : pages ) {
tmp.addAll(page);
}
setup(tmp, pageSize, sort);
}
|
java
|
public void sort(Comparator<T> sort) {
ArrayList<T> tmp = new ArrayList<T>();
for( Collection<T> page : pages ) {
tmp.addAll(page);
}
setup(tmp, pageSize, sort);
}
|
[
"public",
"void",
"sort",
"(",
"Comparator",
"<",
"T",
">",
"sort",
")",
"{",
"ArrayList",
"<",
"T",
">",
"tmp",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"for",
"(",
"Collection",
"<",
"T",
">",
"page",
":",
"pages",
")",
"{",
"tmp",
".",
"addAll",
"(",
"page",
")",
";",
"}",
"setup",
"(",
"tmp",
",",
"pageSize",
",",
"sort",
")",
";",
"}"
] |
Re-sorts the list according to the specified sorter.
@param sort the sorter to sort the list with
|
[
"Re",
"-",
"sorts",
"the",
"list",
"according",
"to",
"the",
"specified",
"sorter",
"."
] |
648606dcb4bd382e3287a6c897a32e65d553dc47
|
https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/BrowseIterator.java#L436-L443
|
149,389
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/MjdbcLogger.java
|
MjdbcLogger.setSLF4jAvailable
|
private static void setSLF4jAvailable(boolean slf4jAvailable) {
if ((SLF4jAvailable != null && SLF4jAvailable == true) && slf4jAvailable == false) {
Logger.getAnonymousLogger().warning("Switching off SLF4j availability. Usually means that SLF4j was found but exception was thrown during it's usage");
}
SLF4jAvailable = slf4jAvailable;
}
|
java
|
private static void setSLF4jAvailable(boolean slf4jAvailable) {
if ((SLF4jAvailable != null && SLF4jAvailable == true) && slf4jAvailable == false) {
Logger.getAnonymousLogger().warning("Switching off SLF4j availability. Usually means that SLF4j was found but exception was thrown during it's usage");
}
SLF4jAvailable = slf4jAvailable;
}
|
[
"private",
"static",
"void",
"setSLF4jAvailable",
"(",
"boolean",
"slf4jAvailable",
")",
"{",
"if",
"(",
"(",
"SLF4jAvailable",
"!=",
"null",
"&&",
"SLF4jAvailable",
"==",
"true",
")",
"&&",
"slf4jAvailable",
"==",
"false",
")",
"{",
"Logger",
".",
"getAnonymousLogger",
"(",
")",
".",
"warning",
"(",
"\"Switching off SLF4j availability. Usually means that SLF4j was found but exception was thrown during it's usage\"",
")",
";",
"}",
"SLF4jAvailable",
"=",
"slf4jAvailable",
";",
"}"
] |
Standard Setter function.
Informs if SLF4j availability was set from true into false
@param slf4jAvailable new SLF4j availability flag
|
[
"Standard",
"Setter",
"function",
".",
"Informs",
"if",
"SLF4j",
"availability",
"was",
"set",
"from",
"true",
"into",
"false"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/MjdbcLogger.java#L207-L213
|
149,390
|
uniform-java/uniform
|
src/main/java/net/uniform/impl/AbstractForm.java
|
AbstractForm.elementsIndexByName
|
protected Map<String, List<Element>> elementsIndexByName() {
HashMap<String, List<Element>> index = new HashMap<>();
for (Object part : renderingParts) {//We have to use the rendering order of elements for multiple elements with same name
if (part instanceof Element) {
Element element = (Element) part;
String name = element.getProperty("name");
if (name != null && !name.trim().isEmpty()) {
boolean multiValued = element.isMultiValue();
if (multiValued && index.containsKey(name)) {
throw new IllegalStateException("Name '" + name + "' cannot be repeated in the form if any of the elements is multi-valued");
}
if (name.contains("[") && name.contains("]")) {
throw new IllegalStateException("Name '" + name + "' cannot be in array form");
}
if (!index.containsKey(name)) {
index.put(name, new ArrayList<Element>());
} else {
Class<?> expectedType = index.get(name).get(0).getValueType();
if (!element.getValueType().equals(expectedType)) {
//This is necessary for calling fillBeanProperties
throw new IllegalStateException("Multiple elements with same name '" + name + "' should all have the same value type");
}
}
index.get(name).add(element);
}
}
}
return index;
}
|
java
|
protected Map<String, List<Element>> elementsIndexByName() {
HashMap<String, List<Element>> index = new HashMap<>();
for (Object part : renderingParts) {//We have to use the rendering order of elements for multiple elements with same name
if (part instanceof Element) {
Element element = (Element) part;
String name = element.getProperty("name");
if (name != null && !name.trim().isEmpty()) {
boolean multiValued = element.isMultiValue();
if (multiValued && index.containsKey(name)) {
throw new IllegalStateException("Name '" + name + "' cannot be repeated in the form if any of the elements is multi-valued");
}
if (name.contains("[") && name.contains("]")) {
throw new IllegalStateException("Name '" + name + "' cannot be in array form");
}
if (!index.containsKey(name)) {
index.put(name, new ArrayList<Element>());
} else {
Class<?> expectedType = index.get(name).get(0).getValueType();
if (!element.getValueType().equals(expectedType)) {
//This is necessary for calling fillBeanProperties
throw new IllegalStateException("Multiple elements with same name '" + name + "' should all have the same value type");
}
}
index.get(name).add(element);
}
}
}
return index;
}
|
[
"protected",
"Map",
"<",
"String",
",",
"List",
"<",
"Element",
">",
">",
"elementsIndexByName",
"(",
")",
"{",
"HashMap",
"<",
"String",
",",
"List",
"<",
"Element",
">",
">",
"index",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Object",
"part",
":",
"renderingParts",
")",
"{",
"//We have to use the rendering order of elements for multiple elements with same name\r",
"if",
"(",
"part",
"instanceof",
"Element",
")",
"{",
"Element",
"element",
"=",
"(",
"Element",
")",
"part",
";",
"String",
"name",
"=",
"element",
".",
"getProperty",
"(",
"\"name\"",
")",
";",
"if",
"(",
"name",
"!=",
"null",
"&&",
"!",
"name",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"boolean",
"multiValued",
"=",
"element",
".",
"isMultiValue",
"(",
")",
";",
"if",
"(",
"multiValued",
"&&",
"index",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Name '\"",
"+",
"name",
"+",
"\"' cannot be repeated in the form if any of the elements is multi-valued\"",
")",
";",
"}",
"if",
"(",
"name",
".",
"contains",
"(",
"\"[\"",
")",
"&&",
"name",
".",
"contains",
"(",
"\"]\"",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Name '\"",
"+",
"name",
"+",
"\"' cannot be in array form\"",
")",
";",
"}",
"if",
"(",
"!",
"index",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"index",
".",
"put",
"(",
"name",
",",
"new",
"ArrayList",
"<",
"Element",
">",
"(",
")",
")",
";",
"}",
"else",
"{",
"Class",
"<",
"?",
">",
"expectedType",
"=",
"index",
".",
"get",
"(",
"name",
")",
".",
"get",
"(",
"0",
")",
".",
"getValueType",
"(",
")",
";",
"if",
"(",
"!",
"element",
".",
"getValueType",
"(",
")",
".",
"equals",
"(",
"expectedType",
")",
")",
"{",
"//This is necessary for calling fillBeanProperties\r",
"throw",
"new",
"IllegalStateException",
"(",
"\"Multiple elements with same name '\"",
"+",
"name",
"+",
"\"' should all have the same value type\"",
")",
";",
"}",
"}",
"index",
".",
"get",
"(",
"name",
")",
".",
"add",
"(",
"element",
")",
";",
"}",
"}",
"}",
"return",
"index",
";",
"}"
] |
Creates an index of the form element by their name. Makes sure that the names are not repeated and are valid.
@return Index of elements by name
|
[
"Creates",
"an",
"index",
"of",
"the",
"form",
"element",
"by",
"their",
"name",
".",
"Makes",
"sure",
"that",
"the",
"names",
"are",
"not",
"repeated",
"and",
"are",
"valid",
"."
] |
0b84f0db562253165bc06c69f631e464dca0cb48
|
https://github.com/uniform-java/uniform/blob/0b84f0db562253165bc06c69f631e464dca0cb48/src/main/java/net/uniform/impl/AbstractForm.java#L943-L976
|
149,391
|
workplacesystems/queuj
|
src/main/java/com/workplacesystems/queuj/process/java/ProcessSection.java
|
ProcessSection.invokeSection
|
protected Integer invokeSection()
{
try
{
// run object is a JavaProcessRunner
S runner = getRunner(getRunObject());
if (run_method_str == null)
return null;
createRunMethod(param_types, runner);
Object[] local_params = (Object[])params.clone();
Integer result_code = (Integer) run_method.invoke(runner, local_params);
return result_code;
}
// Allow ProcessImpl exceptions to be rethrown
catch (ForceProcessComplete fpc)
{
throw fpc;
}
catch (ForceRescheduleException fre)
{
throw fre;
}
catch (InvocationTargetException ite)
{
Throwable cause = ite.getCause();
if (cause instanceof ForceProcessComplete|| cause instanceof ForceRescheduleException)
throw (RuntimeException)cause;
new QueujException(ite);
return BatchProcessServer.FAILURE;
}
catch (Exception e)
{
new QueujException(e);
return BatchProcessServer.FAILURE;
}
}
|
java
|
protected Integer invokeSection()
{
try
{
// run object is a JavaProcessRunner
S runner = getRunner(getRunObject());
if (run_method_str == null)
return null;
createRunMethod(param_types, runner);
Object[] local_params = (Object[])params.clone();
Integer result_code = (Integer) run_method.invoke(runner, local_params);
return result_code;
}
// Allow ProcessImpl exceptions to be rethrown
catch (ForceProcessComplete fpc)
{
throw fpc;
}
catch (ForceRescheduleException fre)
{
throw fre;
}
catch (InvocationTargetException ite)
{
Throwable cause = ite.getCause();
if (cause instanceof ForceProcessComplete|| cause instanceof ForceRescheduleException)
throw (RuntimeException)cause;
new QueujException(ite);
return BatchProcessServer.FAILURE;
}
catch (Exception e)
{
new QueujException(e);
return BatchProcessServer.FAILURE;
}
}
|
[
"protected",
"Integer",
"invokeSection",
"(",
")",
"{",
"try",
"{",
"// run object is a JavaProcessRunner",
"S",
"runner",
"=",
"getRunner",
"(",
"getRunObject",
"(",
")",
")",
";",
"if",
"(",
"run_method_str",
"==",
"null",
")",
"return",
"null",
";",
"createRunMethod",
"(",
"param_types",
",",
"runner",
")",
";",
"Object",
"[",
"]",
"local_params",
"=",
"(",
"Object",
"[",
"]",
")",
"params",
".",
"clone",
"(",
")",
";",
"Integer",
"result_code",
"=",
"(",
"Integer",
")",
"run_method",
".",
"invoke",
"(",
"runner",
",",
"local_params",
")",
";",
"return",
"result_code",
";",
"}",
"// Allow ProcessImpl exceptions to be rethrown",
"catch",
"(",
"ForceProcessComplete",
"fpc",
")",
"{",
"throw",
"fpc",
";",
"}",
"catch",
"(",
"ForceRescheduleException",
"fre",
")",
"{",
"throw",
"fre",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"ite",
")",
"{",
"Throwable",
"cause",
"=",
"ite",
".",
"getCause",
"(",
")",
";",
"if",
"(",
"cause",
"instanceof",
"ForceProcessComplete",
"||",
"cause",
"instanceof",
"ForceRescheduleException",
")",
"throw",
"(",
"RuntimeException",
")",
"cause",
";",
"new",
"QueujException",
"(",
"ite",
")",
";",
"return",
"BatchProcessServer",
".",
"FAILURE",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"new",
"QueujException",
"(",
"e",
")",
";",
"return",
"BatchProcessServer",
".",
"FAILURE",
";",
"}",
"}"
] |
reflectively runs the relevant method
|
[
"reflectively",
"runs",
"the",
"relevant",
"method"
] |
4293116b412b4a20ead99963b9b05a135812c501
|
https://github.com/workplacesystems/queuj/blob/4293116b412b4a20ead99963b9b05a135812c501/src/main/java/com/workplacesystems/queuj/process/java/ProcessSection.java#L74-L115
|
149,392
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/output/AbstractKeyedOutputHandler.java
|
AbstractKeyedOutputHandler.createKey
|
@SuppressWarnings("unchecked")
protected K createKey(QueryParameters params) throws MjdbcException {
K result = null;
if (columnName == null) {
result = (K) params.getValue(params.getNameByPosition(columnIndex));
} else {
result = (K) params.getValue(columnName);
}
return result;
}
|
java
|
@SuppressWarnings("unchecked")
protected K createKey(QueryParameters params) throws MjdbcException {
K result = null;
if (columnName == null) {
result = (K) params.getValue(params.getNameByPosition(columnIndex));
} else {
result = (K) params.getValue(columnName);
}
return result;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"K",
"createKey",
"(",
"QueryParameters",
"params",
")",
"throws",
"MjdbcException",
"{",
"K",
"result",
"=",
"null",
";",
"if",
"(",
"columnName",
"==",
"null",
")",
"{",
"result",
"=",
"(",
"K",
")",
"params",
".",
"getValue",
"(",
"params",
".",
"getNameByPosition",
"(",
"columnIndex",
")",
")",
";",
"}",
"else",
"{",
"result",
"=",
"(",
"K",
")",
"params",
".",
"getValue",
"(",
"columnName",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Generates key for query output row
@param params query output row
@return key for query output row
@throws org.midao.jdbc.core.exception.MjdbcException
|
[
"Generates",
"key",
"for",
"query",
"output",
"row"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/output/AbstractKeyedOutputHandler.java#L99-L110
|
149,393
|
javagl/Common
|
src/main/java/de/javagl/common/iteration/CombiningIterator.java
|
CombiningIterator.prepareNextIterator
|
private void prepareNextIterator()
{
if (currentIterator == null || !currentIterator.hasNext())
{
currentIterator = null;
while (iteratorIterator.hasNext())
{
currentIterator = iteratorIterator.next();
if (currentIterator.hasNext())
{
break;
}
currentIterator = null;
}
}
}
|
java
|
private void prepareNextIterator()
{
if (currentIterator == null || !currentIterator.hasNext())
{
currentIterator = null;
while (iteratorIterator.hasNext())
{
currentIterator = iteratorIterator.next();
if (currentIterator.hasNext())
{
break;
}
currentIterator = null;
}
}
}
|
[
"private",
"void",
"prepareNextIterator",
"(",
")",
"{",
"if",
"(",
"currentIterator",
"==",
"null",
"||",
"!",
"currentIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"currentIterator",
"=",
"null",
";",
"while",
"(",
"iteratorIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"currentIterator",
"=",
"iteratorIterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"currentIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"break",
";",
"}",
"currentIterator",
"=",
"null",
";",
"}",
"}",
"}"
] |
Prepare the next iterator to use
|
[
"Prepare",
"the",
"next",
"iterator",
"to",
"use"
] |
5a4876b48c3a2dc61d21324733cf37512d721c33
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/iteration/CombiningIterator.java#L71-L86
|
149,394
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/InputUtils.java
|
InputUtils.getClassName
|
public static String getClassName(Map<String, Object> map) {
String className = null;
if (map.containsKey(MAP_CLASS_NAME) == true) {
className = (String) map.get(MAP_CLASS_NAME);
}
return className;
}
|
java
|
public static String getClassName(Map<String, Object> map) {
String className = null;
if (map.containsKey(MAP_CLASS_NAME) == true) {
className = (String) map.get(MAP_CLASS_NAME);
}
return className;
}
|
[
"public",
"static",
"String",
"getClassName",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
")",
"{",
"String",
"className",
"=",
"null",
";",
"if",
"(",
"map",
".",
"containsKey",
"(",
"MAP_CLASS_NAME",
")",
"==",
"true",
")",
"{",
"className",
"=",
"(",
"String",
")",
"map",
".",
"get",
"(",
"MAP_CLASS_NAME",
")",
";",
"}",
"return",
"className",
";",
"}"
] |
InputHandler converts every object into Map.
This function returns Class name of object from which this Map was created.
@param map Map from which Class name would be returned
@return Class name from which Map was built
|
[
"InputHandler",
"converts",
"every",
"object",
"into",
"Map",
".",
"This",
"function",
"returns",
"Class",
"name",
"of",
"object",
"from",
"which",
"this",
"Map",
"was",
"created",
"."
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/InputUtils.java#L58-L66
|
149,395
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/InputUtils.java
|
InputUtils.setClassName
|
public static void setClassName(Map<String, Object> map, String className) {
String processedClassName = className;
if (processedClassName != null) {
// it is highly unlikely that class name would contain ".", but we are cleaning it just in case
processedClassName = processedClassName.replaceAll("\\.", "_");
}
map.put(MAP_CLASS_NAME, processedClassName);
}
|
java
|
public static void setClassName(Map<String, Object> map, String className) {
String processedClassName = className;
if (processedClassName != null) {
// it is highly unlikely that class name would contain ".", but we are cleaning it just in case
processedClassName = processedClassName.replaceAll("\\.", "_");
}
map.put(MAP_CLASS_NAME, processedClassName);
}
|
[
"public",
"static",
"void",
"setClassName",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
",",
"String",
"className",
")",
"{",
"String",
"processedClassName",
"=",
"className",
";",
"if",
"(",
"processedClassName",
"!=",
"null",
")",
"{",
"// it is highly unlikely that class name would contain \".\", but we are cleaning it just in case",
"processedClassName",
"=",
"processedClassName",
".",
"replaceAll",
"(",
"\"\\\\.\"",
",",
"\"_\"",
")",
";",
"}",
"map",
".",
"put",
"(",
"MAP_CLASS_NAME",
",",
"processedClassName",
")",
";",
"}"
] |
InputHandler converts every object into Map.
Sets Class name of object from which this Map was created.
@param map Map which would store Class name
@param className Class name
|
[
"InputHandler",
"converts",
"every",
"object",
"into",
"Map",
".",
"Sets",
"Class",
"name",
"of",
"object",
"from",
"which",
"this",
"Map",
"was",
"created",
"."
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/InputUtils.java#L75-L85
|
149,396
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/InputUtils.java
|
InputUtils.isClassNameKey
|
public static boolean isClassNameKey(String key) {
boolean equals = false;
if (MAP_CLASS_NAME.equals(key) == true) {
equals = true;
}
return equals;
}
|
java
|
public static boolean isClassNameKey(String key) {
boolean equals = false;
if (MAP_CLASS_NAME.equals(key) == true) {
equals = true;
}
return equals;
}
|
[
"public",
"static",
"boolean",
"isClassNameKey",
"(",
"String",
"key",
")",
"{",
"boolean",
"equals",
"=",
"false",
";",
"if",
"(",
"MAP_CLASS_NAME",
".",
"equals",
"(",
"key",
")",
"==",
"true",
")",
"{",
"equals",
"=",
"true",
";",
"}",
"return",
"equals",
";",
"}"
] |
Checks if this Map key is Map Class Name
@param key Key which would be checked
@return true - if key equals to Map Class Name key
|
[
"Checks",
"if",
"this",
"Map",
"key",
"is",
"Map",
"Class",
"Name"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/InputUtils.java#L93-L101
|
149,397
|
pryzach/midao
|
midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/InputUtils.java
|
InputUtils.addClassName
|
public static String addClassName(String className, String key) {
return className.toLowerCase() + "." + key.toLowerCase();
}
|
java
|
public static String addClassName(String className, String key) {
return className.toLowerCase() + "." + key.toLowerCase();
}
|
[
"public",
"static",
"String",
"addClassName",
"(",
"String",
"className",
",",
"String",
"key",
")",
"{",
"return",
"className",
".",
"toLowerCase",
"(",
")",
"+",
"\".\"",
"+",
"key",
".",
"toLowerCase",
"(",
")",
";",
"}"
] |
Used by InputHandlers.
Allows combining of few Maps into one Map.
In order to avoid "collisions" - Map Class name is user as prefix
@param className Map Class name
@param key Map key
@return unique key
|
[
"Used",
"by",
"InputHandlers",
".",
"Allows",
"combining",
"of",
"few",
"Maps",
"into",
"one",
"Map",
".",
"In",
"order",
"to",
"avoid",
"collisions",
"-",
"Map",
"Class",
"name",
"is",
"user",
"as",
"prefix"
] |
ed9048ed2c792a4794a2116a25779dfb84cd9447
|
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/InputUtils.java#L112-L114
|
149,398
|
Omertron/api-fanarttv
|
src/main/java/com/omertron/fanarttvapi/FanartTvApi.java
|
FanartTvApi.getTvArtwork
|
public FTSeries getTvArtwork(String id) throws FanartTvException {
URL url = ftapi.getImageUrl(BaseType.TV, id);
String page = requestWebPage(url);
FTSeries series = null;
try {
series = mapper.readValue(page, FTSeries.class);
} catch (IOException ex) {
throw new FanartTvException(ApiExceptionType.MAPPING_FAILED, "Failed to get data for ID " + id, url, ex);
}
if (series.isError()) {
throw new FanartTvException(ApiExceptionType.ID_NOT_FOUND, series.getErrorMessage());
}
return series;
}
|
java
|
public FTSeries getTvArtwork(String id) throws FanartTvException {
URL url = ftapi.getImageUrl(BaseType.TV, id);
String page = requestWebPage(url);
FTSeries series = null;
try {
series = mapper.readValue(page, FTSeries.class);
} catch (IOException ex) {
throw new FanartTvException(ApiExceptionType.MAPPING_FAILED, "Failed to get data for ID " + id, url, ex);
}
if (series.isError()) {
throw new FanartTvException(ApiExceptionType.ID_NOT_FOUND, series.getErrorMessage());
}
return series;
}
|
[
"public",
"FTSeries",
"getTvArtwork",
"(",
"String",
"id",
")",
"throws",
"FanartTvException",
"{",
"URL",
"url",
"=",
"ftapi",
".",
"getImageUrl",
"(",
"BaseType",
".",
"TV",
",",
"id",
")",
";",
"String",
"page",
"=",
"requestWebPage",
"(",
"url",
")",
";",
"FTSeries",
"series",
"=",
"null",
";",
"try",
"{",
"series",
"=",
"mapper",
".",
"readValue",
"(",
"page",
",",
"FTSeries",
".",
"class",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"FanartTvException",
"(",
"ApiExceptionType",
".",
"MAPPING_FAILED",
",",
"\"Failed to get data for ID \"",
"+",
"id",
",",
"url",
",",
"ex",
")",
";",
"}",
"if",
"(",
"series",
".",
"isError",
"(",
")",
")",
"{",
"throw",
"new",
"FanartTvException",
"(",
"ApiExceptionType",
".",
"ID_NOT_FOUND",
",",
"series",
".",
"getErrorMessage",
"(",
")",
")",
";",
"}",
"return",
"series",
";",
"}"
] |
Get images for TV
@param id
@return
@throws FanartTvException
|
[
"Get",
"images",
"for",
"TV"
] |
2a1854c840d8111935d0f6abe5232e2c3c3f318b
|
https://github.com/Omertron/api-fanarttv/blob/2a1854c840d8111935d0f6abe5232e2c3c3f318b/src/main/java/com/omertron/fanarttvapi/FanartTvApi.java#L118-L135
|
149,399
|
Omertron/api-fanarttv
|
src/main/java/com/omertron/fanarttvapi/FanartTvApi.java
|
FanartTvApi.getMovieArtwork
|
public FTMovie getMovieArtwork(String id) throws FanartTvException {
URL url = ftapi.getImageUrl(BaseType.MOVIE, id);
String page = requestWebPage(url);
FTMovie movie = null;
try {
movie = mapper.readValue(page, FTMovie.class);
} catch (IOException ex) {
throw new FanartTvException(ApiExceptionType.MAPPING_FAILED, "Failed to get Movie artwork with ID " + id, url, ex);
}
if (movie.isError()) {
throw new FanartTvException(ApiExceptionType.ID_NOT_FOUND, movie.getErrorMessage());
}
return movie;
}
|
java
|
public FTMovie getMovieArtwork(String id) throws FanartTvException {
URL url = ftapi.getImageUrl(BaseType.MOVIE, id);
String page = requestWebPage(url);
FTMovie movie = null;
try {
movie = mapper.readValue(page, FTMovie.class);
} catch (IOException ex) {
throw new FanartTvException(ApiExceptionType.MAPPING_FAILED, "Failed to get Movie artwork with ID " + id, url, ex);
}
if (movie.isError()) {
throw new FanartTvException(ApiExceptionType.ID_NOT_FOUND, movie.getErrorMessage());
}
return movie;
}
|
[
"public",
"FTMovie",
"getMovieArtwork",
"(",
"String",
"id",
")",
"throws",
"FanartTvException",
"{",
"URL",
"url",
"=",
"ftapi",
".",
"getImageUrl",
"(",
"BaseType",
".",
"MOVIE",
",",
"id",
")",
";",
"String",
"page",
"=",
"requestWebPage",
"(",
"url",
")",
";",
"FTMovie",
"movie",
"=",
"null",
";",
"try",
"{",
"movie",
"=",
"mapper",
".",
"readValue",
"(",
"page",
",",
"FTMovie",
".",
"class",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"FanartTvException",
"(",
"ApiExceptionType",
".",
"MAPPING_FAILED",
",",
"\"Failed to get Movie artwork with ID \"",
"+",
"id",
",",
"url",
",",
"ex",
")",
";",
"}",
"if",
"(",
"movie",
".",
"isError",
"(",
")",
")",
"{",
"throw",
"new",
"FanartTvException",
"(",
"ApiExceptionType",
".",
"ID_NOT_FOUND",
",",
"movie",
".",
"getErrorMessage",
"(",
")",
")",
";",
"}",
"return",
"movie",
";",
"}"
] |
Get images for Movie
@param id
@return
@throws FanartTvException
|
[
"Get",
"images",
"for",
"Movie"
] |
2a1854c840d8111935d0f6abe5232e2c3c3f318b
|
https://github.com/Omertron/api-fanarttv/blob/2a1854c840d8111935d0f6abe5232e2c3c3f318b/src/main/java/com/omertron/fanarttvapi/FanartTvApi.java#L167-L184
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.