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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
146,100
|
Danny02/JOpenCTM
|
src/main/java/darwin/jopenctm/compression/MG2Encoder.java
|
MG2Encoder.setupGrid
|
public Grid setupGrid(float[] vertices) {
int vc = vertices.length / 3;
//CTM_POSITION_ELEMENT_COUNT == 3
// Calculate the mesh boundinggrid. box
float[] min = new float[3];
float[] max = new float[3];
int[] division = new int[3];
for (int i = 0; i < 3; ++i) {
min[i] = max[i] = vertices[i];
}
for (int i = 1; i < vc; ++i) {
for (int j = 0; j < 3; j++) {
min[j] = min(min[j], vertices[i * 3 + j]);
max[j] = max(max[j], vertices[i * 3 + j]);
}
}
// Determine optimal grid resolution, based on the number of vertices and
// the bounding box.
// NOTE: This algorithm is quite crude, and could very well be optimized for
// better compression levels in the future without affecting the file format
// or backward compatibility at all.
float[] factor = new float[3];
for (int i = 0; i < 3; ++i) {
factor[i] = max[i] - min[i];
}
float sum = factor[0] + factor[1] + factor[2];
if (sum > 1e-30f) {
sum = 1.0f / sum;
for (int i = 0; i < 3; ++i) {
factor[i] *= sum;
}
double wantedGrids = pow(100.0f * vc, 1.0f / 3.0f);
for (int i = 0; i < 3; ++i) {
division[i] = (int) ceil(wantedGrids * factor[i]);
if (division[i] < 1) {
division[i] = 1;
}
}
} else {
division[0] = 4;
division[1] = 4;
division[2] = 4;
}
return new Grid(Vec3f.from(min), Vec3f.from(max), Vec3i.from(division));
}
|
java
|
public Grid setupGrid(float[] vertices) {
int vc = vertices.length / 3;
//CTM_POSITION_ELEMENT_COUNT == 3
// Calculate the mesh boundinggrid. box
float[] min = new float[3];
float[] max = new float[3];
int[] division = new int[3];
for (int i = 0; i < 3; ++i) {
min[i] = max[i] = vertices[i];
}
for (int i = 1; i < vc; ++i) {
for (int j = 0; j < 3; j++) {
min[j] = min(min[j], vertices[i * 3 + j]);
max[j] = max(max[j], vertices[i * 3 + j]);
}
}
// Determine optimal grid resolution, based on the number of vertices and
// the bounding box.
// NOTE: This algorithm is quite crude, and could very well be optimized for
// better compression levels in the future without affecting the file format
// or backward compatibility at all.
float[] factor = new float[3];
for (int i = 0; i < 3; ++i) {
factor[i] = max[i] - min[i];
}
float sum = factor[0] + factor[1] + factor[2];
if (sum > 1e-30f) {
sum = 1.0f / sum;
for (int i = 0; i < 3; ++i) {
factor[i] *= sum;
}
double wantedGrids = pow(100.0f * vc, 1.0f / 3.0f);
for (int i = 0; i < 3; ++i) {
division[i] = (int) ceil(wantedGrids * factor[i]);
if (division[i] < 1) {
division[i] = 1;
}
}
} else {
division[0] = 4;
division[1] = 4;
division[2] = 4;
}
return new Grid(Vec3f.from(min), Vec3f.from(max), Vec3i.from(division));
}
|
[
"public",
"Grid",
"setupGrid",
"(",
"float",
"[",
"]",
"vertices",
")",
"{",
"int",
"vc",
"=",
"vertices",
".",
"length",
"/",
"3",
";",
"//CTM_POSITION_ELEMENT_COUNT == 3",
"// Calculate the mesh boundinggrid. box",
"float",
"[",
"]",
"min",
"=",
"new",
"float",
"[",
"3",
"]",
";",
"float",
"[",
"]",
"max",
"=",
"new",
"float",
"[",
"3",
"]",
";",
"int",
"[",
"]",
"division",
"=",
"new",
"int",
"[",
"3",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"++",
"i",
")",
"{",
"min",
"[",
"i",
"]",
"=",
"max",
"[",
"i",
"]",
"=",
"vertices",
"[",
"i",
"]",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"vc",
";",
"++",
"i",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"3",
";",
"j",
"++",
")",
"{",
"min",
"[",
"j",
"]",
"=",
"min",
"(",
"min",
"[",
"j",
"]",
",",
"vertices",
"[",
"i",
"*",
"3",
"+",
"j",
"]",
")",
";",
"max",
"[",
"j",
"]",
"=",
"max",
"(",
"max",
"[",
"j",
"]",
",",
"vertices",
"[",
"i",
"*",
"3",
"+",
"j",
"]",
")",
";",
"}",
"}",
"// Determine optimal grid resolution, based on the number of vertices and",
"// the bounding box.",
"// NOTE: This algorithm is quite crude, and could very well be optimized for",
"// better compression levels in the future without affecting the file format",
"// or backward compatibility at all.",
"float",
"[",
"]",
"factor",
"=",
"new",
"float",
"[",
"3",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"++",
"i",
")",
"{",
"factor",
"[",
"i",
"]",
"=",
"max",
"[",
"i",
"]",
"-",
"min",
"[",
"i",
"]",
";",
"}",
"float",
"sum",
"=",
"factor",
"[",
"0",
"]",
"+",
"factor",
"[",
"1",
"]",
"+",
"factor",
"[",
"2",
"]",
";",
"if",
"(",
"sum",
">",
"1e-30f",
")",
"{",
"sum",
"=",
"1.0f",
"/",
"sum",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"++",
"i",
")",
"{",
"factor",
"[",
"i",
"]",
"*=",
"sum",
";",
"}",
"double",
"wantedGrids",
"=",
"pow",
"(",
"100.0f",
"*",
"vc",
",",
"1.0f",
"/",
"3.0f",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"++",
"i",
")",
"{",
"division",
"[",
"i",
"]",
"=",
"(",
"int",
")",
"ceil",
"(",
"wantedGrids",
"*",
"factor",
"[",
"i",
"]",
")",
";",
"if",
"(",
"division",
"[",
"i",
"]",
"<",
"1",
")",
"{",
"division",
"[",
"i",
"]",
"=",
"1",
";",
"}",
"}",
"}",
"else",
"{",
"division",
"[",
"0",
"]",
"=",
"4",
";",
"division",
"[",
"1",
"]",
"=",
"4",
";",
"division",
"[",
"2",
"]",
"=",
"4",
";",
"}",
"return",
"new",
"Grid",
"(",
"Vec3f",
".",
"from",
"(",
"min",
")",
",",
"Vec3f",
".",
"from",
"(",
"max",
")",
",",
"Vec3i",
".",
"from",
"(",
"division",
")",
")",
";",
"}"
] |
Setup the 3D space subdivision grid.
@param vertices vertex data
@return calculated grid definition
|
[
"Setup",
"the",
"3D",
"space",
"subdivision",
"grid",
"."
] |
c55a2a2d166a55979190f1bb08214fc84c93008f
|
https://github.com/Danny02/JOpenCTM/blob/c55a2a2d166a55979190f1bb08214fc84c93008f/src/main/java/darwin/jopenctm/compression/MG2Encoder.java#L138-L189
|
146,101
|
Danny02/JOpenCTM
|
src/main/java/darwin/jopenctm/compression/MG2Encoder.java
|
MG2Encoder.pointToGridIdx
|
private int pointToGridIdx(Grid grid, float x, float y, float z) {
Vec3f size = grid.getSize();
int idx = calcIndex(x, size.getX(), grid.getMin().getX(), grid.getDivision().getX());
int idy = calcIndex(y, size.getY(), grid.getMin().getY(), grid.getDivision().getY());
int idz = calcIndex(z, size.getZ(), grid.getMin().getZ(), grid.getDivision().getZ());
return idx + grid.getDivision().getX() * (idy + grid.getDivision().getY() * idz);
}
|
java
|
private int pointToGridIdx(Grid grid, float x, float y, float z) {
Vec3f size = grid.getSize();
int idx = calcIndex(x, size.getX(), grid.getMin().getX(), grid.getDivision().getX());
int idy = calcIndex(y, size.getY(), grid.getMin().getY(), grid.getDivision().getY());
int idz = calcIndex(z, size.getZ(), grid.getMin().getZ(), grid.getDivision().getZ());
return idx + grid.getDivision().getX() * (idy + grid.getDivision().getY() * idz);
}
|
[
"private",
"int",
"pointToGridIdx",
"(",
"Grid",
"grid",
",",
"float",
"x",
",",
"float",
"y",
",",
"float",
"z",
")",
"{",
"Vec3f",
"size",
"=",
"grid",
".",
"getSize",
"(",
")",
";",
"int",
"idx",
"=",
"calcIndex",
"(",
"x",
",",
"size",
".",
"getX",
"(",
")",
",",
"grid",
".",
"getMin",
"(",
")",
".",
"getX",
"(",
")",
",",
"grid",
".",
"getDivision",
"(",
")",
".",
"getX",
"(",
")",
")",
";",
"int",
"idy",
"=",
"calcIndex",
"(",
"y",
",",
"size",
".",
"getY",
"(",
")",
",",
"grid",
".",
"getMin",
"(",
")",
".",
"getY",
"(",
")",
",",
"grid",
".",
"getDivision",
"(",
")",
".",
"getY",
"(",
")",
")",
";",
"int",
"idz",
"=",
"calcIndex",
"(",
"z",
",",
"size",
".",
"getZ",
"(",
")",
",",
"grid",
".",
"getMin",
"(",
")",
".",
"getZ",
"(",
")",
",",
"grid",
".",
"getDivision",
"(",
")",
".",
"getZ",
"(",
")",
")",
";",
"return",
"idx",
"+",
"grid",
".",
"getDivision",
"(",
")",
".",
"getX",
"(",
")",
"*",
"(",
"idy",
"+",
"grid",
".",
"getDivision",
"(",
")",
".",
"getY",
"(",
")",
"*",
"idz",
")",
";",
"}"
] |
Convert a point to a grid index.
@param grid grid definition
@return grid index of point
|
[
"Convert",
"a",
"point",
"to",
"a",
"grid",
"index",
"."
] |
c55a2a2d166a55979190f1bb08214fc84c93008f
|
https://github.com/Danny02/JOpenCTM/blob/c55a2a2d166a55979190f1bb08214fc84c93008f/src/main/java/darwin/jopenctm/compression/MG2Encoder.java#L197-L205
|
146,102
|
Danny02/JOpenCTM
|
src/main/java/darwin/jopenctm/compression/MG2Encoder.java
|
MG2Encoder.reIndexIndices
|
private int[] reIndexIndices(SortableVertex[] sortVertices, int[] indices) {
// Create temporary lookup-array, O(n)
int[] indexLUT = new int[sortVertices.length];
int[] newIndices = new int[indices.length];
for (int i = 0; i < sortVertices.length; ++i) {
indexLUT[sortVertices[i].originalIndex] = i;
}
// Convert old indices to new indices, O(n)
for (int i = 0; i < indices.length; ++i) {
newIndices[i] = indexLUT[indices[i]];
}
return newIndices;
}
|
java
|
private int[] reIndexIndices(SortableVertex[] sortVertices, int[] indices) {
// Create temporary lookup-array, O(n)
int[] indexLUT = new int[sortVertices.length];
int[] newIndices = new int[indices.length];
for (int i = 0; i < sortVertices.length; ++i) {
indexLUT[sortVertices[i].originalIndex] = i;
}
// Convert old indices to new indices, O(n)
for (int i = 0; i < indices.length; ++i) {
newIndices[i] = indexLUT[indices[i]];
}
return newIndices;
}
|
[
"private",
"int",
"[",
"]",
"reIndexIndices",
"(",
"SortableVertex",
"[",
"]",
"sortVertices",
",",
"int",
"[",
"]",
"indices",
")",
"{",
"// Create temporary lookup-array, O(n)",
"int",
"[",
"]",
"indexLUT",
"=",
"new",
"int",
"[",
"sortVertices",
".",
"length",
"]",
";",
"int",
"[",
"]",
"newIndices",
"=",
"new",
"int",
"[",
"indices",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"sortVertices",
".",
"length",
";",
"++",
"i",
")",
"{",
"indexLUT",
"[",
"sortVertices",
"[",
"i",
"]",
".",
"originalIndex",
"]",
"=",
"i",
";",
"}",
"// Convert old indices to new indices, O(n)",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"indices",
".",
"length",
";",
"++",
"i",
")",
"{",
"newIndices",
"[",
"i",
"]",
"=",
"indexLUT",
"[",
"indices",
"[",
"i",
"]",
"]",
";",
"}",
"return",
"newIndices",
";",
"}"
] |
Re-index all indices, based on the sorted vertices.
@param sortVertices sorted vertices
@param indices original indices
@return reordered indices
|
[
"Re",
"-",
"index",
"all",
"indices",
"based",
"on",
"the",
"sorted",
"vertices",
"."
] |
c55a2a2d166a55979190f1bb08214fc84c93008f
|
https://github.com/Danny02/JOpenCTM/blob/c55a2a2d166a55979190f1bb08214fc84c93008f/src/main/java/darwin/jopenctm/compression/MG2Encoder.java#L238-L254
|
146,103
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/StatisticalDocumentClassifier.java
|
StatisticalDocumentClassifier.classify
|
public String classify(final String[] document) {
double[] outcomes = docClassifier.classifyProb(document);
String category = docClassifier.getBestLabel(outcomes);
return category;
}
|
java
|
public String classify(final String[] document) {
double[] outcomes = docClassifier.classifyProb(document);
String category = docClassifier.getBestLabel(outcomes);
return category;
}
|
[
"public",
"String",
"classify",
"(",
"final",
"String",
"[",
"]",
"document",
")",
"{",
"double",
"[",
"]",
"outcomes",
"=",
"docClassifier",
".",
"classifyProb",
"(",
"document",
")",
";",
"String",
"category",
"=",
"docClassifier",
".",
"getBestLabel",
"(",
"outcomes",
")",
";",
"return",
"category",
";",
"}"
] |
Classifies the given text, provided in separate tokens.
@param document the tokens of text to classify
@return the best label found
|
[
"Classifies",
"the",
"given",
"text",
"provided",
"in",
"separate",
"tokens",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/StatisticalDocumentClassifier.java#L37-L41
|
146,104
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/StatisticalDocumentClassifier.java
|
StatisticalDocumentClassifier.classifySortedScoreMap
|
public SortedMap<Double, Set<String>> classifySortedScoreMap(final String[] document) {
return docClassifier.sortedScoreMap(document);
}
|
java
|
public SortedMap<Double, Set<String>> classifySortedScoreMap(final String[] document) {
return docClassifier.sortedScoreMap(document);
}
|
[
"public",
"SortedMap",
"<",
"Double",
",",
"Set",
"<",
"String",
">",
">",
"classifySortedScoreMap",
"(",
"final",
"String",
"[",
"]",
"document",
")",
"{",
"return",
"docClassifier",
".",
"sortedScoreMap",
"(",
"document",
")",
";",
"}"
] |
Get a map of the scores sorted in ascending order together with their associated labels.
Many labels can have the same score, hence the Set as value.
@param document the input text to classify
@return a map with the score as a key. The value is a Set of labels with their score.
|
[
"Get",
"a",
"map",
"of",
"the",
"scores",
"sorted",
"in",
"ascending",
"order",
"together",
"with",
"their",
"associated",
"labels",
".",
"Many",
"labels",
"can",
"have",
"the",
"same",
"score",
"hence",
"the",
"Set",
"as",
"value",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/StatisticalDocumentClassifier.java#L59-L61
|
146,105
|
geomajas/geomajas-project-client-gwt2
|
plugin/editing/common/src/main/java/org/geomajas/plugin/editing/client/controller/AbstractGeometryIndexController.java
|
AbstractGeometryIndexController.getLocationWithinMaxBounds
|
public Coordinate getLocationWithinMaxBounds(HumanInputEvent<?> event) {
Coordinate location = getLocation(event, RenderSpace.WORLD);
location = getLocationWithinMaxBounds(location);
return location;
}
|
java
|
public Coordinate getLocationWithinMaxBounds(HumanInputEvent<?> event) {
Coordinate location = getLocation(event, RenderSpace.WORLD);
location = getLocationWithinMaxBounds(location);
return location;
}
|
[
"public",
"Coordinate",
"getLocationWithinMaxBounds",
"(",
"HumanInputEvent",
"<",
"?",
">",
"event",
")",
"{",
"Coordinate",
"location",
"=",
"getLocation",
"(",
"event",
",",
"RenderSpace",
".",
"WORLD",
")",
";",
"location",
"=",
"getLocationWithinMaxBounds",
"(",
"location",
")",
";",
"return",
"location",
";",
"}"
] |
Get the real world location of the event, while making sure it is within the maximum bounds. If no maximum bounds
have been set, the original event location in world space is returned.
@param event
The event to extract the location from.
@return The location within maximum bounds.
|
[
"Get",
"the",
"real",
"world",
"location",
"of",
"the",
"event",
"while",
"making",
"sure",
"it",
"is",
"within",
"the",
"maximum",
"bounds",
".",
"If",
"no",
"maximum",
"bounds",
"have",
"been",
"set",
"the",
"original",
"event",
"location",
"in",
"world",
"space",
"is",
"returned",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/editing/common/src/main/java/org/geomajas/plugin/editing/client/controller/AbstractGeometryIndexController.java#L73-L77
|
146,106
|
geomajas/geomajas-project-client-gwt2
|
plugin/editing/common/src/main/java/org/geomajas/plugin/editing/client/controller/AbstractGeometryIndexController.java
|
AbstractGeometryIndexController.getSnappedLocationWithinMaxBounds
|
public Coordinate getSnappedLocationWithinMaxBounds(HumanInputEvent<?> event) {
Coordinate location = getLocation(event, RenderSpace.WORLD);
location = getLocationWithinMaxBounds(location);
if (snappingEnabled) {
location = snappingService.snap(location);
}
return location;
}
|
java
|
public Coordinate getSnappedLocationWithinMaxBounds(HumanInputEvent<?> event) {
Coordinate location = getLocation(event, RenderSpace.WORLD);
location = getLocationWithinMaxBounds(location);
if (snappingEnabled) {
location = snappingService.snap(location);
}
return location;
}
|
[
"public",
"Coordinate",
"getSnappedLocationWithinMaxBounds",
"(",
"HumanInputEvent",
"<",
"?",
">",
"event",
")",
"{",
"Coordinate",
"location",
"=",
"getLocation",
"(",
"event",
",",
"RenderSpace",
".",
"WORLD",
")",
";",
"location",
"=",
"getLocationWithinMaxBounds",
"(",
"location",
")",
";",
"if",
"(",
"snappingEnabled",
")",
"{",
"location",
"=",
"snappingService",
".",
"snap",
"(",
"location",
")",
";",
"}",
"return",
"location",
";",
"}"
] |
Get the snapped real world location of the event, while making sure it is within the maximum bounds. If no
maximum bounds have been set, the snapped location of the event in world space is returned.
@param event
The event to extract the location from.
@return The location within maximum bounds.
|
[
"Get",
"the",
"snapped",
"real",
"world",
"location",
"of",
"the",
"event",
"while",
"making",
"sure",
"it",
"is",
"within",
"the",
"maximum",
"bounds",
".",
"If",
"no",
"maximum",
"bounds",
"have",
"been",
"set",
"the",
"snapped",
"location",
"of",
"the",
"event",
"in",
"world",
"space",
"is",
"returned",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/editing/common/src/main/java/org/geomajas/plugin/editing/client/controller/AbstractGeometryIndexController.java#L87-L94
|
146,107
|
geomajas/geomajas-project-client-gwt2
|
plugin/editing/common/src/main/java/org/geomajas/plugin/editing/client/controller/AbstractGeometryIndexController.java
|
AbstractGeometryIndexController.getLocationWithinMaxBounds
|
private Coordinate getLocationWithinMaxBounds(Coordinate original) {
double x = original.getX();
double y = original.getY();
if (maxBounds != null) {
if (original.getX() < maxBounds.getX()) {
x = maxBounds.getX();
} else if (original.getX() > maxBounds.getMaxX()) {
x = maxBounds.getMaxX();
}
if (original.getY() < maxBounds.getY()) {
y = maxBounds.getY();
} else if (original.getY() > maxBounds.getMaxY()) {
y = maxBounds.getMaxY();
}
}
return new Coordinate(x, y);
}
|
java
|
private Coordinate getLocationWithinMaxBounds(Coordinate original) {
double x = original.getX();
double y = original.getY();
if (maxBounds != null) {
if (original.getX() < maxBounds.getX()) {
x = maxBounds.getX();
} else if (original.getX() > maxBounds.getMaxX()) {
x = maxBounds.getMaxX();
}
if (original.getY() < maxBounds.getY()) {
y = maxBounds.getY();
} else if (original.getY() > maxBounds.getMaxY()) {
y = maxBounds.getMaxY();
}
}
return new Coordinate(x, y);
}
|
[
"private",
"Coordinate",
"getLocationWithinMaxBounds",
"(",
"Coordinate",
"original",
")",
"{",
"double",
"x",
"=",
"original",
".",
"getX",
"(",
")",
";",
"double",
"y",
"=",
"original",
".",
"getY",
"(",
")",
";",
"if",
"(",
"maxBounds",
"!=",
"null",
")",
"{",
"if",
"(",
"original",
".",
"getX",
"(",
")",
"<",
"maxBounds",
".",
"getX",
"(",
")",
")",
"{",
"x",
"=",
"maxBounds",
".",
"getX",
"(",
")",
";",
"}",
"else",
"if",
"(",
"original",
".",
"getX",
"(",
")",
">",
"maxBounds",
".",
"getMaxX",
"(",
")",
")",
"{",
"x",
"=",
"maxBounds",
".",
"getMaxX",
"(",
")",
";",
"}",
"if",
"(",
"original",
".",
"getY",
"(",
")",
"<",
"maxBounds",
".",
"getY",
"(",
")",
")",
"{",
"y",
"=",
"maxBounds",
".",
"getY",
"(",
")",
";",
"}",
"else",
"if",
"(",
"original",
".",
"getY",
"(",
")",
">",
"maxBounds",
".",
"getMaxY",
"(",
")",
")",
"{",
"y",
"=",
"maxBounds",
".",
"getMaxY",
"(",
")",
";",
"}",
"}",
"return",
"new",
"Coordinate",
"(",
"x",
",",
"y",
")",
";",
"}"
] |
Get a location, derived from the original, that is sure to be within the maximum bounds. If no maximum bounds
have been set, a clone of the original is returned.
@param original
The original location.
@return The derived location within the maximum bounds.
|
[
"Get",
"a",
"location",
"derived",
"from",
"the",
"original",
"that",
"is",
"sure",
"to",
"be",
"within",
"the",
"maximum",
"bounds",
".",
"If",
"no",
"maximum",
"bounds",
"have",
"been",
"set",
"a",
"clone",
"of",
"the",
"original",
"is",
"returned",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/editing/common/src/main/java/org/geomajas/plugin/editing/client/controller/AbstractGeometryIndexController.java#L151-L167
|
146,108
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/CacheManager.java
|
CacheManager.handleOption
|
private void handleOption(Option option) {
if (LIST_CACHE_OPTION.equals(option.getOpt())) {
handleListCache();
} else if (CACHE_RESOURCE_OPTION.equals(option.getOpt())) {
handleLoadResource(option);
} else if (CACHE_SYSCONFIG_FILE_OPTION.equals(option.getOpt())) {
handleLoadDefaultIndex();
} else if (CACHE_INDEX_FILE.equals(option.getOpt())) {
handleLoadIndex(option.getValue());
} else if (PURGE_CACHE_OPTION.equals(option.getOpt())) {
handlePurgeCache();
} else if (GENERATE_CHECKSUM_OPTION.equals(option.getOpt())) {
handleGenerateHash(option);
}
}
|
java
|
private void handleOption(Option option) {
if (LIST_CACHE_OPTION.equals(option.getOpt())) {
handleListCache();
} else if (CACHE_RESOURCE_OPTION.equals(option.getOpt())) {
handleLoadResource(option);
} else if (CACHE_SYSCONFIG_FILE_OPTION.equals(option.getOpt())) {
handleLoadDefaultIndex();
} else if (CACHE_INDEX_FILE.equals(option.getOpt())) {
handleLoadIndex(option.getValue());
} else if (PURGE_CACHE_OPTION.equals(option.getOpt())) {
handlePurgeCache();
} else if (GENERATE_CHECKSUM_OPTION.equals(option.getOpt())) {
handleGenerateHash(option);
}
}
|
[
"private",
"void",
"handleOption",
"(",
"Option",
"option",
")",
"{",
"if",
"(",
"LIST_CACHE_OPTION",
".",
"equals",
"(",
"option",
".",
"getOpt",
"(",
")",
")",
")",
"{",
"handleListCache",
"(",
")",
";",
"}",
"else",
"if",
"(",
"CACHE_RESOURCE_OPTION",
".",
"equals",
"(",
"option",
".",
"getOpt",
"(",
")",
")",
")",
"{",
"handleLoadResource",
"(",
"option",
")",
";",
"}",
"else",
"if",
"(",
"CACHE_SYSCONFIG_FILE_OPTION",
".",
"equals",
"(",
"option",
".",
"getOpt",
"(",
")",
")",
")",
"{",
"handleLoadDefaultIndex",
"(",
")",
";",
"}",
"else",
"if",
"(",
"CACHE_INDEX_FILE",
".",
"equals",
"(",
"option",
".",
"getOpt",
"(",
")",
")",
")",
"{",
"handleLoadIndex",
"(",
"option",
".",
"getValue",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"PURGE_CACHE_OPTION",
".",
"equals",
"(",
"option",
".",
"getOpt",
"(",
")",
")",
")",
"{",
"handlePurgeCache",
"(",
")",
";",
"}",
"else",
"if",
"(",
"GENERATE_CHECKSUM_OPTION",
".",
"equals",
"(",
"option",
".",
"getOpt",
"(",
")",
")",
")",
"{",
"handleGenerateHash",
"(",
"option",
")",
";",
"}",
"}"
] |
Handle the cli option that was provided.
@param option {@link Option} the current option to handle
|
[
"Handle",
"the",
"cli",
"option",
"that",
"was",
"provided",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/CacheManager.java#L173-L187
|
146,109
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/CacheManager.java
|
CacheManager.handleListCache
|
protected void handleListCache() {
reportable.output("Listing resources in the cache");
List<CachedResource> resources = cacheLookupService.getResources();
if (resources.isEmpty()) {
reportable.output("No resources in the cache.");
}
for (CachedResource resource : resources) {
reportable.output("\t" + resource.getType().getResourceFolderName()
+ "\t" + resource.getRemoteLocation());
}
}
|
java
|
protected void handleListCache() {
reportable.output("Listing resources in the cache");
List<CachedResource> resources = cacheLookupService.getResources();
if (resources.isEmpty()) {
reportable.output("No resources in the cache.");
}
for (CachedResource resource : resources) {
reportable.output("\t" + resource.getType().getResourceFolderName()
+ "\t" + resource.getRemoteLocation());
}
}
|
[
"protected",
"void",
"handleListCache",
"(",
")",
"{",
"reportable",
".",
"output",
"(",
"\"Listing resources in the cache\"",
")",
";",
"List",
"<",
"CachedResource",
">",
"resources",
"=",
"cacheLookupService",
".",
"getResources",
"(",
")",
";",
"if",
"(",
"resources",
".",
"isEmpty",
"(",
")",
")",
"{",
"reportable",
".",
"output",
"(",
"\"No resources in the cache.\"",
")",
";",
"}",
"for",
"(",
"CachedResource",
"resource",
":",
"resources",
")",
"{",
"reportable",
".",
"output",
"(",
"\"\\t\"",
"+",
"resource",
".",
"getType",
"(",
")",
".",
"getResourceFolderName",
"(",
")",
"+",
"\"\\t\"",
"+",
"resource",
".",
"getRemoteLocation",
"(",
")",
")",
";",
"}",
"}"
] |
Handle the list cache option.
|
[
"Handle",
"the",
"list",
"cache",
"option",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/CacheManager.java#L192-L204
|
146,110
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/CacheManager.java
|
CacheManager.handleLoadResource
|
protected void handleLoadResource(Option option) {
String resourceLocation = option.getValue();
reportable.output("Loading resource into the cache:");
reportable.output(" " + resourceLocation);
ResourceType type = ResourceType.fromLocation(resourceLocation);
if (type == null) {
reportable
.error("Resource type cannot be determined, consult help with -h.");
bail(GENERAL_FAILURE);
}
cacheMgrService.updateResourceInCache(type, resourceLocation);
}
|
java
|
protected void handleLoadResource(Option option) {
String resourceLocation = option.getValue();
reportable.output("Loading resource into the cache:");
reportable.output(" " + resourceLocation);
ResourceType type = ResourceType.fromLocation(resourceLocation);
if (type == null) {
reportable
.error("Resource type cannot be determined, consult help with -h.");
bail(GENERAL_FAILURE);
}
cacheMgrService.updateResourceInCache(type, resourceLocation);
}
|
[
"protected",
"void",
"handleLoadResource",
"(",
"Option",
"option",
")",
"{",
"String",
"resourceLocation",
"=",
"option",
".",
"getValue",
"(",
")",
";",
"reportable",
".",
"output",
"(",
"\"Loading resource into the cache:\"",
")",
";",
"reportable",
".",
"output",
"(",
"\" \"",
"+",
"resourceLocation",
")",
";",
"ResourceType",
"type",
"=",
"ResourceType",
".",
"fromLocation",
"(",
"resourceLocation",
")",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"reportable",
".",
"error",
"(",
"\"Resource type cannot be determined, consult help with -h.\"",
")",
";",
"bail",
"(",
"GENERAL_FAILURE",
")",
";",
"}",
"cacheMgrService",
".",
"updateResourceInCache",
"(",
"type",
",",
"resourceLocation",
")",
";",
"}"
] |
Handle the load resource option.
@param option {@link Option} the option to fetch the cli argument from
|
[
"Handle",
"the",
"load",
"resource",
"option",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/CacheManager.java#L216-L231
|
146,111
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/CacheManager.java
|
CacheManager.handleLoadIndex
|
protected void handleLoadIndex(String indexLocation) {
reportable.output("Loading resource from index file:");
reportable.output(" " + indexLocation);
File indexFile = new File(indexLocation);
if (!indexFile.exists() || !indexFile.canRead()) {
// try the index as an online resource.
try {
ResolvedResource resolvedResource = cacheService
.resolveResource(ResourceType.RESOURCE_INDEX,
indexLocation);
indexFile = resolvedResource.getCacheResourceCopy();
} catch (Exception e) {
reportable.error("Index could not be read");
bail(GENERAL_FAILURE);
}
}
try {
ResourceIndex.INSTANCE.loadIndex(indexFile);
} catch (Exception e) {
reportable.error("Unable to load index");
reportable.error("Reason: " + e.getMessage());
bail(GENERAL_FAILURE);
}
Index index = ResourceIndex.INSTANCE.getIndex();
cacheMgrService.updateResourceIndexInCache(index);
}
|
java
|
protected void handleLoadIndex(String indexLocation) {
reportable.output("Loading resource from index file:");
reportable.output(" " + indexLocation);
File indexFile = new File(indexLocation);
if (!indexFile.exists() || !indexFile.canRead()) {
// try the index as an online resource.
try {
ResolvedResource resolvedResource = cacheService
.resolveResource(ResourceType.RESOURCE_INDEX,
indexLocation);
indexFile = resolvedResource.getCacheResourceCopy();
} catch (Exception e) {
reportable.error("Index could not be read");
bail(GENERAL_FAILURE);
}
}
try {
ResourceIndex.INSTANCE.loadIndex(indexFile);
} catch (Exception e) {
reportable.error("Unable to load index");
reportable.error("Reason: " + e.getMessage());
bail(GENERAL_FAILURE);
}
Index index = ResourceIndex.INSTANCE.getIndex();
cacheMgrService.updateResourceIndexInCache(index);
}
|
[
"protected",
"void",
"handleLoadIndex",
"(",
"String",
"indexLocation",
")",
"{",
"reportable",
".",
"output",
"(",
"\"Loading resource from index file:\"",
")",
";",
"reportable",
".",
"output",
"(",
"\" \"",
"+",
"indexLocation",
")",
";",
"File",
"indexFile",
"=",
"new",
"File",
"(",
"indexLocation",
")",
";",
"if",
"(",
"!",
"indexFile",
".",
"exists",
"(",
")",
"||",
"!",
"indexFile",
".",
"canRead",
"(",
")",
")",
"{",
"// try the index as an online resource.",
"try",
"{",
"ResolvedResource",
"resolvedResource",
"=",
"cacheService",
".",
"resolveResource",
"(",
"ResourceType",
".",
"RESOURCE_INDEX",
",",
"indexLocation",
")",
";",
"indexFile",
"=",
"resolvedResource",
".",
"getCacheResourceCopy",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"reportable",
".",
"error",
"(",
"\"Index could not be read\"",
")",
";",
"bail",
"(",
"GENERAL_FAILURE",
")",
";",
"}",
"}",
"try",
"{",
"ResourceIndex",
".",
"INSTANCE",
".",
"loadIndex",
"(",
"indexFile",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"reportable",
".",
"error",
"(",
"\"Unable to load index\"",
")",
";",
"reportable",
".",
"error",
"(",
"\"Reason: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"bail",
"(",
"GENERAL_FAILURE",
")",
";",
"}",
"Index",
"index",
"=",
"ResourceIndex",
".",
"INSTANCE",
".",
"getIndex",
"(",
")",
";",
"cacheMgrService",
".",
"updateResourceIndexInCache",
"(",
"index",
")",
";",
"}"
] |
Handle the load index option.
@param indexLocation {@link String} the index location
|
[
"Handle",
"the",
"load",
"index",
"option",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/CacheManager.java#L238-L266
|
146,112
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/CacheManager.java
|
CacheManager.handlePurgeCache
|
protected void handlePurgeCache() {
reportable.output("Purging all resources from the cache");
try {
cacheMgrService.purgeResources();
} catch (Exception e) {
reportable.error("Unable to remove all resources in the cache");
reportable.error("Reason: " + e.getMessage());
bail(GENERAL_FAILURE);
}
}
|
java
|
protected void handlePurgeCache() {
reportable.output("Purging all resources from the cache");
try {
cacheMgrService.purgeResources();
} catch (Exception e) {
reportable.error("Unable to remove all resources in the cache");
reportable.error("Reason: " + e.getMessage());
bail(GENERAL_FAILURE);
}
}
|
[
"protected",
"void",
"handlePurgeCache",
"(",
")",
"{",
"reportable",
".",
"output",
"(",
"\"Purging all resources from the cache\"",
")",
";",
"try",
"{",
"cacheMgrService",
".",
"purgeResources",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"reportable",
".",
"error",
"(",
"\"Unable to remove all resources in the cache\"",
")",
";",
"reportable",
".",
"error",
"(",
"\"Reason: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"bail",
"(",
"GENERAL_FAILURE",
")",
";",
"}",
"}"
] |
Handle the purge cache option.
|
[
"Handle",
"the",
"purge",
"cache",
"option",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/CacheManager.java#L271-L281
|
146,113
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/CacheManager.java
|
CacheManager.handleGenerateHash
|
protected void handleGenerateHash(Option option) {
String hashFileLocation = option.getValue();
reportable.output("Generating checksum for file: " + hashFileLocation);
File hashFile = new File(hashFileLocation);
if (!hashFile.exists() || !hashFile.canRead()) {
reportable.error("File cannot be read");
bail(GENERAL_FAILURE);
}
String hashContents = null;
try {
hashContents = FileUtils.readFileToString(hashFile);
} catch (IOException e) {
reportable.error("Unable to read file");
reportable.error("Reason: " + e.getMessage());
bail(GENERAL_FAILURE);
}
Hasher hasher = Hasher.INSTANCE;
try {
String generatedhash = hasher.hashValue(hashContents);
reportable.output("Checksum: " + generatedhash);
} catch (Exception e) {
reportable.error("Unable to created checksum");
reportable.error("Reason: " + e.getMessage());
bail(GENERAL_FAILURE);
}
}
|
java
|
protected void handleGenerateHash(Option option) {
String hashFileLocation = option.getValue();
reportable.output("Generating checksum for file: " + hashFileLocation);
File hashFile = new File(hashFileLocation);
if (!hashFile.exists() || !hashFile.canRead()) {
reportable.error("File cannot be read");
bail(GENERAL_FAILURE);
}
String hashContents = null;
try {
hashContents = FileUtils.readFileToString(hashFile);
} catch (IOException e) {
reportable.error("Unable to read file");
reportable.error("Reason: " + e.getMessage());
bail(GENERAL_FAILURE);
}
Hasher hasher = Hasher.INSTANCE;
try {
String generatedhash = hasher.hashValue(hashContents);
reportable.output("Checksum: " + generatedhash);
} catch (Exception e) {
reportable.error("Unable to created checksum");
reportable.error("Reason: " + e.getMessage());
bail(GENERAL_FAILURE);
}
}
|
[
"protected",
"void",
"handleGenerateHash",
"(",
"Option",
"option",
")",
"{",
"String",
"hashFileLocation",
"=",
"option",
".",
"getValue",
"(",
")",
";",
"reportable",
".",
"output",
"(",
"\"Generating checksum for file: \"",
"+",
"hashFileLocation",
")",
";",
"File",
"hashFile",
"=",
"new",
"File",
"(",
"hashFileLocation",
")",
";",
"if",
"(",
"!",
"hashFile",
".",
"exists",
"(",
")",
"||",
"!",
"hashFile",
".",
"canRead",
"(",
")",
")",
"{",
"reportable",
".",
"error",
"(",
"\"File cannot be read\"",
")",
";",
"bail",
"(",
"GENERAL_FAILURE",
")",
";",
"}",
"String",
"hashContents",
"=",
"null",
";",
"try",
"{",
"hashContents",
"=",
"FileUtils",
".",
"readFileToString",
"(",
"hashFile",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"reportable",
".",
"error",
"(",
"\"Unable to read file\"",
")",
";",
"reportable",
".",
"error",
"(",
"\"Reason: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"bail",
"(",
"GENERAL_FAILURE",
")",
";",
"}",
"Hasher",
"hasher",
"=",
"Hasher",
".",
"INSTANCE",
";",
"try",
"{",
"String",
"generatedhash",
"=",
"hasher",
".",
"hashValue",
"(",
"hashContents",
")",
";",
"reportable",
".",
"output",
"(",
"\"Checksum: \"",
"+",
"generatedhash",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"reportable",
".",
"error",
"(",
"\"Unable to created checksum\"",
")",
";",
"reportable",
".",
"error",
"(",
"\"Reason: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"bail",
"(",
"GENERAL_FAILURE",
")",
";",
"}",
"}"
] |
Handle the generate hash option.
@param option {@link Option} the option to fetch the cli argument from
|
[
"Handle",
"the",
"generate",
"hash",
"option",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/CacheManager.java#L288-L318
|
146,114
|
netheosgithub/pcs_api
|
java/src/main/java/net/netheos/pcsapi/utils/URIUtil.java
|
URIUtil.getQueryParameter
|
public static String getQueryParameter( URI uri, String name )
{
Map<String, String> params = parseQueryParameters( uri.getRawQuery() );
return params.get( name );
}
|
java
|
public static String getQueryParameter( URI uri, String name )
{
Map<String, String> params = parseQueryParameters( uri.getRawQuery() );
return params.get( name );
}
|
[
"public",
"static",
"String",
"getQueryParameter",
"(",
"URI",
"uri",
",",
"String",
"name",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"parseQueryParameters",
"(",
"uri",
".",
"getRawQuery",
"(",
")",
")",
";",
"return",
"params",
".",
"get",
"(",
"name",
")",
";",
"}"
] |
Retrieves a query param in a URL according to a key.
If several parameters are to be retrieved from the same URI, better use
<code>parseQueryString( uri.getRawQuery() )</code>.
@param uri
@param name
@return parameter value (if found) ; null if not found or no = after name.
|
[
"Retrieves",
"a",
"query",
"param",
"in",
"a",
"URL",
"according",
"to",
"a",
"key",
"."
] |
20691e52e144014f99ca75cb7dedc7ba0c18586c
|
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/utils/URIUtil.java#L121-L125
|
146,115
|
netheosgithub/pcs_api
|
java/src/main/java/net/netheos/pcsapi/utils/URIUtil.java
|
URIUtil.parseQueryParameters
|
public static Map<String, String> parseQueryParameters( String rawQuery )
{
Map<String, String> ret = new LinkedHashMap<String, String>();
if ( rawQuery == null || rawQuery.length() == 0 ) {
return ret;
}
try {
String[] pairs = rawQuery.split( "&" );
for ( String pair : pairs ) {
int idx = pair.indexOf( "=" );
String name;
String value;
if ( idx > 0 ) {
// name=value
name = pair.substring( 0, idx );
value = URLDecoder.decode( pair.substring( idx + 1 ), PcsUtils.UTF8.name() );
} else if ( idx < 0 ) {
// name (no value)
name = pair;
value = null;
} else {
// =value ?? we ignore this
name = null;
value = null;
}
if ( name != null ) {
ret.put( name, value );
}
}
return ret;
} catch ( UnsupportedEncodingException ex ) {
throw new RuntimeException( ex );
}
}
|
java
|
public static Map<String, String> parseQueryParameters( String rawQuery )
{
Map<String, String> ret = new LinkedHashMap<String, String>();
if ( rawQuery == null || rawQuery.length() == 0 ) {
return ret;
}
try {
String[] pairs = rawQuery.split( "&" );
for ( String pair : pairs ) {
int idx = pair.indexOf( "=" );
String name;
String value;
if ( idx > 0 ) {
// name=value
name = pair.substring( 0, idx );
value = URLDecoder.decode( pair.substring( idx + 1 ), PcsUtils.UTF8.name() );
} else if ( idx < 0 ) {
// name (no value)
name = pair;
value = null;
} else {
// =value ?? we ignore this
name = null;
value = null;
}
if ( name != null ) {
ret.put( name, value );
}
}
return ret;
} catch ( UnsupportedEncodingException ex ) {
throw new RuntimeException( ex );
}
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"parseQueryParameters",
"(",
"String",
"rawQuery",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"ret",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"rawQuery",
"==",
"null",
"||",
"rawQuery",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"ret",
";",
"}",
"try",
"{",
"String",
"[",
"]",
"pairs",
"=",
"rawQuery",
".",
"split",
"(",
"\"&\"",
")",
";",
"for",
"(",
"String",
"pair",
":",
"pairs",
")",
"{",
"int",
"idx",
"=",
"pair",
".",
"indexOf",
"(",
"\"=\"",
")",
";",
"String",
"name",
";",
"String",
"value",
";",
"if",
"(",
"idx",
">",
"0",
")",
"{",
"// name=value",
"name",
"=",
"pair",
".",
"substring",
"(",
"0",
",",
"idx",
")",
";",
"value",
"=",
"URLDecoder",
".",
"decode",
"(",
"pair",
".",
"substring",
"(",
"idx",
"+",
"1",
")",
",",
"PcsUtils",
".",
"UTF8",
".",
"name",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"idx",
"<",
"0",
")",
"{",
"// name (no value)",
"name",
"=",
"pair",
";",
"value",
"=",
"null",
";",
"}",
"else",
"{",
"// =value ?? we ignore this",
"name",
"=",
"null",
";",
"value",
"=",
"null",
";",
"}",
"if",
"(",
"name",
"!=",
"null",
")",
"{",
"ret",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}"
] |
Parse a query param string into a map of parameters.
Duplicated parameters cannot be handled by this method. Parameters names not followed by '=' sign are only keys
but have null value. Parameters names followed by '=' sign have an empty string value.
@param rawQuery The query param string, as returned by URI.getRawQuery() (UTF-8 charset)
@return a (mutable) map of parameters (empty map if rawQuery is null or empty). Order of parameters is kept.
|
[
"Parse",
"a",
"query",
"param",
"string",
"into",
"a",
"map",
"of",
"parameters",
"."
] |
20691e52e144014f99ca75cb7dedc7ba0c18586c
|
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/utils/URIUtil.java#L136-L170
|
146,116
|
astrapi69/jaulp-wicket
|
jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/WicketImageExtensions.java
|
WicketImageExtensions.getNonCachingImage
|
public static NonCachingImage getNonCachingImage(final String wicketId,
final String contentType, final byte[] data)
{
return new NonCachingImage(wicketId, new DatabaseImageResource(contentType, data));
}
|
java
|
public static NonCachingImage getNonCachingImage(final String wicketId,
final String contentType, final byte[] data)
{
return new NonCachingImage(wicketId, new DatabaseImageResource(contentType, data));
}
|
[
"public",
"static",
"NonCachingImage",
"getNonCachingImage",
"(",
"final",
"String",
"wicketId",
",",
"final",
"String",
"contentType",
",",
"final",
"byte",
"[",
"]",
"data",
")",
"{",
"return",
"new",
"NonCachingImage",
"(",
"wicketId",
",",
"new",
"DatabaseImageResource",
"(",
"contentType",
",",
"data",
")",
")",
";",
"}"
] |
Gets a non caching image from the given wicketId, contentType and the byte array data.
@param wicketId
the id from the image for the html template.
@param contentType
the content type of the image.
@param data
the data for the image as an byte array.
@return the non caching image
|
[
"Gets",
"a",
"non",
"caching",
"image",
"from",
"the",
"given",
"wicketId",
"contentType",
"and",
"the",
"byte",
"array",
"data",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/WicketImageExtensions.java#L76-L80
|
146,117
|
astrapi69/jaulp-wicket
|
jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/WicketImageExtensions.java
|
WicketImageExtensions.getNonCachingImage
|
public static NonCachingImage getNonCachingImage(final String wicketId,
final String contentType, final Byte[] data)
{
final byte[] byteArrayData = ArrayUtils.toPrimitive(data);
return getNonCachingImage(wicketId, contentType, byteArrayData);
}
|
java
|
public static NonCachingImage getNonCachingImage(final String wicketId,
final String contentType, final Byte[] data)
{
final byte[] byteArrayData = ArrayUtils.toPrimitive(data);
return getNonCachingImage(wicketId, contentType, byteArrayData);
}
|
[
"public",
"static",
"NonCachingImage",
"getNonCachingImage",
"(",
"final",
"String",
"wicketId",
",",
"final",
"String",
"contentType",
",",
"final",
"Byte",
"[",
"]",
"data",
")",
"{",
"final",
"byte",
"[",
"]",
"byteArrayData",
"=",
"ArrayUtils",
".",
"toPrimitive",
"(",
"data",
")",
";",
"return",
"getNonCachingImage",
"(",
"wicketId",
",",
"contentType",
",",
"byteArrayData",
")",
";",
"}"
] |
Gets a non caching image from the given wicketId, contentType and the Byte array data.
@param wicketId
the id from the image for the html template.
@param contentType
the content type of the image.
@param data
the data for the image as an Byte array.
@return the non caching image
|
[
"Gets",
"a",
"non",
"caching",
"image",
"from",
"the",
"given",
"wicketId",
"contentType",
"and",
"the",
"Byte",
"array",
"data",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/WicketImageExtensions.java#L94-L99
|
146,118
|
geomajas/geomajas-project-client-gwt2
|
plugin/corewidget/example-jar/src/main/java/org/geomajas/gwt2/plugin/corewidget/example/client/sample/feature/featureinfo/FeatureInfoPanel.java
|
FeatureInfoPanel.onFeatureClicked
|
@Override
public void onFeatureClicked(FeatureClickedEvent event) {
// Create feature info widget if this is the first time displaying a feature:
if (featureInfoWidget == null) {
// Create info widget with some actions:
FeatureInfoWidgetFactory factory = new FeatureInfoWidgetFactory();
featureInfoWidget = factory.getFeatureInfoWidgetWithActions(mapPresenter);
leftPanel.add(featureInfoWidget);
}
// (Over)write the feature of the widget:
List<Feature> featureList = event.getFeatures();
if (featureList != null && featureList.size() == 1 && featureList.get(0) != null) {
featureInfoWidget.setFeature(featureList.get(0));
}
}
|
java
|
@Override
public void onFeatureClicked(FeatureClickedEvent event) {
// Create feature info widget if this is the first time displaying a feature:
if (featureInfoWidget == null) {
// Create info widget with some actions:
FeatureInfoWidgetFactory factory = new FeatureInfoWidgetFactory();
featureInfoWidget = factory.getFeatureInfoWidgetWithActions(mapPresenter);
leftPanel.add(featureInfoWidget);
}
// (Over)write the feature of the widget:
List<Feature> featureList = event.getFeatures();
if (featureList != null && featureList.size() == 1 && featureList.get(0) != null) {
featureInfoWidget.setFeature(featureList.get(0));
}
}
|
[
"@",
"Override",
"public",
"void",
"onFeatureClicked",
"(",
"FeatureClickedEvent",
"event",
")",
"{",
"// Create feature info widget if this is the first time displaying a feature:",
"if",
"(",
"featureInfoWidget",
"==",
"null",
")",
"{",
"// Create info widget with some actions:",
"FeatureInfoWidgetFactory",
"factory",
"=",
"new",
"FeatureInfoWidgetFactory",
"(",
")",
";",
"featureInfoWidget",
"=",
"factory",
".",
"getFeatureInfoWidgetWithActions",
"(",
"mapPresenter",
")",
";",
"leftPanel",
".",
"add",
"(",
"featureInfoWidget",
")",
";",
"}",
"// (Over)write the feature of the widget:",
"List",
"<",
"Feature",
">",
"featureList",
"=",
"event",
".",
"getFeatures",
"(",
")",
";",
"if",
"(",
"featureList",
"!=",
"null",
"&&",
"featureList",
".",
"size",
"(",
")",
"==",
"1",
"&&",
"featureList",
".",
"get",
"(",
"0",
")",
"!=",
"null",
")",
"{",
"featureInfoWidget",
".",
"setFeature",
"(",
"featureList",
".",
"get",
"(",
"0",
")",
")",
";",
"}",
"}"
] |
Action called when a feature is clicked. Displays the information of the clicked
feature in the left panel of the sample, overwriting any feature info that may
be already there.
@param event {@link org.geomajas.gwt2.plugin
.corewidget.example.client.sample.feature.controller.FeatureClickedEvent}
|
[
"Action",
"called",
"when",
"a",
"feature",
"is",
"clicked",
".",
"Displays",
"the",
"information",
"of",
"the",
"clicked",
"feature",
"in",
"the",
"left",
"panel",
"of",
"the",
"sample",
"overwriting",
"any",
"feature",
"info",
"that",
"may",
"be",
"already",
"there",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/corewidget/example-jar/src/main/java/org/geomajas/gwt2/plugin/corewidget/example/client/sample/feature/featureinfo/FeatureInfoPanel.java#L100-L115
|
146,119
|
alb-i986/selenium-tinafw
|
src/main/java/me/alb_i986/selenium/tinafw/config/PropertyLoaderFromResource.java
|
PropertyLoaderFromResource.loadPropsFromResource
|
private static Properties loadPropsFromResource(String resourceName, boolean failOnResourceNotFoundOrNotLoaded) {
Properties props = new Properties();
InputStream resource = PropertyLoaderFromResource.class.getResourceAsStream(resourceName);
boolean resourceNotFound = (resource == null);
if(resourceNotFound) {
if(failOnResourceNotFoundOrNotLoaded) {
throw new ConfigException("resource " + resourceName + " not found");
} else {
// if the resource is not found, return an empty Properties
logger.warn("Skipping resource " + resourceName + ": file not found.");
return props;
}
}
try {
props.load(resource);
} catch (IOException e) {
if(failOnResourceNotFoundOrNotLoaded)
throw new ConfigException("Cannot load properties from " + resourceName, e);
else
logger.warn("Cannot load properties from " + resourceName + ": " + e.getMessage());
}
return props;
}
|
java
|
private static Properties loadPropsFromResource(String resourceName, boolean failOnResourceNotFoundOrNotLoaded) {
Properties props = new Properties();
InputStream resource = PropertyLoaderFromResource.class.getResourceAsStream(resourceName);
boolean resourceNotFound = (resource == null);
if(resourceNotFound) {
if(failOnResourceNotFoundOrNotLoaded) {
throw new ConfigException("resource " + resourceName + " not found");
} else {
// if the resource is not found, return an empty Properties
logger.warn("Skipping resource " + resourceName + ": file not found.");
return props;
}
}
try {
props.load(resource);
} catch (IOException e) {
if(failOnResourceNotFoundOrNotLoaded)
throw new ConfigException("Cannot load properties from " + resourceName, e);
else
logger.warn("Cannot load properties from " + resourceName + ": " + e.getMessage());
}
return props;
}
|
[
"private",
"static",
"Properties",
"loadPropsFromResource",
"(",
"String",
"resourceName",
",",
"boolean",
"failOnResourceNotFoundOrNotLoaded",
")",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"InputStream",
"resource",
"=",
"PropertyLoaderFromResource",
".",
"class",
".",
"getResourceAsStream",
"(",
"resourceName",
")",
";",
"boolean",
"resourceNotFound",
"=",
"(",
"resource",
"==",
"null",
")",
";",
"if",
"(",
"resourceNotFound",
")",
"{",
"if",
"(",
"failOnResourceNotFoundOrNotLoaded",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"\"resource \"",
"+",
"resourceName",
"+",
"\" not found\"",
")",
";",
"}",
"else",
"{",
"// if the resource is not found, return an empty Properties",
"logger",
".",
"warn",
"(",
"\"Skipping resource \"",
"+",
"resourceName",
"+",
"\": file not found.\"",
")",
";",
"return",
"props",
";",
"}",
"}",
"try",
"{",
"props",
".",
"load",
"(",
"resource",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"if",
"(",
"failOnResourceNotFoundOrNotLoaded",
")",
"throw",
"new",
"ConfigException",
"(",
"\"Cannot load properties from \"",
"+",
"resourceName",
",",
"e",
")",
";",
"else",
"logger",
".",
"warn",
"(",
"\"Cannot load properties from \"",
"+",
"resourceName",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"props",
";",
"}"
] |
Load properties from a resource.
@param resourceName
@param failOnResourceNotFoundOrNotLoaded when true, a ConfigException
is raised if the resource cannot be found or loaded
@return a {@link Properties} instance with the properties loaded from the resource;
might be empty if the resource is not found or if it cannot be loaded
@throws ConfigException if the resource cannot be found or loaded,
and failOnResourceNotFound is true
@see Properties#load(InputStream)
|
[
"Load",
"properties",
"from",
"a",
"resource",
"."
] |
91c66720cda9f69751f96c58c0a0624b2222186e
|
https://github.com/alb-i986/selenium-tinafw/blob/91c66720cda9f69751f96c58c0a0624b2222186e/src/main/java/me/alb_i986/selenium/tinafw/config/PropertyLoaderFromResource.java#L40-L62
|
146,120
|
nohana/Amalgam
|
amalgam/src/main/java/com/amalgam/app/ActivityUtils.java
|
ActivityUtils.findViewById
|
@SuppressWarnings("unchecked") // we know that return value type is a child of view, and V is bound to a child of view.
public static <V extends View> V findViewById(Activity activity, int id) {
return (V) activity.findViewById(id);
}
|
java
|
@SuppressWarnings("unchecked") // we know that return value type is a child of view, and V is bound to a child of view.
public static <V extends View> V findViewById(Activity activity, int id) {
return (V) activity.findViewById(id);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"// we know that return value type is a child of view, and V is bound to a child of view.",
"public",
"static",
"<",
"V",
"extends",
"View",
">",
"V",
"findViewById",
"(",
"Activity",
"activity",
",",
"int",
"id",
")",
"{",
"return",
"(",
"V",
")",
"activity",
".",
"findViewById",
"(",
"id",
")",
";",
"}"
] |
Find the specific view from the activity.
Returning value type is bound to your variable type.
@param activity the activity.
@param id the view id.
@param <V> the view class type parameter.
@return the view, null if not found.
|
[
"Find",
"the",
"specific",
"view",
"from",
"the",
"activity",
".",
"Returning",
"value",
"type",
"is",
"bound",
"to",
"your",
"variable",
"type",
"."
] |
57809ddbfe7897e979cf507982ce0b3aa5e0ed8a
|
https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/app/ActivityUtils.java#L23-L26
|
146,121
|
OpenBEL/openbel-framework
|
org.openbel.framework.core/src/main/java/org/openbel/framework/core/kam/JdbcKAMLoaderImpl.java
|
JdbcKAMLoaderImpl.saveObject
|
protected int saveObject(int tid, String v) throws SQLException {
final String objectsIdColumn = (dbConnection.isPostgresql() ?
OBJECTS_ID_COLUMN_POSTGRESQL : OBJECTS_ID_COLUMN);
PreparedStatement ps = getPreparedStatement(OBJECTS_SQL,
new String[] { objectsIdColumn });
ResultSet rs = null;
if (v == null) {
throw new InvalidArgument("object value cannot be null");
}
try {
v = new String(v.getBytes(), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("utf-8 unsupported", e);
}
try {
// Insert into objects_text if we are over MAX_VARCHAR_LENGTH
Integer objectsTextId = null;
if (v.length() > MAX_VARCHAR_LENGTH) {
final String objectsTextColumn = (dbConnection.isPostgresql() ?
OBJECTS_TEXT_COLUMN_POSTGRESQL : OBJECTS_TEXT_COLUMN);
PreparedStatement otps = getPreparedStatement(OBJECTS_TEXT_SQL,
new String[] { objectsTextColumn });
ResultSet otrs = null;
StringReader sr = null;
try {
sr = new StringReader(v);
otps.setClob(1, sr, v.length());
otps.execute();
otrs = otps.getGeneratedKeys();
if (otrs.next()) {
objectsTextId = otrs.getInt(1);
}
} finally {
close(otrs);
if (sr != null) {
sr.close();
}
}
}
// FIXME Hardcoding objects_type to 1?
ps.setInt(1, 1);
if (objectsTextId == null) {
// insert value into objects table
ps.setString(2, v);
ps.setNull(3, Types.INTEGER);
} else {
ps.setNull(2, Types.VARCHAR);
ps.setInt(3, objectsTextId);
}
ps.execute();
rs = ps.getGeneratedKeys();
int oid;
if (rs.next()) {
oid = rs.getInt(1);
} else {
throw new IllegalStateException("object insert failed.");
}
return oid;
} finally {
close(rs);
}
}
|
java
|
protected int saveObject(int tid, String v) throws SQLException {
final String objectsIdColumn = (dbConnection.isPostgresql() ?
OBJECTS_ID_COLUMN_POSTGRESQL : OBJECTS_ID_COLUMN);
PreparedStatement ps = getPreparedStatement(OBJECTS_SQL,
new String[] { objectsIdColumn });
ResultSet rs = null;
if (v == null) {
throw new InvalidArgument("object value cannot be null");
}
try {
v = new String(v.getBytes(), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("utf-8 unsupported", e);
}
try {
// Insert into objects_text if we are over MAX_VARCHAR_LENGTH
Integer objectsTextId = null;
if (v.length() > MAX_VARCHAR_LENGTH) {
final String objectsTextColumn = (dbConnection.isPostgresql() ?
OBJECTS_TEXT_COLUMN_POSTGRESQL : OBJECTS_TEXT_COLUMN);
PreparedStatement otps = getPreparedStatement(OBJECTS_TEXT_SQL,
new String[] { objectsTextColumn });
ResultSet otrs = null;
StringReader sr = null;
try {
sr = new StringReader(v);
otps.setClob(1, sr, v.length());
otps.execute();
otrs = otps.getGeneratedKeys();
if (otrs.next()) {
objectsTextId = otrs.getInt(1);
}
} finally {
close(otrs);
if (sr != null) {
sr.close();
}
}
}
// FIXME Hardcoding objects_type to 1?
ps.setInt(1, 1);
if (objectsTextId == null) {
// insert value into objects table
ps.setString(2, v);
ps.setNull(3, Types.INTEGER);
} else {
ps.setNull(2, Types.VARCHAR);
ps.setInt(3, objectsTextId);
}
ps.execute();
rs = ps.getGeneratedKeys();
int oid;
if (rs.next()) {
oid = rs.getInt(1);
} else {
throw new IllegalStateException("object insert failed.");
}
return oid;
} finally {
close(rs);
}
}
|
[
"protected",
"int",
"saveObject",
"(",
"int",
"tid",
",",
"String",
"v",
")",
"throws",
"SQLException",
"{",
"final",
"String",
"objectsIdColumn",
"=",
"(",
"dbConnection",
".",
"isPostgresql",
"(",
")",
"?",
"OBJECTS_ID_COLUMN_POSTGRESQL",
":",
"OBJECTS_ID_COLUMN",
")",
";",
"PreparedStatement",
"ps",
"=",
"getPreparedStatement",
"(",
"OBJECTS_SQL",
",",
"new",
"String",
"[",
"]",
"{",
"objectsIdColumn",
"}",
")",
";",
"ResultSet",
"rs",
"=",
"null",
";",
"if",
"(",
"v",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgument",
"(",
"\"object value cannot be null\"",
")",
";",
"}",
"try",
"{",
"v",
"=",
"new",
"String",
"(",
"v",
".",
"getBytes",
"(",
")",
",",
"\"UTF-8\"",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"utf-8 unsupported\"",
",",
"e",
")",
";",
"}",
"try",
"{",
"// Insert into objects_text if we are over MAX_VARCHAR_LENGTH",
"Integer",
"objectsTextId",
"=",
"null",
";",
"if",
"(",
"v",
".",
"length",
"(",
")",
">",
"MAX_VARCHAR_LENGTH",
")",
"{",
"final",
"String",
"objectsTextColumn",
"=",
"(",
"dbConnection",
".",
"isPostgresql",
"(",
")",
"?",
"OBJECTS_TEXT_COLUMN_POSTGRESQL",
":",
"OBJECTS_TEXT_COLUMN",
")",
";",
"PreparedStatement",
"otps",
"=",
"getPreparedStatement",
"(",
"OBJECTS_TEXT_SQL",
",",
"new",
"String",
"[",
"]",
"{",
"objectsTextColumn",
"}",
")",
";",
"ResultSet",
"otrs",
"=",
"null",
";",
"StringReader",
"sr",
"=",
"null",
";",
"try",
"{",
"sr",
"=",
"new",
"StringReader",
"(",
"v",
")",
";",
"otps",
".",
"setClob",
"(",
"1",
",",
"sr",
",",
"v",
".",
"length",
"(",
")",
")",
";",
"otps",
".",
"execute",
"(",
")",
";",
"otrs",
"=",
"otps",
".",
"getGeneratedKeys",
"(",
")",
";",
"if",
"(",
"otrs",
".",
"next",
"(",
")",
")",
"{",
"objectsTextId",
"=",
"otrs",
".",
"getInt",
"(",
"1",
")",
";",
"}",
"}",
"finally",
"{",
"close",
"(",
"otrs",
")",
";",
"if",
"(",
"sr",
"!=",
"null",
")",
"{",
"sr",
".",
"close",
"(",
")",
";",
"}",
"}",
"}",
"// FIXME Hardcoding objects_type to 1?",
"ps",
".",
"setInt",
"(",
"1",
",",
"1",
")",
";",
"if",
"(",
"objectsTextId",
"==",
"null",
")",
"{",
"// insert value into objects table",
"ps",
".",
"setString",
"(",
"2",
",",
"v",
")",
";",
"ps",
".",
"setNull",
"(",
"3",
",",
"Types",
".",
"INTEGER",
")",
";",
"}",
"else",
"{",
"ps",
".",
"setNull",
"(",
"2",
",",
"Types",
".",
"VARCHAR",
")",
";",
"ps",
".",
"setInt",
"(",
"3",
",",
"objectsTextId",
")",
";",
"}",
"ps",
".",
"execute",
"(",
")",
";",
"rs",
"=",
"ps",
".",
"getGeneratedKeys",
"(",
")",
";",
"int",
"oid",
";",
"if",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"oid",
"=",
"rs",
".",
"getInt",
"(",
"1",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"object insert failed.\"",
")",
";",
"}",
"return",
"oid",
";",
"}",
"finally",
"{",
"close",
"(",
"rs",
")",
";",
"}",
"}"
] |
Saves an entry to the object table.
@param tid {@code int}, the object type id
@param v {@link String}, the non-null object value
@return {@code int}, the object primary key
@throws SQLException - Thrown if a sql error occurred saving an entry to
the object table
|
[
"Saves",
"an",
"entry",
"to",
"the",
"object",
"table",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.core/src/main/java/org/openbel/framework/core/kam/JdbcKAMLoaderImpl.java#L857-L927
|
146,122
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/sequence/SequenceLabelerME.java
|
SequenceLabelerME.tag
|
public Span[] tag(final String[] tokens, final String[][] additionalContext) {
this.additionalContextFeatureGenerator.setCurrentContext(additionalContext);
this.bestSequence = this.model.bestSequence(tokens, additionalContext,
this.contextGenerator, this.sequenceValidator);
final List<String> c = this.bestSequence.getOutcomes();
this.contextGenerator.updateAdaptiveData(tokens,
c.toArray(new String[c.size()]));
Span[] spans = this.seqCodec.decode(c);
spans = setProbs(spans);
return spans;
}
|
java
|
public Span[] tag(final String[] tokens, final String[][] additionalContext) {
this.additionalContextFeatureGenerator.setCurrentContext(additionalContext);
this.bestSequence = this.model.bestSequence(tokens, additionalContext,
this.contextGenerator, this.sequenceValidator);
final List<String> c = this.bestSequence.getOutcomes();
this.contextGenerator.updateAdaptiveData(tokens,
c.toArray(new String[c.size()]));
Span[] spans = this.seqCodec.decode(c);
spans = setProbs(spans);
return spans;
}
|
[
"public",
"Span",
"[",
"]",
"tag",
"(",
"final",
"String",
"[",
"]",
"tokens",
",",
"final",
"String",
"[",
"]",
"[",
"]",
"additionalContext",
")",
"{",
"this",
".",
"additionalContextFeatureGenerator",
".",
"setCurrentContext",
"(",
"additionalContext",
")",
";",
"this",
".",
"bestSequence",
"=",
"this",
".",
"model",
".",
"bestSequence",
"(",
"tokens",
",",
"additionalContext",
",",
"this",
".",
"contextGenerator",
",",
"this",
".",
"sequenceValidator",
")",
";",
"final",
"List",
"<",
"String",
">",
"c",
"=",
"this",
".",
"bestSequence",
".",
"getOutcomes",
"(",
")",
";",
"this",
".",
"contextGenerator",
".",
"updateAdaptiveData",
"(",
"tokens",
",",
"c",
".",
"toArray",
"(",
"new",
"String",
"[",
"c",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"Span",
"[",
"]",
"spans",
"=",
"this",
".",
"seqCodec",
".",
"decode",
"(",
"c",
")",
";",
"spans",
"=",
"setProbs",
"(",
"spans",
")",
";",
"return",
"spans",
";",
"}"
] |
Generates sequence tags for the given sequence, returning spans for any
identified sequences.
@param tokens
an array of the tokens or words, typically a sentence.
@param additionalContext
features which are based on context outside of the sentence but
which should also be used.
@return an array of spans for each of the names identified.
|
[
"Generates",
"sequence",
"tags",
"for",
"the",
"given",
"sequence",
"returning",
"spans",
"for",
"any",
"identified",
"sequences",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/sequence/SequenceLabelerME.java#L105-L115
|
146,123
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/sequence/SequenceLabelerME.java
|
SequenceLabelerME.tag
|
public Span[][] tag(final int numTaggings, final String[] tokens) {
final Sequence[] bestSequences = this.model.bestSequences(numTaggings,
tokens, null, this.contextGenerator, this.sequenceValidator);
final Span[][] tags = new Span[bestSequences.length][];
for (int i = 0; i < tags.length; i++) {
final List<String> c = bestSequences[i].getOutcomes();
this.contextGenerator.updateAdaptiveData(tokens,
c.toArray(new String[c.size()]));
final Span[] spans = this.seqCodec.decode(c);
tags[i] = spans;
}
return tags;
}
|
java
|
public Span[][] tag(final int numTaggings, final String[] tokens) {
final Sequence[] bestSequences = this.model.bestSequences(numTaggings,
tokens, null, this.contextGenerator, this.sequenceValidator);
final Span[][] tags = new Span[bestSequences.length][];
for (int i = 0; i < tags.length; i++) {
final List<String> c = bestSequences[i].getOutcomes();
this.contextGenerator.updateAdaptiveData(tokens,
c.toArray(new String[c.size()]));
final Span[] spans = this.seqCodec.decode(c);
tags[i] = spans;
}
return tags;
}
|
[
"public",
"Span",
"[",
"]",
"[",
"]",
"tag",
"(",
"final",
"int",
"numTaggings",
",",
"final",
"String",
"[",
"]",
"tokens",
")",
"{",
"final",
"Sequence",
"[",
"]",
"bestSequences",
"=",
"this",
".",
"model",
".",
"bestSequences",
"(",
"numTaggings",
",",
"tokens",
",",
"null",
",",
"this",
".",
"contextGenerator",
",",
"this",
".",
"sequenceValidator",
")",
";",
"final",
"Span",
"[",
"]",
"[",
"]",
"tags",
"=",
"new",
"Span",
"[",
"bestSequences",
".",
"length",
"]",
"[",
"",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tags",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"List",
"<",
"String",
">",
"c",
"=",
"bestSequences",
"[",
"i",
"]",
".",
"getOutcomes",
"(",
")",
";",
"this",
".",
"contextGenerator",
".",
"updateAdaptiveData",
"(",
"tokens",
",",
"c",
".",
"toArray",
"(",
"new",
"String",
"[",
"c",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"final",
"Span",
"[",
"]",
"spans",
"=",
"this",
".",
"seqCodec",
".",
"decode",
"(",
"c",
")",
";",
"tags",
"[",
"i",
"]",
"=",
"spans",
";",
"}",
"return",
"tags",
";",
"}"
] |
Returns at most the specified number of taggings for the specified
sentence.
@param numTaggings
the number of labels to be returned.
@param tokens
an array of tokens which make up a sentence.
@return at most the specified number of labels for the specified sentence.
|
[
"Returns",
"at",
"most",
"the",
"specified",
"number",
"of",
"taggings",
"for",
"the",
"specified",
"sentence",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/sequence/SequenceLabelerME.java#L137-L149
|
146,124
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/sequence/SequenceLabelerME.java
|
SequenceLabelerME.setProbs
|
private Span[] setProbs(final Span[] spans) {
final double[] probs = probs(spans);
if (probs != null) {
for (int i = 0; i < probs.length; i++) {
final double prob = probs[i];
spans[i] = new Span(spans[i], prob);
}
}
return spans;
}
|
java
|
private Span[] setProbs(final Span[] spans) {
final double[] probs = probs(spans);
if (probs != null) {
for (int i = 0; i < probs.length; i++) {
final double prob = probs[i];
spans[i] = new Span(spans[i], prob);
}
}
return spans;
}
|
[
"private",
"Span",
"[",
"]",
"setProbs",
"(",
"final",
"Span",
"[",
"]",
"spans",
")",
"{",
"final",
"double",
"[",
"]",
"probs",
"=",
"probs",
"(",
"spans",
")",
";",
"if",
"(",
"probs",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"probs",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"double",
"prob",
"=",
"probs",
"[",
"i",
"]",
";",
"spans",
"[",
"i",
"]",
"=",
"new",
"Span",
"(",
"spans",
"[",
"i",
"]",
",",
"prob",
")",
";",
"}",
"}",
"return",
"spans",
";",
"}"
] |
sets the probs for the spans
@param spans
@return
|
[
"sets",
"the",
"probs",
"for",
"the",
"spans"
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/sequence/SequenceLabelerME.java#L205-L215
|
146,125
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/sequence/SequenceLabelerME.java
|
SequenceLabelerME.probs
|
public double[] probs(final Span[] spans) {
final double[] sprobs = new double[spans.length];
final double[] probs = this.bestSequence.getProbs();
for (int si = 0; si < spans.length; si++) {
double p = 0;
for (int oi = spans[si].getStart(); oi < spans[si].getEnd(); oi++) {
p += probs[oi];
}
p /= spans[si].length();
sprobs[si] = p;
}
return sprobs;
}
|
java
|
public double[] probs(final Span[] spans) {
final double[] sprobs = new double[spans.length];
final double[] probs = this.bestSequence.getProbs();
for (int si = 0; si < spans.length; si++) {
double p = 0;
for (int oi = spans[si].getStart(); oi < spans[si].getEnd(); oi++) {
p += probs[oi];
}
p /= spans[si].length();
sprobs[si] = p;
}
return sprobs;
}
|
[
"public",
"double",
"[",
"]",
"probs",
"(",
"final",
"Span",
"[",
"]",
"spans",
")",
"{",
"final",
"double",
"[",
"]",
"sprobs",
"=",
"new",
"double",
"[",
"spans",
".",
"length",
"]",
";",
"final",
"double",
"[",
"]",
"probs",
"=",
"this",
".",
"bestSequence",
".",
"getProbs",
"(",
")",
";",
"for",
"(",
"int",
"si",
"=",
"0",
";",
"si",
"<",
"spans",
".",
"length",
";",
"si",
"++",
")",
"{",
"double",
"p",
"=",
"0",
";",
"for",
"(",
"int",
"oi",
"=",
"spans",
"[",
"si",
"]",
".",
"getStart",
"(",
")",
";",
"oi",
"<",
"spans",
"[",
"si",
"]",
".",
"getEnd",
"(",
")",
";",
"oi",
"++",
")",
"{",
"p",
"+=",
"probs",
"[",
"oi",
"]",
";",
"}",
"p",
"/=",
"spans",
"[",
"si",
"]",
".",
"length",
"(",
")",
";",
"sprobs",
"[",
"si",
"]",
"=",
"p",
";",
"}",
"return",
"sprobs",
";",
"}"
] |
Returns an array of probabilities for each of the specified spans which is
the arithmetic mean of the probabilities for each of the outcomes which
make up the span.
@param spans
The spans of the names for which probabilities are desired.
@return an array of probabilities for each of the specified spans.
|
[
"Returns",
"an",
"array",
"of",
"probabilities",
"for",
"each",
"of",
"the",
"specified",
"spans",
"which",
"is",
"the",
"arithmetic",
"mean",
"of",
"the",
"probabilities",
"for",
"each",
"of",
"the",
"outcomes",
"which",
"make",
"up",
"the",
"span",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/sequence/SequenceLabelerME.java#L227-L242
|
146,126
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/sequence/SequenceLabelerME.java
|
SequenceLabelerME.extractNameType
|
static final String extractNameType(final String outcome) {
final Matcher matcher = typedOutcomePattern.matcher(outcome);
if (matcher.matches()) {
final String nameType = matcher.group(1);
return nameType;
}
return null;
}
|
java
|
static final String extractNameType(final String outcome) {
final Matcher matcher = typedOutcomePattern.matcher(outcome);
if (matcher.matches()) {
final String nameType = matcher.group(1);
return nameType;
}
return null;
}
|
[
"static",
"final",
"String",
"extractNameType",
"(",
"final",
"String",
"outcome",
")",
"{",
"final",
"Matcher",
"matcher",
"=",
"typedOutcomePattern",
".",
"matcher",
"(",
"outcome",
")",
";",
"if",
"(",
"matcher",
".",
"matches",
"(",
")",
")",
"{",
"final",
"String",
"nameType",
"=",
"matcher",
".",
"group",
"(",
"1",
")",
";",
"return",
"nameType",
";",
"}",
"return",
"null",
";",
"}"
] |
Gets the name type from the outcome
@param outcome
the outcome
@return the name type, or null if not set
|
[
"Gets",
"the",
"name",
"type",
"from",
"the",
"outcome"
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/sequence/SequenceLabelerME.java#L313-L321
|
146,127
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/sequence/SequenceLabelerME.java
|
SequenceLabelerME.dropOverlappingSpans
|
public static Span[] dropOverlappingSpans(final Span[] spans) {
final List<Span> sortedSpans = new ArrayList<Span>(spans.length);
Collections.addAll(sortedSpans, spans);
Collections.sort(sortedSpans);
final Iterator<Span> it = sortedSpans.iterator();
Span lastSpan = null;
while (it.hasNext()) {
Span span = it.next();
if (lastSpan != null) {
if (lastSpan.intersects(span)) {
it.remove();
span = lastSpan;
}
}
lastSpan = span;
}
return sortedSpans.toArray(new Span[sortedSpans.size()]);
}
|
java
|
public static Span[] dropOverlappingSpans(final Span[] spans) {
final List<Span> sortedSpans = new ArrayList<Span>(spans.length);
Collections.addAll(sortedSpans, spans);
Collections.sort(sortedSpans);
final Iterator<Span> it = sortedSpans.iterator();
Span lastSpan = null;
while (it.hasNext()) {
Span span = it.next();
if (lastSpan != null) {
if (lastSpan.intersects(span)) {
it.remove();
span = lastSpan;
}
}
lastSpan = span;
}
return sortedSpans.toArray(new Span[sortedSpans.size()]);
}
|
[
"public",
"static",
"Span",
"[",
"]",
"dropOverlappingSpans",
"(",
"final",
"Span",
"[",
"]",
"spans",
")",
"{",
"final",
"List",
"<",
"Span",
">",
"sortedSpans",
"=",
"new",
"ArrayList",
"<",
"Span",
">",
"(",
"spans",
".",
"length",
")",
";",
"Collections",
".",
"addAll",
"(",
"sortedSpans",
",",
"spans",
")",
";",
"Collections",
".",
"sort",
"(",
"sortedSpans",
")",
";",
"final",
"Iterator",
"<",
"Span",
">",
"it",
"=",
"sortedSpans",
".",
"iterator",
"(",
")",
";",
"Span",
"lastSpan",
"=",
"null",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Span",
"span",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"lastSpan",
"!=",
"null",
")",
"{",
"if",
"(",
"lastSpan",
".",
"intersects",
"(",
"span",
")",
")",
"{",
"it",
".",
"remove",
"(",
")",
";",
"span",
"=",
"lastSpan",
";",
"}",
"}",
"lastSpan",
"=",
"span",
";",
"}",
"return",
"sortedSpans",
".",
"toArray",
"(",
"new",
"Span",
"[",
"sortedSpans",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Removes spans with are intersecting or crossing in anyway.
<p>
The following rules are used to remove the spans:<br>
Identical spans: The first span in the array after sorting it remains<br>
Intersecting spans: The first span after sorting remains<br>
Contained spans: All spans which are contained by another are removed<br>
@param spans
the spans
@return non-overlapping spans
|
[
"Removes",
"spans",
"with",
"are",
"intersecting",
"or",
"crossing",
"in",
"anyway",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/sequence/SequenceLabelerME.java#L337-L357
|
146,128
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/sequence/SequenceLabelerME.java
|
SequenceLabelerME.decodeSequences
|
public String[] decodeSequences(final String[] preds) {
final List<String> decodedSequences = new ArrayList<>();
for (String pred : preds) {
pred = startPattern.matcher(pred).replaceAll("B-$1");
pred = contPattern.matcher(pred).replaceAll("I-$1");
pred = lastPattern.matcher(pred).replaceAll("I-$1");
pred = unitPattern.matcher(pred).replaceAll("B-$1");
pred = otherPattern.matcher(pred).replaceAll("O");
decodedSequences.add(pred);
}
return decodedSequences.toArray(new String[decodedSequences.size()]);
}
|
java
|
public String[] decodeSequences(final String[] preds) {
final List<String> decodedSequences = new ArrayList<>();
for (String pred : preds) {
pred = startPattern.matcher(pred).replaceAll("B-$1");
pred = contPattern.matcher(pred).replaceAll("I-$1");
pred = lastPattern.matcher(pred).replaceAll("I-$1");
pred = unitPattern.matcher(pred).replaceAll("B-$1");
pred = otherPattern.matcher(pred).replaceAll("O");
decodedSequences.add(pred);
}
return decodedSequences.toArray(new String[decodedSequences.size()]);
}
|
[
"public",
"String",
"[",
"]",
"decodeSequences",
"(",
"final",
"String",
"[",
"]",
"preds",
")",
"{",
"final",
"List",
"<",
"String",
">",
"decodedSequences",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"pred",
":",
"preds",
")",
"{",
"pred",
"=",
"startPattern",
".",
"matcher",
"(",
"pred",
")",
".",
"replaceAll",
"(",
"\"B-$1\"",
")",
";",
"pred",
"=",
"contPattern",
".",
"matcher",
"(",
"pred",
")",
".",
"replaceAll",
"(",
"\"I-$1\"",
")",
";",
"pred",
"=",
"lastPattern",
".",
"matcher",
"(",
"pred",
")",
".",
"replaceAll",
"(",
"\"I-$1\"",
")",
";",
"pred",
"=",
"unitPattern",
".",
"matcher",
"(",
"pred",
")",
".",
"replaceAll",
"(",
"\"B-$1\"",
")",
";",
"pred",
"=",
"otherPattern",
".",
"matcher",
"(",
"pred",
")",
".",
"replaceAll",
"(",
"\"O\"",
")",
";",
"decodedSequences",
".",
"add",
"(",
"pred",
")",
";",
"}",
"return",
"decodedSequences",
".",
"toArray",
"(",
"new",
"String",
"[",
"decodedSequences",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Decode Sequences from an array of Strings.
@param preds
the sequences in an string array.
@return the decoded sequences
|
[
"Decode",
"Sequences",
"from",
"an",
"array",
"of",
"Strings",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/sequence/SequenceLabelerME.java#L366-L377
|
146,129
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/utils/StringUtils.java
|
StringUtils.decodeLemmasToSpans
|
public static void decodeLemmasToSpans(final String[] tokens,
final Span[] preds) {
for (final Span span : preds) {
String lemma = decodeShortestEditScript(
span.getCoveredText(tokens).toLowerCase(), span.getType());
// System.err.println("-> DEBUG: " + toks[i].toLowerCase() + " " +
// preds[i] + " " + lemma);
if (lemma.length() == 0) {
lemma = "_";
}
span.setType(lemma);
}
}
|
java
|
public static void decodeLemmasToSpans(final String[] tokens,
final Span[] preds) {
for (final Span span : preds) {
String lemma = decodeShortestEditScript(
span.getCoveredText(tokens).toLowerCase(), span.getType());
// System.err.println("-> DEBUG: " + toks[i].toLowerCase() + " " +
// preds[i] + " " + lemma);
if (lemma.length() == 0) {
lemma = "_";
}
span.setType(lemma);
}
}
|
[
"public",
"static",
"void",
"decodeLemmasToSpans",
"(",
"final",
"String",
"[",
"]",
"tokens",
",",
"final",
"Span",
"[",
"]",
"preds",
")",
"{",
"for",
"(",
"final",
"Span",
"span",
":",
"preds",
")",
"{",
"String",
"lemma",
"=",
"decodeShortestEditScript",
"(",
"span",
".",
"getCoveredText",
"(",
"tokens",
")",
".",
"toLowerCase",
"(",
")",
",",
"span",
".",
"getType",
"(",
")",
")",
";",
"// System.err.println(\"-> DEBUG: \" + toks[i].toLowerCase() + \" \" +",
"// preds[i] + \" \" + lemma);",
"if",
"(",
"lemma",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"lemma",
"=",
"\"_\"",
";",
"}",
"span",
".",
"setType",
"(",
"lemma",
")",
";",
"}",
"}"
] |
Decodes the lemma induced type into the lemma and sets it as value of the
Span type.
@param tokens
the tokens in the sentence
@param preds
the predicted spans
|
[
"Decodes",
"the",
"lemma",
"induced",
"type",
"into",
"the",
"lemma",
"and",
"sets",
"it",
"as",
"value",
"of",
"the",
"Span",
"type",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/utils/StringUtils.java#L476-L488
|
146,130
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/utils/StringUtils.java
|
StringUtils.splitLine
|
public static void splitLine(final String line, final char delimiter,
final String[] splitted) {
int idxComma, idxToken = 0, fromIndex = 0;
while ((idxComma = line.indexOf(delimiter, fromIndex)) != -1) {
splitted[idxToken++] = line.substring(fromIndex, idxComma);
fromIndex = idxComma + 1;
}
splitted[idxToken] = line.substring(fromIndex);
}
|
java
|
public static void splitLine(final String line, final char delimiter,
final String[] splitted) {
int idxComma, idxToken = 0, fromIndex = 0;
while ((idxComma = line.indexOf(delimiter, fromIndex)) != -1) {
splitted[idxToken++] = line.substring(fromIndex, idxComma);
fromIndex = idxComma + 1;
}
splitted[idxToken] = line.substring(fromIndex);
}
|
[
"public",
"static",
"void",
"splitLine",
"(",
"final",
"String",
"line",
",",
"final",
"char",
"delimiter",
",",
"final",
"String",
"[",
"]",
"splitted",
")",
"{",
"int",
"idxComma",
",",
"idxToken",
"=",
"0",
",",
"fromIndex",
"=",
"0",
";",
"while",
"(",
"(",
"idxComma",
"=",
"line",
".",
"indexOf",
"(",
"delimiter",
",",
"fromIndex",
")",
")",
"!=",
"-",
"1",
")",
"{",
"splitted",
"[",
"idxToken",
"++",
"]",
"=",
"line",
".",
"substring",
"(",
"fromIndex",
",",
"idxComma",
")",
";",
"fromIndex",
"=",
"idxComma",
"+",
"1",
";",
"}",
"splitted",
"[",
"idxToken",
"]",
"=",
"line",
".",
"substring",
"(",
"fromIndex",
")",
";",
"}"
] |
Fast line splitting with a separator, typically a tab or space character.
@param line
the line to be splitted
@param delimiter
the delimiter
@param splitted
the array containing the splitted tokens for each line
|
[
"Fast",
"line",
"splitting",
"with",
"a",
"separator",
"typically",
"a",
"tab",
"or",
"space",
"character",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/utils/StringUtils.java#L529-L537
|
146,131
|
alb-i986/selenium-tinafw
|
src/main/java/me/alb_i986/selenium/tinafw/tasks/ImLoggedInBase.java
|
ImLoggedInBase.run
|
@Override
public WebPage run(WebPage noPage) {
LoginPage<?> loginPage = (LoginPage<?>) super.run(noPage);
return loginPage.loginAs(user.getUsername(), user.getPassword());
}
|
java
|
@Override
public WebPage run(WebPage noPage) {
LoginPage<?> loginPage = (LoginPage<?>) super.run(noPage);
return loginPage.loginAs(user.getUsername(), user.getPassword());
}
|
[
"@",
"Override",
"public",
"WebPage",
"run",
"(",
"WebPage",
"noPage",
")",
"{",
"LoginPage",
"<",
"?",
">",
"loginPage",
"=",
"(",
"LoginPage",
"<",
"?",
">",
")",
"super",
".",
"run",
"(",
"noPage",
")",
";",
"return",
"loginPage",
".",
"loginAs",
"(",
"user",
".",
"getUsername",
"(",
")",
",",
"user",
".",
"getPassword",
"(",
")",
")",
";",
"}"
] |
Browse to the login page and do the login.
@param noPage this param won't be considered: may be null
|
[
"Browse",
"to",
"the",
"login",
"page",
"and",
"do",
"the",
"login",
"."
] |
91c66720cda9f69751f96c58c0a0624b2222186e
|
https://github.com/alb-i986/selenium-tinafw/blob/91c66720cda9f69751f96c58c0a0624b2222186e/src/main/java/me/alb_i986/selenium/tinafw/tasks/ImLoggedInBase.java#L22-L26
|
146,132
|
geomajas/geomajas-project-client-gwt2
|
impl/src/main/java/org/geomajas/gwt2/client/widget/control/zoom/ZoomControl.java
|
ZoomControl.initializeForDesktop
|
private void initializeForDesktop() {
logger.log(Level.FINE, "ZoomControl ->initializeForDesktop()");
StopPropagationHandler preventWeirdBehaviourHandler = new StopPropagationHandler();
addDomHandler(preventWeirdBehaviourHandler, MouseDownEvent.getType());
addDomHandler(preventWeirdBehaviourHandler, MouseUpEvent.getType());
addDomHandler(preventWeirdBehaviourHandler, ClickEvent.getType());
addDomHandler(preventWeirdBehaviourHandler, DoubleClickEvent.getType());
final ViewPort viewPort = mapPresenter.getViewPort();
// Zoom in button:
zoomInElement.addDomHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
logger.log(Level.FINE, "ZoomControl -> zoomInElement onClick()");
int index = viewPort.getResolutionIndex(viewPort.getResolution());
if (index < viewPort.getResolutionCount() - 1) {
viewPort.registerAnimation(NavigationAnimationFactory.createZoomIn(mapPresenter));
}
event.stopPropagation();
}
}, ClickEvent.getType());
// Zoom out button:
zoomOutElement.addDomHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
logger.log(Level.FINE, "ZoomControl -> zoomOutElement onClick()");
int index = viewPort.getResolutionIndex(viewPort.getResolution());
if (index > 0) {
viewPort.registerAnimation(NavigationAnimationFactory.createZoomOut(mapPresenter));
}
event.stopPropagation();
}
}, ClickEvent.getType());
}
|
java
|
private void initializeForDesktop() {
logger.log(Level.FINE, "ZoomControl ->initializeForDesktop()");
StopPropagationHandler preventWeirdBehaviourHandler = new StopPropagationHandler();
addDomHandler(preventWeirdBehaviourHandler, MouseDownEvent.getType());
addDomHandler(preventWeirdBehaviourHandler, MouseUpEvent.getType());
addDomHandler(preventWeirdBehaviourHandler, ClickEvent.getType());
addDomHandler(preventWeirdBehaviourHandler, DoubleClickEvent.getType());
final ViewPort viewPort = mapPresenter.getViewPort();
// Zoom in button:
zoomInElement.addDomHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
logger.log(Level.FINE, "ZoomControl -> zoomInElement onClick()");
int index = viewPort.getResolutionIndex(viewPort.getResolution());
if (index < viewPort.getResolutionCount() - 1) {
viewPort.registerAnimation(NavigationAnimationFactory.createZoomIn(mapPresenter));
}
event.stopPropagation();
}
}, ClickEvent.getType());
// Zoom out button:
zoomOutElement.addDomHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
logger.log(Level.FINE, "ZoomControl -> zoomOutElement onClick()");
int index = viewPort.getResolutionIndex(viewPort.getResolution());
if (index > 0) {
viewPort.registerAnimation(NavigationAnimationFactory.createZoomOut(mapPresenter));
}
event.stopPropagation();
}
}, ClickEvent.getType());
}
|
[
"private",
"void",
"initializeForDesktop",
"(",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"ZoomControl ->initializeForDesktop()\"",
")",
";",
"StopPropagationHandler",
"preventWeirdBehaviourHandler",
"=",
"new",
"StopPropagationHandler",
"(",
")",
";",
"addDomHandler",
"(",
"preventWeirdBehaviourHandler",
",",
"MouseDownEvent",
".",
"getType",
"(",
")",
")",
";",
"addDomHandler",
"(",
"preventWeirdBehaviourHandler",
",",
"MouseUpEvent",
".",
"getType",
"(",
")",
")",
";",
"addDomHandler",
"(",
"preventWeirdBehaviourHandler",
",",
"ClickEvent",
".",
"getType",
"(",
")",
")",
";",
"addDomHandler",
"(",
"preventWeirdBehaviourHandler",
",",
"DoubleClickEvent",
".",
"getType",
"(",
")",
")",
";",
"final",
"ViewPort",
"viewPort",
"=",
"mapPresenter",
".",
"getViewPort",
"(",
")",
";",
"// Zoom in button:",
"zoomInElement",
".",
"addDomHandler",
"(",
"new",
"ClickHandler",
"(",
")",
"{",
"public",
"void",
"onClick",
"(",
"ClickEvent",
"event",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"ZoomControl -> zoomInElement onClick()\"",
")",
";",
"int",
"index",
"=",
"viewPort",
".",
"getResolutionIndex",
"(",
"viewPort",
".",
"getResolution",
"(",
")",
")",
";",
"if",
"(",
"index",
"<",
"viewPort",
".",
"getResolutionCount",
"(",
")",
"-",
"1",
")",
"{",
"viewPort",
".",
"registerAnimation",
"(",
"NavigationAnimationFactory",
".",
"createZoomIn",
"(",
"mapPresenter",
")",
")",
";",
"}",
"event",
".",
"stopPropagation",
"(",
")",
";",
"}",
"}",
",",
"ClickEvent",
".",
"getType",
"(",
")",
")",
";",
"// Zoom out button:",
"zoomOutElement",
".",
"addDomHandler",
"(",
"new",
"ClickHandler",
"(",
")",
"{",
"public",
"void",
"onClick",
"(",
"ClickEvent",
"event",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"ZoomControl -> zoomOutElement onClick()\"",
")",
";",
"int",
"index",
"=",
"viewPort",
".",
"getResolutionIndex",
"(",
"viewPort",
".",
"getResolution",
"(",
")",
")",
";",
"if",
"(",
"index",
">",
"0",
")",
"{",
"viewPort",
".",
"registerAnimation",
"(",
"NavigationAnimationFactory",
".",
"createZoomOut",
"(",
"mapPresenter",
")",
")",
";",
"}",
"event",
".",
"stopPropagation",
"(",
")",
";",
"}",
"}",
",",
"ClickEvent",
".",
"getType",
"(",
")",
")",
";",
"}"
] |
Initialize handlers for desktop browser.
|
[
"Initialize",
"handlers",
"for",
"desktop",
"browser",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/impl/src/main/java/org/geomajas/gwt2/client/widget/control/zoom/ZoomControl.java#L116-L151
|
146,133
|
geomajas/geomajas-project-client-gwt2
|
impl/src/main/java/org/geomajas/gwt2/client/widget/control/zoom/ZoomControl.java
|
ZoomControl.initializeForTouchDevice
|
private void initializeForTouchDevice() {
logger.log(Level.FINE, "ZoomControl -> initializeForTouchDevice()");
// Add touch handlers to the zoom in button:
zoomInElement.addDomHandler(new TouchStartHandler() {
@Override
public void onTouchStart(TouchStartEvent event) {
event.stopPropagation();
event.preventDefault();
logger.log(Level.FINE, "ZoomControl -> zoomInElement onTouchStart()");
ViewPort viewPort = mapPresenter.getViewPort();
int index = viewPort.getResolutionIndex(viewPort.getResolution());
if (index < viewPort.getResolutionCount() - 1) {
viewPort.applyResolution(viewPort.getResolution(index + 1));
viewPort.getPosition();
}
}
}, TouchStartEvent.getType());
// Add touch handlers to the zoom out button:
zoomOutElement.addDomHandler(new TouchStartHandler() {
@Override
public void onTouchStart(TouchStartEvent event) {
logger.log(Level.FINE, "zoomOutElement -> zoomInElement onTouchStart()");
event.stopPropagation();
event.preventDefault();
ViewPort viewPort = mapPresenter.getViewPort();
int index = viewPort.getResolutionIndex(viewPort.getResolution());
if (index > 0) {
viewPort.applyResolution(viewPort.getResolution(index - 1));
}
}
}, TouchStartEvent.getType());
}
|
java
|
private void initializeForTouchDevice() {
logger.log(Level.FINE, "ZoomControl -> initializeForTouchDevice()");
// Add touch handlers to the zoom in button:
zoomInElement.addDomHandler(new TouchStartHandler() {
@Override
public void onTouchStart(TouchStartEvent event) {
event.stopPropagation();
event.preventDefault();
logger.log(Level.FINE, "ZoomControl -> zoomInElement onTouchStart()");
ViewPort viewPort = mapPresenter.getViewPort();
int index = viewPort.getResolutionIndex(viewPort.getResolution());
if (index < viewPort.getResolutionCount() - 1) {
viewPort.applyResolution(viewPort.getResolution(index + 1));
viewPort.getPosition();
}
}
}, TouchStartEvent.getType());
// Add touch handlers to the zoom out button:
zoomOutElement.addDomHandler(new TouchStartHandler() {
@Override
public void onTouchStart(TouchStartEvent event) {
logger.log(Level.FINE, "zoomOutElement -> zoomInElement onTouchStart()");
event.stopPropagation();
event.preventDefault();
ViewPort viewPort = mapPresenter.getViewPort();
int index = viewPort.getResolutionIndex(viewPort.getResolution());
if (index > 0) {
viewPort.applyResolution(viewPort.getResolution(index - 1));
}
}
}, TouchStartEvent.getType());
}
|
[
"private",
"void",
"initializeForTouchDevice",
"(",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"ZoomControl -> initializeForTouchDevice()\"",
")",
";",
"// Add touch handlers to the zoom in button:",
"zoomInElement",
".",
"addDomHandler",
"(",
"new",
"TouchStartHandler",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onTouchStart",
"(",
"TouchStartEvent",
"event",
")",
"{",
"event",
".",
"stopPropagation",
"(",
")",
";",
"event",
".",
"preventDefault",
"(",
")",
";",
"logger",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"ZoomControl -> zoomInElement onTouchStart()\"",
")",
";",
"ViewPort",
"viewPort",
"=",
"mapPresenter",
".",
"getViewPort",
"(",
")",
";",
"int",
"index",
"=",
"viewPort",
".",
"getResolutionIndex",
"(",
"viewPort",
".",
"getResolution",
"(",
")",
")",
";",
"if",
"(",
"index",
"<",
"viewPort",
".",
"getResolutionCount",
"(",
")",
"-",
"1",
")",
"{",
"viewPort",
".",
"applyResolution",
"(",
"viewPort",
".",
"getResolution",
"(",
"index",
"+",
"1",
")",
")",
";",
"viewPort",
".",
"getPosition",
"(",
")",
";",
"}",
"}",
"}",
",",
"TouchStartEvent",
".",
"getType",
"(",
")",
")",
";",
"// Add touch handlers to the zoom out button:",
"zoomOutElement",
".",
"addDomHandler",
"(",
"new",
"TouchStartHandler",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onTouchStart",
"(",
"TouchStartEvent",
"event",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"zoomOutElement -> zoomInElement onTouchStart()\"",
")",
";",
"event",
".",
"stopPropagation",
"(",
")",
";",
"event",
".",
"preventDefault",
"(",
")",
";",
"ViewPort",
"viewPort",
"=",
"mapPresenter",
".",
"getViewPort",
"(",
")",
";",
"int",
"index",
"=",
"viewPort",
".",
"getResolutionIndex",
"(",
"viewPort",
".",
"getResolution",
"(",
")",
")",
";",
"if",
"(",
"index",
">",
"0",
")",
"{",
"viewPort",
".",
"applyResolution",
"(",
"viewPort",
".",
"getResolution",
"(",
"index",
"-",
"1",
")",
")",
";",
"}",
"}",
"}",
",",
"TouchStartEvent",
".",
"getType",
"(",
")",
")",
";",
"}"
] |
Initialize handlers for mobile devices.
|
[
"Initialize",
"handlers",
"for",
"mobile",
"devices",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/impl/src/main/java/org/geomajas/gwt2/client/widget/control/zoom/ZoomControl.java#L156-L194
|
146,134
|
lexs/webimageloader
|
webimageloader/src/main/java/com/webimageloader/Request.java
|
Request.forFile
|
public static Request forFile(File file) {
String url = Uri.fromFile(file).toString();
return new Request(url).addFlag(Flag.SKIP_DISK_CACHE);
}
|
java
|
public static Request forFile(File file) {
String url = Uri.fromFile(file).toString();
return new Request(url).addFlag(Flag.SKIP_DISK_CACHE);
}
|
[
"public",
"static",
"Request",
"forFile",
"(",
"File",
"file",
")",
"{",
"String",
"url",
"=",
"Uri",
".",
"fromFile",
"(",
"file",
")",
".",
"toString",
"(",
")",
";",
"return",
"new",
"Request",
"(",
"url",
")",
".",
"addFlag",
"(",
"Flag",
".",
"SKIP_DISK_CACHE",
")",
";",
"}"
] |
Create a request for this file on the local file system.
Note that this sets the SKIP_DISK_CACHE to skip disk cache
@param file path to the file
@return a request for this file
|
[
"Create",
"a",
"request",
"for",
"this",
"file",
"on",
"the",
"local",
"file",
"system",
"."
] |
b29bac036a3855e2f0adf95d3391ee4bbc14457c
|
https://github.com/lexs/webimageloader/blob/b29bac036a3855e2f0adf95d3391ee4bbc14457c/webimageloader/src/main/java/com/webimageloader/Request.java#L74-L77
|
146,135
|
astrapi69/jaulp-wicket
|
jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/seo/BotAgentInspector.java
|
BotAgentInspector.isAgent
|
public static boolean isAgent(final String agent)
{
if (agent != null)
{
final String lowerAgent = agent.toLowerCase();
for (final String noBot : NO_BOT_AGENTS)
{
if (lowerAgent.contains(noBot))
{
return false;
}
}
for (final String bot : BOT_AGENTS)
{
if (lowerAgent.contains(bot))
{
return true;
}
}
}
return false;
}
|
java
|
public static boolean isAgent(final String agent)
{
if (agent != null)
{
final String lowerAgent = agent.toLowerCase();
for (final String noBot : NO_BOT_AGENTS)
{
if (lowerAgent.contains(noBot))
{
return false;
}
}
for (final String bot : BOT_AGENTS)
{
if (lowerAgent.contains(bot))
{
return true;
}
}
}
return false;
}
|
[
"public",
"static",
"boolean",
"isAgent",
"(",
"final",
"String",
"agent",
")",
"{",
"if",
"(",
"agent",
"!=",
"null",
")",
"{",
"final",
"String",
"lowerAgent",
"=",
"agent",
".",
"toLowerCase",
"(",
")",
";",
"for",
"(",
"final",
"String",
"noBot",
":",
"NO_BOT_AGENTS",
")",
"{",
"if",
"(",
"lowerAgent",
".",
"contains",
"(",
"noBot",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"for",
"(",
"final",
"String",
"bot",
":",
"BOT_AGENTS",
")",
"{",
"if",
"(",
"lowerAgent",
".",
"contains",
"(",
"bot",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks if the given String object is agent over the String array BOT_AGENTS.
@param agent
String to check.
@return true, if is agent
|
[
"Checks",
"if",
"the",
"given",
"String",
"object",
"is",
"agent",
"over",
"the",
"String",
"array",
"BOT_AGENTS",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/seo/BotAgentInspector.java#L94-L115
|
146,136
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java
|
IOUtils.getDictionaryResource
|
public static final InputStream getDictionaryResource(final String resource) {
InputStream dictInputStream;
final Path resourcePath = Paths.get(resource);
final String normalizedPath = resourcePath.toString();
dictInputStream = getStreamFromClassPath(normalizedPath);
if (dictInputStream == null) {
try {
dictInputStream = new FileInputStream(normalizedPath);
} catch (final FileNotFoundException e) {
e.printStackTrace();
}
}
return new BufferedInputStream(dictInputStream);
}
|
java
|
public static final InputStream getDictionaryResource(final String resource) {
InputStream dictInputStream;
final Path resourcePath = Paths.get(resource);
final String normalizedPath = resourcePath.toString();
dictInputStream = getStreamFromClassPath(normalizedPath);
if (dictInputStream == null) {
try {
dictInputStream = new FileInputStream(normalizedPath);
} catch (final FileNotFoundException e) {
e.printStackTrace();
}
}
return new BufferedInputStream(dictInputStream);
}
|
[
"public",
"static",
"final",
"InputStream",
"getDictionaryResource",
"(",
"final",
"String",
"resource",
")",
"{",
"InputStream",
"dictInputStream",
";",
"final",
"Path",
"resourcePath",
"=",
"Paths",
".",
"get",
"(",
"resource",
")",
";",
"final",
"String",
"normalizedPath",
"=",
"resourcePath",
".",
"toString",
"(",
")",
";",
"dictInputStream",
"=",
"getStreamFromClassPath",
"(",
"normalizedPath",
")",
";",
"if",
"(",
"dictInputStream",
"==",
"null",
")",
"{",
"try",
"{",
"dictInputStream",
"=",
"new",
"FileInputStream",
"(",
"normalizedPath",
")",
";",
"}",
"catch",
"(",
"final",
"FileNotFoundException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"return",
"new",
"BufferedInputStream",
"(",
"dictInputStream",
")",
";",
"}"
] |
Get an input stream from a resource name. This could be either an absolute
path pointing to a resource in the classpath or a file or a directory in
the file system. If found in the classpath that will be loaded first.
@param resource
the name of the resource (absolute path with no starting /)
@return the inputstream of the dictionary
|
[
"Get",
"an",
"input",
"stream",
"from",
"a",
"resource",
"name",
".",
"This",
"could",
"be",
"either",
"an",
"absolute",
"path",
"pointing",
"to",
"a",
"resource",
"in",
"the",
"classpath",
"or",
"a",
"file",
"or",
"a",
"directory",
"in",
"the",
"file",
"system",
".",
"If",
"found",
"in",
"the",
"classpath",
"that",
"will",
"be",
"loaded",
"first",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java#L94-L108
|
146,137
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java
|
IOUtils.getStreamFromClassPath
|
private static InputStream getStreamFromClassPath(
final String normalizedPath) {
InputStream dictInputStream = null;
final String[] dictPaths = normalizedPath.split("src/main/resources");
if (dictPaths.length == 2) {
dictInputStream = IOUtils.class.getClassLoader()
.getResourceAsStream(dictPaths[1]);
} else {
final String[] windowsPaths = normalizedPath
.split("src\\\\main\\\\resources\\\\");
if (windowsPaths.length == 2) {
dictInputStream = IOUtils.class.getClassLoader()
.getResourceAsStream(windowsPaths[1]);
}
}
return dictInputStream;
}
|
java
|
private static InputStream getStreamFromClassPath(
final String normalizedPath) {
InputStream dictInputStream = null;
final String[] dictPaths = normalizedPath.split("src/main/resources");
if (dictPaths.length == 2) {
dictInputStream = IOUtils.class.getClassLoader()
.getResourceAsStream(dictPaths[1]);
} else {
final String[] windowsPaths = normalizedPath
.split("src\\\\main\\\\resources\\\\");
if (windowsPaths.length == 2) {
dictInputStream = IOUtils.class.getClassLoader()
.getResourceAsStream(windowsPaths[1]);
}
}
return dictInputStream;
}
|
[
"private",
"static",
"InputStream",
"getStreamFromClassPath",
"(",
"final",
"String",
"normalizedPath",
")",
"{",
"InputStream",
"dictInputStream",
"=",
"null",
";",
"final",
"String",
"[",
"]",
"dictPaths",
"=",
"normalizedPath",
".",
"split",
"(",
"\"src/main/resources\"",
")",
";",
"if",
"(",
"dictPaths",
".",
"length",
"==",
"2",
")",
"{",
"dictInputStream",
"=",
"IOUtils",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"dictPaths",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"final",
"String",
"[",
"]",
"windowsPaths",
"=",
"normalizedPath",
".",
"split",
"(",
"\"src\\\\\\\\main\\\\\\\\resources\\\\\\\\\"",
")",
";",
"if",
"(",
"windowsPaths",
".",
"length",
"==",
"2",
")",
"{",
"dictInputStream",
"=",
"IOUtils",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"windowsPaths",
"[",
"1",
"]",
")",
";",
"}",
"}",
"return",
"dictInputStream",
";",
"}"
] |
Load a resource from the classpath.
@param normalizedPath
the path normalized using {@code Paths} functions.
@return the input stream of the resource
|
[
"Load",
"a",
"resource",
"from",
"the",
"classpath",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java#L117-L133
|
146,138
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java
|
IOUtils.checkInputFile
|
private static void checkInputFile(final String name, final File inFile) {
String isFailure = null;
if (inFile.isDirectory()) {
isFailure = "The " + name + " file is a directory!";
} else if (!inFile.exists()) {
isFailure = "The " + name + " file does not exist!";
} else if (!inFile.canRead()) {
isFailure = "No permissions to read the " + name + " file!";
}
if (null != isFailure) {
throw new TerminateToolException(-1,
isFailure + " Path: " + inFile.getAbsolutePath());
}
}
|
java
|
private static void checkInputFile(final String name, final File inFile) {
String isFailure = null;
if (inFile.isDirectory()) {
isFailure = "The " + name + " file is a directory!";
} else if (!inFile.exists()) {
isFailure = "The " + name + " file does not exist!";
} else if (!inFile.canRead()) {
isFailure = "No permissions to read the " + name + " file!";
}
if (null != isFailure) {
throw new TerminateToolException(-1,
isFailure + " Path: " + inFile.getAbsolutePath());
}
}
|
[
"private",
"static",
"void",
"checkInputFile",
"(",
"final",
"String",
"name",
",",
"final",
"File",
"inFile",
")",
"{",
"String",
"isFailure",
"=",
"null",
";",
"if",
"(",
"inFile",
".",
"isDirectory",
"(",
")",
")",
"{",
"isFailure",
"=",
"\"The \"",
"+",
"name",
"+",
"\" file is a directory!\"",
";",
"}",
"else",
"if",
"(",
"!",
"inFile",
".",
"exists",
"(",
")",
")",
"{",
"isFailure",
"=",
"\"The \"",
"+",
"name",
"+",
"\" file does not exist!\"",
";",
"}",
"else",
"if",
"(",
"!",
"inFile",
".",
"canRead",
"(",
")",
")",
"{",
"isFailure",
"=",
"\"No permissions to read the \"",
"+",
"name",
"+",
"\" file!\"",
";",
"}",
"if",
"(",
"null",
"!=",
"isFailure",
")",
"{",
"throw",
"new",
"TerminateToolException",
"(",
"-",
"1",
",",
"isFailure",
"+",
"\" Path: \"",
"+",
"inFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}"
] |
Check input file integrity.
@param name
the name of the file
@param inFile
the file
|
[
"Check",
"input",
"file",
"integrity",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java#L143-L159
|
146,139
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java
|
IOUtils.writeObjectToFile
|
public static File writeObjectToFile(final Object o, final String fileName)
throws IOException {
final File outFile = new File(fileName);
OutputStream outputStream = new FileOutputStream(outFile);
if (fileName.endsWith(".gz")) {
outputStream = new GZIPOutputStream(outputStream);
}
outputStream = new BufferedOutputStream(outputStream);
final ObjectOutputStream oos = new ObjectOutputStream(outputStream);
oos.writeObject(o);
oos.close();
return outFile;
}
|
java
|
public static File writeObjectToFile(final Object o, final String fileName)
throws IOException {
final File outFile = new File(fileName);
OutputStream outputStream = new FileOutputStream(outFile);
if (fileName.endsWith(".gz")) {
outputStream = new GZIPOutputStream(outputStream);
}
outputStream = new BufferedOutputStream(outputStream);
final ObjectOutputStream oos = new ObjectOutputStream(outputStream);
oos.writeObject(o);
oos.close();
return outFile;
}
|
[
"public",
"static",
"File",
"writeObjectToFile",
"(",
"final",
"Object",
"o",
",",
"final",
"String",
"fileName",
")",
"throws",
"IOException",
"{",
"final",
"File",
"outFile",
"=",
"new",
"File",
"(",
"fileName",
")",
";",
"OutputStream",
"outputStream",
"=",
"new",
"FileOutputStream",
"(",
"outFile",
")",
";",
"if",
"(",
"fileName",
".",
"endsWith",
"(",
"\".gz\"",
")",
")",
"{",
"outputStream",
"=",
"new",
"GZIPOutputStream",
"(",
"outputStream",
")",
";",
"}",
"outputStream",
"=",
"new",
"BufferedOutputStream",
"(",
"outputStream",
")",
";",
"final",
"ObjectOutputStream",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"outputStream",
")",
";",
"oos",
".",
"writeObject",
"(",
"o",
")",
";",
"oos",
".",
"close",
"(",
")",
";",
"return",
"outFile",
";",
"}"
] |
Serialize java object to a file.
@param o
the java object
@param fileName
the name of the file
@return the file
@throws IOException
if io problems
|
[
"Serialize",
"java",
"object",
"to",
"a",
"file",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java#L307-L319
|
146,140
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java
|
IOUtils.writeGzipObjectToStream
|
public static void writeGzipObjectToStream(final Object o, OutputStream out) {
out = new BufferedOutputStream(out);
try {
out = new GZIPOutputStream(out, true);
final ObjectOutputStream oos = new ObjectOutputStream(out);
oos.writeObject(o);
oos.flush();
} catch (final IOException e) {
e.printStackTrace();
}
}
|
java
|
public static void writeGzipObjectToStream(final Object o, OutputStream out) {
out = new BufferedOutputStream(out);
try {
out = new GZIPOutputStream(out, true);
final ObjectOutputStream oos = new ObjectOutputStream(out);
oos.writeObject(o);
oos.flush();
} catch (final IOException e) {
e.printStackTrace();
}
}
|
[
"public",
"static",
"void",
"writeGzipObjectToStream",
"(",
"final",
"Object",
"o",
",",
"OutputStream",
"out",
")",
"{",
"out",
"=",
"new",
"BufferedOutputStream",
"(",
"out",
")",
";",
"try",
"{",
"out",
"=",
"new",
"GZIPOutputStream",
"(",
"out",
",",
"true",
")",
";",
"final",
"ObjectOutputStream",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"out",
")",
";",
"oos",
".",
"writeObject",
"(",
"o",
")",
";",
"oos",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] |
Serialized gzipped java object to an ObjectOutputStream. The stream remains
open.
@param o
the java object
@param out
the output stream
|
[
"Serialized",
"gzipped",
"java",
"object",
"to",
"an",
"ObjectOutputStream",
".",
"The",
"stream",
"remains",
"open",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java#L330-L340
|
146,141
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java
|
IOUtils.writeObjectToStream
|
public static void writeObjectToStream(final Object o, OutputStream out) {
out = new BufferedOutputStream(out);
try {
final ObjectOutputStream oos = new ObjectOutputStream(out);
oos.writeObject(o);
oos.flush();
} catch (final IOException e) {
e.printStackTrace();
}
}
|
java
|
public static void writeObjectToStream(final Object o, OutputStream out) {
out = new BufferedOutputStream(out);
try {
final ObjectOutputStream oos = new ObjectOutputStream(out);
oos.writeObject(o);
oos.flush();
} catch (final IOException e) {
e.printStackTrace();
}
}
|
[
"public",
"static",
"void",
"writeObjectToStream",
"(",
"final",
"Object",
"o",
",",
"OutputStream",
"out",
")",
"{",
"out",
"=",
"new",
"BufferedOutputStream",
"(",
"out",
")",
";",
"try",
"{",
"final",
"ObjectOutputStream",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"out",
")",
";",
"oos",
".",
"writeObject",
"(",
"o",
")",
";",
"oos",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] |
Serialize java object to an ObjectOutputStream. The stream remains open.
@param o
the java object
@param out
the output stream
|
[
"Serialize",
"java",
"object",
"to",
"an",
"ObjectOutputStream",
".",
"The",
"stream",
"remains",
"open",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java#L350-L359
|
146,142
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java
|
IOUtils.openFromFile
|
public static InputStream openFromFile(final File file) {
try {
InputStream is = new BufferedInputStream(new FileInputStream(file),
BUFFER_SIZE);
if (file.getName().endsWith(".gz") || file.getName().endsWith("gz")) {
is = new GZIPInputStream(is, BUFFER_SIZE);
}
return is;
} catch (final IOException e) {
throw new TerminateToolException(-1,
"File '" + file + "' cannot be found", e);
}
}
|
java
|
public static InputStream openFromFile(final File file) {
try {
InputStream is = new BufferedInputStream(new FileInputStream(file),
BUFFER_SIZE);
if (file.getName().endsWith(".gz") || file.getName().endsWith("gz")) {
is = new GZIPInputStream(is, BUFFER_SIZE);
}
return is;
} catch (final IOException e) {
throw new TerminateToolException(-1,
"File '" + file + "' cannot be found", e);
}
}
|
[
"public",
"static",
"InputStream",
"openFromFile",
"(",
"final",
"File",
"file",
")",
"{",
"try",
"{",
"InputStream",
"is",
"=",
"new",
"BufferedInputStream",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
",",
"BUFFER_SIZE",
")",
";",
"if",
"(",
"file",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"\".gz\"",
")",
"||",
"file",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"\"gz\"",
")",
")",
"{",
"is",
"=",
"new",
"GZIPInputStream",
"(",
"is",
",",
"BUFFER_SIZE",
")",
";",
"}",
"return",
"is",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"throw",
"new",
"TerminateToolException",
"(",
"-",
"1",
",",
"\"File '\"",
"+",
"file",
"+",
"\"' cannot be found\"",
",",
"e",
")",
";",
"}",
"}"
] |
Open file to an input stream.
@param file
the file
@return the input stream
|
[
"Open",
"file",
"to",
"an",
"input",
"stream",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java#L368-L380
|
146,143
|
geomajas/geomajas-project-client-gwt2
|
api/src/main/java/org/geomajas/gwt2/client/map/layer/tile/TileConfiguration.java
|
TileConfiguration.getResolutionIndex
|
public int getResolutionIndex(double resolution) {
double maximumResolution = getMaximumResolution();
if (resolution >= maximumResolution) {
return 0;
}
double minimumResolution = getMinimumResolution();
if (resolution <= minimumResolution) {
return resolutions.size() - 1;
}
for (int i = 0; i < resolutions.size(); i++) {
double upper = resolutions.get(i);
double lower = resolutions.get(i + 1);
if (resolution < upper && resolution >= lower) {
if (Math.abs(upper - resolution) >= Math.abs(lower - resolution)) {
return i + 1;
} else {
return i;
}
}
}
return 0;
}
|
java
|
public int getResolutionIndex(double resolution) {
double maximumResolution = getMaximumResolution();
if (resolution >= maximumResolution) {
return 0;
}
double minimumResolution = getMinimumResolution();
if (resolution <= minimumResolution) {
return resolutions.size() - 1;
}
for (int i = 0; i < resolutions.size(); i++) {
double upper = resolutions.get(i);
double lower = resolutions.get(i + 1);
if (resolution < upper && resolution >= lower) {
if (Math.abs(upper - resolution) >= Math.abs(lower - resolution)) {
return i + 1;
} else {
return i;
}
}
}
return 0;
}
|
[
"public",
"int",
"getResolutionIndex",
"(",
"double",
"resolution",
")",
"{",
"double",
"maximumResolution",
"=",
"getMaximumResolution",
"(",
")",
";",
"if",
"(",
"resolution",
">=",
"maximumResolution",
")",
"{",
"return",
"0",
";",
"}",
"double",
"minimumResolution",
"=",
"getMinimumResolution",
"(",
")",
";",
"if",
"(",
"resolution",
"<=",
"minimumResolution",
")",
"{",
"return",
"resolutions",
".",
"size",
"(",
")",
"-",
"1",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"resolutions",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"double",
"upper",
"=",
"resolutions",
".",
"get",
"(",
"i",
")",
";",
"double",
"lower",
"=",
"resolutions",
".",
"get",
"(",
"i",
"+",
"1",
")",
";",
"if",
"(",
"resolution",
"<",
"upper",
"&&",
"resolution",
">=",
"lower",
")",
"{",
"if",
"(",
"Math",
".",
"abs",
"(",
"upper",
"-",
"resolution",
")",
">=",
"Math",
".",
"abs",
"(",
"lower",
"-",
"resolution",
")",
")",
"{",
"return",
"i",
"+",
"1",
";",
"}",
"else",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"0",
";",
"}"
] |
Get the index for the fixed resolution that is closest to the provided resolution.
@param resolution The resolution to request the closest fixed resolution level for.
@return Returns the fixed resolution level index.
|
[
"Get",
"the",
"index",
"for",
"the",
"fixed",
"resolution",
"that",
"is",
"closest",
"to",
"the",
"provided",
"resolution",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/api/src/main/java/org/geomajas/gwt2/client/map/layer/tile/TileConfiguration.java#L203-L225
|
146,144
|
astrapi69/jaulp-wicket
|
jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/resource/ByteArrayResourceStreamWriter.java
|
ByteArrayResourceStreamWriter.write
|
@Override
public void write(final OutputStream output) throws IOException
{
initialize();
if (content == null)
{
content = new byte[0];
}
output.write(content, 0, content.length);
output.flush();
}
|
java
|
@Override
public void write(final OutputStream output) throws IOException
{
initialize();
if (content == null)
{
content = new byte[0];
}
output.write(content, 0, content.length);
output.flush();
}
|
[
"@",
"Override",
"public",
"void",
"write",
"(",
"final",
"OutputStream",
"output",
")",
"throws",
"IOException",
"{",
"initialize",
"(",
")",
";",
"if",
"(",
"content",
"==",
"null",
")",
"{",
"content",
"=",
"new",
"byte",
"[",
"0",
"]",
";",
"}",
"output",
".",
"write",
"(",
"content",
",",
"0",
",",
"content",
".",
"length",
")",
";",
"output",
".",
"flush",
"(",
")",
";",
"}"
] |
Writes the byte array to the OutputStream from the client.
@param output
the output
@throws IOException
Signals that an I/O exception has occurred.
@see org.apache.wicket.util.resource.IResourceStreamWriter#write(java.io.OutputStream)
|
[
"Writes",
"the",
"byte",
"array",
"to",
"the",
"OutputStream",
"from",
"the",
"client",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/resource/ByteArrayResourceStreamWriter.java#L76-L86
|
146,145
|
lexs/webimageloader
|
webimageloader/src/main/java/com/webimageloader/util/IOUtil.java
|
IOUtil.getExternalCacheDir
|
@TargetApi(8)
public static File getExternalCacheDir(Context context) {
// Do we have a built-in external cache dir method.
if (Android.isAPI(8)) {
File cacheDir = context.getExternalCacheDir();
if (cacheDir != null) {
return cacheDir;
}
}
// Before Froyo we need to construct the external cache dir ourselves
final String cacheDir = "/Android/data/" + context.getPackageName() + "/cache/";
return new File(Environment.getExternalStorageDirectory().getPath() + cacheDir);
}
|
java
|
@TargetApi(8)
public static File getExternalCacheDir(Context context) {
// Do we have a built-in external cache dir method.
if (Android.isAPI(8)) {
File cacheDir = context.getExternalCacheDir();
if (cacheDir != null) {
return cacheDir;
}
}
// Before Froyo we need to construct the external cache dir ourselves
final String cacheDir = "/Android/data/" + context.getPackageName() + "/cache/";
return new File(Environment.getExternalStorageDirectory().getPath() + cacheDir);
}
|
[
"@",
"TargetApi",
"(",
"8",
")",
"public",
"static",
"File",
"getExternalCacheDir",
"(",
"Context",
"context",
")",
"{",
"// Do we have a built-in external cache dir method.",
"if",
"(",
"Android",
".",
"isAPI",
"(",
"8",
")",
")",
"{",
"File",
"cacheDir",
"=",
"context",
".",
"getExternalCacheDir",
"(",
")",
";",
"if",
"(",
"cacheDir",
"!=",
"null",
")",
"{",
"return",
"cacheDir",
";",
"}",
"}",
"// Before Froyo we need to construct the external cache dir ourselves",
"final",
"String",
"cacheDir",
"=",
"\"/Android/data/\"",
"+",
"context",
".",
"getPackageName",
"(",
")",
"+",
"\"/cache/\"",
";",
"return",
"new",
"File",
"(",
"Environment",
".",
"getExternalStorageDirectory",
"(",
")",
".",
"getPath",
"(",
")",
"+",
"cacheDir",
")",
";",
"}"
] |
Get the external app cache directory.
@param context The context to use
@return The external cache dir
|
[
"Get",
"the",
"external",
"app",
"cache",
"directory",
"."
] |
b29bac036a3855e2f0adf95d3391ee4bbc14457c
|
https://github.com/lexs/webimageloader/blob/b29bac036a3855e2f0adf95d3391ee4bbc14457c/webimageloader/src/main/java/com/webimageloader/util/IOUtil.java#L58-L71
|
146,146
|
OpenBEL/openbel-framework
|
org.openbel.framework.api/src/main/java/org/openbel/framework/api/AbstractPathFinder.java
|
AbstractPathFinder.kams
|
Kam[] kams(KamNode... nodes) {
List<Kam> kams = new ArrayList<Kam>(nodes.length);
for (int i = 0; i < nodes.length; i++) {
KamNode node = nodes[i];
kams.add(node.getKam());
}
return kams.toArray(new Kam[0]);
}
|
java
|
Kam[] kams(KamNode... nodes) {
List<Kam> kams = new ArrayList<Kam>(nodes.length);
for (int i = 0; i < nodes.length; i++) {
KamNode node = nodes[i];
kams.add(node.getKam());
}
return kams.toArray(new Kam[0]);
}
|
[
"Kam",
"[",
"]",
"kams",
"(",
"KamNode",
"...",
"nodes",
")",
"{",
"List",
"<",
"Kam",
">",
"kams",
"=",
"new",
"ArrayList",
"<",
"Kam",
">",
"(",
"nodes",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nodes",
".",
"length",
";",
"i",
"++",
")",
"{",
"KamNode",
"node",
"=",
"nodes",
"[",
"i",
"]",
";",
"kams",
".",
"add",
"(",
"node",
".",
"getKam",
"(",
")",
")",
";",
"}",
"return",
"kams",
".",
"toArray",
"(",
"new",
"Kam",
"[",
"0",
"]",
")",
";",
"}"
] |
Returns the KAMs associated with each KAM node.
@param nodes KAM nodes
@return Kam array
|
[
"Returns",
"the",
"KAMs",
"associated",
"with",
"each",
"KAM",
"node",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.api/src/main/java/org/openbel/framework/api/AbstractPathFinder.java#L195-L202
|
146,147
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/pos/Clitic.java
|
Clitic.addAffixForRoot
|
public String addAffixForRoot(String word) {
String result = word;
if (!this.affixForRoot.equals("*")) {
result = result + this.affixForRoot;
}
return result;
}
|
java
|
public String addAffixForRoot(String word) {
String result = word;
if (!this.affixForRoot.equals("*")) {
result = result + this.affixForRoot;
}
return result;
}
|
[
"public",
"String",
"addAffixForRoot",
"(",
"String",
"word",
")",
"{",
"String",
"result",
"=",
"word",
";",
"if",
"(",
"!",
"this",
".",
"affixForRoot",
".",
"equals",
"(",
"\"*\"",
")",
")",
"{",
"result",
"=",
"result",
"+",
"this",
".",
"affixForRoot",
";",
"}",
"return",
"result",
";",
"}"
] |
Given a word, adds an affix to build the root, if necessary.
@param word
the token
@return the resulting token
|
[
"Given",
"a",
"word",
"adds",
"an",
"affix",
"to",
"build",
"the",
"root",
"if",
"necessary",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/pos/Clitic.java#L97-L103
|
146,148
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java
|
PhaseTwoApplication.processOutputDirectory
|
private void processOutputDirectory() {
final String root = outputDirectory.getAbsolutePath();
final String leaf = PhaseOneApplication.DIR_ARTIFACT;
final String path = asPath(root, leaf);
final File phaseIPath = new File(path);
// Fail if the working path doesn't contain a phase I artifact
if (!phaseIPath.isDirectory()) {
error(NOT_A_PHASE1_DIR + ": " + phaseIPath);
failUsage();
}
// Fail if the working path doesn't contain any proto-networks
final File[] networks = phaseIPath.listFiles(new ProtonetworkFilter());
if (networks.length == 0) {
error(NO_PROTO_NETWORKS + " found in " + phaseIPath);
failUsage();
}
// Create the directory artifact or fail
artifactPath = createDirectoryArtifact(outputDirectory, DIR_ARTIFACT);
processDirectories(networks);
}
|
java
|
private void processOutputDirectory() {
final String root = outputDirectory.getAbsolutePath();
final String leaf = PhaseOneApplication.DIR_ARTIFACT;
final String path = asPath(root, leaf);
final File phaseIPath = new File(path);
// Fail if the working path doesn't contain a phase I artifact
if (!phaseIPath.isDirectory()) {
error(NOT_A_PHASE1_DIR + ": " + phaseIPath);
failUsage();
}
// Fail if the working path doesn't contain any proto-networks
final File[] networks = phaseIPath.listFiles(new ProtonetworkFilter());
if (networks.length == 0) {
error(NO_PROTO_NETWORKS + " found in " + phaseIPath);
failUsage();
}
// Create the directory artifact or fail
artifactPath = createDirectoryArtifact(outputDirectory, DIR_ARTIFACT);
processDirectories(networks);
}
|
[
"private",
"void",
"processOutputDirectory",
"(",
")",
"{",
"final",
"String",
"root",
"=",
"outputDirectory",
".",
"getAbsolutePath",
"(",
")",
";",
"final",
"String",
"leaf",
"=",
"PhaseOneApplication",
".",
"DIR_ARTIFACT",
";",
"final",
"String",
"path",
"=",
"asPath",
"(",
"root",
",",
"leaf",
")",
";",
"final",
"File",
"phaseIPath",
"=",
"new",
"File",
"(",
"path",
")",
";",
"// Fail if the working path doesn't contain a phase I artifact",
"if",
"(",
"!",
"phaseIPath",
".",
"isDirectory",
"(",
")",
")",
"{",
"error",
"(",
"NOT_A_PHASE1_DIR",
"+",
"\": \"",
"+",
"phaseIPath",
")",
";",
"failUsage",
"(",
")",
";",
"}",
"// Fail if the working path doesn't contain any proto-networks",
"final",
"File",
"[",
"]",
"networks",
"=",
"phaseIPath",
".",
"listFiles",
"(",
"new",
"ProtonetworkFilter",
"(",
")",
")",
";",
"if",
"(",
"networks",
".",
"length",
"==",
"0",
")",
"{",
"error",
"(",
"NO_PROTO_NETWORKS",
"+",
"\" found in \"",
"+",
"phaseIPath",
")",
";",
"failUsage",
"(",
")",
";",
"}",
"// Create the directory artifact or fail",
"artifactPath",
"=",
"createDirectoryArtifact",
"(",
"outputDirectory",
",",
"DIR_ARTIFACT",
")",
";",
"processDirectories",
"(",
"networks",
")",
";",
"}"
] |
Processes the output directory.
|
[
"Processes",
"the",
"output",
"directory",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java#L155-L178
|
146,149
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java
|
PhaseTwoApplication.processDirectories
|
private void processDirectories(final File[] networks) {
phaseOutput(format("=== %s ===", getApplicationName()));
ProtoNetwork network = stage1(networks);
Set<EquivalenceDataIndex> eqs = stage2();
if (!eqs.isEmpty()) {
network = stage3(network, eqs);
}
stage4(network);
}
|
java
|
private void processDirectories(final File[] networks) {
phaseOutput(format("=== %s ===", getApplicationName()));
ProtoNetwork network = stage1(networks);
Set<EquivalenceDataIndex> eqs = stage2();
if (!eqs.isEmpty()) {
network = stage3(network, eqs);
}
stage4(network);
}
|
[
"private",
"void",
"processDirectories",
"(",
"final",
"File",
"[",
"]",
"networks",
")",
"{",
"phaseOutput",
"(",
"format",
"(",
"\"=== %s ===\"",
",",
"getApplicationName",
"(",
")",
")",
")",
";",
"ProtoNetwork",
"network",
"=",
"stage1",
"(",
"networks",
")",
";",
"Set",
"<",
"EquivalenceDataIndex",
">",
"eqs",
"=",
"stage2",
"(",
")",
";",
"if",
"(",
"!",
"eqs",
".",
"isEmpty",
"(",
")",
")",
"{",
"network",
"=",
"stage3",
"(",
"network",
",",
"eqs",
")",
";",
"}",
"stage4",
"(",
"network",
")",
";",
"}"
] |
Starts phase two compilation of proto-networks.
@param networks
|
[
"Starts",
"phase",
"two",
"compilation",
"of",
"proto",
"-",
"networks",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java#L185-L195
|
146,150
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java
|
PhaseTwoApplication.stage1
|
private ProtoNetwork stage1(final File[] networks) {
beginStage(PHASE2_STAGE1_HDR, "1", NUM_PHASES);
final int netct = networks.length;
final StringBuilder bldr = new StringBuilder();
bldr.append("Merging ");
bldr.append(netct);
bldr.append(" network");
if (netct > 1) {
bldr.append("s");
}
stageOutput(bldr.toString());
long t1 = currentTimeMillis();
Collection<ProtoNetworkDescriptor> nds = sizedArrayList(netct);
for (final File network : networks) {
final String root = network.getAbsolutePath();
final String netPath = asPath(root, PROTO_NETWORK_FILENAME);
final File networkBin = new File(netPath);
nds.add(new BinaryProtoNetworkDescriptor(networkBin));
}
ProtoNetwork ret = p2.stage1Merger(nds);
new File(artifactPath.getAbsolutePath() + "/merged").mkdirs();
p2.stage4WriteEquivalentProtoNetwork(ret,
artifactPath.getAbsolutePath() + "/merged");
if (withDebug()) {
try {
TextProtoNetworkExternalizer textExternalizer =
new TextProtoNetworkExternalizer();
textExternalizer.writeProtoNetwork(ret,
artifactPath.getAbsolutePath() + "/merged");
} catch (ProtoNetworkError e) {
error("Could not write out equivalenced proto network.");
}
}
long t2 = currentTimeMillis();
bldr.setLength(0);
markTime(bldr, t1, t2);
markEndStage(bldr);
stageOutput(bldr.toString());
return ret;
}
|
java
|
private ProtoNetwork stage1(final File[] networks) {
beginStage(PHASE2_STAGE1_HDR, "1", NUM_PHASES);
final int netct = networks.length;
final StringBuilder bldr = new StringBuilder();
bldr.append("Merging ");
bldr.append(netct);
bldr.append(" network");
if (netct > 1) {
bldr.append("s");
}
stageOutput(bldr.toString());
long t1 = currentTimeMillis();
Collection<ProtoNetworkDescriptor> nds = sizedArrayList(netct);
for (final File network : networks) {
final String root = network.getAbsolutePath();
final String netPath = asPath(root, PROTO_NETWORK_FILENAME);
final File networkBin = new File(netPath);
nds.add(new BinaryProtoNetworkDescriptor(networkBin));
}
ProtoNetwork ret = p2.stage1Merger(nds);
new File(artifactPath.getAbsolutePath() + "/merged").mkdirs();
p2.stage4WriteEquivalentProtoNetwork(ret,
artifactPath.getAbsolutePath() + "/merged");
if (withDebug()) {
try {
TextProtoNetworkExternalizer textExternalizer =
new TextProtoNetworkExternalizer();
textExternalizer.writeProtoNetwork(ret,
artifactPath.getAbsolutePath() + "/merged");
} catch (ProtoNetworkError e) {
error("Could not write out equivalenced proto network.");
}
}
long t2 = currentTimeMillis();
bldr.setLength(0);
markTime(bldr, t1, t2);
markEndStage(bldr);
stageOutput(bldr.toString());
return ret;
}
|
[
"private",
"ProtoNetwork",
"stage1",
"(",
"final",
"File",
"[",
"]",
"networks",
")",
"{",
"beginStage",
"(",
"PHASE2_STAGE1_HDR",
",",
"\"1\"",
",",
"NUM_PHASES",
")",
";",
"final",
"int",
"netct",
"=",
"networks",
".",
"length",
";",
"final",
"StringBuilder",
"bldr",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"bldr",
".",
"append",
"(",
"\"Merging \"",
")",
";",
"bldr",
".",
"append",
"(",
"netct",
")",
";",
"bldr",
".",
"append",
"(",
"\" network\"",
")",
";",
"if",
"(",
"netct",
">",
"1",
")",
"{",
"bldr",
".",
"append",
"(",
"\"s\"",
")",
";",
"}",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"long",
"t1",
"=",
"currentTimeMillis",
"(",
")",
";",
"Collection",
"<",
"ProtoNetworkDescriptor",
">",
"nds",
"=",
"sizedArrayList",
"(",
"netct",
")",
";",
"for",
"(",
"final",
"File",
"network",
":",
"networks",
")",
"{",
"final",
"String",
"root",
"=",
"network",
".",
"getAbsolutePath",
"(",
")",
";",
"final",
"String",
"netPath",
"=",
"asPath",
"(",
"root",
",",
"PROTO_NETWORK_FILENAME",
")",
";",
"final",
"File",
"networkBin",
"=",
"new",
"File",
"(",
"netPath",
")",
";",
"nds",
".",
"add",
"(",
"new",
"BinaryProtoNetworkDescriptor",
"(",
"networkBin",
")",
")",
";",
"}",
"ProtoNetwork",
"ret",
"=",
"p2",
".",
"stage1Merger",
"(",
"nds",
")",
";",
"new",
"File",
"(",
"artifactPath",
".",
"getAbsolutePath",
"(",
")",
"+",
"\"/merged\"",
")",
".",
"mkdirs",
"(",
")",
";",
"p2",
".",
"stage4WriteEquivalentProtoNetwork",
"(",
"ret",
",",
"artifactPath",
".",
"getAbsolutePath",
"(",
")",
"+",
"\"/merged\"",
")",
";",
"if",
"(",
"withDebug",
"(",
")",
")",
"{",
"try",
"{",
"TextProtoNetworkExternalizer",
"textExternalizer",
"=",
"new",
"TextProtoNetworkExternalizer",
"(",
")",
";",
"textExternalizer",
".",
"writeProtoNetwork",
"(",
"ret",
",",
"artifactPath",
".",
"getAbsolutePath",
"(",
")",
"+",
"\"/merged\"",
")",
";",
"}",
"catch",
"(",
"ProtoNetworkError",
"e",
")",
"{",
"error",
"(",
"\"Could not write out equivalenced proto network.\"",
")",
";",
"}",
"}",
"long",
"t2",
"=",
"currentTimeMillis",
"(",
")",
";",
"bldr",
".",
"setLength",
"(",
"0",
")",
";",
"markTime",
"(",
"bldr",
",",
"t1",
",",
"t2",
")",
";",
"markEndStage",
"(",
"bldr",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"return",
"ret",
";",
"}"
] |
Stage one merger of networks, returning the merged proto-network.
@param networks Proto-networks
@return {@link ProtoNetwork}
|
[
"Stage",
"one",
"merger",
"of",
"networks",
"returning",
"the",
"merged",
"proto",
"-",
"network",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java#L203-L250
|
146,151
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java
|
PhaseTwoApplication.stage2
|
private Set<EquivalenceDataIndex> stage2() {
beginStage(PHASE2_STAGE2_HDR, "2", NUM_PHASES);
Set<EquivalenceDataIndex> ret = new HashSet<EquivalenceDataIndex>();
final StringBuilder bldr = new StringBuilder();
bldr.append("Loading namespace equivalences from resource index");
stageOutput(bldr.toString());
long t1 = currentTimeMillis();
try {
ret.addAll(p2.stage2LoadNamespaceEquivalences());
} catch (EquivalenceMapResolutionFailure e) {
warning(e.getUserFacingMessage());
// continue with an empty equivalence data index set
}
for (final EquivalenceDataIndex edi : ret) {
final String nsLocation = edi.getNamespaceResourceLocation();
bldr.setLength(0);
bldr.append("Equivalence for ");
bldr.append(nsLocation);
stageOutput(bldr.toString());
}
long t2 = currentTimeMillis();
bldr.setLength(0);
markTime(bldr, t1, t2);
markEndStage(bldr);
stageOutput(bldr.toString());
return ret;
}
|
java
|
private Set<EquivalenceDataIndex> stage2() {
beginStage(PHASE2_STAGE2_HDR, "2", NUM_PHASES);
Set<EquivalenceDataIndex> ret = new HashSet<EquivalenceDataIndex>();
final StringBuilder bldr = new StringBuilder();
bldr.append("Loading namespace equivalences from resource index");
stageOutput(bldr.toString());
long t1 = currentTimeMillis();
try {
ret.addAll(p2.stage2LoadNamespaceEquivalences());
} catch (EquivalenceMapResolutionFailure e) {
warning(e.getUserFacingMessage());
// continue with an empty equivalence data index set
}
for (final EquivalenceDataIndex edi : ret) {
final String nsLocation = edi.getNamespaceResourceLocation();
bldr.setLength(0);
bldr.append("Equivalence for ");
bldr.append(nsLocation);
stageOutput(bldr.toString());
}
long t2 = currentTimeMillis();
bldr.setLength(0);
markTime(bldr, t1, t2);
markEndStage(bldr);
stageOutput(bldr.toString());
return ret;
}
|
[
"private",
"Set",
"<",
"EquivalenceDataIndex",
">",
"stage2",
"(",
")",
"{",
"beginStage",
"(",
"PHASE2_STAGE2_HDR",
",",
"\"2\"",
",",
"NUM_PHASES",
")",
";",
"Set",
"<",
"EquivalenceDataIndex",
">",
"ret",
"=",
"new",
"HashSet",
"<",
"EquivalenceDataIndex",
">",
"(",
")",
";",
"final",
"StringBuilder",
"bldr",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"bldr",
".",
"append",
"(",
"\"Loading namespace equivalences from resource index\"",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"long",
"t1",
"=",
"currentTimeMillis",
"(",
")",
";",
"try",
"{",
"ret",
".",
"addAll",
"(",
"p2",
".",
"stage2LoadNamespaceEquivalences",
"(",
")",
")",
";",
"}",
"catch",
"(",
"EquivalenceMapResolutionFailure",
"e",
")",
"{",
"warning",
"(",
"e",
".",
"getUserFacingMessage",
"(",
")",
")",
";",
"// continue with an empty equivalence data index set",
"}",
"for",
"(",
"final",
"EquivalenceDataIndex",
"edi",
":",
"ret",
")",
"{",
"final",
"String",
"nsLocation",
"=",
"edi",
".",
"getNamespaceResourceLocation",
"(",
")",
";",
"bldr",
".",
"setLength",
"(",
"0",
")",
";",
"bldr",
".",
"append",
"(",
"\"Equivalence for \"",
")",
";",
"bldr",
".",
"append",
"(",
"nsLocation",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"}",
"long",
"t2",
"=",
"currentTimeMillis",
"(",
")",
";",
"bldr",
".",
"setLength",
"(",
"0",
")",
";",
"markTime",
"(",
"bldr",
",",
"t1",
",",
"t2",
")",
";",
"markEndStage",
"(",
"bldr",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"return",
"ret",
";",
"}"
] |
Stage two equivalence loading, returning a set of data indices.
@param equivalenceFile Equivalence file
@return Set of equivalence data indices
|
[
"Stage",
"two",
"equivalence",
"loading",
"returning",
"a",
"set",
"of",
"data",
"indices",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java#L258-L288
|
146,152
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java
|
PhaseTwoApplication.stage3Term
|
private void stage3Term(final ProtoNetwork network, int pct) {
stageOutput("Equivalencing terms");
int tct = p2.stage3EquivalenceTerms(network);
stageOutput("(" + tct + " equivalences)");
}
|
java
|
private void stage3Term(final ProtoNetwork network, int pct) {
stageOutput("Equivalencing terms");
int tct = p2.stage3EquivalenceTerms(network);
stageOutput("(" + tct + " equivalences)");
}
|
[
"private",
"void",
"stage3Term",
"(",
"final",
"ProtoNetwork",
"network",
",",
"int",
"pct",
")",
"{",
"stageOutput",
"(",
"\"Equivalencing terms\"",
")",
";",
"int",
"tct",
"=",
"p2",
".",
"stage3EquivalenceTerms",
"(",
"network",
")",
";",
"stageOutput",
"(",
"\"(\"",
"+",
"tct",
"+",
"\" equivalences)\"",
")",
";",
"}"
] |
Stage three term equivalencing.
@param network the {@link ProtoNetwork network} to equivalence
@param pct the parameter equivalencing count to control output
|
[
"Stage",
"three",
"term",
"equivalencing",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java#L363-L367
|
146,153
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java
|
PhaseTwoApplication.stage3Statement
|
private void stage3Statement(final ProtoNetwork network, int pct) {
stageOutput("Equivalencing statements");
int sct = p2.stage3EquivalenceStatements(network);
stageOutput("(" + sct + " equivalences)");
}
|
java
|
private void stage3Statement(final ProtoNetwork network, int pct) {
stageOutput("Equivalencing statements");
int sct = p2.stage3EquivalenceStatements(network);
stageOutput("(" + sct + " equivalences)");
}
|
[
"private",
"void",
"stage3Statement",
"(",
"final",
"ProtoNetwork",
"network",
",",
"int",
"pct",
")",
"{",
"stageOutput",
"(",
"\"Equivalencing statements\"",
")",
";",
"int",
"sct",
"=",
"p2",
".",
"stage3EquivalenceStatements",
"(",
"network",
")",
";",
"stageOutput",
"(",
"\"(\"",
"+",
"sct",
"+",
"\" equivalences)\"",
")",
";",
"}"
] |
Stage three statement equivalencing.
@param network the {@link ProtoNetwork network} to equivalence
@param pct the parameter equivalencing count to control output
|
[
"Stage",
"three",
"statement",
"equivalencing",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java#L375-L379
|
146,154
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java
|
PhaseTwoApplication.stage4
|
private ProtoNetworkDescriptor stage4(final ProtoNetwork eqNetwork) {
beginStage(PHASE2_STAGE4_HDR, "4", NUM_PHASES);
final StringBuilder bldr = new StringBuilder();
bldr.append("Saving network");
stageOutput(bldr.toString());
long t1 = currentTimeMillis();
ProtoNetworkDescriptor ret =
p2.stage4WriteEquivalentProtoNetwork(eqNetwork,
artifactPath.getAbsolutePath());
if (withDebug()) {
try {
TextProtoNetworkExternalizer textExternalizer =
new TextProtoNetworkExternalizer();
textExternalizer.writeProtoNetwork(eqNetwork,
artifactPath.getAbsolutePath());
} catch (ProtoNetworkError e) {
error("Could not write out equivalenced proto network.");
}
}
bldr.setLength(0);
long t2 = currentTimeMillis();
markTime(bldr, t1, t2);
markEndStage(bldr);
stageOutput(bldr.toString());
return ret;
}
|
java
|
private ProtoNetworkDescriptor stage4(final ProtoNetwork eqNetwork) {
beginStage(PHASE2_STAGE4_HDR, "4", NUM_PHASES);
final StringBuilder bldr = new StringBuilder();
bldr.append("Saving network");
stageOutput(bldr.toString());
long t1 = currentTimeMillis();
ProtoNetworkDescriptor ret =
p2.stage4WriteEquivalentProtoNetwork(eqNetwork,
artifactPath.getAbsolutePath());
if (withDebug()) {
try {
TextProtoNetworkExternalizer textExternalizer =
new TextProtoNetworkExternalizer();
textExternalizer.writeProtoNetwork(eqNetwork,
artifactPath.getAbsolutePath());
} catch (ProtoNetworkError e) {
error("Could not write out equivalenced proto network.");
}
}
bldr.setLength(0);
long t2 = currentTimeMillis();
markTime(bldr, t1, t2);
markEndStage(bldr);
stageOutput(bldr.toString());
return ret;
}
|
[
"private",
"ProtoNetworkDescriptor",
"stage4",
"(",
"final",
"ProtoNetwork",
"eqNetwork",
")",
"{",
"beginStage",
"(",
"PHASE2_STAGE4_HDR",
",",
"\"4\"",
",",
"NUM_PHASES",
")",
";",
"final",
"StringBuilder",
"bldr",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"bldr",
".",
"append",
"(",
"\"Saving network\"",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"long",
"t1",
"=",
"currentTimeMillis",
"(",
")",
";",
"ProtoNetworkDescriptor",
"ret",
"=",
"p2",
".",
"stage4WriteEquivalentProtoNetwork",
"(",
"eqNetwork",
",",
"artifactPath",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"if",
"(",
"withDebug",
"(",
")",
")",
"{",
"try",
"{",
"TextProtoNetworkExternalizer",
"textExternalizer",
"=",
"new",
"TextProtoNetworkExternalizer",
"(",
")",
";",
"textExternalizer",
".",
"writeProtoNetwork",
"(",
"eqNetwork",
",",
"artifactPath",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ProtoNetworkError",
"e",
")",
"{",
"error",
"(",
"\"Could not write out equivalenced proto network.\"",
")",
";",
"}",
"}",
"bldr",
".",
"setLength",
"(",
"0",
")",
";",
"long",
"t2",
"=",
"currentTimeMillis",
"(",
")",
";",
"markTime",
"(",
"bldr",
",",
"t1",
",",
"t2",
")",
";",
"markEndStage",
"(",
"bldr",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"return",
"ret",
";",
"}"
] |
Stage four saving
@param eqNetwork
@return
|
[
"Stage",
"four",
"saving"
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java#L387-L415
|
146,155
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java
|
PhaseTwoApplication.getApplicationDescription
|
@Override
public String getApplicationDescription() {
final StringBuilder bldr = new StringBuilder();
bldr.append("Merges proto-networks into a composite network and ");
bldr.append("equivalences term references across namespaces.");
return bldr.toString();
}
|
java
|
@Override
public String getApplicationDescription() {
final StringBuilder bldr = new StringBuilder();
bldr.append("Merges proto-networks into a composite network and ");
bldr.append("equivalences term references across namespaces.");
return bldr.toString();
}
|
[
"@",
"Override",
"public",
"String",
"getApplicationDescription",
"(",
")",
"{",
"final",
"StringBuilder",
"bldr",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"bldr",
".",
"append",
"(",
"\"Merges proto-networks into a composite network and \"",
")",
";",
"bldr",
".",
"append",
"(",
"\"equivalences term references across namespaces.\"",
")",
";",
"return",
"bldr",
".",
"toString",
"(",
")",
";",
"}"
] |
Returns the application's description.
@return String
|
[
"Returns",
"the",
"application",
"s",
"description",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseTwoApplication.java#L467-L473
|
146,156
|
alb-i986/selenium-tinafw
|
src/main/java/me/alb_i986/selenium/tinafw/ui/PageHelper.java
|
PageHelper.loopFindOrRefresh
|
public static WebElement loopFindOrRefresh(int maxRefreshes, By locator, WebDriver driver) {
for (int i = 0; i < maxRefreshes; i++) {
WebElement element;
try {
// implicitly wait
element = driver.findElement(locator);
// if no exception is thrown, then we can exit the loop
return element;
} catch(NoSuchElementException e) {
// if implicit wait times out, then refresh page and continue the loop
logger.info("after implicit wait, element " + locator + " is still not present: refreshing page and trying again");
Navigation.refreshPage(driver);
}
}
return null;
}
|
java
|
public static WebElement loopFindOrRefresh(int maxRefreshes, By locator, WebDriver driver) {
for (int i = 0; i < maxRefreshes; i++) {
WebElement element;
try {
// implicitly wait
element = driver.findElement(locator);
// if no exception is thrown, then we can exit the loop
return element;
} catch(NoSuchElementException e) {
// if implicit wait times out, then refresh page and continue the loop
logger.info("after implicit wait, element " + locator + " is still not present: refreshing page and trying again");
Navigation.refreshPage(driver);
}
}
return null;
}
|
[
"public",
"static",
"WebElement",
"loopFindOrRefresh",
"(",
"int",
"maxRefreshes",
",",
"By",
"locator",
",",
"WebDriver",
"driver",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"maxRefreshes",
";",
"i",
"++",
")",
"{",
"WebElement",
"element",
";",
"try",
"{",
"// implicitly wait",
"element",
"=",
"driver",
".",
"findElement",
"(",
"locator",
")",
";",
"// if no exception is thrown, then we can exit the loop",
"return",
"element",
";",
"}",
"catch",
"(",
"NoSuchElementException",
"e",
")",
"{",
"// if implicit wait times out, then refresh page and continue the loop",
"logger",
".",
"info",
"(",
"\"after implicit wait, element \"",
"+",
"locator",
"+",
"\" is still not present: refreshing page and trying again\"",
")",
";",
"Navigation",
".",
"refreshPage",
"(",
"driver",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Implicitly wait for an element.
Then, if the element cannot be found, refresh the page.
Try finding the element again, reiterating for maxRefreshes
times or until the element is found.
Finally, return the element.
@param maxRefreshes max num of iterations of the loop
@param locator the locator for the element we want to find
@param driver
@return the element identified by the given locator;
null if the element is not found after the last iteration
|
[
"Implicitly",
"wait",
"for",
"an",
"element",
".",
"Then",
"if",
"the",
"element",
"cannot",
"be",
"found",
"refresh",
"the",
"page",
".",
"Try",
"finding",
"the",
"element",
"again",
"reiterating",
"for",
"maxRefreshes",
"times",
"or",
"until",
"the",
"element",
"is",
"found",
".",
"Finally",
"return",
"the",
"element",
"."
] |
91c66720cda9f69751f96c58c0a0624b2222186e
|
https://github.com/alb-i986/selenium-tinafw/blob/91c66720cda9f69751f96c58c0a0624b2222186e/src/main/java/me/alb_i986/selenium/tinafw/ui/PageHelper.java#L131-L146
|
146,157
|
alb-i986/selenium-tinafw
|
src/main/java/me/alb_i986/selenium/tinafw/ui/PageHelper.java
|
PageHelper.hitKeys
|
public static void hitKeys(WebDriver driver, CharSequence keys) {
new Actions(driver)
.sendKeys(keys)
.perform()
;
}
|
java
|
public static void hitKeys(WebDriver driver, CharSequence keys) {
new Actions(driver)
.sendKeys(keys)
.perform()
;
}
|
[
"public",
"static",
"void",
"hitKeys",
"(",
"WebDriver",
"driver",
",",
"CharSequence",
"keys",
")",
"{",
"new",
"Actions",
"(",
"driver",
")",
".",
"sendKeys",
"(",
"keys",
")",
".",
"perform",
"(",
")",
";",
"}"
] |
Typical use is to simulate hitting ESCAPE or ENTER.
@param driver
@param keys
@see Actions#sendKeys(CharSequence...)
|
[
"Typical",
"use",
"is",
"to",
"simulate",
"hitting",
"ESCAPE",
"or",
"ENTER",
"."
] |
91c66720cda9f69751f96c58c0a0624b2222186e
|
https://github.com/alb-i986/selenium-tinafw/blob/91c66720cda9f69751f96c58c0a0624b2222186e/src/main/java/me/alb_i986/selenium/tinafw/ui/PageHelper.java#L245-L250
|
146,158
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/model/Term.java
|
Term.getAllParameters
|
public List<Parameter> getAllParameters() {
List<Parameter> ret = new ArrayList<Parameter>();
if (parameters != null)
ret.addAll(parameters);
if (terms != null) {
for (final Term t : terms) {
ret.addAll(t.getAllParameters());
}
}
return ret;
}
|
java
|
public List<Parameter> getAllParameters() {
List<Parameter> ret = new ArrayList<Parameter>();
if (parameters != null)
ret.addAll(parameters);
if (terms != null) {
for (final Term t : terms) {
ret.addAll(t.getAllParameters());
}
}
return ret;
}
|
[
"public",
"List",
"<",
"Parameter",
">",
"getAllParameters",
"(",
")",
"{",
"List",
"<",
"Parameter",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"Parameter",
">",
"(",
")",
";",
"if",
"(",
"parameters",
"!=",
"null",
")",
"ret",
".",
"addAll",
"(",
"parameters",
")",
";",
"if",
"(",
"terms",
"!=",
"null",
")",
"{",
"for",
"(",
"final",
"Term",
"t",
":",
"terms",
")",
"{",
"ret",
".",
"addAll",
"(",
"t",
".",
"getAllParameters",
"(",
")",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}"
] |
Returns a list of all parameters contained by both this term and any
nested terms.
@return Non-null list of parameters
|
[
"Returns",
"a",
"list",
"of",
"all",
"parameters",
"contained",
"by",
"both",
"this",
"term",
"and",
"any",
"nested",
"terms",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/model/Term.java#L272-L285
|
146,159
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/model/Term.java
|
Term.getAllTerms
|
public List<Term> getAllTerms() {
List<Term> ret = new ArrayList<Term>();
if (terms != null) {
ret.addAll(terms);
for (final Term term : terms) {
ret.addAll(term.getAllTerms());
}
}
return ret;
}
|
java
|
public List<Term> getAllTerms() {
List<Term> ret = new ArrayList<Term>();
if (terms != null) {
ret.addAll(terms);
for (final Term term : terms) {
ret.addAll(term.getAllTerms());
}
}
return ret;
}
|
[
"public",
"List",
"<",
"Term",
">",
"getAllTerms",
"(",
")",
"{",
"List",
"<",
"Term",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"Term",
">",
"(",
")",
";",
"if",
"(",
"terms",
"!=",
"null",
")",
"{",
"ret",
".",
"addAll",
"(",
"terms",
")",
";",
"for",
"(",
"final",
"Term",
"term",
":",
"terms",
")",
"{",
"ret",
".",
"addAll",
"(",
"term",
".",
"getAllTerms",
"(",
")",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}"
] |
Returns a list of all terms contained by and within this term.
@return Non-null list of terms
|
[
"Returns",
"a",
"list",
"of",
"all",
"terms",
"contained",
"by",
"and",
"within",
"this",
"term",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/model/Term.java#L315-L326
|
146,160
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/model/Term.java
|
Term.setFunctionArgs
|
private void setFunctionArgs(final List<BELObject> args) {
if (args != null) {
this.functionArgs = args;
this.terms = new ArrayList<Term>();
this.parameters = new ArrayList<Parameter>();
for (final BELObject arg : functionArgs) {
if (arg instanceof Term) {
terms.add((Term) arg);
} else if (arg instanceof Parameter) {
parameters.add((Parameter) arg);
} else {
String err = arg.getClass().getName();
err = err.concat(" is not a valid function argument");
throw new UnsupportedOperationException(err);
}
}
} else {
this.functionArgs = null;
this.terms = null;
this.parameters = null;
}
}
|
java
|
private void setFunctionArgs(final List<BELObject> args) {
if (args != null) {
this.functionArgs = args;
this.terms = new ArrayList<Term>();
this.parameters = new ArrayList<Parameter>();
for (final BELObject arg : functionArgs) {
if (arg instanceof Term) {
terms.add((Term) arg);
} else if (arg instanceof Parameter) {
parameters.add((Parameter) arg);
} else {
String err = arg.getClass().getName();
err = err.concat(" is not a valid function argument");
throw new UnsupportedOperationException(err);
}
}
} else {
this.functionArgs = null;
this.terms = null;
this.parameters = null;
}
}
|
[
"private",
"void",
"setFunctionArgs",
"(",
"final",
"List",
"<",
"BELObject",
">",
"args",
")",
"{",
"if",
"(",
"args",
"!=",
"null",
")",
"{",
"this",
".",
"functionArgs",
"=",
"args",
";",
"this",
".",
"terms",
"=",
"new",
"ArrayList",
"<",
"Term",
">",
"(",
")",
";",
"this",
".",
"parameters",
"=",
"new",
"ArrayList",
"<",
"Parameter",
">",
"(",
")",
";",
"for",
"(",
"final",
"BELObject",
"arg",
":",
"functionArgs",
")",
"{",
"if",
"(",
"arg",
"instanceof",
"Term",
")",
"{",
"terms",
".",
"add",
"(",
"(",
"Term",
")",
"arg",
")",
";",
"}",
"else",
"if",
"(",
"arg",
"instanceof",
"Parameter",
")",
"{",
"parameters",
".",
"add",
"(",
"(",
"Parameter",
")",
"arg",
")",
";",
"}",
"else",
"{",
"String",
"err",
"=",
"arg",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"err",
"=",
"err",
".",
"concat",
"(",
"\" is not a valid function argument\"",
")",
";",
"throw",
"new",
"UnsupportedOperationException",
"(",
"err",
")",
";",
"}",
"}",
"}",
"else",
"{",
"this",
".",
"functionArgs",
"=",
"null",
";",
"this",
".",
"terms",
"=",
"null",
";",
"this",
".",
"parameters",
"=",
"null",
";",
"}",
"}"
] |
Sets the function arguments, terms, and parameters. A null argument will
result in null function arguments, terms, and parameters.
@param args List of BEL objects, or null
@throws UnsupportedOperationException Thrown if a {@link BELObject}
within {@code args} is not a {@link Term} or {@link Parameter}
|
[
"Sets",
"the",
"function",
"arguments",
"terms",
"and",
"parameters",
".",
"A",
"null",
"argument",
"will",
"result",
"in",
"null",
"function",
"arguments",
"terms",
"and",
"parameters",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/model/Term.java#L562-L583
|
146,161
|
netheosgithub/pcs_api
|
java/src/main/java/net/netheos/pcsapi/oauth/OAuth2Bootstrapper.java
|
OAuth2Bootstrapper.getAuthorizeBrowserUrl
|
public URI getAuthorizeBrowserUrl()
{
OAuth2AppInfo appInfo = sessionManager.getAppInfo();
state = PcsUtils.randomString( 30 );
URI uri = new URIBuilder( URI.create( sessionManager.getAuthorizeUrl() ) )
.addParameter( OAuth2.CLIENT_ID, appInfo.getAppId() )
.addParameter( OAuth2.STATE, state )
.addParameter( OAuth2.RESPONSE_TYPE, "code" )
.addParameter( OAuth2.REDIRECT_URI, appInfo.getRedirectUrl() )
.addParameter( OAuth2.SCOPE, sessionManager.getScopeForAuthorization() )
.build();
return uri;
}
|
java
|
public URI getAuthorizeBrowserUrl()
{
OAuth2AppInfo appInfo = sessionManager.getAppInfo();
state = PcsUtils.randomString( 30 );
URI uri = new URIBuilder( URI.create( sessionManager.getAuthorizeUrl() ) )
.addParameter( OAuth2.CLIENT_ID, appInfo.getAppId() )
.addParameter( OAuth2.STATE, state )
.addParameter( OAuth2.RESPONSE_TYPE, "code" )
.addParameter( OAuth2.REDIRECT_URI, appInfo.getRedirectUrl() )
.addParameter( OAuth2.SCOPE, sessionManager.getScopeForAuthorization() )
.build();
return uri;
}
|
[
"public",
"URI",
"getAuthorizeBrowserUrl",
"(",
")",
"{",
"OAuth2AppInfo",
"appInfo",
"=",
"sessionManager",
".",
"getAppInfo",
"(",
")",
";",
"state",
"=",
"PcsUtils",
".",
"randomString",
"(",
"30",
")",
";",
"URI",
"uri",
"=",
"new",
"URIBuilder",
"(",
"URI",
".",
"create",
"(",
"sessionManager",
".",
"getAuthorizeUrl",
"(",
")",
")",
")",
".",
"addParameter",
"(",
"OAuth2",
".",
"CLIENT_ID",
",",
"appInfo",
".",
"getAppId",
"(",
")",
")",
".",
"addParameter",
"(",
"OAuth2",
".",
"STATE",
",",
"state",
")",
".",
"addParameter",
"(",
"OAuth2",
".",
"RESPONSE_TYPE",
",",
"\"code\"",
")",
".",
"addParameter",
"(",
"OAuth2",
".",
"REDIRECT_URI",
",",
"appInfo",
".",
"getRedirectUrl",
"(",
")",
")",
".",
"addParameter",
"(",
"OAuth2",
".",
"SCOPE",
",",
"sessionManager",
".",
"getScopeForAuthorization",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"return",
"uri",
";",
"}"
] |
Builds the authorize URI that must be loaded in a browser to allow the application to use the API
@return The authorize URI
|
[
"Builds",
"the",
"authorize",
"URI",
"that",
"must",
"be",
"loaded",
"in",
"a",
"browser",
"to",
"allow",
"the",
"application",
"to",
"use",
"the",
"API"
] |
20691e52e144014f99ca75cb7dedc7ba0c18586c
|
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/oauth/OAuth2Bootstrapper.java#L64-L78
|
146,162
|
netheosgithub/pcs_api
|
java/src/main/java/net/netheos/pcsapi/oauth/OAuth2Bootstrapper.java
|
OAuth2Bootstrapper.getUserCredentials
|
public void getUserCredentials( String codeOrUrl )
throws IOException
{
if ( state == null ) {
// should not occur if this class is used properly
throw new IllegalStateException( "No anti CSRF state defined" );
}
String code;
if ( codeOrUrl.startsWith( "http://" ) || codeOrUrl.startsWith( "https://" ) ) {
// It's a URL : extract code and check state
String url = codeOrUrl;
LOGGER.debug( "redirect URL: {}", url );
URI uri = URI.create( url );
String error = URIUtil.getQueryParameter( uri, "error" );
String errorDescription = URIUtil.getQueryParameter( uri, "error_description" );
if ( error != null ) {
String msg = "User authorization failed : " + error;
if ( errorDescription != null ) {
msg += " (" + errorDescription + ")";
}
throw new CStorageException( msg );
}
String stateToTest = URIUtil.getQueryParameter( uri, "state" );
if ( !state.equals( stateToTest ) ) {
throw new CStorageException( "State received (" + stateToTest + ") is not state expected (" + state + ")" );
}
code = URIUtil.getQueryParameter( uri, "code" );
if ( code == null ) {
throw new CStorageException( "Can't find code in redirected URL: " + url );
}
} else {
// It's a code
code = codeOrUrl;
}
UserCredentials userCredentials = sessionManager.fetchUserCredentials( code );
// From access token we can get user id...
String userId = storageProvider.getUserId();
LOGGER.debug( "User identifier retrieved: {}", userId );
// ...so that by now we can persist tokens :
userCredentials.setUserId( userId );
sessionManager.getUserCredentialsRepository().save( userCredentials );
}
|
java
|
public void getUserCredentials( String codeOrUrl )
throws IOException
{
if ( state == null ) {
// should not occur if this class is used properly
throw new IllegalStateException( "No anti CSRF state defined" );
}
String code;
if ( codeOrUrl.startsWith( "http://" ) || codeOrUrl.startsWith( "https://" ) ) {
// It's a URL : extract code and check state
String url = codeOrUrl;
LOGGER.debug( "redirect URL: {}", url );
URI uri = URI.create( url );
String error = URIUtil.getQueryParameter( uri, "error" );
String errorDescription = URIUtil.getQueryParameter( uri, "error_description" );
if ( error != null ) {
String msg = "User authorization failed : " + error;
if ( errorDescription != null ) {
msg += " (" + errorDescription + ")";
}
throw new CStorageException( msg );
}
String stateToTest = URIUtil.getQueryParameter( uri, "state" );
if ( !state.equals( stateToTest ) ) {
throw new CStorageException( "State received (" + stateToTest + ") is not state expected (" + state + ")" );
}
code = URIUtil.getQueryParameter( uri, "code" );
if ( code == null ) {
throw new CStorageException( "Can't find code in redirected URL: " + url );
}
} else {
// It's a code
code = codeOrUrl;
}
UserCredentials userCredentials = sessionManager.fetchUserCredentials( code );
// From access token we can get user id...
String userId = storageProvider.getUserId();
LOGGER.debug( "User identifier retrieved: {}", userId );
// ...so that by now we can persist tokens :
userCredentials.setUserId( userId );
sessionManager.getUserCredentialsRepository().save( userCredentials );
}
|
[
"public",
"void",
"getUserCredentials",
"(",
"String",
"codeOrUrl",
")",
"throws",
"IOException",
"{",
"if",
"(",
"state",
"==",
"null",
")",
"{",
"// should not occur if this class is used properly",
"throw",
"new",
"IllegalStateException",
"(",
"\"No anti CSRF state defined\"",
")",
";",
"}",
"String",
"code",
";",
"if",
"(",
"codeOrUrl",
".",
"startsWith",
"(",
"\"http://\"",
")",
"||",
"codeOrUrl",
".",
"startsWith",
"(",
"\"https://\"",
")",
")",
"{",
"// It's a URL : extract code and check state",
"String",
"url",
"=",
"codeOrUrl",
";",
"LOGGER",
".",
"debug",
"(",
"\"redirect URL: {}\"",
",",
"url",
")",
";",
"URI",
"uri",
"=",
"URI",
".",
"create",
"(",
"url",
")",
";",
"String",
"error",
"=",
"URIUtil",
".",
"getQueryParameter",
"(",
"uri",
",",
"\"error\"",
")",
";",
"String",
"errorDescription",
"=",
"URIUtil",
".",
"getQueryParameter",
"(",
"uri",
",",
"\"error_description\"",
")",
";",
"if",
"(",
"error",
"!=",
"null",
")",
"{",
"String",
"msg",
"=",
"\"User authorization failed : \"",
"+",
"error",
";",
"if",
"(",
"errorDescription",
"!=",
"null",
")",
"{",
"msg",
"+=",
"\" (\"",
"+",
"errorDescription",
"+",
"\")\"",
";",
"}",
"throw",
"new",
"CStorageException",
"(",
"msg",
")",
";",
"}",
"String",
"stateToTest",
"=",
"URIUtil",
".",
"getQueryParameter",
"(",
"uri",
",",
"\"state\"",
")",
";",
"if",
"(",
"!",
"state",
".",
"equals",
"(",
"stateToTest",
")",
")",
"{",
"throw",
"new",
"CStorageException",
"(",
"\"State received (\"",
"+",
"stateToTest",
"+",
"\") is not state expected (\"",
"+",
"state",
"+",
"\")\"",
")",
";",
"}",
"code",
"=",
"URIUtil",
".",
"getQueryParameter",
"(",
"uri",
",",
"\"code\"",
")",
";",
"if",
"(",
"code",
"==",
"null",
")",
"{",
"throw",
"new",
"CStorageException",
"(",
"\"Can't find code in redirected URL: \"",
"+",
"url",
")",
";",
"}",
"}",
"else",
"{",
"// It's a code",
"code",
"=",
"codeOrUrl",
";",
"}",
"UserCredentials",
"userCredentials",
"=",
"sessionManager",
".",
"fetchUserCredentials",
"(",
"code",
")",
";",
"// From access token we can get user id...",
"String",
"userId",
"=",
"storageProvider",
".",
"getUserId",
"(",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"User identifier retrieved: {}\"",
",",
"userId",
")",
";",
"// ...so that by now we can persist tokens :",
"userCredentials",
".",
"setUserId",
"(",
"userId",
")",
";",
"sessionManager",
".",
"getUserCredentialsRepository",
"(",
")",
".",
"save",
"(",
"userCredentials",
")",
";",
"}"
] |
Gets users Credentials
@param codeOrUrl code or redirect URL provided by the browser
@throws IOException
|
[
"Gets",
"users",
"Credentials"
] |
20691e52e144014f99ca75cb7dedc7ba0c18586c
|
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/oauth/OAuth2Bootstrapper.java#L86-L134
|
146,163
|
nohana/Amalgam
|
amalgam/src/main/java/com/amalgam/net/ConnectivityManagerUtils.java
|
ConnectivityManagerUtils.isNetworkConnected
|
public static boolean isNetworkConnected(Context context) {
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getActiveNetworkInfo();
return info != null && info.isConnected();
}
|
java
|
public static boolean isNetworkConnected(Context context) {
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getActiveNetworkInfo();
return info != null && info.isConnected();
}
|
[
"public",
"static",
"boolean",
"isNetworkConnected",
"(",
"Context",
"context",
")",
"{",
"ConnectivityManager",
"manager",
"=",
"(",
"ConnectivityManager",
")",
"context",
".",
"getSystemService",
"(",
"Context",
".",
"CONNECTIVITY_SERVICE",
")",
";",
"NetworkInfo",
"info",
"=",
"manager",
".",
"getActiveNetworkInfo",
"(",
")",
";",
"return",
"info",
"!=",
"null",
"&&",
"info",
".",
"isConnected",
"(",
")",
";",
"}"
] |
Checks if the network is connected or not.
@param context the context.
@return true if the network is connected.
|
[
"Checks",
"if",
"the",
"network",
"is",
"connected",
"or",
"not",
"."
] |
57809ddbfe7897e979cf507982ce0b3aa5e0ed8a
|
https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/net/ConnectivityManagerUtils.java#L36-L40
|
146,164
|
nohana/Amalgam
|
amalgam/src/main/java/com/amalgam/net/ConnectivityManagerUtils.java
|
ConnectivityManagerUtils.isNetworkAvailable
|
public static boolean isNetworkAvailable(Context context) {
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getActiveNetworkInfo();
return info != null && info.isAvailable();
}
|
java
|
public static boolean isNetworkAvailable(Context context) {
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getActiveNetworkInfo();
return info != null && info.isAvailable();
}
|
[
"public",
"static",
"boolean",
"isNetworkAvailable",
"(",
"Context",
"context",
")",
"{",
"ConnectivityManager",
"manager",
"=",
"(",
"ConnectivityManager",
")",
"context",
".",
"getSystemService",
"(",
"Context",
".",
"CONNECTIVITY_SERVICE",
")",
";",
"NetworkInfo",
"info",
"=",
"manager",
".",
"getActiveNetworkInfo",
"(",
")",
";",
"return",
"info",
"!=",
"null",
"&&",
"info",
".",
"isAvailable",
"(",
")",
";",
"}"
] |
Checks if the network is available or not.
This is not guarantee that the network is connected and can communicate through the network.
@param context the context.
@return true if the network is available.
|
[
"Checks",
"if",
"the",
"network",
"is",
"available",
"or",
"not",
".",
"This",
"is",
"not",
"guarantee",
"that",
"the",
"network",
"is",
"connected",
"and",
"can",
"communicate",
"through",
"the",
"network",
"."
] |
57809ddbfe7897e979cf507982ce0b3aa5e0ed8a
|
https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/net/ConnectivityManagerUtils.java#L48-L52
|
146,165
|
ihaolin/session
|
session-redis/src/main/java/me/hao0/session/redis/RedisSessionManager.java
|
RedisSessionManager.initJedisPool
|
private void initJedisPool(Properties props) {
JedisPoolConfig config = new JedisPoolConfig();
config.setTestOnBorrow(true);
Integer maxIdle = Integer.parseInt(props.getProperty("session.redis.pool.max.idle", "2"));
config.setMaxIdle(maxIdle);
Integer maxTotal = Integer.parseInt(props.getProperty("session.redis.pool.max.total", "5"));
config.setMaxTotal(maxTotal);
final String mode = props.getProperty("session.redis.mode");
if (Objects.equal(mode, SENTINEL_MODE)){
// sentinel
this.executor = new RedisExecutor(config, true, props);
} else {
// standalone
this.executor = new RedisExecutor(config, false, props);
}
}
|
java
|
private void initJedisPool(Properties props) {
JedisPoolConfig config = new JedisPoolConfig();
config.setTestOnBorrow(true);
Integer maxIdle = Integer.parseInt(props.getProperty("session.redis.pool.max.idle", "2"));
config.setMaxIdle(maxIdle);
Integer maxTotal = Integer.parseInt(props.getProperty("session.redis.pool.max.total", "5"));
config.setMaxTotal(maxTotal);
final String mode = props.getProperty("session.redis.mode");
if (Objects.equal(mode, SENTINEL_MODE)){
// sentinel
this.executor = new RedisExecutor(config, true, props);
} else {
// standalone
this.executor = new RedisExecutor(config, false, props);
}
}
|
[
"private",
"void",
"initJedisPool",
"(",
"Properties",
"props",
")",
"{",
"JedisPoolConfig",
"config",
"=",
"new",
"JedisPoolConfig",
"(",
")",
";",
"config",
".",
"setTestOnBorrow",
"(",
"true",
")",
";",
"Integer",
"maxIdle",
"=",
"Integer",
".",
"parseInt",
"(",
"props",
".",
"getProperty",
"(",
"\"session.redis.pool.max.idle\"",
",",
"\"2\"",
")",
")",
";",
"config",
".",
"setMaxIdle",
"(",
"maxIdle",
")",
";",
"Integer",
"maxTotal",
"=",
"Integer",
".",
"parseInt",
"(",
"props",
".",
"getProperty",
"(",
"\"session.redis.pool.max.total\"",
",",
"\"5\"",
")",
")",
";",
"config",
".",
"setMaxTotal",
"(",
"maxTotal",
")",
";",
"final",
"String",
"mode",
"=",
"props",
".",
"getProperty",
"(",
"\"session.redis.mode\"",
")",
";",
"if",
"(",
"Objects",
".",
"equal",
"(",
"mode",
",",
"SENTINEL_MODE",
")",
")",
"{",
"// sentinel",
"this",
".",
"executor",
"=",
"new",
"RedisExecutor",
"(",
"config",
",",
"true",
",",
"props",
")",
";",
"}",
"else",
"{",
"// standalone",
"this",
".",
"executor",
"=",
"new",
"RedisExecutor",
"(",
"config",
",",
"false",
",",
"props",
")",
";",
"}",
"}"
] |
init jedis pool with properties
@param props
|
[
"init",
"jedis",
"pool",
"with",
"properties"
] |
322c3a9f47b305a39345135fa8163dd7e065b4f8
|
https://github.com/ihaolin/session/blob/322c3a9f47b305a39345135fa8163dd7e065b4f8/session-redis/src/main/java/me/hao0/session/redis/RedisSessionManager.java#L53-L72
|
146,166
|
ihaolin/session
|
session-redis/src/main/java/me/hao0/session/redis/RedisSessionManager.java
|
RedisSessionManager.persist
|
public Boolean persist(final String id, final Map<String, Object> snapshot, final int maxInactiveInterval) {
final String sid = sessionPrefix + ":" + id;
try {
this.executor.execute(new RedisCallback<Void>() {
public Void execute(Jedis jedis) {
if (snapshot.isEmpty()) {
// delete session
jedis.del(sid);
} else {
// set session
jedis.setex(sid, maxInactiveInterval, serializer.serialize(snapshot));
}
return null;
}
});
return Boolean.TRUE;
} catch (Exception e) {
log.error("failed to persist session(id={}, snapshot={}), cause:{}",
sid, snapshot, Throwables.getStackTraceAsString(e));
return Boolean.FALSE;
}
}
|
java
|
public Boolean persist(final String id, final Map<String, Object> snapshot, final int maxInactiveInterval) {
final String sid = sessionPrefix + ":" + id;
try {
this.executor.execute(new RedisCallback<Void>() {
public Void execute(Jedis jedis) {
if (snapshot.isEmpty()) {
// delete session
jedis.del(sid);
} else {
// set session
jedis.setex(sid, maxInactiveInterval, serializer.serialize(snapshot));
}
return null;
}
});
return Boolean.TRUE;
} catch (Exception e) {
log.error("failed to persist session(id={}, snapshot={}), cause:{}",
sid, snapshot, Throwables.getStackTraceAsString(e));
return Boolean.FALSE;
}
}
|
[
"public",
"Boolean",
"persist",
"(",
"final",
"String",
"id",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"snapshot",
",",
"final",
"int",
"maxInactiveInterval",
")",
"{",
"final",
"String",
"sid",
"=",
"sessionPrefix",
"+",
"\":\"",
"+",
"id",
";",
"try",
"{",
"this",
".",
"executor",
".",
"execute",
"(",
"new",
"RedisCallback",
"<",
"Void",
">",
"(",
")",
"{",
"public",
"Void",
"execute",
"(",
"Jedis",
"jedis",
")",
"{",
"if",
"(",
"snapshot",
".",
"isEmpty",
"(",
")",
")",
"{",
"// delete session",
"jedis",
".",
"del",
"(",
"sid",
")",
";",
"}",
"else",
"{",
"// set session",
"jedis",
".",
"setex",
"(",
"sid",
",",
"maxInactiveInterval",
",",
"serializer",
".",
"serialize",
"(",
"snapshot",
")",
")",
";",
"}",
"return",
"null",
";",
"}",
"}",
")",
";",
"return",
"Boolean",
".",
"TRUE",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"failed to persist session(id={}, snapshot={}), cause:{}\"",
",",
"sid",
",",
"snapshot",
",",
"Throwables",
".",
"getStackTraceAsString",
"(",
"e",
")",
")",
";",
"return",
"Boolean",
".",
"FALSE",
";",
"}",
"}"
] |
persist session to session store
@param id session id
@param snapshot session attributes' snapshot
@param maxInactiveInterval session max life(seconds)
@return true if save successfully, or false
|
[
"persist",
"session",
"to",
"session",
"store"
] |
322c3a9f47b305a39345135fa8163dd7e065b4f8
|
https://github.com/ihaolin/session/blob/322c3a9f47b305a39345135fa8163dd7e065b4f8/session-redis/src/main/java/me/hao0/session/redis/RedisSessionManager.java#L81-L102
|
146,167
|
ihaolin/session
|
session-redis/src/main/java/me/hao0/session/redis/RedisSessionManager.java
|
RedisSessionManager.loadById
|
public Map<String, Object> loadById(String id) {
final String sid = sessionPrefix + ":" + id;
try {
return this.executor.execute(new RedisCallback<Map<String, Object>>() {
public Map<String, Object> execute(Jedis jedis) {
String session = jedis.get(sid);
if (!Strings.isNullOrEmpty(session)) {
return serializer.deserialize(session);
}
return Collections.emptyMap();
}
});
} catch (Exception e) {
log.error("failed to load session(key={}), cause:{}", sid, Throwables.getStackTraceAsString(e));
throw new SessionException("load session failed", e);
}
}
|
java
|
public Map<String, Object> loadById(String id) {
final String sid = sessionPrefix + ":" + id;
try {
return this.executor.execute(new RedisCallback<Map<String, Object>>() {
public Map<String, Object> execute(Jedis jedis) {
String session = jedis.get(sid);
if (!Strings.isNullOrEmpty(session)) {
return serializer.deserialize(session);
}
return Collections.emptyMap();
}
});
} catch (Exception e) {
log.error("failed to load session(key={}), cause:{}", sid, Throwables.getStackTraceAsString(e));
throw new SessionException("load session failed", e);
}
}
|
[
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"loadById",
"(",
"String",
"id",
")",
"{",
"final",
"String",
"sid",
"=",
"sessionPrefix",
"+",
"\":\"",
"+",
"id",
";",
"try",
"{",
"return",
"this",
".",
"executor",
".",
"execute",
"(",
"new",
"RedisCallback",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"(",
")",
"{",
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"execute",
"(",
"Jedis",
"jedis",
")",
"{",
"String",
"session",
"=",
"jedis",
".",
"get",
"(",
"sid",
")",
";",
"if",
"(",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
"session",
")",
")",
"{",
"return",
"serializer",
".",
"deserialize",
"(",
"session",
")",
";",
"}",
"return",
"Collections",
".",
"emptyMap",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"failed to load session(key={}), cause:{}\"",
",",
"sid",
",",
"Throwables",
".",
"getStackTraceAsString",
"(",
"e",
")",
")",
";",
"throw",
"new",
"SessionException",
"(",
"\"load session failed\"",
",",
"e",
")",
";",
"}",
"}"
] |
load session by id
@param id session id
@return session map object
|
[
"load",
"session",
"by",
"id"
] |
322c3a9f47b305a39345135fa8163dd7e065b4f8
|
https://github.com/ihaolin/session/blob/322c3a9f47b305a39345135fa8163dd7e065b4f8/session-redis/src/main/java/me/hao0/session/redis/RedisSessionManager.java#L109-L125
|
146,168
|
ihaolin/session
|
session-redis/src/main/java/me/hao0/session/redis/RedisSessionManager.java
|
RedisSessionManager.deleteById
|
public void deleteById(String id) {
final String sid = sessionPrefix + ":" + id;
try {
this.executor.execute(new RedisCallback<Void>() {
public Void execute(Jedis jedis) {
jedis.del(sid);
return null;
}
});
} catch (Exception e) {
log.error("failed to delete session(key={}) in redis,cause:{}", sid, Throwables.getStackTraceAsString(e));
}
}
|
java
|
public void deleteById(String id) {
final String sid = sessionPrefix + ":" + id;
try {
this.executor.execute(new RedisCallback<Void>() {
public Void execute(Jedis jedis) {
jedis.del(sid);
return null;
}
});
} catch (Exception e) {
log.error("failed to delete session(key={}) in redis,cause:{}", sid, Throwables.getStackTraceAsString(e));
}
}
|
[
"public",
"void",
"deleteById",
"(",
"String",
"id",
")",
"{",
"final",
"String",
"sid",
"=",
"sessionPrefix",
"+",
"\":\"",
"+",
"id",
";",
"try",
"{",
"this",
".",
"executor",
".",
"execute",
"(",
"new",
"RedisCallback",
"<",
"Void",
">",
"(",
")",
"{",
"public",
"Void",
"execute",
"(",
"Jedis",
"jedis",
")",
"{",
"jedis",
".",
"del",
"(",
"sid",
")",
";",
"return",
"null",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"failed to delete session(key={}) in redis,cause:{}\"",
",",
"sid",
",",
"Throwables",
".",
"getStackTraceAsString",
"(",
"e",
")",
")",
";",
"}",
"}"
] |
delete session physically
@param id session id
|
[
"delete",
"session",
"physically"
] |
322c3a9f47b305a39345135fa8163dd7e065b4f8
|
https://github.com/ihaolin/session/blob/322c3a9f47b305a39345135fa8163dd7e065b4f8/session-redis/src/main/java/me/hao0/session/redis/RedisSessionManager.java#L131-L143
|
146,169
|
geomajas/geomajas-project-client-gwt2
|
plugin/geocoder/geocoder/src/main/java/org/geomajas/gwt2/plugin/geocoder/client/widget/GeocoderWidgetViewImpl.java
|
GeocoderWidgetViewImpl.getWidgetViewBbox
|
public Bbox getWidgetViewBbox() {
return new Bbox(textBox.getAbsoluteLeft(), textBox.getAbsoluteTop(),
textBox.getOffsetWidth(), textBox.getOffsetHeight());
}
|
java
|
public Bbox getWidgetViewBbox() {
return new Bbox(textBox.getAbsoluteLeft(), textBox.getAbsoluteTop(),
textBox.getOffsetWidth(), textBox.getOffsetHeight());
}
|
[
"public",
"Bbox",
"getWidgetViewBbox",
"(",
")",
"{",
"return",
"new",
"Bbox",
"(",
"textBox",
".",
"getAbsoluteLeft",
"(",
")",
",",
"textBox",
".",
"getAbsoluteTop",
"(",
")",
",",
"textBox",
".",
"getOffsetWidth",
"(",
")",
",",
"textBox",
".",
"getOffsetHeight",
"(",
")",
")",
";",
"}"
] |
Return the bbox of the textbox element. These bounds will be used to position the
alternative locations view.
@return bbox of the textbox
|
[
"Return",
"the",
"bbox",
"of",
"the",
"textbox",
"element",
".",
"These",
"bounds",
"will",
"be",
"used",
"to",
"position",
"the",
"alternative",
"locations",
"view",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/geocoder/geocoder/src/main/java/org/geomajas/gwt2/plugin/geocoder/client/widget/GeocoderWidgetViewImpl.java#L203-L206
|
146,170
|
cattaka/CatHandsGendroid
|
cathandsgendroid-apt/src/main/java/net/cattaka/util/cathandsgendroid/apt/Bug300408.java
|
Bug300408.getEnclosedElementsDeclarationOrder
|
public static List<? extends Element> getEnclosedElementsDeclarationOrder(TypeElement type) {
List<? extends Element> result = null;
try {
Object binding = field(type, "_binding");
Class<?> sourceTypeBinding = null;
{
Class<?> c = binding.getClass();
do {
if (c.getCanonicalName().equals(
"org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding")) {
sourceTypeBinding = c;
break;
}
} while ((c = c.getSuperclass()) != null);
}
final List<Object> declarationOrder;
if (sourceTypeBinding != null) {
declarationOrder = findSourceOrder(binding);
List<Element> enclosedElements = new ArrayList<Element>(type.getEnclosedElements());
Collections.sort(enclosedElements, new Comparator<Element>() {
public int compare(Element o1, Element o2) {
try {
Object o1Binding = field(o1, "_binding");
Object o2Binding = field(o2, "_binding");
int i1 = declarationOrder.indexOf(o1Binding);
int i2 = declarationOrder.indexOf(o2Binding);
return i1 - i2;
} catch (Exception e) {
return 0;
}
}
});
result = enclosedElements;
}
} catch (Exception e) {
// ignore
}
return (result != null) ? result : type.getEnclosedElements();
}
|
java
|
public static List<? extends Element> getEnclosedElementsDeclarationOrder(TypeElement type) {
List<? extends Element> result = null;
try {
Object binding = field(type, "_binding");
Class<?> sourceTypeBinding = null;
{
Class<?> c = binding.getClass();
do {
if (c.getCanonicalName().equals(
"org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding")) {
sourceTypeBinding = c;
break;
}
} while ((c = c.getSuperclass()) != null);
}
final List<Object> declarationOrder;
if (sourceTypeBinding != null) {
declarationOrder = findSourceOrder(binding);
List<Element> enclosedElements = new ArrayList<Element>(type.getEnclosedElements());
Collections.sort(enclosedElements, new Comparator<Element>() {
public int compare(Element o1, Element o2) {
try {
Object o1Binding = field(o1, "_binding");
Object o2Binding = field(o2, "_binding");
int i1 = declarationOrder.indexOf(o1Binding);
int i2 = declarationOrder.indexOf(o2Binding);
return i1 - i2;
} catch (Exception e) {
return 0;
}
}
});
result = enclosedElements;
}
} catch (Exception e) {
// ignore
}
return (result != null) ? result : type.getEnclosedElements();
}
|
[
"public",
"static",
"List",
"<",
"?",
"extends",
"Element",
">",
"getEnclosedElementsDeclarationOrder",
"(",
"TypeElement",
"type",
")",
"{",
"List",
"<",
"?",
"extends",
"Element",
">",
"result",
"=",
"null",
";",
"try",
"{",
"Object",
"binding",
"=",
"field",
"(",
"type",
",",
"\"_binding\"",
")",
";",
"Class",
"<",
"?",
">",
"sourceTypeBinding",
"=",
"null",
";",
"{",
"Class",
"<",
"?",
">",
"c",
"=",
"binding",
".",
"getClass",
"(",
")",
";",
"do",
"{",
"if",
"(",
"c",
".",
"getCanonicalName",
"(",
")",
".",
"equals",
"(",
"\"org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding\"",
")",
")",
"{",
"sourceTypeBinding",
"=",
"c",
";",
"break",
";",
"}",
"}",
"while",
"(",
"(",
"c",
"=",
"c",
".",
"getSuperclass",
"(",
")",
")",
"!=",
"null",
")",
";",
"}",
"final",
"List",
"<",
"Object",
">",
"declarationOrder",
";",
"if",
"(",
"sourceTypeBinding",
"!=",
"null",
")",
"{",
"declarationOrder",
"=",
"findSourceOrder",
"(",
"binding",
")",
";",
"List",
"<",
"Element",
">",
"enclosedElements",
"=",
"new",
"ArrayList",
"<",
"Element",
">",
"(",
"type",
".",
"getEnclosedElements",
"(",
")",
")",
";",
"Collections",
".",
"sort",
"(",
"enclosedElements",
",",
"new",
"Comparator",
"<",
"Element",
">",
"(",
")",
"{",
"public",
"int",
"compare",
"(",
"Element",
"o1",
",",
"Element",
"o2",
")",
"{",
"try",
"{",
"Object",
"o1Binding",
"=",
"field",
"(",
"o1",
",",
"\"_binding\"",
")",
";",
"Object",
"o2Binding",
"=",
"field",
"(",
"o2",
",",
"\"_binding\"",
")",
";",
"int",
"i1",
"=",
"declarationOrder",
".",
"indexOf",
"(",
"o1Binding",
")",
";",
"int",
"i2",
"=",
"declarationOrder",
".",
"indexOf",
"(",
"o2Binding",
")",
";",
"return",
"i1",
"-",
"i2",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"0",
";",
"}",
"}",
"}",
")",
";",
"result",
"=",
"enclosedElements",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// ignore",
"}",
"return",
"(",
"result",
"!=",
"null",
")",
"?",
"result",
":",
"type",
".",
"getEnclosedElements",
"(",
")",
";",
"}"
] |
If given TypeElement is SourceTypeBinding, the order of results are corrected.
@param type target
@return the enclosed elements, or an empty list if none
|
[
"If",
"given",
"TypeElement",
"is",
"SourceTypeBinding",
"the",
"order",
"of",
"results",
"are",
"corrected",
"."
] |
6e496cc5901e0e1be2142c69cab898f61974db4d
|
https://github.com/cattaka/CatHandsGendroid/blob/6e496cc5901e0e1be2142c69cab898f61974db4d/cathandsgendroid-apt/src/main/java/net/cattaka/util/cathandsgendroid/apt/Bug300408.java#L28-L73
|
146,171
|
alb-i986/selenium-tinafw
|
src/main/java/me/alb_i986/selenium/tinafw/config/PropertyLoaderComposite.java
|
PropertyLoaderComposite.getProperty
|
@Override
public String getProperty(String key) {
for (PropertyLoader loader : loaders) {
String value = loader.getProperty(key);
if(value != null)
return value;
}
return null;
}
|
java
|
@Override
public String getProperty(String key) {
for (PropertyLoader loader : loaders) {
String value = loader.getProperty(key);
if(value != null)
return value;
}
return null;
}
|
[
"@",
"Override",
"public",
"String",
"getProperty",
"(",
"String",
"key",
")",
"{",
"for",
"(",
"PropertyLoader",
"loader",
":",
"loaders",
")",
"{",
"String",
"value",
"=",
"loader",
".",
"getProperty",
"(",
"key",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"return",
"value",
";",
"}",
"return",
"null",
";",
"}"
] |
Loop over the components and
return the first not null value found.
|
[
"Loop",
"over",
"the",
"components",
"and",
"return",
"the",
"first",
"not",
"null",
"value",
"found",
"."
] |
91c66720cda9f69751f96c58c0a0624b2222186e
|
https://github.com/alb-i986/selenium-tinafw/blob/91c66720cda9f69751f96c58c0a0624b2222186e/src/main/java/me/alb_i986/selenium/tinafw/config/PropertyLoaderComposite.java#L22-L30
|
146,172
|
kcthota/JSONQuery
|
src/main/java/com/kcthota/JSONQuery/expressions/ValueExpression.java
|
ValueExpression.evaluate
|
public JsonNode evaluate(JsonNode node) {
if(innerExpression==null) {
return getValue(node, property);
} else {
return getValue(innerExpression.evaluate(node), property);
}
}
|
java
|
public JsonNode evaluate(JsonNode node) {
if(innerExpression==null) {
return getValue(node, property);
} else {
return getValue(innerExpression.evaluate(node), property);
}
}
|
[
"public",
"JsonNode",
"evaluate",
"(",
"JsonNode",
"node",
")",
"{",
"if",
"(",
"innerExpression",
"==",
"null",
")",
"{",
"return",
"getValue",
"(",
"node",
",",
"property",
")",
";",
"}",
"else",
"{",
"return",
"getValue",
"(",
"innerExpression",
".",
"evaluate",
"(",
"node",
")",
",",
"property",
")",
";",
"}",
"}"
] |
Evaluates the expression on passed JSONNode
@param node JSONNode object
@return returns the value of the property
|
[
"Evaluates",
"the",
"expression",
"on",
"passed",
"JSONNode"
] |
190f8fbcd05d42cfda265ecd8ce4ced192d57c16
|
https://github.com/kcthota/JSONQuery/blob/190f8fbcd05d42cfda265ecd8ce4ced192d57c16/src/main/java/com/kcthota/JSONQuery/expressions/ValueExpression.java#L34-L40
|
146,173
|
kcthota/JSONQuery
|
src/main/java/com/kcthota/JSONQuery/expressions/ValueExpression.java
|
ValueExpression.getValue
|
protected JsonNode getValue(JsonNode node, String property) {
if(node==null) {
throw new MissingNodeException(property + " is missing");
}
if(property==null) {
return node;
}
JsonNode value = node.at(formatPropertyName(property));
if (value.isMissingNode()) {
throw new MissingNodeException(property + " is missing");
}
return value;
}
|
java
|
protected JsonNode getValue(JsonNode node, String property) {
if(node==null) {
throw new MissingNodeException(property + " is missing");
}
if(property==null) {
return node;
}
JsonNode value = node.at(formatPropertyName(property));
if (value.isMissingNode()) {
throw new MissingNodeException(property + " is missing");
}
return value;
}
|
[
"protected",
"JsonNode",
"getValue",
"(",
"JsonNode",
"node",
",",
"String",
"property",
")",
"{",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"throw",
"new",
"MissingNodeException",
"(",
"property",
"+",
"\" is missing\"",
")",
";",
"}",
"if",
"(",
"property",
"==",
"null",
")",
"{",
"return",
"node",
";",
"}",
"JsonNode",
"value",
"=",
"node",
".",
"at",
"(",
"formatPropertyName",
"(",
"property",
")",
")",
";",
"if",
"(",
"value",
".",
"isMissingNode",
"(",
")",
")",
"{",
"throw",
"new",
"MissingNodeException",
"(",
"property",
"+",
"\" is missing\"",
")",
";",
"}",
"return",
"value",
";",
"}"
] |
Fetches the value for a property from the passed JsonNode. Throws MissingNodeException if the property doesn't exist
@param node JSONNode Object
@param property Property for which the value should be returned
@return returns the value of the property
|
[
"Fetches",
"the",
"value",
"for",
"a",
"property",
"from",
"the",
"passed",
"JsonNode",
".",
"Throws",
"MissingNodeException",
"if",
"the",
"property",
"doesn",
"t",
"exist"
] |
190f8fbcd05d42cfda265ecd8ce4ced192d57c16
|
https://github.com/kcthota/JSONQuery/blob/190f8fbcd05d42cfda265ecd8ce4ced192d57c16/src/main/java/com/kcthota/JSONQuery/expressions/ValueExpression.java#L48-L62
|
146,174
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/pos/TagSetMappingsToNAF.java
|
TagSetMappingsToNAF.mapGermanCoNLL09TagSetToNAF
|
private static String mapGermanCoNLL09TagSetToNAF(final String postag) {
if (postag.startsWith("ADV")) {
return "A"; // adverb
} else if (postag.startsWith("KO")) {
return "C"; // conjunction
} else if (postag.equalsIgnoreCase("ART")) {
return "D"; // determiner and predeterminer
} else if (postag.startsWith("ADJ")) {
return "G"; // adjective
} else if (postag.equalsIgnoreCase("NN")) {
return "N"; // common noun
} else if (postag.startsWith("NE")) {
return "R"; // proper noun
} else if (postag.startsWith("AP")) {
return "P"; // preposition
} else if (postag.startsWith("PD") || postag.startsWith("PI")
|| postag.startsWith("PP") || postag.startsWith("PR")
|| postag.startsWith("PW") || postag.startsWith("PA")) {
return "Q"; // pronoun
} else if (postag.startsWith("V")) {
return "V"; // verb
} else {
return "O"; // other
}
}
|
java
|
private static String mapGermanCoNLL09TagSetToNAF(final String postag) {
if (postag.startsWith("ADV")) {
return "A"; // adverb
} else if (postag.startsWith("KO")) {
return "C"; // conjunction
} else if (postag.equalsIgnoreCase("ART")) {
return "D"; // determiner and predeterminer
} else if (postag.startsWith("ADJ")) {
return "G"; // adjective
} else if (postag.equalsIgnoreCase("NN")) {
return "N"; // common noun
} else if (postag.startsWith("NE")) {
return "R"; // proper noun
} else if (postag.startsWith("AP")) {
return "P"; // preposition
} else if (postag.startsWith("PD") || postag.startsWith("PI")
|| postag.startsWith("PP") || postag.startsWith("PR")
|| postag.startsWith("PW") || postag.startsWith("PA")) {
return "Q"; // pronoun
} else if (postag.startsWith("V")) {
return "V"; // verb
} else {
return "O"; // other
}
}
|
[
"private",
"static",
"String",
"mapGermanCoNLL09TagSetToNAF",
"(",
"final",
"String",
"postag",
")",
"{",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"ADV\"",
")",
")",
"{",
"return",
"\"A\"",
";",
"// adverb",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"KO\"",
")",
")",
"{",
"return",
"\"C\"",
";",
"// conjunction",
"}",
"else",
"if",
"(",
"postag",
".",
"equalsIgnoreCase",
"(",
"\"ART\"",
")",
")",
"{",
"return",
"\"D\"",
";",
"// determiner and predeterminer",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"ADJ\"",
")",
")",
"{",
"return",
"\"G\"",
";",
"// adjective",
"}",
"else",
"if",
"(",
"postag",
".",
"equalsIgnoreCase",
"(",
"\"NN\"",
")",
")",
"{",
"return",
"\"N\"",
";",
"// common noun",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"NE\"",
")",
")",
"{",
"return",
"\"R\"",
";",
"// proper noun",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"AP\"",
")",
")",
"{",
"return",
"\"P\"",
";",
"// preposition",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"PD\"",
")",
"||",
"postag",
".",
"startsWith",
"(",
"\"PI\"",
")",
"||",
"postag",
".",
"startsWith",
"(",
"\"PP\"",
")",
"||",
"postag",
".",
"startsWith",
"(",
"\"PR\"",
")",
"||",
"postag",
".",
"startsWith",
"(",
"\"PW\"",
")",
"||",
"postag",
".",
"startsWith",
"(",
"\"PA\"",
")",
")",
"{",
"return",
"\"Q\"",
";",
"// pronoun",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"V\"",
")",
")",
"{",
"return",
"\"V\"",
";",
"// verb",
"}",
"else",
"{",
"return",
"\"O\"",
";",
"// other",
"}",
"}"
] |
Mapping between CoNLL 2009 German tagset and NAF tagset. Based on the
Stuttgart-Tuebingen tagset.
@param postag
the postag
@return NAF POS tag
|
[
"Mapping",
"between",
"CoNLL",
"2009",
"German",
"tagset",
"and",
"NAF",
"tagset",
".",
"Based",
"on",
"the",
"Stuttgart",
"-",
"Tuebingen",
"tagset",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/pos/TagSetMappingsToNAF.java#L91-L115
|
146,175
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/pos/TagSetMappingsToNAF.java
|
TagSetMappingsToNAF.mapEnglishPennTagSetToNAF
|
private static String mapEnglishPennTagSetToNAF(final String postag) {
if (postag.startsWith("RB")) {
return "A"; // adverb
} else if (postag.equalsIgnoreCase("CC")) {
return "C"; // conjunction
} else if (postag.startsWith("D") || postag.equalsIgnoreCase("PDT")) {
return "D"; // determiner and predeterminer
} else if (postag.startsWith("J")) {
return "G"; // adjective
} else if (postag.equalsIgnoreCase("NN")
|| postag.equalsIgnoreCase("NNS")) {
return "N"; // common noun
} else if (postag.startsWith("NNP")) {
return "R"; // proper noun
} else if (postag.equalsIgnoreCase("TO") || postag.equalsIgnoreCase("IN")) {
return "P"; // preposition
} else if (postag.startsWith("PRP") || postag.startsWith("WP")) {
return "Q"; // pronoun
} else if (postag.startsWith("V")) {
return "V"; // verb
} else {
return "O"; // other
}
}
|
java
|
private static String mapEnglishPennTagSetToNAF(final String postag) {
if (postag.startsWith("RB")) {
return "A"; // adverb
} else if (postag.equalsIgnoreCase("CC")) {
return "C"; // conjunction
} else if (postag.startsWith("D") || postag.equalsIgnoreCase("PDT")) {
return "D"; // determiner and predeterminer
} else if (postag.startsWith("J")) {
return "G"; // adjective
} else if (postag.equalsIgnoreCase("NN")
|| postag.equalsIgnoreCase("NNS")) {
return "N"; // common noun
} else if (postag.startsWith("NNP")) {
return "R"; // proper noun
} else if (postag.equalsIgnoreCase("TO") || postag.equalsIgnoreCase("IN")) {
return "P"; // preposition
} else if (postag.startsWith("PRP") || postag.startsWith("WP")) {
return "Q"; // pronoun
} else if (postag.startsWith("V")) {
return "V"; // verb
} else {
return "O"; // other
}
}
|
[
"private",
"static",
"String",
"mapEnglishPennTagSetToNAF",
"(",
"final",
"String",
"postag",
")",
"{",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"RB\"",
")",
")",
"{",
"return",
"\"A\"",
";",
"// adverb",
"}",
"else",
"if",
"(",
"postag",
".",
"equalsIgnoreCase",
"(",
"\"CC\"",
")",
")",
"{",
"return",
"\"C\"",
";",
"// conjunction",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"D\"",
")",
"||",
"postag",
".",
"equalsIgnoreCase",
"(",
"\"PDT\"",
")",
")",
"{",
"return",
"\"D\"",
";",
"// determiner and predeterminer",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"J\"",
")",
")",
"{",
"return",
"\"G\"",
";",
"// adjective",
"}",
"else",
"if",
"(",
"postag",
".",
"equalsIgnoreCase",
"(",
"\"NN\"",
")",
"||",
"postag",
".",
"equalsIgnoreCase",
"(",
"\"NNS\"",
")",
")",
"{",
"return",
"\"N\"",
";",
"// common noun",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"NNP\"",
")",
")",
"{",
"return",
"\"R\"",
";",
"// proper noun",
"}",
"else",
"if",
"(",
"postag",
".",
"equalsIgnoreCase",
"(",
"\"TO\"",
")",
"||",
"postag",
".",
"equalsIgnoreCase",
"(",
"\"IN\"",
")",
")",
"{",
"return",
"\"P\"",
";",
"// preposition",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"PRP\"",
")",
"||",
"postag",
".",
"startsWith",
"(",
"\"WP\"",
")",
")",
"{",
"return",
"\"Q\"",
";",
"// pronoun",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"V\"",
")",
")",
"{",
"return",
"\"V\"",
";",
"// verb",
"}",
"else",
"{",
"return",
"\"O\"",
";",
"// other",
"}",
"}"
] |
Mapping between Penn Treebank tagset and NAF tagset.
@param postag
treebank postag
@return NAF POS tag
|
[
"Mapping",
"between",
"Penn",
"Treebank",
"tagset",
"and",
"NAF",
"tagset",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/pos/TagSetMappingsToNAF.java#L124-L147
|
146,176
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/pos/TagSetMappingsToNAF.java
|
TagSetMappingsToNAF.mapSpanishAncoraTagSetToNAF
|
private static String mapSpanishAncoraTagSetToNAF(final String postag) {
if (postag.equalsIgnoreCase("RG") || postag.equalsIgnoreCase("RN")) {
return "A"; // adverb
} else if (postag.equalsIgnoreCase("CC") || postag.equalsIgnoreCase("CS")) {
return "C"; // conjunction
} else if (postag.startsWith("D")) {
return "D"; // det predeterminer
} else if (postag.startsWith("A")) {
return "G"; // adjective
} else if (postag.startsWith("NC")) {
return "N"; // common noun
} else if (postag.startsWith("NP")) {
return "R"; // proper noun
} else if (postag.startsWith("SP")) {
return "P"; // preposition
} else if (postag.startsWith("P")) {
return "Q"; // pronoun
} else if (postag.startsWith("V")) {
return "V"; // verb
} else {
return "O"; // other
}
}
|
java
|
private static String mapSpanishAncoraTagSetToNAF(final String postag) {
if (postag.equalsIgnoreCase("RG") || postag.equalsIgnoreCase("RN")) {
return "A"; // adverb
} else if (postag.equalsIgnoreCase("CC") || postag.equalsIgnoreCase("CS")) {
return "C"; // conjunction
} else if (postag.startsWith("D")) {
return "D"; // det predeterminer
} else if (postag.startsWith("A")) {
return "G"; // adjective
} else if (postag.startsWith("NC")) {
return "N"; // common noun
} else if (postag.startsWith("NP")) {
return "R"; // proper noun
} else if (postag.startsWith("SP")) {
return "P"; // preposition
} else if (postag.startsWith("P")) {
return "Q"; // pronoun
} else if (postag.startsWith("V")) {
return "V"; // verb
} else {
return "O"; // other
}
}
|
[
"private",
"static",
"String",
"mapSpanishAncoraTagSetToNAF",
"(",
"final",
"String",
"postag",
")",
"{",
"if",
"(",
"postag",
".",
"equalsIgnoreCase",
"(",
"\"RG\"",
")",
"||",
"postag",
".",
"equalsIgnoreCase",
"(",
"\"RN\"",
")",
")",
"{",
"return",
"\"A\"",
";",
"// adverb",
"}",
"else",
"if",
"(",
"postag",
".",
"equalsIgnoreCase",
"(",
"\"CC\"",
")",
"||",
"postag",
".",
"equalsIgnoreCase",
"(",
"\"CS\"",
")",
")",
"{",
"return",
"\"C\"",
";",
"// conjunction",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"D\"",
")",
")",
"{",
"return",
"\"D\"",
";",
"// det predeterminer",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"A\"",
")",
")",
"{",
"return",
"\"G\"",
";",
"// adjective",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"NC\"",
")",
")",
"{",
"return",
"\"N\"",
";",
"// common noun",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"NP\"",
")",
")",
"{",
"return",
"\"R\"",
";",
"// proper noun",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"SP\"",
")",
")",
"{",
"return",
"\"P\"",
";",
"// preposition",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"P\"",
")",
")",
"{",
"return",
"\"Q\"",
";",
"// pronoun",
"}",
"else",
"if",
"(",
"postag",
".",
"startsWith",
"(",
"\"V\"",
")",
")",
"{",
"return",
"\"V\"",
";",
"// verb",
"}",
"else",
"{",
"return",
"\"O\"",
";",
"// other",
"}",
"}"
] |
Mapping between EAGLES PAROLE Ancora tagset and NAF.
@param postag
the postag
@return the mapping to NAF pos tagset
|
[
"Mapping",
"between",
"EAGLES",
"PAROLE",
"Ancora",
"tagset",
"and",
"NAF",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/pos/TagSetMappingsToNAF.java#L156-L178
|
146,177
|
geomajas/geomajas-project-client-gwt2
|
plugin/editing/impl/src/main/java/org/geomajas/gwt2/plugin/editing/client/gfx/GeometryRendererImpl.java
|
GeometryRendererImpl.redraw
|
public void redraw() {
shapes.clear();
if (container != null) {
container.setTranslation(0, 0);
container.clear();
try {
tentativeMoveLine = new Path(-5, -5);
tentativeMoveLine.lineTo(-5, -5);
ShapeStyle style = styleProvider.getEdgeTentativeMoveStyle();
GeomajasImpl.getInstance().getGfxUtil().applyStyle(tentativeMoveLine, style);
container.add(tentativeMoveLine);
draw();
} catch (GeometryIndexNotFoundException e) {
// Happens when creating new geometries...can't render points that don't exist yet.
}
}
}
|
java
|
public void redraw() {
shapes.clear();
if (container != null) {
container.setTranslation(0, 0);
container.clear();
try {
tentativeMoveLine = new Path(-5, -5);
tentativeMoveLine.lineTo(-5, -5);
ShapeStyle style = styleProvider.getEdgeTentativeMoveStyle();
GeomajasImpl.getInstance().getGfxUtil().applyStyle(tentativeMoveLine, style);
container.add(tentativeMoveLine);
draw();
} catch (GeometryIndexNotFoundException e) {
// Happens when creating new geometries...can't render points that don't exist yet.
}
}
}
|
[
"public",
"void",
"redraw",
"(",
")",
"{",
"shapes",
".",
"clear",
"(",
")",
";",
"if",
"(",
"container",
"!=",
"null",
")",
"{",
"container",
".",
"setTranslation",
"(",
"0",
",",
"0",
")",
";",
"container",
".",
"clear",
"(",
")",
";",
"try",
"{",
"tentativeMoveLine",
"=",
"new",
"Path",
"(",
"-",
"5",
",",
"-",
"5",
")",
";",
"tentativeMoveLine",
".",
"lineTo",
"(",
"-",
"5",
",",
"-",
"5",
")",
";",
"ShapeStyle",
"style",
"=",
"styleProvider",
".",
"getEdgeTentativeMoveStyle",
"(",
")",
";",
"GeomajasImpl",
".",
"getInstance",
"(",
")",
".",
"getGfxUtil",
"(",
")",
".",
"applyStyle",
"(",
"tentativeMoveLine",
",",
"style",
")",
";",
"container",
".",
"add",
"(",
"tentativeMoveLine",
")",
";",
"draw",
"(",
")",
";",
"}",
"catch",
"(",
"GeometryIndexNotFoundException",
"e",
")",
"{",
"// Happens when creating new geometries...can't render points that don't exist yet.",
"}",
"}",
"}"
] |
Clear everything and completely redraw the edited geometry.
|
[
"Clear",
"everything",
"and",
"completely",
"redraw",
"the",
"edited",
"geometry",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/editing/impl/src/main/java/org/geomajas/gwt2/plugin/editing/client/gfx/GeometryRendererImpl.java#L159-L175
|
146,178
|
geomajas/geomajas-project-client-gwt2
|
plugin/editing/impl/src/main/java/org/geomajas/gwt2/plugin/editing/client/gfx/GeometryRendererImpl.java
|
GeometryRendererImpl.onGeometryEditStart
|
public void onGeometryEditStart(GeometryEditStartEvent event) {
if (container != null) {
mapPresenter.getContainerManager().removeVectorContainer(container);
}
container = mapPresenter.getContainerManager().addScreenContainer();
redraw();
}
|
java
|
public void onGeometryEditStart(GeometryEditStartEvent event) {
if (container != null) {
mapPresenter.getContainerManager().removeVectorContainer(container);
}
container = mapPresenter.getContainerManager().addScreenContainer();
redraw();
}
|
[
"public",
"void",
"onGeometryEditStart",
"(",
"GeometryEditStartEvent",
"event",
")",
"{",
"if",
"(",
"container",
"!=",
"null",
")",
"{",
"mapPresenter",
".",
"getContainerManager",
"(",
")",
".",
"removeVectorContainer",
"(",
"container",
")",
";",
"}",
"container",
"=",
"mapPresenter",
".",
"getContainerManager",
"(",
")",
".",
"addScreenContainer",
"(",
")",
";",
"redraw",
"(",
")",
";",
"}"
] |
Clean up the previous state, create a container to draw in and then draw the geometry.
|
[
"Clean",
"up",
"the",
"previous",
"state",
"create",
"a",
"container",
"to",
"draw",
"in",
"and",
"then",
"draw",
"the",
"geometry",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/editing/impl/src/main/java/org/geomajas/gwt2/plugin/editing/client/gfx/GeometryRendererImpl.java#L195-L201
|
146,179
|
geomajas/geomajas-project-client-gwt2
|
plugin/editing/impl/src/main/java/org/geomajas/gwt2/plugin/editing/client/gfx/GeometryRendererImpl.java
|
GeometryRendererImpl.onGeometryEditStop
|
public void onGeometryEditStop(GeometryEditStopEvent event) {
// Remove the vector container from the map:
mapPresenter.getContainerManager().removeVectorContainer(container);
container = null;
shapes.clear();
}
|
java
|
public void onGeometryEditStop(GeometryEditStopEvent event) {
// Remove the vector container from the map:
mapPresenter.getContainerManager().removeVectorContainer(container);
container = null;
shapes.clear();
}
|
[
"public",
"void",
"onGeometryEditStop",
"(",
"GeometryEditStopEvent",
"event",
")",
"{",
"// Remove the vector container from the map:",
"mapPresenter",
".",
"getContainerManager",
"(",
")",
".",
"removeVectorContainer",
"(",
"container",
")",
";",
"container",
"=",
"null",
";",
"shapes",
".",
"clear",
"(",
")",
";",
"}"
] |
Clean up all rendering.
|
[
"Clean",
"up",
"all",
"rendering",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/editing/impl/src/main/java/org/geomajas/gwt2/plugin/editing/client/gfx/GeometryRendererImpl.java#L206-L211
|
146,180
|
geomajas/geomajas-project-client-gwt2
|
plugin/editing/impl/src/main/java/org/geomajas/gwt2/plugin/editing/client/gfx/GeometryRendererImpl.java
|
GeometryRendererImpl.onChangeEditingState
|
public void onChangeEditingState(GeometryEditChangeStateEvent event) {
switch (event.getEditingState()) {
case DRAGGING:
mapPresenter.setCursor("move");
break;
case IDLE:
default:
mapPresenter.setCursor("default");
redraw();
}
}
|
java
|
public void onChangeEditingState(GeometryEditChangeStateEvent event) {
switch (event.getEditingState()) {
case DRAGGING:
mapPresenter.setCursor("move");
break;
case IDLE:
default:
mapPresenter.setCursor("default");
redraw();
}
}
|
[
"public",
"void",
"onChangeEditingState",
"(",
"GeometryEditChangeStateEvent",
"event",
")",
"{",
"switch",
"(",
"event",
".",
"getEditingState",
"(",
")",
")",
"{",
"case",
"DRAGGING",
":",
"mapPresenter",
".",
"setCursor",
"(",
"\"move\"",
")",
";",
"break",
";",
"case",
"IDLE",
":",
"default",
":",
"mapPresenter",
".",
"setCursor",
"(",
"\"default\"",
")",
";",
"redraw",
"(",
")",
";",
"}",
"}"
] |
Change the cursor while dragging.
|
[
"Change",
"the",
"cursor",
"while",
"dragging",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/editing/impl/src/main/java/org/geomajas/gwt2/plugin/editing/client/gfx/GeometryRendererImpl.java#L314-L324
|
146,181
|
geomajas/geomajas-project-client-gwt2
|
plugin/editing/impl/src/main/java/org/geomajas/gwt2/plugin/editing/client/gfx/GeometryRendererImpl.java
|
GeometryRendererImpl.onGeometryEditMove
|
public void onGeometryEditMove(GeometryEditMoveEvent event) {
// Find the elements that need updating:
Map<GeometryIndex, Boolean> indicesToUpdate = new HashMap<GeometryIndex, Boolean>();
for (GeometryIndex index : event.getIndices()) {
if (!indicesToUpdate.containsKey(index)) {
indicesToUpdate.put(index, false);
if (!Geometry.POINT.equals(editService.getGeometry().getGeometryType())
&& !Geometry.MULTI_POINT.equals(editService.getGeometry().getGeometryType())) {
try {
List<GeometryIndex> neighbors;
switch (editService.getIndexService().getType(index)) {
case TYPE_VERTEX:
// Move current vertex to the back. This helps the delete operation.
indicesToUpdate.put(index, true);
neighbors = editService.getIndexService().getAdjacentEdges(event.getGeometry(), index);
if (neighbors != null) {
for (GeometryIndex neighborIndex : neighbors) {
if (!indicesToUpdate.containsKey(neighborIndex)) {
indicesToUpdate.put(neighborIndex, false);
}
}
}
neighbors = editService.getIndexService().getAdjacentVertices(event.getGeometry(),
index);
if (neighbors != null) {
for (GeometryIndex neighborIndex : neighbors) {
if (!indicesToUpdate.containsKey(neighborIndex)) {
indicesToUpdate.put(neighborIndex, false);
}
}
}
break;
case TYPE_EDGE:
neighbors = editService.getIndexService().getAdjacentVertices(event.getGeometry(),
index);
if (neighbors != null) {
for (GeometryIndex neighborIndex : neighbors) {
if (!indicesToUpdate.containsKey(neighborIndex)) {
indicesToUpdate.put(neighborIndex, false);
}
}
}
break;
default:
}
} catch (GeometryIndexNotFoundException e) {
throw new IllegalStateException(e);
}
}
}
}
// Check if we need to draw the background (nice, but slows down):
if (styleProvider.getBackgroundStyle() != null && styleProvider.getBackgroundStyle().getFillOpacity() > 0) {
if (event.getGeometry().getGeometryType().equals(Geometry.POLYGON)) {
update(null, false);
} else if (event.getGeometry().getGeometryType().equals(Geometry.MULTI_POLYGON)
&& event.getGeometry().getGeometries() != null) {
for (int i = 0; i < event.getGeometry().getGeometries().length; i++) {
GeometryIndex index = editService.getIndexService().create(GeometryIndexType.TYPE_GEOMETRY, i);
indicesToUpdate.put(index, false);
}
}
}
// Next, redraw the list:
for (GeometryIndex index : indicesToUpdate.keySet()) {
update(index, indicesToUpdate.get(index));
}
}
|
java
|
public void onGeometryEditMove(GeometryEditMoveEvent event) {
// Find the elements that need updating:
Map<GeometryIndex, Boolean> indicesToUpdate = new HashMap<GeometryIndex, Boolean>();
for (GeometryIndex index : event.getIndices()) {
if (!indicesToUpdate.containsKey(index)) {
indicesToUpdate.put(index, false);
if (!Geometry.POINT.equals(editService.getGeometry().getGeometryType())
&& !Geometry.MULTI_POINT.equals(editService.getGeometry().getGeometryType())) {
try {
List<GeometryIndex> neighbors;
switch (editService.getIndexService().getType(index)) {
case TYPE_VERTEX:
// Move current vertex to the back. This helps the delete operation.
indicesToUpdate.put(index, true);
neighbors = editService.getIndexService().getAdjacentEdges(event.getGeometry(), index);
if (neighbors != null) {
for (GeometryIndex neighborIndex : neighbors) {
if (!indicesToUpdate.containsKey(neighborIndex)) {
indicesToUpdate.put(neighborIndex, false);
}
}
}
neighbors = editService.getIndexService().getAdjacentVertices(event.getGeometry(),
index);
if (neighbors != null) {
for (GeometryIndex neighborIndex : neighbors) {
if (!indicesToUpdate.containsKey(neighborIndex)) {
indicesToUpdate.put(neighborIndex, false);
}
}
}
break;
case TYPE_EDGE:
neighbors = editService.getIndexService().getAdjacentVertices(event.getGeometry(),
index);
if (neighbors != null) {
for (GeometryIndex neighborIndex : neighbors) {
if (!indicesToUpdate.containsKey(neighborIndex)) {
indicesToUpdate.put(neighborIndex, false);
}
}
}
break;
default:
}
} catch (GeometryIndexNotFoundException e) {
throw new IllegalStateException(e);
}
}
}
}
// Check if we need to draw the background (nice, but slows down):
if (styleProvider.getBackgroundStyle() != null && styleProvider.getBackgroundStyle().getFillOpacity() > 0) {
if (event.getGeometry().getGeometryType().equals(Geometry.POLYGON)) {
update(null, false);
} else if (event.getGeometry().getGeometryType().equals(Geometry.MULTI_POLYGON)
&& event.getGeometry().getGeometries() != null) {
for (int i = 0; i < event.getGeometry().getGeometries().length; i++) {
GeometryIndex index = editService.getIndexService().create(GeometryIndexType.TYPE_GEOMETRY, i);
indicesToUpdate.put(index, false);
}
}
}
// Next, redraw the list:
for (GeometryIndex index : indicesToUpdate.keySet()) {
update(index, indicesToUpdate.get(index));
}
}
|
[
"public",
"void",
"onGeometryEditMove",
"(",
"GeometryEditMoveEvent",
"event",
")",
"{",
"// Find the elements that need updating:",
"Map",
"<",
"GeometryIndex",
",",
"Boolean",
">",
"indicesToUpdate",
"=",
"new",
"HashMap",
"<",
"GeometryIndex",
",",
"Boolean",
">",
"(",
")",
";",
"for",
"(",
"GeometryIndex",
"index",
":",
"event",
".",
"getIndices",
"(",
")",
")",
"{",
"if",
"(",
"!",
"indicesToUpdate",
".",
"containsKey",
"(",
"index",
")",
")",
"{",
"indicesToUpdate",
".",
"put",
"(",
"index",
",",
"false",
")",
";",
"if",
"(",
"!",
"Geometry",
".",
"POINT",
".",
"equals",
"(",
"editService",
".",
"getGeometry",
"(",
")",
".",
"getGeometryType",
"(",
")",
")",
"&&",
"!",
"Geometry",
".",
"MULTI_POINT",
".",
"equals",
"(",
"editService",
".",
"getGeometry",
"(",
")",
".",
"getGeometryType",
"(",
")",
")",
")",
"{",
"try",
"{",
"List",
"<",
"GeometryIndex",
">",
"neighbors",
";",
"switch",
"(",
"editService",
".",
"getIndexService",
"(",
")",
".",
"getType",
"(",
"index",
")",
")",
"{",
"case",
"TYPE_VERTEX",
":",
"// Move current vertex to the back. This helps the delete operation.",
"indicesToUpdate",
".",
"put",
"(",
"index",
",",
"true",
")",
";",
"neighbors",
"=",
"editService",
".",
"getIndexService",
"(",
")",
".",
"getAdjacentEdges",
"(",
"event",
".",
"getGeometry",
"(",
")",
",",
"index",
")",
";",
"if",
"(",
"neighbors",
"!=",
"null",
")",
"{",
"for",
"(",
"GeometryIndex",
"neighborIndex",
":",
"neighbors",
")",
"{",
"if",
"(",
"!",
"indicesToUpdate",
".",
"containsKey",
"(",
"neighborIndex",
")",
")",
"{",
"indicesToUpdate",
".",
"put",
"(",
"neighborIndex",
",",
"false",
")",
";",
"}",
"}",
"}",
"neighbors",
"=",
"editService",
".",
"getIndexService",
"(",
")",
".",
"getAdjacentVertices",
"(",
"event",
".",
"getGeometry",
"(",
")",
",",
"index",
")",
";",
"if",
"(",
"neighbors",
"!=",
"null",
")",
"{",
"for",
"(",
"GeometryIndex",
"neighborIndex",
":",
"neighbors",
")",
"{",
"if",
"(",
"!",
"indicesToUpdate",
".",
"containsKey",
"(",
"neighborIndex",
")",
")",
"{",
"indicesToUpdate",
".",
"put",
"(",
"neighborIndex",
",",
"false",
")",
";",
"}",
"}",
"}",
"break",
";",
"case",
"TYPE_EDGE",
":",
"neighbors",
"=",
"editService",
".",
"getIndexService",
"(",
")",
".",
"getAdjacentVertices",
"(",
"event",
".",
"getGeometry",
"(",
")",
",",
"index",
")",
";",
"if",
"(",
"neighbors",
"!=",
"null",
")",
"{",
"for",
"(",
"GeometryIndex",
"neighborIndex",
":",
"neighbors",
")",
"{",
"if",
"(",
"!",
"indicesToUpdate",
".",
"containsKey",
"(",
"neighborIndex",
")",
")",
"{",
"indicesToUpdate",
".",
"put",
"(",
"neighborIndex",
",",
"false",
")",
";",
"}",
"}",
"}",
"break",
";",
"default",
":",
"}",
"}",
"catch",
"(",
"GeometryIndexNotFoundException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}",
"}",
"}",
"// Check if we need to draw the background (nice, but slows down):",
"if",
"(",
"styleProvider",
".",
"getBackgroundStyle",
"(",
")",
"!=",
"null",
"&&",
"styleProvider",
".",
"getBackgroundStyle",
"(",
")",
".",
"getFillOpacity",
"(",
")",
">",
"0",
")",
"{",
"if",
"(",
"event",
".",
"getGeometry",
"(",
")",
".",
"getGeometryType",
"(",
")",
".",
"equals",
"(",
"Geometry",
".",
"POLYGON",
")",
")",
"{",
"update",
"(",
"null",
",",
"false",
")",
";",
"}",
"else",
"if",
"(",
"event",
".",
"getGeometry",
"(",
")",
".",
"getGeometryType",
"(",
")",
".",
"equals",
"(",
"Geometry",
".",
"MULTI_POLYGON",
")",
"&&",
"event",
".",
"getGeometry",
"(",
")",
".",
"getGeometries",
"(",
")",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"event",
".",
"getGeometry",
"(",
")",
".",
"getGeometries",
"(",
")",
".",
"length",
";",
"i",
"++",
")",
"{",
"GeometryIndex",
"index",
"=",
"editService",
".",
"getIndexService",
"(",
")",
".",
"create",
"(",
"GeometryIndexType",
".",
"TYPE_GEOMETRY",
",",
"i",
")",
";",
"indicesToUpdate",
".",
"put",
"(",
"index",
",",
"false",
")",
";",
"}",
"}",
"}",
"// Next, redraw the list:",
"for",
"(",
"GeometryIndex",
"index",
":",
"indicesToUpdate",
".",
"keySet",
"(",
")",
")",
"{",
"update",
"(",
"index",
",",
"indicesToUpdate",
".",
"get",
"(",
"index",
")",
")",
";",
"}",
"}"
] |
Figure out what's being moved and update only adjacent objects. This is far more performing than simply redrawing
everything.
|
[
"Figure",
"out",
"what",
"s",
"being",
"moved",
"and",
"update",
"only",
"adjacent",
"objects",
".",
"This",
"is",
"far",
"more",
"performing",
"than",
"simply",
"redrawing",
"everything",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/editing/impl/src/main/java/org/geomajas/gwt2/plugin/editing/client/gfx/GeometryRendererImpl.java#L341-L411
|
146,182
|
geomajas/geomajas-project-client-gwt2
|
plugin/editing/impl/src/main/java/org/geomajas/gwt2/plugin/editing/client/gfx/GeometryRendererImpl.java
|
GeometryRendererImpl.onTentativeMove
|
public void onTentativeMove(GeometryEditTentativeMoveEvent event) {
try {
Coordinate[] vertices = editService.getIndexService().getSiblingVertices(editService.getGeometry(),
editService.getInsertIndex());
String geometryType = editService.getIndexService().getGeometryType(editService.getGeometry(),
editService.getInsertIndex());
if (vertices != null
&& (Geometry.LINE_STRING.equals(geometryType) || Geometry.LINEAR_RING.equals(geometryType))) {
Coordinate temp1 = event.getOrigin();
Coordinate temp2 = event.getCurrentPosition();
Coordinate c1 = mapPresenter.getViewPort().getTransformationService()
.transform(temp1, RenderSpace.WORLD, RenderSpace.SCREEN);
Coordinate c2 = mapPresenter.getViewPort().getTransformationService()
.transform(temp2, RenderSpace.WORLD, RenderSpace.SCREEN);
tentativeMoveLine.setStep(0, new MoveTo(false, c1.getX(), c1.getY()));
tentativeMoveLine.setStep(1, new LineTo(false, c2.getX(), c2.getY()));
} else if (vertices != null && Geometry.LINEAR_RING.equals(geometryType)) {
// Draw the second line (as an option...)
}
} catch (GeometryIndexNotFoundException e) {
throw new IllegalStateException(e);
}
}
|
java
|
public void onTentativeMove(GeometryEditTentativeMoveEvent event) {
try {
Coordinate[] vertices = editService.getIndexService().getSiblingVertices(editService.getGeometry(),
editService.getInsertIndex());
String geometryType = editService.getIndexService().getGeometryType(editService.getGeometry(),
editService.getInsertIndex());
if (vertices != null
&& (Geometry.LINE_STRING.equals(geometryType) || Geometry.LINEAR_RING.equals(geometryType))) {
Coordinate temp1 = event.getOrigin();
Coordinate temp2 = event.getCurrentPosition();
Coordinate c1 = mapPresenter.getViewPort().getTransformationService()
.transform(temp1, RenderSpace.WORLD, RenderSpace.SCREEN);
Coordinate c2 = mapPresenter.getViewPort().getTransformationService()
.transform(temp2, RenderSpace.WORLD, RenderSpace.SCREEN);
tentativeMoveLine.setStep(0, new MoveTo(false, c1.getX(), c1.getY()));
tentativeMoveLine.setStep(1, new LineTo(false, c2.getX(), c2.getY()));
} else if (vertices != null && Geometry.LINEAR_RING.equals(geometryType)) {
// Draw the second line (as an option...)
}
} catch (GeometryIndexNotFoundException e) {
throw new IllegalStateException(e);
}
}
|
[
"public",
"void",
"onTentativeMove",
"(",
"GeometryEditTentativeMoveEvent",
"event",
")",
"{",
"try",
"{",
"Coordinate",
"[",
"]",
"vertices",
"=",
"editService",
".",
"getIndexService",
"(",
")",
".",
"getSiblingVertices",
"(",
"editService",
".",
"getGeometry",
"(",
")",
",",
"editService",
".",
"getInsertIndex",
"(",
")",
")",
";",
"String",
"geometryType",
"=",
"editService",
".",
"getIndexService",
"(",
")",
".",
"getGeometryType",
"(",
"editService",
".",
"getGeometry",
"(",
")",
",",
"editService",
".",
"getInsertIndex",
"(",
")",
")",
";",
"if",
"(",
"vertices",
"!=",
"null",
"&&",
"(",
"Geometry",
".",
"LINE_STRING",
".",
"equals",
"(",
"geometryType",
")",
"||",
"Geometry",
".",
"LINEAR_RING",
".",
"equals",
"(",
"geometryType",
")",
")",
")",
"{",
"Coordinate",
"temp1",
"=",
"event",
".",
"getOrigin",
"(",
")",
";",
"Coordinate",
"temp2",
"=",
"event",
".",
"getCurrentPosition",
"(",
")",
";",
"Coordinate",
"c1",
"=",
"mapPresenter",
".",
"getViewPort",
"(",
")",
".",
"getTransformationService",
"(",
")",
".",
"transform",
"(",
"temp1",
",",
"RenderSpace",
".",
"WORLD",
",",
"RenderSpace",
".",
"SCREEN",
")",
";",
"Coordinate",
"c2",
"=",
"mapPresenter",
".",
"getViewPort",
"(",
")",
".",
"getTransformationService",
"(",
")",
".",
"transform",
"(",
"temp2",
",",
"RenderSpace",
".",
"WORLD",
",",
"RenderSpace",
".",
"SCREEN",
")",
";",
"tentativeMoveLine",
".",
"setStep",
"(",
"0",
",",
"new",
"MoveTo",
"(",
"false",
",",
"c1",
".",
"getX",
"(",
")",
",",
"c1",
".",
"getY",
"(",
")",
")",
")",
";",
"tentativeMoveLine",
".",
"setStep",
"(",
"1",
",",
"new",
"LineTo",
"(",
"false",
",",
"c2",
".",
"getX",
"(",
")",
",",
"c2",
".",
"getY",
"(",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"vertices",
"!=",
"null",
"&&",
"Geometry",
".",
"LINEAR_RING",
".",
"equals",
"(",
"geometryType",
")",
")",
"{",
"// Draw the second line (as an option...)",
"}",
"}",
"catch",
"(",
"GeometryIndexNotFoundException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}"
] |
Renders a line from the last inserted point to the current mouse position, indicating what the new situation
would look like if a vertex where to be inserted at the mouse location.
|
[
"Renders",
"a",
"line",
"from",
"the",
"last",
"inserted",
"point",
"to",
"the",
"current",
"mouse",
"position",
"indicating",
"what",
"the",
"new",
"situation",
"would",
"look",
"like",
"if",
"a",
"vertex",
"where",
"to",
"be",
"inserted",
"at",
"the",
"mouse",
"location",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/editing/impl/src/main/java/org/geomajas/gwt2/plugin/editing/client/gfx/GeometryRendererImpl.java#L417-L441
|
146,183
|
geomajas/geomajas-project-client-gwt2
|
plugin/wms/wms/src/main/java/org/geomajas/gwt2/plugin/wms/client/controller/WmsGetFeatureInfoController.java
|
WmsGetFeatureInfoController.onMouseUp
|
public void onMouseUp(MouseUpEvent event) {
// Do not interfere with default behaviour:
super.onMouseUp(event);
// Get the event location in world space:
Coordinate worldLocation = getLocation(event, RenderSpace.WORLD);
// Now execute the GetFeatureInfo for each layer:
for (FeatureInfoSupported layer : layers) {
GetFeatureInfoFormat f = GetFeatureInfoFormat.fromFormat(format);
if (f != null) {
switch (f) {
case GML2:
case GML3:
case JSON:
if (featureCallback == null) {
throw new IllegalStateException(
"No callback has been set on the WmsGetFeatureInfoController");
}
layer.getFeatureInfo(worldLocation, format, featureCallback);
break;
case HTML:
case TEXT:
default:
if (htmlCallback == null) {
throw new IllegalStateException(
"No callback has been set on the WmsGetFeatureInfoController");
}
htmlCallback.onSuccess(layer.getFeatureInfoUrl(worldLocation, format));
break;
}
}
}
}
|
java
|
public void onMouseUp(MouseUpEvent event) {
// Do not interfere with default behaviour:
super.onMouseUp(event);
// Get the event location in world space:
Coordinate worldLocation = getLocation(event, RenderSpace.WORLD);
// Now execute the GetFeatureInfo for each layer:
for (FeatureInfoSupported layer : layers) {
GetFeatureInfoFormat f = GetFeatureInfoFormat.fromFormat(format);
if (f != null) {
switch (f) {
case GML2:
case GML3:
case JSON:
if (featureCallback == null) {
throw new IllegalStateException(
"No callback has been set on the WmsGetFeatureInfoController");
}
layer.getFeatureInfo(worldLocation, format, featureCallback);
break;
case HTML:
case TEXT:
default:
if (htmlCallback == null) {
throw new IllegalStateException(
"No callback has been set on the WmsGetFeatureInfoController");
}
htmlCallback.onSuccess(layer.getFeatureInfoUrl(worldLocation, format));
break;
}
}
}
}
|
[
"public",
"void",
"onMouseUp",
"(",
"MouseUpEvent",
"event",
")",
"{",
"// Do not interfere with default behaviour:",
"super",
".",
"onMouseUp",
"(",
"event",
")",
";",
"// Get the event location in world space:",
"Coordinate",
"worldLocation",
"=",
"getLocation",
"(",
"event",
",",
"RenderSpace",
".",
"WORLD",
")",
";",
"// Now execute the GetFeatureInfo for each layer:",
"for",
"(",
"FeatureInfoSupported",
"layer",
":",
"layers",
")",
"{",
"GetFeatureInfoFormat",
"f",
"=",
"GetFeatureInfoFormat",
".",
"fromFormat",
"(",
"format",
")",
";",
"if",
"(",
"f",
"!=",
"null",
")",
"{",
"switch",
"(",
"f",
")",
"{",
"case",
"GML2",
":",
"case",
"GML3",
":",
"case",
"JSON",
":",
"if",
"(",
"featureCallback",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"No callback has been set on the WmsGetFeatureInfoController\"",
")",
";",
"}",
"layer",
".",
"getFeatureInfo",
"(",
"worldLocation",
",",
"format",
",",
"featureCallback",
")",
";",
"break",
";",
"case",
"HTML",
":",
"case",
"TEXT",
":",
"default",
":",
"if",
"(",
"htmlCallback",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"No callback has been set on the WmsGetFeatureInfoController\"",
")",
";",
"}",
"htmlCallback",
".",
"onSuccess",
"(",
"layer",
".",
"getFeatureInfoUrl",
"(",
"worldLocation",
",",
"format",
")",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] |
Execute a GetFeatureInfo on mouse up.
|
[
"Execute",
"a",
"GetFeatureInfo",
"on",
"mouse",
"up",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/wms/wms/src/main/java/org/geomajas/gwt2/plugin/wms/client/controller/WmsGetFeatureInfoController.java#L75-L109
|
146,184
|
kcthota/JSONQuery
|
src/main/java/com/kcthota/JSONQuery/Query.java
|
Query.is
|
public boolean is(ComparisonExpression expr) {
try {
if (expr != null) {
return expr.evaluate(node);
}
} catch (MissingNodeException e) {
return false;
}
return false;
}
|
java
|
public boolean is(ComparisonExpression expr) {
try {
if (expr != null) {
return expr.evaluate(node);
}
} catch (MissingNodeException e) {
return false;
}
return false;
}
|
[
"public",
"boolean",
"is",
"(",
"ComparisonExpression",
"expr",
")",
"{",
"try",
"{",
"if",
"(",
"expr",
"!=",
"null",
")",
"{",
"return",
"expr",
".",
"evaluate",
"(",
"node",
")",
";",
"}",
"}",
"catch",
"(",
"MissingNodeException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"false",
";",
"}"
] |
Verifies if the passed expression is true for the JsonNode
@param expr
Comparison expression to be evaluated
@return returns if the expression is true for the JsonNode
|
[
"Verifies",
"if",
"the",
"passed",
"expression",
"is",
"true",
"for",
"the",
"JsonNode"
] |
190f8fbcd05d42cfda265ecd8ce4ced192d57c16
|
https://github.com/kcthota/JSONQuery/blob/190f8fbcd05d42cfda265ecd8ce4ced192d57c16/src/main/java/com/kcthota/JSONQuery/Query.java#L53-L63
|
146,185
|
kcthota/JSONQuery
|
src/main/java/com/kcthota/JSONQuery/Query.java
|
Query.isExist
|
public boolean isExist(String property) {
try {
new ValueExpression(property).evaluate(node);
} catch (MissingNodeException e) {
return false;
}
return true;
}
|
java
|
public boolean isExist(String property) {
try {
new ValueExpression(property).evaluate(node);
} catch (MissingNodeException e) {
return false;
}
return true;
}
|
[
"public",
"boolean",
"isExist",
"(",
"String",
"property",
")",
"{",
"try",
"{",
"new",
"ValueExpression",
"(",
"property",
")",
".",
"evaluate",
"(",
"node",
")",
";",
"}",
"catch",
"(",
"MissingNodeException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Checks if property exist in the JsonNode
@param property
JSON property
@return Returns the value for the passed property
|
[
"Checks",
"if",
"property",
"exist",
"in",
"the",
"JsonNode"
] |
190f8fbcd05d42cfda265ecd8ce4ced192d57c16
|
https://github.com/kcthota/JSONQuery/blob/190f8fbcd05d42cfda265ecd8ce4ced192d57c16/src/main/java/com/kcthota/JSONQuery/Query.java#L124-L131
|
146,186
|
kcthota/JSONQuery
|
src/main/java/com/kcthota/JSONQuery/Query.java
|
Query.filter
|
public ArrayNode filter(ComparisonExpression expression) {
ArrayNode result = new ObjectMapper().createArrayNode();
if (node.isArray()) {
Iterator<JsonNode> iterator = node.iterator();
int validObjectsCount = 0;
int topCount=0;
while (iterator.hasNext()) {
JsonNode curNode = iterator.next();
if (expression==null || (expression!=null && new Query(curNode).is(expression))) {
validObjectsCount++;
if (this.skip != null && this.skip.intValue() > 0 && this.skip.intValue() >= validObjectsCount) {
continue;
}
if (this.top != null && topCount >= this.top.intValue()) {
break;
}
result.add(curNode);
topCount++;
}
}
} else {
throw new UnsupportedExprException("Filters are only supported on ArrayNode objects");
}
return result;
}
|
java
|
public ArrayNode filter(ComparisonExpression expression) {
ArrayNode result = new ObjectMapper().createArrayNode();
if (node.isArray()) {
Iterator<JsonNode> iterator = node.iterator();
int validObjectsCount = 0;
int topCount=0;
while (iterator.hasNext()) {
JsonNode curNode = iterator.next();
if (expression==null || (expression!=null && new Query(curNode).is(expression))) {
validObjectsCount++;
if (this.skip != null && this.skip.intValue() > 0 && this.skip.intValue() >= validObjectsCount) {
continue;
}
if (this.top != null && topCount >= this.top.intValue()) {
break;
}
result.add(curNode);
topCount++;
}
}
} else {
throw new UnsupportedExprException("Filters are only supported on ArrayNode objects");
}
return result;
}
|
[
"public",
"ArrayNode",
"filter",
"(",
"ComparisonExpression",
"expression",
")",
"{",
"ArrayNode",
"result",
"=",
"new",
"ObjectMapper",
"(",
")",
".",
"createArrayNode",
"(",
")",
";",
"if",
"(",
"node",
".",
"isArray",
"(",
")",
")",
"{",
"Iterator",
"<",
"JsonNode",
">",
"iterator",
"=",
"node",
".",
"iterator",
"(",
")",
";",
"int",
"validObjectsCount",
"=",
"0",
";",
"int",
"topCount",
"=",
"0",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"JsonNode",
"curNode",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"expression",
"==",
"null",
"||",
"(",
"expression",
"!=",
"null",
"&&",
"new",
"Query",
"(",
"curNode",
")",
".",
"is",
"(",
"expression",
")",
")",
")",
"{",
"validObjectsCount",
"++",
";",
"if",
"(",
"this",
".",
"skip",
"!=",
"null",
"&&",
"this",
".",
"skip",
".",
"intValue",
"(",
")",
">",
"0",
"&&",
"this",
".",
"skip",
".",
"intValue",
"(",
")",
">=",
"validObjectsCount",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"this",
".",
"top",
"!=",
"null",
"&&",
"topCount",
">=",
"this",
".",
"top",
".",
"intValue",
"(",
")",
")",
"{",
"break",
";",
"}",
"result",
".",
"add",
"(",
"curNode",
")",
";",
"topCount",
"++",
";",
"}",
"}",
"}",
"else",
"{",
"throw",
"new",
"UnsupportedExprException",
"(",
"\"Filters are only supported on ArrayNode objects\"",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Allows filtering values in a ArrayNode as per passed ComparisonExpression
@param expression
@return
|
[
"Allows",
"filtering",
"values",
"in",
"a",
"ArrayNode",
"as",
"per",
"passed",
"ComparisonExpression"
] |
190f8fbcd05d42cfda265ecd8ce4ced192d57c16
|
https://github.com/kcthota/JSONQuery/blob/190f8fbcd05d42cfda265ecd8ce4ced192d57c16/src/main/java/com/kcthota/JSONQuery/Query.java#L139-L165
|
146,187
|
kcthota/JSONQuery
|
src/main/java/com/kcthota/JSONQuery/Query.java
|
Query.filter
|
public ArrayNode filter(String property, ComparisonExpression expression) {
JsonNode propValueNode = this.value(property);
return Query.q(propValueNode).top(this.getTop()).skip(this.getSkip()).filter(expression);
}
|
java
|
public ArrayNode filter(String property, ComparisonExpression expression) {
JsonNode propValueNode = this.value(property);
return Query.q(propValueNode).top(this.getTop()).skip(this.getSkip()).filter(expression);
}
|
[
"public",
"ArrayNode",
"filter",
"(",
"String",
"property",
",",
"ComparisonExpression",
"expression",
")",
"{",
"JsonNode",
"propValueNode",
"=",
"this",
".",
"value",
"(",
"property",
")",
";",
"return",
"Query",
".",
"q",
"(",
"propValueNode",
")",
".",
"top",
"(",
"this",
".",
"getTop",
"(",
")",
")",
".",
"skip",
"(",
"this",
".",
"getSkip",
"(",
")",
")",
".",
"filter",
"(",
"expression",
")",
";",
"}"
] |
Allows applying filter on a property value, which is ArrayNode, as per
passed ComparisonExpression
@param property
@param expression
@return
|
[
"Allows",
"applying",
"filter",
"on",
"a",
"property",
"value",
"which",
"is",
"ArrayNode",
"as",
"per",
"passed",
"ComparisonExpression"
] |
190f8fbcd05d42cfda265ecd8ce4ced192d57c16
|
https://github.com/kcthota/JSONQuery/blob/190f8fbcd05d42cfda265ecd8ce4ced192d57c16/src/main/java/com/kcthota/JSONQuery/Query.java#L175-L178
|
146,188
|
astrapi69/jaulp-wicket
|
jaulp-wicket-behaviors/src/main/java/de/alpharogroup/wicket/behaviors/animations/Animate.java
|
Animate.slideUpAndDown
|
public static void slideUpAndDown(final Component component, final AjaxRequestTarget target,
int slideUpDuration, int slideDownDuration)
{
component.add(new DisplayNoneBehavior());
target.prependJavaScript("notify|jQuery('#" + component.getMarkupId() + "').slideUp("
+ slideUpDuration + ", notify);");
target.add(component);
target.appendJavaScript(
"jQuery('#" + component.getMarkupId() + "').slideDown(" + slideDownDuration + ");");
}
|
java
|
public static void slideUpAndDown(final Component component, final AjaxRequestTarget target,
int slideUpDuration, int slideDownDuration)
{
component.add(new DisplayNoneBehavior());
target.prependJavaScript("notify|jQuery('#" + component.getMarkupId() + "').slideUp("
+ slideUpDuration + ", notify);");
target.add(component);
target.appendJavaScript(
"jQuery('#" + component.getMarkupId() + "').slideDown(" + slideDownDuration + ");");
}
|
[
"public",
"static",
"void",
"slideUpAndDown",
"(",
"final",
"Component",
"component",
",",
"final",
"AjaxRequestTarget",
"target",
",",
"int",
"slideUpDuration",
",",
"int",
"slideDownDuration",
")",
"{",
"component",
".",
"add",
"(",
"new",
"DisplayNoneBehavior",
"(",
")",
")",
";",
"target",
".",
"prependJavaScript",
"(",
"\"notify|jQuery('#\"",
"+",
"component",
".",
"getMarkupId",
"(",
")",
"+",
"\"').slideUp(\"",
"+",
"slideUpDuration",
"+",
"\", notify);\"",
")",
";",
"target",
".",
"add",
"(",
"component",
")",
";",
"target",
".",
"appendJavaScript",
"(",
"\"jQuery('#\"",
"+",
"component",
".",
"getMarkupId",
"(",
")",
"+",
"\"').slideDown(\"",
"+",
"slideDownDuration",
"+",
"\");\"",
")",
";",
"}"
] |
Replace the given component with animation.
@param target
the target
@param component
the component
@param slideUpDuration
the slide up duration
@param slideDownDuration
the slide down duration
|
[
"Replace",
"the",
"given",
"component",
"with",
"animation",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-behaviors/src/main/java/de/alpharogroup/wicket/behaviors/animations/Animate.java#L54-L63
|
146,189
|
nohana/Amalgam
|
amalgam/src/main/java/com/amalgam/app/ApplicationUtils.java
|
ApplicationUtils.isDebuggable
|
public static boolean isDebuggable(Application app) {
ApplicationInfo info = app.getApplicationInfo();
return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
}
|
java
|
public static boolean isDebuggable(Application app) {
ApplicationInfo info = app.getApplicationInfo();
return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
}
|
[
"public",
"static",
"boolean",
"isDebuggable",
"(",
"Application",
"app",
")",
"{",
"ApplicationInfo",
"info",
"=",
"app",
".",
"getApplicationInfo",
"(",
")",
";",
"return",
"(",
"info",
".",
"flags",
"&",
"ApplicationInfo",
".",
"FLAG_DEBUGGABLE",
")",
"!=",
"0",
";",
"}"
] |
Checks if the application is running as debug mode or not.
@param app the application to check
@return true if debuggable, false otherwise.
|
[
"Checks",
"if",
"the",
"application",
"is",
"running",
"as",
"debug",
"mode",
"or",
"not",
"."
] |
57809ddbfe7897e979cf507982ce0b3aa5e0ed8a
|
https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/app/ApplicationUtils.java#L58-L61
|
146,190
|
nohana/Amalgam
|
amalgam/src/main/java/com/amalgam/app/ApplicationUtils.java
|
ApplicationUtils.isInstalledOnSDCard
|
public static boolean isInstalledOnSDCard(Application app) {
try {
String packageName = app.getPackageName();
PackageInfo info = app.getPackageManager().getPackageInfo(packageName, 0);
String dir = info.applicationInfo.sourceDir;
for (String path : INTERNAL_PATH) {
if (path.equals(dir.substring(0, path.length())))
return false;
}
} catch (PackageManager.NameNotFoundException exp) {
throw new IllegalArgumentException(exp);
}
return true;
}
|
java
|
public static boolean isInstalledOnSDCard(Application app) {
try {
String packageName = app.getPackageName();
PackageInfo info = app.getPackageManager().getPackageInfo(packageName, 0);
String dir = info.applicationInfo.sourceDir;
for (String path : INTERNAL_PATH) {
if (path.equals(dir.substring(0, path.length())))
return false;
}
} catch (PackageManager.NameNotFoundException exp) {
throw new IllegalArgumentException(exp);
}
return true;
}
|
[
"public",
"static",
"boolean",
"isInstalledOnSDCard",
"(",
"Application",
"app",
")",
"{",
"try",
"{",
"String",
"packageName",
"=",
"app",
".",
"getPackageName",
"(",
")",
";",
"PackageInfo",
"info",
"=",
"app",
".",
"getPackageManager",
"(",
")",
".",
"getPackageInfo",
"(",
"packageName",
",",
"0",
")",
";",
"String",
"dir",
"=",
"info",
".",
"applicationInfo",
".",
"sourceDir",
";",
"for",
"(",
"String",
"path",
":",
"INTERNAL_PATH",
")",
"{",
"if",
"(",
"path",
".",
"equals",
"(",
"dir",
".",
"substring",
"(",
"0",
",",
"path",
".",
"length",
"(",
")",
")",
")",
")",
"return",
"false",
";",
"}",
"}",
"catch",
"(",
"PackageManager",
".",
"NameNotFoundException",
"exp",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"exp",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Checks if the application is installed on external storage, in most case on the SD card.
@param app the application to check.
@return true if the application is installed on external storage, false otherwise.
|
[
"Checks",
"if",
"the",
"application",
"is",
"installed",
"on",
"external",
"storage",
"in",
"most",
"case",
"on",
"the",
"SD",
"card",
"."
] |
57809ddbfe7897e979cf507982ce0b3aa5e0ed8a
|
https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/app/ApplicationUtils.java#L77-L91
|
146,191
|
geomajas/geomajas-project-client-gwt2
|
plugin/corewidget/corewidget/src/main/java/org/geomajas/gwt2/plugin/corewidget/client/feature/featureinfo/builder/AttributeWidgetFactory.java
|
AttributeWidgetFactory.removeAttributeBuilder
|
public void removeAttributeBuilder(AttributeWidgetBuilder<?> builder) {
Iterator<AttributeWidgetBuilder<?>> iterator = builders.values().iterator();
while (iterator.hasNext()) {
AttributeWidgetBuilder<?> widgetBuilder = iterator.next();
if (widgetBuilder.equals(builder)) {
iterator.remove();
}
}
}
|
java
|
public void removeAttributeBuilder(AttributeWidgetBuilder<?> builder) {
Iterator<AttributeWidgetBuilder<?>> iterator = builders.values().iterator();
while (iterator.hasNext()) {
AttributeWidgetBuilder<?> widgetBuilder = iterator.next();
if (widgetBuilder.equals(builder)) {
iterator.remove();
}
}
}
|
[
"public",
"void",
"removeAttributeBuilder",
"(",
"AttributeWidgetBuilder",
"<",
"?",
">",
"builder",
")",
"{",
"Iterator",
"<",
"AttributeWidgetBuilder",
"<",
"?",
">",
">",
"iterator",
"=",
"builders",
".",
"values",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"AttributeWidgetBuilder",
"<",
"?",
">",
"widgetBuilder",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"widgetBuilder",
".",
"equals",
"(",
"builder",
")",
")",
"{",
"iterator",
".",
"remove",
"(",
")",
";",
"}",
"}",
"}"
] |
Remove an attribute widget builder from the collection.
@param builder the builder to remove.
|
[
"Remove",
"an",
"attribute",
"widget",
"builder",
"from",
"the",
"collection",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/corewidget/corewidget/src/main/java/org/geomajas/gwt2/plugin/corewidget/client/feature/featureinfo/builder/AttributeWidgetFactory.java#L88-L96
|
146,192
|
ihaolin/session
|
session-api/src/main/java/me/hao0/session/core/HttpSession2.java
|
HttpSession2.snapshot
|
public Map<String, Object> snapshot() {
Map<String, Object> snap = Maps.newHashMap();
snap.putAll(sessionStore);
snap.putAll(newAttributes);
for (String name : deleteAttribute) {
snap.remove(name);
}
return snap;
}
|
java
|
public Map<String, Object> snapshot() {
Map<String, Object> snap = Maps.newHashMap();
snap.putAll(sessionStore);
snap.putAll(newAttributes);
for (String name : deleteAttribute) {
snap.remove(name);
}
return snap;
}
|
[
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"snapshot",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"snap",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"snap",
".",
"putAll",
"(",
"sessionStore",
")",
";",
"snap",
".",
"putAll",
"(",
"newAttributes",
")",
";",
"for",
"(",
"String",
"name",
":",
"deleteAttribute",
")",
"{",
"snap",
".",
"remove",
"(",
"name",
")",
";",
"}",
"return",
"snap",
";",
"}"
] |
get session attributes' snapshot
@return session attributes' map object
|
[
"get",
"session",
"attributes",
"snapshot"
] |
322c3a9f47b305a39345135fa8163dd7e065b4f8
|
https://github.com/ihaolin/session/blob/322c3a9f47b305a39345135fa8163dd7e065b4f8/session-api/src/main/java/me/hao0/session/core/HttpSession2.java#L207-L215
|
146,193
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java
|
PhaseOneApplication.processInputDirectories
|
private void processInputDirectories() {
String[] inputdirs = getOptionValues(SHORT_OPT_IN_PATH);
final List<File> files = new ArrayList<File>();
final XBELFileFilter xbelFileFilter = new XBELFileFilter();
final BELFileFilter belFileFilter = new BELFileFilter();
for (String inputdir : inputdirs) {
final File workingPath = new File(inputdir);
if (!workingPath.canRead()) {
error(BAD_INPUT_PATH + inputdir);
failUsage();
}
final File[] xbels = workingPath.listFiles(xbelFileFilter);
if (xbels != null && xbels.length != 0) {
files.addAll(asList(xbels));
}
final File[] bels = workingPath.listFiles(belFileFilter);
if (bels != null && bels.length != 0) {
files.addAll(asList(bels));
}
}
// Fail if none of the input directories contain BEL/XBEL files
if (files.size() == 0) {
error(NO_DOCUMENT_FILES);
failUsage();
}
// Create the directory artifact or fail
artifactPath = createDirectoryArtifact(outputDirectory, DIR_ARTIFACT);
processFiles(files.toArray(new File[0]));
}
|
java
|
private void processInputDirectories() {
String[] inputdirs = getOptionValues(SHORT_OPT_IN_PATH);
final List<File> files = new ArrayList<File>();
final XBELFileFilter xbelFileFilter = new XBELFileFilter();
final BELFileFilter belFileFilter = new BELFileFilter();
for (String inputdir : inputdirs) {
final File workingPath = new File(inputdir);
if (!workingPath.canRead()) {
error(BAD_INPUT_PATH + inputdir);
failUsage();
}
final File[] xbels = workingPath.listFiles(xbelFileFilter);
if (xbels != null && xbels.length != 0) {
files.addAll(asList(xbels));
}
final File[] bels = workingPath.listFiles(belFileFilter);
if (bels != null && bels.length != 0) {
files.addAll(asList(bels));
}
}
// Fail if none of the input directories contain BEL/XBEL files
if (files.size() == 0) {
error(NO_DOCUMENT_FILES);
failUsage();
}
// Create the directory artifact or fail
artifactPath = createDirectoryArtifact(outputDirectory, DIR_ARTIFACT);
processFiles(files.toArray(new File[0]));
}
|
[
"private",
"void",
"processInputDirectories",
"(",
")",
"{",
"String",
"[",
"]",
"inputdirs",
"=",
"getOptionValues",
"(",
"SHORT_OPT_IN_PATH",
")",
";",
"final",
"List",
"<",
"File",
">",
"files",
"=",
"new",
"ArrayList",
"<",
"File",
">",
"(",
")",
";",
"final",
"XBELFileFilter",
"xbelFileFilter",
"=",
"new",
"XBELFileFilter",
"(",
")",
";",
"final",
"BELFileFilter",
"belFileFilter",
"=",
"new",
"BELFileFilter",
"(",
")",
";",
"for",
"(",
"String",
"inputdir",
":",
"inputdirs",
")",
"{",
"final",
"File",
"workingPath",
"=",
"new",
"File",
"(",
"inputdir",
")",
";",
"if",
"(",
"!",
"workingPath",
".",
"canRead",
"(",
")",
")",
"{",
"error",
"(",
"BAD_INPUT_PATH",
"+",
"inputdir",
")",
";",
"failUsage",
"(",
")",
";",
"}",
"final",
"File",
"[",
"]",
"xbels",
"=",
"workingPath",
".",
"listFiles",
"(",
"xbelFileFilter",
")",
";",
"if",
"(",
"xbels",
"!=",
"null",
"&&",
"xbels",
".",
"length",
"!=",
"0",
")",
"{",
"files",
".",
"addAll",
"(",
"asList",
"(",
"xbels",
")",
")",
";",
"}",
"final",
"File",
"[",
"]",
"bels",
"=",
"workingPath",
".",
"listFiles",
"(",
"belFileFilter",
")",
";",
"if",
"(",
"bels",
"!=",
"null",
"&&",
"bels",
".",
"length",
"!=",
"0",
")",
"{",
"files",
".",
"addAll",
"(",
"asList",
"(",
"bels",
")",
")",
";",
"}",
"}",
"// Fail if none of the input directories contain BEL/XBEL files",
"if",
"(",
"files",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"error",
"(",
"NO_DOCUMENT_FILES",
")",
";",
"failUsage",
"(",
")",
";",
"}",
"// Create the directory artifact or fail",
"artifactPath",
"=",
"createDirectoryArtifact",
"(",
"outputDirectory",
",",
"DIR_ARTIFACT",
")",
";",
"processFiles",
"(",
"files",
".",
"toArray",
"(",
"new",
"File",
"[",
"0",
"]",
")",
")",
";",
"}"
] |
Process documents in the input directories.
|
[
"Process",
"documents",
"in",
"the",
"input",
"directories",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java#L195-L228
|
146,194
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java
|
PhaseOneApplication.processFiles
|
private void processFiles() {
String[] fileArgs = getOptionValues(INFILE_SHORT_OPT);
final List<File> files = new ArrayList<File>(fileArgs.length);
for (final String fileArg : fileArgs) {
File file = new File(fileArg);
if (!file.canRead()) {
error(INPUT_FILE_UNREADABLE + file);
} else {
files.add(file);
}
}
if (files.size() == 0) {
error(NO_DOCUMENT_FILES);
failUsage();
}
// Create the directory artifact or fail
artifactPath = createDirectoryArtifact(outputDirectory, DIR_ARTIFACT);
processFiles(files.toArray(new File[0]));
}
|
java
|
private void processFiles() {
String[] fileArgs = getOptionValues(INFILE_SHORT_OPT);
final List<File> files = new ArrayList<File>(fileArgs.length);
for (final String fileArg : fileArgs) {
File file = new File(fileArg);
if (!file.canRead()) {
error(INPUT_FILE_UNREADABLE + file);
} else {
files.add(file);
}
}
if (files.size() == 0) {
error(NO_DOCUMENT_FILES);
failUsage();
}
// Create the directory artifact or fail
artifactPath = createDirectoryArtifact(outputDirectory, DIR_ARTIFACT);
processFiles(files.toArray(new File[0]));
}
|
[
"private",
"void",
"processFiles",
"(",
")",
"{",
"String",
"[",
"]",
"fileArgs",
"=",
"getOptionValues",
"(",
"INFILE_SHORT_OPT",
")",
";",
"final",
"List",
"<",
"File",
">",
"files",
"=",
"new",
"ArrayList",
"<",
"File",
">",
"(",
"fileArgs",
".",
"length",
")",
";",
"for",
"(",
"final",
"String",
"fileArg",
":",
"fileArgs",
")",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"fileArg",
")",
";",
"if",
"(",
"!",
"file",
".",
"canRead",
"(",
")",
")",
"{",
"error",
"(",
"INPUT_FILE_UNREADABLE",
"+",
"file",
")",
";",
"}",
"else",
"{",
"files",
".",
"add",
"(",
"file",
")",
";",
"}",
"}",
"if",
"(",
"files",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"error",
"(",
"NO_DOCUMENT_FILES",
")",
";",
"failUsage",
"(",
")",
";",
"}",
"// Create the directory artifact or fail",
"artifactPath",
"=",
"createDirectoryArtifact",
"(",
"outputDirectory",
",",
"DIR_ARTIFACT",
")",
";",
"processFiles",
"(",
"files",
".",
"toArray",
"(",
"new",
"File",
"[",
"0",
"]",
")",
")",
";",
"}"
] |
Process file arguments.
|
[
"Process",
"file",
"arguments",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java#L233-L253
|
146,195
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java
|
PhaseOneApplication.runCommonStages
|
private void runCommonStages(boolean pedantic, Document document) {
if (!stage2(document)) {
if (pedantic) {
bail(NAMESPACE_RESOLUTION_FAILURE);
}
}
if (!stage3(document)) {
if (pedantic) {
bail(SYMBOL_VERIFICATION_FAILURE);
}
}
if (!stage4(document)) {
if (pedantic) {
bail(SEMANTIC_VERIFICATION_FAILURE);
}
}
ProtoNetwork pn = stage5(document);
if (!stage6(document, pn)) {
if (pedantic) {
bail(STATEMENT_EXPANSION_FAILURE);
}
}
if (!stage7(pn, document)) {
if (pedantic) {
bail(PROTO_NETWORK_SAVE_FAILURE);
}
}
}
|
java
|
private void runCommonStages(boolean pedantic, Document document) {
if (!stage2(document)) {
if (pedantic) {
bail(NAMESPACE_RESOLUTION_FAILURE);
}
}
if (!stage3(document)) {
if (pedantic) {
bail(SYMBOL_VERIFICATION_FAILURE);
}
}
if (!stage4(document)) {
if (pedantic) {
bail(SEMANTIC_VERIFICATION_FAILURE);
}
}
ProtoNetwork pn = stage5(document);
if (!stage6(document, pn)) {
if (pedantic) {
bail(STATEMENT_EXPANSION_FAILURE);
}
}
if (!stage7(pn, document)) {
if (pedantic) {
bail(PROTO_NETWORK_SAVE_FAILURE);
}
}
}
|
[
"private",
"void",
"runCommonStages",
"(",
"boolean",
"pedantic",
",",
"Document",
"document",
")",
"{",
"if",
"(",
"!",
"stage2",
"(",
"document",
")",
")",
"{",
"if",
"(",
"pedantic",
")",
"{",
"bail",
"(",
"NAMESPACE_RESOLUTION_FAILURE",
")",
";",
"}",
"}",
"if",
"(",
"!",
"stage3",
"(",
"document",
")",
")",
"{",
"if",
"(",
"pedantic",
")",
"{",
"bail",
"(",
"SYMBOL_VERIFICATION_FAILURE",
")",
";",
"}",
"}",
"if",
"(",
"!",
"stage4",
"(",
"document",
")",
")",
"{",
"if",
"(",
"pedantic",
")",
"{",
"bail",
"(",
"SEMANTIC_VERIFICATION_FAILURE",
")",
";",
"}",
"}",
"ProtoNetwork",
"pn",
"=",
"stage5",
"(",
"document",
")",
";",
"if",
"(",
"!",
"stage6",
"(",
"document",
",",
"pn",
")",
")",
"{",
"if",
"(",
"pedantic",
")",
"{",
"bail",
"(",
"STATEMENT_EXPANSION_FAILURE",
")",
";",
"}",
"}",
"if",
"(",
"!",
"stage7",
"(",
"pn",
",",
"document",
")",
")",
"{",
"if",
"(",
"pedantic",
")",
"{",
"bail",
"(",
"PROTO_NETWORK_SAVE_FAILURE",
")",
";",
"}",
"}",
"}"
] |
Runs stages 2 - 7 which remain static regardless of the BEL document
input.
@param pedantic the flag for pedantic-ness
@param document the {@link Document BEL document}
|
[
"Runs",
"stages",
"2",
"-",
"7",
"which",
"remain",
"static",
"regardless",
"of",
"the",
"BEL",
"document",
"input",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java#L303-L335
|
146,196
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java
|
PhaseOneApplication.stage2
|
private boolean stage2(final Document document) {
beginStage(PHASE1_STAGE2_HDR, "2", NUM_PHASES);
final StringBuilder bldr = new StringBuilder();
Collection<Namespace> namespaces = document.getNamespaceMap().values();
final int docNSCount = namespaces.size();
bldr.append("Compiling ");
bldr.append(docNSCount);
bldr.append(" namespace");
if (docNSCount > 1) {
bldr.append("s");
}
bldr.append(" for ");
bldr.append(document.getName());
stageOutput(bldr.toString());
boolean success = true;
long t1 = currentTimeMillis();
try {
p1.stage2NamespaceCompilation(document);
} catch (ResourceDownloadError e) {
success = false;
stageError(e.getUserFacingMessage());
} catch (IndexingFailure e) {
success = false;
stageError(e.getUserFacingMessage());
}
long t2 = currentTimeMillis();
bldr.setLength(0);
markTime(bldr, t1, t2);
markEndStage(bldr);
stageOutput(bldr.toString());
return success;
}
|
java
|
private boolean stage2(final Document document) {
beginStage(PHASE1_STAGE2_HDR, "2", NUM_PHASES);
final StringBuilder bldr = new StringBuilder();
Collection<Namespace> namespaces = document.getNamespaceMap().values();
final int docNSCount = namespaces.size();
bldr.append("Compiling ");
bldr.append(docNSCount);
bldr.append(" namespace");
if (docNSCount > 1) {
bldr.append("s");
}
bldr.append(" for ");
bldr.append(document.getName());
stageOutput(bldr.toString());
boolean success = true;
long t1 = currentTimeMillis();
try {
p1.stage2NamespaceCompilation(document);
} catch (ResourceDownloadError e) {
success = false;
stageError(e.getUserFacingMessage());
} catch (IndexingFailure e) {
success = false;
stageError(e.getUserFacingMessage());
}
long t2 = currentTimeMillis();
bldr.setLength(0);
markTime(bldr, t1, t2);
markEndStage(bldr);
stageOutput(bldr.toString());
return success;
}
|
[
"private",
"boolean",
"stage2",
"(",
"final",
"Document",
"document",
")",
"{",
"beginStage",
"(",
"PHASE1_STAGE2_HDR",
",",
"\"2\"",
",",
"NUM_PHASES",
")",
";",
"final",
"StringBuilder",
"bldr",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Collection",
"<",
"Namespace",
">",
"namespaces",
"=",
"document",
".",
"getNamespaceMap",
"(",
")",
".",
"values",
"(",
")",
";",
"final",
"int",
"docNSCount",
"=",
"namespaces",
".",
"size",
"(",
")",
";",
"bldr",
".",
"append",
"(",
"\"Compiling \"",
")",
";",
"bldr",
".",
"append",
"(",
"docNSCount",
")",
";",
"bldr",
".",
"append",
"(",
"\" namespace\"",
")",
";",
"if",
"(",
"docNSCount",
">",
"1",
")",
"{",
"bldr",
".",
"append",
"(",
"\"s\"",
")",
";",
"}",
"bldr",
".",
"append",
"(",
"\" for \"",
")",
";",
"bldr",
".",
"append",
"(",
"document",
".",
"getName",
"(",
")",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"boolean",
"success",
"=",
"true",
";",
"long",
"t1",
"=",
"currentTimeMillis",
"(",
")",
";",
"try",
"{",
"p1",
".",
"stage2NamespaceCompilation",
"(",
"document",
")",
";",
"}",
"catch",
"(",
"ResourceDownloadError",
"e",
")",
"{",
"success",
"=",
"false",
";",
"stageError",
"(",
"e",
".",
"getUserFacingMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IndexingFailure",
"e",
")",
"{",
"success",
"=",
"false",
";",
"stageError",
"(",
"e",
".",
"getUserFacingMessage",
"(",
")",
")",
";",
"}",
"long",
"t2",
"=",
"currentTimeMillis",
"(",
")",
";",
"bldr",
".",
"setLength",
"(",
"0",
")",
";",
"markTime",
"(",
"bldr",
",",
"t1",
",",
"t2",
")",
";",
"markEndStage",
"(",
"bldr",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"return",
"success",
";",
"}"
] |
Stage two resolution of document namespaces.
@param document BEL common document
@return boolean true if success, false otherwise
|
[
"Stage",
"two",
"resolution",
"of",
"document",
"namespaces",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java#L387-L422
|
146,197
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java
|
PhaseOneApplication.stage3
|
private boolean stage3(final Document document) {
beginStage(PHASE1_STAGE3_HDR, "3", NUM_PHASES);
final StringBuilder bldr = new StringBuilder();
if (hasOption(NO_SYNTAX_CHECK)) {
bldr.append(SYMBOL_CHECKS_DISABLED);
markEndStage(bldr);
stageOutput(bldr.toString());
return true;
}
bldr.append("Verifying symbols in ");
bldr.append(document.getName());
stageOutput(bldr.toString());
boolean warnings = false;
long t1 = currentTimeMillis();
try {
p1.stage3SymbolVerification(document);
} catch (SymbolWarning e) {
warnings = true;
String resname = e.getName();
if (resname == null) {
e.setName(document.getName());
} else {
e.setName(resname + " (" + document.getName() + ")");
}
stageWarning(e.getUserFacingMessage());
} catch (IndexingFailure e) {
stageError("Failed to open namespace index file for symbol " +
"verification.");
} catch (ResourceDownloadError e) {
stageError("Failed to resolve namespace during symbol " +
"verification.");
}
long t2 = currentTimeMillis();
bldr.setLength(0);
if (warnings) {
bldr.append("Symbol verification resulted in warnings in ");
bldr.append(document.getName());
bldr.append("\n");
}
markTime(bldr, t1, t2);
markEndStage(bldr);
stageOutput(bldr.toString());
if (warnings) {
return false;
}
return true;
}
|
java
|
private boolean stage3(final Document document) {
beginStage(PHASE1_STAGE3_HDR, "3", NUM_PHASES);
final StringBuilder bldr = new StringBuilder();
if (hasOption(NO_SYNTAX_CHECK)) {
bldr.append(SYMBOL_CHECKS_DISABLED);
markEndStage(bldr);
stageOutput(bldr.toString());
return true;
}
bldr.append("Verifying symbols in ");
bldr.append(document.getName());
stageOutput(bldr.toString());
boolean warnings = false;
long t1 = currentTimeMillis();
try {
p1.stage3SymbolVerification(document);
} catch (SymbolWarning e) {
warnings = true;
String resname = e.getName();
if (resname == null) {
e.setName(document.getName());
} else {
e.setName(resname + " (" + document.getName() + ")");
}
stageWarning(e.getUserFacingMessage());
} catch (IndexingFailure e) {
stageError("Failed to open namespace index file for symbol " +
"verification.");
} catch (ResourceDownloadError e) {
stageError("Failed to resolve namespace during symbol " +
"verification.");
}
long t2 = currentTimeMillis();
bldr.setLength(0);
if (warnings) {
bldr.append("Symbol verification resulted in warnings in ");
bldr.append(document.getName());
bldr.append("\n");
}
markTime(bldr, t1, t2);
markEndStage(bldr);
stageOutput(bldr.toString());
if (warnings) {
return false;
}
return true;
}
|
[
"private",
"boolean",
"stage3",
"(",
"final",
"Document",
"document",
")",
"{",
"beginStage",
"(",
"PHASE1_STAGE3_HDR",
",",
"\"3\"",
",",
"NUM_PHASES",
")",
";",
"final",
"StringBuilder",
"bldr",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"hasOption",
"(",
"NO_SYNTAX_CHECK",
")",
")",
"{",
"bldr",
".",
"append",
"(",
"SYMBOL_CHECKS_DISABLED",
")",
";",
"markEndStage",
"(",
"bldr",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"bldr",
".",
"append",
"(",
"\"Verifying symbols in \"",
")",
";",
"bldr",
".",
"append",
"(",
"document",
".",
"getName",
"(",
")",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"boolean",
"warnings",
"=",
"false",
";",
"long",
"t1",
"=",
"currentTimeMillis",
"(",
")",
";",
"try",
"{",
"p1",
".",
"stage3SymbolVerification",
"(",
"document",
")",
";",
"}",
"catch",
"(",
"SymbolWarning",
"e",
")",
"{",
"warnings",
"=",
"true",
";",
"String",
"resname",
"=",
"e",
".",
"getName",
"(",
")",
";",
"if",
"(",
"resname",
"==",
"null",
")",
"{",
"e",
".",
"setName",
"(",
"document",
".",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"e",
".",
"setName",
"(",
"resname",
"+",
"\" (\"",
"+",
"document",
".",
"getName",
"(",
")",
"+",
"\")\"",
")",
";",
"}",
"stageWarning",
"(",
"e",
".",
"getUserFacingMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IndexingFailure",
"e",
")",
"{",
"stageError",
"(",
"\"Failed to open namespace index file for symbol \"",
"+",
"\"verification.\"",
")",
";",
"}",
"catch",
"(",
"ResourceDownloadError",
"e",
")",
"{",
"stageError",
"(",
"\"Failed to resolve namespace during symbol \"",
"+",
"\"verification.\"",
")",
";",
"}",
"long",
"t2",
"=",
"currentTimeMillis",
"(",
")",
";",
"bldr",
".",
"setLength",
"(",
"0",
")",
";",
"if",
"(",
"warnings",
")",
"{",
"bldr",
".",
"append",
"(",
"\"Symbol verification resulted in warnings in \"",
")",
";",
"bldr",
".",
"append",
"(",
"document",
".",
"getName",
"(",
")",
")",
";",
"bldr",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}",
"markTime",
"(",
"bldr",
",",
"t1",
",",
"t2",
")",
";",
"markEndStage",
"(",
"bldr",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"warnings",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Stage three symbol verification of the document.
@param document BEL common document
@return boolean true if success, false otherwise
|
[
"Stage",
"three",
"symbol",
"verification",
"of",
"the",
"document",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java#L430-L480
|
146,198
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java
|
PhaseOneApplication.stage4
|
private boolean stage4(final Document document) {
beginStage(PHASE1_STAGE4_HDR, "4", NUM_PHASES);
final StringBuilder bldr = new StringBuilder();
if (hasOption(NO_SEMANTIC_CHECK)) {
bldr.append(SEMANTIC_CHECKS_DISABLED);
markEndStage(bldr);
stageOutput(bldr.toString());
return true;
}
bldr.append("Verifying semantics in ");
bldr.append(document.getName());
stageOutput(bldr.toString());
boolean warnings = false;
long t1 = currentTimeMillis();
try {
p1.stage4SemanticVerification(document);
} catch (SemanticFailure sf) {
warnings = true;
String resname = sf.getName();
if (resname == null) {
sf.setName(document.getName());
} else {
sf.setName(resname + " (" + document.getName() + ")");
}
stageWarning(sf.getUserFacingMessage());
} catch (IndexingFailure e) {
stageError("Failed to process namespace index files for semantic" +
" verification.");
}
long t2 = currentTimeMillis();
bldr.setLength(0);
if (warnings) {
bldr.append("Semantic verification resulted in warnings in ");
bldr.append(document.getName());
bldr.append("\n");
}
markTime(bldr, t1, t2);
markEndStage(bldr);
stageOutput(bldr.toString());
if (warnings) {
return false;
}
return true;
}
|
java
|
private boolean stage4(final Document document) {
beginStage(PHASE1_STAGE4_HDR, "4", NUM_PHASES);
final StringBuilder bldr = new StringBuilder();
if (hasOption(NO_SEMANTIC_CHECK)) {
bldr.append(SEMANTIC_CHECKS_DISABLED);
markEndStage(bldr);
stageOutput(bldr.toString());
return true;
}
bldr.append("Verifying semantics in ");
bldr.append(document.getName());
stageOutput(bldr.toString());
boolean warnings = false;
long t1 = currentTimeMillis();
try {
p1.stage4SemanticVerification(document);
} catch (SemanticFailure sf) {
warnings = true;
String resname = sf.getName();
if (resname == null) {
sf.setName(document.getName());
} else {
sf.setName(resname + " (" + document.getName() + ")");
}
stageWarning(sf.getUserFacingMessage());
} catch (IndexingFailure e) {
stageError("Failed to process namespace index files for semantic" +
" verification.");
}
long t2 = currentTimeMillis();
bldr.setLength(0);
if (warnings) {
bldr.append("Semantic verification resulted in warnings in ");
bldr.append(document.getName());
bldr.append("\n");
}
markTime(bldr, t1, t2);
markEndStage(bldr);
stageOutput(bldr.toString());
if (warnings) {
return false;
}
return true;
}
|
[
"private",
"boolean",
"stage4",
"(",
"final",
"Document",
"document",
")",
"{",
"beginStage",
"(",
"PHASE1_STAGE4_HDR",
",",
"\"4\"",
",",
"NUM_PHASES",
")",
";",
"final",
"StringBuilder",
"bldr",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"hasOption",
"(",
"NO_SEMANTIC_CHECK",
")",
")",
"{",
"bldr",
".",
"append",
"(",
"SEMANTIC_CHECKS_DISABLED",
")",
";",
"markEndStage",
"(",
"bldr",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"bldr",
".",
"append",
"(",
"\"Verifying semantics in \"",
")",
";",
"bldr",
".",
"append",
"(",
"document",
".",
"getName",
"(",
")",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"boolean",
"warnings",
"=",
"false",
";",
"long",
"t1",
"=",
"currentTimeMillis",
"(",
")",
";",
"try",
"{",
"p1",
".",
"stage4SemanticVerification",
"(",
"document",
")",
";",
"}",
"catch",
"(",
"SemanticFailure",
"sf",
")",
"{",
"warnings",
"=",
"true",
";",
"String",
"resname",
"=",
"sf",
".",
"getName",
"(",
")",
";",
"if",
"(",
"resname",
"==",
"null",
")",
"{",
"sf",
".",
"setName",
"(",
"document",
".",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"sf",
".",
"setName",
"(",
"resname",
"+",
"\" (\"",
"+",
"document",
".",
"getName",
"(",
")",
"+",
"\")\"",
")",
";",
"}",
"stageWarning",
"(",
"sf",
".",
"getUserFacingMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IndexingFailure",
"e",
")",
"{",
"stageError",
"(",
"\"Failed to process namespace index files for semantic\"",
"+",
"\" verification.\"",
")",
";",
"}",
"long",
"t2",
"=",
"currentTimeMillis",
"(",
")",
";",
"bldr",
".",
"setLength",
"(",
"0",
")",
";",
"if",
"(",
"warnings",
")",
"{",
"bldr",
".",
"append",
"(",
"\"Semantic verification resulted in warnings in \"",
")",
";",
"bldr",
".",
"append",
"(",
"document",
".",
"getName",
"(",
")",
")",
";",
"bldr",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}",
"markTime",
"(",
"bldr",
",",
"t1",
",",
"t2",
")",
";",
"markEndStage",
"(",
"bldr",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"warnings",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Stage four semantic verification of the document.
@param document BEL common document
@return boolean true if success, false otherwise
|
[
"Stage",
"four",
"semantic",
"verification",
"of",
"the",
"document",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java#L488-L535
|
146,199
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java
|
PhaseOneApplication.stage5
|
private ProtoNetwork stage5(final Document document) {
beginStage(PHASE1_STAGE5_HDR, "5", NUM_PHASES);
final StringBuilder bldr = new StringBuilder();
bldr.append("Building proto-network for ");
bldr.append(document.getName());
stageOutput(bldr.toString());
long t1 = currentTimeMillis();
ProtoNetwork ret = p1.stage5Building(document);
long t2 = currentTimeMillis();
bldr.setLength(0);
markTime(bldr, t1, t2);
markEndStage(bldr);
stageOutput(bldr.toString());
return ret;
}
|
java
|
private ProtoNetwork stage5(final Document document) {
beginStage(PHASE1_STAGE5_HDR, "5", NUM_PHASES);
final StringBuilder bldr = new StringBuilder();
bldr.append("Building proto-network for ");
bldr.append(document.getName());
stageOutput(bldr.toString());
long t1 = currentTimeMillis();
ProtoNetwork ret = p1.stage5Building(document);
long t2 = currentTimeMillis();
bldr.setLength(0);
markTime(bldr, t1, t2);
markEndStage(bldr);
stageOutput(bldr.toString());
return ret;
}
|
[
"private",
"ProtoNetwork",
"stage5",
"(",
"final",
"Document",
"document",
")",
"{",
"beginStage",
"(",
"PHASE1_STAGE5_HDR",
",",
"\"5\"",
",",
"NUM_PHASES",
")",
";",
"final",
"StringBuilder",
"bldr",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"bldr",
".",
"append",
"(",
"\"Building proto-network for \"",
")",
";",
"bldr",
".",
"append",
"(",
"document",
".",
"getName",
"(",
")",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"long",
"t1",
"=",
"currentTimeMillis",
"(",
")",
";",
"ProtoNetwork",
"ret",
"=",
"p1",
".",
"stage5Building",
"(",
"document",
")",
";",
"long",
"t2",
"=",
"currentTimeMillis",
"(",
")",
";",
"bldr",
".",
"setLength",
"(",
"0",
")",
";",
"markTime",
"(",
"bldr",
",",
"t1",
",",
"t2",
")",
";",
"markEndStage",
"(",
"bldr",
")",
";",
"stageOutput",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"return",
"ret",
";",
"}"
] |
Stage five build of proto-network.
@param document BEL common document
|
[
"Stage",
"five",
"build",
"of",
"proto",
"-",
"network",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java#L542-L560
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.