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 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java | OrientModelGraph.cleanDatabase | public void cleanDatabase() {
lockingMechanism.writeLock().lock();
try {
for (ODocument edge : graph.browseEdges()) {
edge.delete();
}
for (ODocument node : graph.browseVertices()) {
node.delete();
}
} finally {
lockingMechanism.writeLock().unlock();
}
} | java | public void cleanDatabase() {
lockingMechanism.writeLock().lock();
try {
for (ODocument edge : graph.browseEdges()) {
edge.delete();
}
for (ODocument node : graph.browseVertices()) {
node.delete();
}
} finally {
lockingMechanism.writeLock().unlock();
}
} | [
"public",
"void",
"cleanDatabase",
"(",
")",
"{",
"lockingMechanism",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"for",
"(",
"ODocument",
"edge",
":",
"graph",
".",
"browseEdges",
"(",
")",
")",
"{",
"edge",
".",
"delete",
"(",
")",
";",
"}",
"for",
"(",
"ODocument",
"node",
":",
"graph",
".",
"browseVertices",
"(",
")",
")",
"{",
"node",
".",
"delete",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"lockingMechanism",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Deletes all edges and nodes from the graph database. This method is used in the tests to have at every test the
same start situation. | [
"Deletes",
"all",
"edges",
"and",
"nodes",
"from",
"the",
"graph",
"database",
".",
"This",
"method",
"is",
"used",
"in",
"the",
"tests",
"to",
"have",
"at",
"every",
"test",
"the",
"same",
"start",
"situation",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java#L93-L105 | train |
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java | OrientModelGraph.checkTransformationDescriptionId | private void checkTransformationDescriptionId(TransformationDescription description) {
if (description.getId() == null) {
description.setId("EKBInternal-" + counter.incrementAndGet());
}
} | java | private void checkTransformationDescriptionId(TransformationDescription description) {
if (description.getId() == null) {
description.setId("EKBInternal-" + counter.incrementAndGet());
}
} | [
"private",
"void",
"checkTransformationDescriptionId",
"(",
"TransformationDescription",
"description",
")",
"{",
"if",
"(",
"description",
".",
"getId",
"(",
")",
"==",
"null",
")",
"{",
"description",
".",
"setId",
"(",
"\"EKBInternal-\"",
"+",
"counter",
".",
"incrementAndGet",
"(",
")",
")",
";",
"}",
"}"
] | Tests if a transformation description has an id and adds an unique id if it hasn't one. | [
"Tests",
"if",
"a",
"transformation",
"description",
"has",
"an",
"id",
"and",
"adds",
"an",
"unique",
"id",
"if",
"it",
"hasn",
"t",
"one",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java#L240-L244 | train |
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java | OrientModelGraph.getEdgesBetweenModels | private List<ODocument> getEdgesBetweenModels(String source, String target) {
ODocument from = getModel(source);
ODocument to = getModel(target);
String query = "select from E where out = ? AND in = ?";
return graph.query(new OSQLSynchQuery<ODocument>(query), from, to);
} | java | private List<ODocument> getEdgesBetweenModels(String source, String target) {
ODocument from = getModel(source);
ODocument to = getModel(target);
String query = "select from E where out = ? AND in = ?";
return graph.query(new OSQLSynchQuery<ODocument>(query), from, to);
} | [
"private",
"List",
"<",
"ODocument",
">",
"getEdgesBetweenModels",
"(",
"String",
"source",
",",
"String",
"target",
")",
"{",
"ODocument",
"from",
"=",
"getModel",
"(",
"source",
")",
";",
"ODocument",
"to",
"=",
"getModel",
"(",
"target",
")",
";",
"String",
"query",
"=",
"\"select from E where out = ? AND in = ?\"",
";",
"return",
"graph",
".",
"query",
"(",
"new",
"OSQLSynchQuery",
"<",
"ODocument",
">",
"(",
"query",
")",
",",
"from",
",",
"to",
")",
";",
"}"
] | Returns all edges which start at the source model and end in the target model. | [
"Returns",
"all",
"edges",
"which",
"start",
"at",
"the",
"source",
"model",
"and",
"end",
"in",
"the",
"target",
"model",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java#L256-L261 | train |
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java | OrientModelGraph.getNeighborsOfModel | private List<ODocument> getNeighborsOfModel(String model) {
String query = String.format("select from Models where in.out.%s in [?]", OGraphDatabase.LABEL);
List<ODocument> neighbors = graph.query(new OSQLSynchQuery<ODocument>(query), model);
return neighbors;
} | java | private List<ODocument> getNeighborsOfModel(String model) {
String query = String.format("select from Models where in.out.%s in [?]", OGraphDatabase.LABEL);
List<ODocument> neighbors = graph.query(new OSQLSynchQuery<ODocument>(query), model);
return neighbors;
} | [
"private",
"List",
"<",
"ODocument",
">",
"getNeighborsOfModel",
"(",
"String",
"model",
")",
"{",
"String",
"query",
"=",
"String",
".",
"format",
"(",
"\"select from Models where in.out.%s in [?]\"",
",",
"OGraphDatabase",
".",
"LABEL",
")",
";",
"List",
"<",
"ODocument",
">",
"neighbors",
"=",
"graph",
".",
"query",
"(",
"new",
"OSQLSynchQuery",
"<",
"ODocument",
">",
"(",
"query",
")",
",",
"model",
")",
";",
"return",
"neighbors",
";",
"}"
] | Returns all neighbors of a model. | [
"Returns",
"all",
"neighbors",
"of",
"a",
"model",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java#L266-L270 | train |
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java | OrientModelGraph.getOrCreateModel | private ODocument getOrCreateModel(String model) {
ODocument node = getModel(model);
if (node == null) {
node = graph.createVertex("Models");
OrientModelGraphUtils.setIdFieldValue(node, model.toString());
OrientModelGraphUtils.setActiveFieldValue(node, false);
node.save();
}
return node;
} | java | private ODocument getOrCreateModel(String model) {
ODocument node = getModel(model);
if (node == null) {
node = graph.createVertex("Models");
OrientModelGraphUtils.setIdFieldValue(node, model.toString());
OrientModelGraphUtils.setActiveFieldValue(node, false);
node.save();
}
return node;
} | [
"private",
"ODocument",
"getOrCreateModel",
"(",
"String",
"model",
")",
"{",
"ODocument",
"node",
"=",
"getModel",
"(",
"model",
")",
";",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"node",
"=",
"graph",
".",
"createVertex",
"(",
"\"Models\"",
")",
";",
"OrientModelGraphUtils",
".",
"setIdFieldValue",
"(",
"node",
",",
"model",
".",
"toString",
"(",
")",
")",
";",
"OrientModelGraphUtils",
".",
"setActiveFieldValue",
"(",
"node",
",",
"false",
")",
";",
"node",
".",
"save",
"(",
")",
";",
"}",
"return",
"node",
";",
"}"
] | Returns the model with the given name, or creates one if it isn't existing until then and returns the new one. | [
"Returns",
"the",
"model",
"with",
"the",
"given",
"name",
"or",
"creates",
"one",
"if",
"it",
"isn",
"t",
"existing",
"until",
"then",
"and",
"returns",
"the",
"new",
"one",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java#L275-L284 | train |
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java | OrientModelGraph.getModel | private ODocument getModel(String model) {
String query = String.format("select from Models where %s = ?", OGraphDatabase.LABEL);
List<ODocument> from = graph.query(new OSQLSynchQuery<ODocument>(query), model);
if (from.size() > 0) {
return from.get(0);
} else {
return null;
}
} | java | private ODocument getModel(String model) {
String query = String.format("select from Models where %s = ?", OGraphDatabase.LABEL);
List<ODocument> from = graph.query(new OSQLSynchQuery<ODocument>(query), model);
if (from.size() > 0) {
return from.get(0);
} else {
return null;
}
} | [
"private",
"ODocument",
"getModel",
"(",
"String",
"model",
")",
"{",
"String",
"query",
"=",
"String",
".",
"format",
"(",
"\"select from Models where %s = ?\"",
",",
"OGraphDatabase",
".",
"LABEL",
")",
";",
"List",
"<",
"ODocument",
">",
"from",
"=",
"graph",
".",
"query",
"(",
"new",
"OSQLSynchQuery",
"<",
"ODocument",
">",
"(",
"query",
")",
",",
"model",
")",
";",
"if",
"(",
"from",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"return",
"from",
".",
"get",
"(",
"0",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Returns the model with the given name. | [
"Returns",
"the",
"model",
"with",
"the",
"given",
"name",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java#L289-L297 | train |
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java | OrientModelGraph.recursivePathSearch | private List<ODocument> recursivePathSearch(String start, String end, List<String> ids, ODocument... steps) {
List<ODocument> neighbors = getNeighborsOfModel(start);
for (ODocument neighbor : neighbors) {
if (alreadyVisited(neighbor, steps) || !OrientModelGraphUtils.getActiveFieldValue(neighbor)) {
continue;
}
ODocument nextStep = getEdgeWithPossibleId(start, OrientModelGraphUtils.getIdFieldValue(neighbor), ids);
if (nextStep == null) {
continue;
}
if (OrientModelGraphUtils.getIdFieldValue(neighbor).equals(end)) {
List<ODocument> result = new ArrayList<ODocument>();
List<String> copyIds = new ArrayList<String>(ids);
for (ODocument step : steps) {
String id = OrientModelGraphUtils.getIdFieldValue(step);
if (id != null && copyIds.contains(id)) {
copyIds.remove(id);
}
result.add(step);
}
String id = OrientModelGraphUtils.getIdFieldValue(nextStep);
if (id != null && copyIds.contains(id)) {
copyIds.remove(id);
}
result.add(nextStep);
if (copyIds.isEmpty()) {
return result;
}
}
ODocument[] path = Arrays.copyOf(steps, steps.length + 1);
path[path.length - 1] = nextStep;
List<ODocument> check =
recursivePathSearch(OrientModelGraphUtils.getIdFieldValue(neighbor), end, ids, path);
if (check != null) {
return check;
}
}
return null;
} | java | private List<ODocument> recursivePathSearch(String start, String end, List<String> ids, ODocument... steps) {
List<ODocument> neighbors = getNeighborsOfModel(start);
for (ODocument neighbor : neighbors) {
if (alreadyVisited(neighbor, steps) || !OrientModelGraphUtils.getActiveFieldValue(neighbor)) {
continue;
}
ODocument nextStep = getEdgeWithPossibleId(start, OrientModelGraphUtils.getIdFieldValue(neighbor), ids);
if (nextStep == null) {
continue;
}
if (OrientModelGraphUtils.getIdFieldValue(neighbor).equals(end)) {
List<ODocument> result = new ArrayList<ODocument>();
List<String> copyIds = new ArrayList<String>(ids);
for (ODocument step : steps) {
String id = OrientModelGraphUtils.getIdFieldValue(step);
if (id != null && copyIds.contains(id)) {
copyIds.remove(id);
}
result.add(step);
}
String id = OrientModelGraphUtils.getIdFieldValue(nextStep);
if (id != null && copyIds.contains(id)) {
copyIds.remove(id);
}
result.add(nextStep);
if (copyIds.isEmpty()) {
return result;
}
}
ODocument[] path = Arrays.copyOf(steps, steps.length + 1);
path[path.length - 1] = nextStep;
List<ODocument> check =
recursivePathSearch(OrientModelGraphUtils.getIdFieldValue(neighbor), end, ids, path);
if (check != null) {
return check;
}
}
return null;
} | [
"private",
"List",
"<",
"ODocument",
">",
"recursivePathSearch",
"(",
"String",
"start",
",",
"String",
"end",
",",
"List",
"<",
"String",
">",
"ids",
",",
"ODocument",
"...",
"steps",
")",
"{",
"List",
"<",
"ODocument",
">",
"neighbors",
"=",
"getNeighborsOfModel",
"(",
"start",
")",
";",
"for",
"(",
"ODocument",
"neighbor",
":",
"neighbors",
")",
"{",
"if",
"(",
"alreadyVisited",
"(",
"neighbor",
",",
"steps",
")",
"||",
"!",
"OrientModelGraphUtils",
".",
"getActiveFieldValue",
"(",
"neighbor",
")",
")",
"{",
"continue",
";",
"}",
"ODocument",
"nextStep",
"=",
"getEdgeWithPossibleId",
"(",
"start",
",",
"OrientModelGraphUtils",
".",
"getIdFieldValue",
"(",
"neighbor",
")",
",",
"ids",
")",
";",
"if",
"(",
"nextStep",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"OrientModelGraphUtils",
".",
"getIdFieldValue",
"(",
"neighbor",
")",
".",
"equals",
"(",
"end",
")",
")",
"{",
"List",
"<",
"ODocument",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"ODocument",
">",
"(",
")",
";",
"List",
"<",
"String",
">",
"copyIds",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"ids",
")",
";",
"for",
"(",
"ODocument",
"step",
":",
"steps",
")",
"{",
"String",
"id",
"=",
"OrientModelGraphUtils",
".",
"getIdFieldValue",
"(",
"step",
")",
";",
"if",
"(",
"id",
"!=",
"null",
"&&",
"copyIds",
".",
"contains",
"(",
"id",
")",
")",
"{",
"copyIds",
".",
"remove",
"(",
"id",
")",
";",
"}",
"result",
".",
"add",
"(",
"step",
")",
";",
"}",
"String",
"id",
"=",
"OrientModelGraphUtils",
".",
"getIdFieldValue",
"(",
"nextStep",
")",
";",
"if",
"(",
"id",
"!=",
"null",
"&&",
"copyIds",
".",
"contains",
"(",
"id",
")",
")",
"{",
"copyIds",
".",
"remove",
"(",
"id",
")",
";",
"}",
"result",
".",
"add",
"(",
"nextStep",
")",
";",
"if",
"(",
"copyIds",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"result",
";",
"}",
"}",
"ODocument",
"[",
"]",
"path",
"=",
"Arrays",
".",
"copyOf",
"(",
"steps",
",",
"steps",
".",
"length",
"+",
"1",
")",
";",
"path",
"[",
"path",
".",
"length",
"-",
"1",
"]",
"=",
"nextStep",
";",
"List",
"<",
"ODocument",
">",
"check",
"=",
"recursivePathSearch",
"(",
"OrientModelGraphUtils",
".",
"getIdFieldValue",
"(",
"neighbor",
")",
",",
"end",
",",
"ids",
",",
"path",
")",
";",
"if",
"(",
"check",
"!=",
"null",
")",
"{",
"return",
"check",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Recursive path search function. It performs a depth first search with integrated loop check to find a path from
the start model to the end model. If the id list is not empty, then the function only returns a path as valid if
all transformations defined with the id list are in the path. It also takes care of models which aren't
available. Returns null if there is no path found. | [
"Recursive",
"path",
"search",
"function",
".",
"It",
"performs",
"a",
"depth",
"first",
"search",
"with",
"integrated",
"loop",
"check",
"to",
"find",
"a",
"path",
"from",
"the",
"start",
"model",
"to",
"the",
"end",
"model",
".",
"If",
"the",
"id",
"list",
"is",
"not",
"empty",
"then",
"the",
"function",
"only",
"returns",
"a",
"path",
"as",
"valid",
"if",
"all",
"transformations",
"defined",
"with",
"the",
"id",
"list",
"are",
"in",
"the",
"path",
".",
"It",
"also",
"takes",
"care",
"of",
"models",
"which",
"aren",
"t",
"available",
".",
"Returns",
"null",
"if",
"there",
"is",
"no",
"path",
"found",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java#L305-L343 | train |
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java | OrientModelGraph.getEdgeWithPossibleId | private ODocument getEdgeWithPossibleId(String start, String end, List<String> ids) {
List<ODocument> edges = getEdgesBetweenModels(start, end);
for (ODocument edge : edges) {
if (ids.contains(OrientModelGraphUtils.getIdFieldValue(edge))) {
return edge;
}
}
return edges.size() != 0 ? edges.get(0) : null;
} | java | private ODocument getEdgeWithPossibleId(String start, String end, List<String> ids) {
List<ODocument> edges = getEdgesBetweenModels(start, end);
for (ODocument edge : edges) {
if (ids.contains(OrientModelGraphUtils.getIdFieldValue(edge))) {
return edge;
}
}
return edges.size() != 0 ? edges.get(0) : null;
} | [
"private",
"ODocument",
"getEdgeWithPossibleId",
"(",
"String",
"start",
",",
"String",
"end",
",",
"List",
"<",
"String",
">",
"ids",
")",
"{",
"List",
"<",
"ODocument",
">",
"edges",
"=",
"getEdgesBetweenModels",
"(",
"start",
",",
"end",
")",
";",
"for",
"(",
"ODocument",
"edge",
":",
"edges",
")",
"{",
"if",
"(",
"ids",
".",
"contains",
"(",
"OrientModelGraphUtils",
".",
"getIdFieldValue",
"(",
"edge",
")",
")",
")",
"{",
"return",
"edge",
";",
"}",
"}",
"return",
"edges",
".",
"size",
"(",
")",
"!=",
"0",
"?",
"edges",
".",
"get",
"(",
"0",
")",
":",
"null",
";",
"}"
] | Returns an edge between the start and the end model. If there is an edge which has an id which is contained in
the given id list, then this transformation is returned. If not, then the first found is returned. | [
"Returns",
"an",
"edge",
"between",
"the",
"start",
"and",
"the",
"end",
"model",
".",
"If",
"there",
"is",
"an",
"edge",
"which",
"has",
"an",
"id",
"which",
"is",
"contained",
"in",
"the",
"given",
"id",
"list",
"then",
"this",
"transformation",
"is",
"returned",
".",
"If",
"not",
"then",
"the",
"first",
"found",
"is",
"returned",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java#L349-L357 | train |
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java | OrientModelGraph.alreadyVisited | private boolean alreadyVisited(ODocument neighbor, ODocument[] steps) {
for (ODocument step : steps) {
ODocument out = graph.getOutVertex(step);
if (out.equals(neighbor)) {
return true;
}
}
return false;
} | java | private boolean alreadyVisited(ODocument neighbor, ODocument[] steps) {
for (ODocument step : steps) {
ODocument out = graph.getOutVertex(step);
if (out.equals(neighbor)) {
return true;
}
}
return false;
} | [
"private",
"boolean",
"alreadyVisited",
"(",
"ODocument",
"neighbor",
",",
"ODocument",
"[",
"]",
"steps",
")",
"{",
"for",
"(",
"ODocument",
"step",
":",
"steps",
")",
"{",
"ODocument",
"out",
"=",
"graph",
".",
"getOutVertex",
"(",
"step",
")",
";",
"if",
"(",
"out",
".",
"equals",
"(",
"neighbor",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if a model is already visited in the path search algorithm. Needed for the loop detection. | [
"Checks",
"if",
"a",
"model",
"is",
"already",
"visited",
"in",
"the",
"path",
"search",
"algorithm",
".",
"Needed",
"for",
"the",
"loop",
"detection",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java#L362-L370 | train |
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java | OrientModelGraph.isModelActive | public boolean isModelActive(ModelDescription model) {
lockingMechanism.readLock().lock();
try {
ODocument node = getModel(model.toString());
return OrientModelGraphUtils.getActiveFieldValue(node);
} finally {
lockingMechanism.readLock().unlock();
}
} | java | public boolean isModelActive(ModelDescription model) {
lockingMechanism.readLock().lock();
try {
ODocument node = getModel(model.toString());
return OrientModelGraphUtils.getActiveFieldValue(node);
} finally {
lockingMechanism.readLock().unlock();
}
} | [
"public",
"boolean",
"isModelActive",
"(",
"ModelDescription",
"model",
")",
"{",
"lockingMechanism",
".",
"readLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"ODocument",
"node",
"=",
"getModel",
"(",
"model",
".",
"toString",
"(",
")",
")",
";",
"return",
"OrientModelGraphUtils",
".",
"getActiveFieldValue",
"(",
"node",
")",
";",
"}",
"finally",
"{",
"lockingMechanism",
".",
"readLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Returns true if the model is currently active, returns false if not. | [
"Returns",
"true",
"if",
"the",
"model",
"is",
"currently",
"active",
"returns",
"false",
"if",
"not",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraph.java#L375-L383 | train |
galaxyproject/blend4j | src/main/java/com/github/jmchilton/blend4j/galaxy/DefaultWebResourceFactoryImpl.java | DefaultWebResourceFactoryImpl.getJerseyClient | protected com.sun.jersey.api.client.Client getJerseyClient() {
final ClientConfig clientConfig = new DefaultClientConfig();
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
com.sun.jersey.api.client.Client client = com.sun.jersey.api.client.Client.create(clientConfig);
if(this.debug) {
client.addFilter(new LoggingFilter(System.out));
}
return client;
} | java | protected com.sun.jersey.api.client.Client getJerseyClient() {
final ClientConfig clientConfig = new DefaultClientConfig();
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
com.sun.jersey.api.client.Client client = com.sun.jersey.api.client.Client.create(clientConfig);
if(this.debug) {
client.addFilter(new LoggingFilter(System.out));
}
return client;
} | [
"protected",
"com",
".",
"sun",
".",
"jersey",
".",
"api",
".",
"client",
".",
"Client",
"getJerseyClient",
"(",
")",
"{",
"final",
"ClientConfig",
"clientConfig",
"=",
"new",
"DefaultClientConfig",
"(",
")",
";",
"clientConfig",
".",
"getFeatures",
"(",
")",
".",
"put",
"(",
"JSONConfiguration",
".",
"FEATURE_POJO_MAPPING",
",",
"Boolean",
".",
"TRUE",
")",
";",
"com",
".",
"sun",
".",
"jersey",
".",
"api",
".",
"client",
".",
"Client",
"client",
"=",
"com",
".",
"sun",
".",
"jersey",
".",
"api",
".",
"client",
".",
"Client",
".",
"create",
"(",
"clientConfig",
")",
";",
"if",
"(",
"this",
".",
"debug",
")",
"{",
"client",
".",
"addFilter",
"(",
"new",
"LoggingFilter",
"(",
"System",
".",
"out",
")",
")",
";",
"}",
"return",
"client",
";",
"}"
] | Return a configured Jersey client for Galaxy API code to interact with. If this method is overridden ensure
FEATURE_POJO_MAPPING is enabled.
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
@return Jersey client. | [
"Return",
"a",
"configured",
"Jersey",
"client",
"for",
"Galaxy",
"API",
"code",
"to",
"interact",
"with",
".",
"If",
"this",
"method",
"is",
"overridden",
"ensure",
"FEATURE_POJO_MAPPING",
"is",
"enabled",
"."
] | a2ec4e412be40013bb88a3a2cf2478abd19ce162 | https://github.com/galaxyproject/blend4j/blob/a2ec4e412be40013bb88a3a2cf2478abd19ce162/src/main/java/com/github/jmchilton/blend4j/galaxy/DefaultWebResourceFactoryImpl.java#L67-L75 | train |
codelibs/elasticsearch-util | src/main/java/org/codelibs/elasticsearch/util/lang/StringUtils.java | StringUtils.isEmpty | public static boolean isEmpty(final Collection<String> c) {
if (c == null || c.isEmpty()) {
return false;
}
for (final String text : c) {
if (isNotEmpty(text)) {
return false;
}
}
return true;
} | java | public static boolean isEmpty(final Collection<String> c) {
if (c == null || c.isEmpty()) {
return false;
}
for (final String text : c) {
if (isNotEmpty(text)) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"isEmpty",
"(",
"final",
"Collection",
"<",
"String",
">",
"c",
")",
"{",
"if",
"(",
"c",
"==",
"null",
"||",
"c",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"final",
"String",
"text",
":",
"c",
")",
"{",
"if",
"(",
"isNotEmpty",
"(",
"text",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Check if a collection of a string is empty.
@param c
@return | [
"Check",
"if",
"a",
"collection",
"of",
"a",
"string",
"is",
"empty",
"."
] | c439cd6533d6997734a6d608f36e386f31893a50 | https://github.com/codelibs/elasticsearch-util/blob/c439cd6533d6997734a6d608f36e386f31893a50/src/main/java/org/codelibs/elasticsearch/util/lang/StringUtils.java#L22-L32 | train |
codelibs/elasticsearch-util | src/main/java/org/codelibs/elasticsearch/util/lang/StringUtils.java | StringUtils.isBlank | public static boolean isBlank(final Collection<String> c) {
if (c == null || c.isEmpty()) {
return false;
}
for (final String text : c) {
if (isNotBlank(text)) {
return false;
}
}
return true;
} | java | public static boolean isBlank(final Collection<String> c) {
if (c == null || c.isEmpty()) {
return false;
}
for (final String text : c) {
if (isNotBlank(text)) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"isBlank",
"(",
"final",
"Collection",
"<",
"String",
">",
"c",
")",
"{",
"if",
"(",
"c",
"==",
"null",
"||",
"c",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"final",
"String",
"text",
":",
"c",
")",
"{",
"if",
"(",
"isNotBlank",
"(",
"text",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Check if a collection of a string is blank.
@param c
@return | [
"Check",
"if",
"a",
"collection",
"of",
"a",
"string",
"is",
"blank",
"."
] | c439cd6533d6997734a6d608f36e386f31893a50 | https://github.com/codelibs/elasticsearch-util/blob/c439cd6533d6997734a6d608f36e386f31893a50/src/main/java/org/codelibs/elasticsearch/util/lang/StringUtils.java#L50-L60 | train |
SG-O/miIO | src/main/java/de/sg_o/app/miio/base/Device.java | Device.hello | private boolean hello(InetAddress broadcast) {
if (socket == null) return false;
Command hello = new Command();
byte[] helloMsg = hello.create();
DatagramPacket packet;
if (ip == null){
if (this.acceptableModels == null) return false;
packet = new DatagramPacket(helloMsg, helloMsg.length, broadcast, PORT);
} else {
packet = new DatagramPacket(helloMsg, helloMsg.length, ip, PORT);
}
try {
socket.send(packet);
} catch (IOException e) {
return false;
}
packet = new DatagramPacket(rcv, rcv.length);
try {
socket.receive(packet);
} catch (IOException e) {
return false;
}
if (ip == null){
ip = packet.getAddress();
}
byte[] worker = new byte[2];
System.arraycopy(rcv, 2, worker, 0, 2);
int length = (int)ByteArray.fromBytes(worker);
worker = new byte[length];
System.arraycopy(rcv, 0, worker, 0, length);
Response response;
try {
response = new Response(worker, null);
} catch (CommandExecutionException e) {
return false;
}
if (token == null){
if (!(response.getToken().equals(new Token("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",16)) || response.getToken().equals(new Token("00000000000000000000000000000000",16)))) {
token = response.getToken();
} else {
return false;
}
}
if (!((response.getDeviceID() == -1) || (response.getTimeStamp() == -1))){
deviceID = response.getDeviceID();
timeStamp = response.getTimeStamp();
methodID = timeStamp & 0b1111111111111; // Possible collision about every 2 hours > acceptable
if (this.acceptableModels != null){
boolean modelOk = false;
for (String s: this.acceptableModels) {
try {
if (s.equals(model())) modelOk = true;
} catch (CommandExecutionException ignored) {
}
}
return modelOk;
}
return true;
}
return false;
} | java | private boolean hello(InetAddress broadcast) {
if (socket == null) return false;
Command hello = new Command();
byte[] helloMsg = hello.create();
DatagramPacket packet;
if (ip == null){
if (this.acceptableModels == null) return false;
packet = new DatagramPacket(helloMsg, helloMsg.length, broadcast, PORT);
} else {
packet = new DatagramPacket(helloMsg, helloMsg.length, ip, PORT);
}
try {
socket.send(packet);
} catch (IOException e) {
return false;
}
packet = new DatagramPacket(rcv, rcv.length);
try {
socket.receive(packet);
} catch (IOException e) {
return false;
}
if (ip == null){
ip = packet.getAddress();
}
byte[] worker = new byte[2];
System.arraycopy(rcv, 2, worker, 0, 2);
int length = (int)ByteArray.fromBytes(worker);
worker = new byte[length];
System.arraycopy(rcv, 0, worker, 0, length);
Response response;
try {
response = new Response(worker, null);
} catch (CommandExecutionException e) {
return false;
}
if (token == null){
if (!(response.getToken().equals(new Token("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",16)) || response.getToken().equals(new Token("00000000000000000000000000000000",16)))) {
token = response.getToken();
} else {
return false;
}
}
if (!((response.getDeviceID() == -1) || (response.getTimeStamp() == -1))){
deviceID = response.getDeviceID();
timeStamp = response.getTimeStamp();
methodID = timeStamp & 0b1111111111111; // Possible collision about every 2 hours > acceptable
if (this.acceptableModels != null){
boolean modelOk = false;
for (String s: this.acceptableModels) {
try {
if (s.equals(model())) modelOk = true;
} catch (CommandExecutionException ignored) {
}
}
return modelOk;
}
return true;
}
return false;
} | [
"private",
"boolean",
"hello",
"(",
"InetAddress",
"broadcast",
")",
"{",
"if",
"(",
"socket",
"==",
"null",
")",
"return",
"false",
";",
"Command",
"hello",
"=",
"new",
"Command",
"(",
")",
";",
"byte",
"[",
"]",
"helloMsg",
"=",
"hello",
".",
"create",
"(",
")",
";",
"DatagramPacket",
"packet",
";",
"if",
"(",
"ip",
"==",
"null",
")",
"{",
"if",
"(",
"this",
".",
"acceptableModels",
"==",
"null",
")",
"return",
"false",
";",
"packet",
"=",
"new",
"DatagramPacket",
"(",
"helloMsg",
",",
"helloMsg",
".",
"length",
",",
"broadcast",
",",
"PORT",
")",
";",
"}",
"else",
"{",
"packet",
"=",
"new",
"DatagramPacket",
"(",
"helloMsg",
",",
"helloMsg",
".",
"length",
",",
"ip",
",",
"PORT",
")",
";",
"}",
"try",
"{",
"socket",
".",
"send",
"(",
"packet",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"packet",
"=",
"new",
"DatagramPacket",
"(",
"rcv",
",",
"rcv",
".",
"length",
")",
";",
"try",
"{",
"socket",
".",
"receive",
"(",
"packet",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"ip",
"==",
"null",
")",
"{",
"ip",
"=",
"packet",
".",
"getAddress",
"(",
")",
";",
"}",
"byte",
"[",
"]",
"worker",
"=",
"new",
"byte",
"[",
"2",
"]",
";",
"System",
".",
"arraycopy",
"(",
"rcv",
",",
"2",
",",
"worker",
",",
"0",
",",
"2",
")",
";",
"int",
"length",
"=",
"(",
"int",
")",
"ByteArray",
".",
"fromBytes",
"(",
"worker",
")",
";",
"worker",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"rcv",
",",
"0",
",",
"worker",
",",
"0",
",",
"length",
")",
";",
"Response",
"response",
";",
"try",
"{",
"response",
"=",
"new",
"Response",
"(",
"worker",
",",
"null",
")",
";",
"}",
"catch",
"(",
"CommandExecutionException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"token",
"==",
"null",
")",
"{",
"if",
"(",
"!",
"(",
"response",
".",
"getToken",
"(",
")",
".",
"equals",
"(",
"new",
"Token",
"(",
"\"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\"",
",",
"16",
")",
")",
"||",
"response",
".",
"getToken",
"(",
")",
".",
"equals",
"(",
"new",
"Token",
"(",
"\"00000000000000000000000000000000\"",
",",
"16",
")",
")",
")",
")",
"{",
"token",
"=",
"response",
".",
"getToken",
"(",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"!",
"(",
"(",
"response",
".",
"getDeviceID",
"(",
")",
"==",
"-",
"1",
")",
"||",
"(",
"response",
".",
"getTimeStamp",
"(",
")",
"==",
"-",
"1",
")",
")",
")",
"{",
"deviceID",
"=",
"response",
".",
"getDeviceID",
"(",
")",
";",
"timeStamp",
"=",
"response",
".",
"getTimeStamp",
"(",
")",
";",
"methodID",
"=",
"timeStamp",
"&",
"0b1111111111111",
";",
"// Possible collision about every 2 hours > acceptable",
"if",
"(",
"this",
".",
"acceptableModels",
"!=",
"null",
")",
"{",
"boolean",
"modelOk",
"=",
"false",
";",
"for",
"(",
"String",
"s",
":",
"this",
".",
"acceptableModels",
")",
"{",
"try",
"{",
"if",
"(",
"s",
".",
"equals",
"(",
"model",
"(",
")",
")",
")",
"modelOk",
"=",
"true",
";",
"}",
"catch",
"(",
"CommandExecutionException",
"ignored",
")",
"{",
"}",
"}",
"return",
"modelOk",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Try to connect to a device or discover it.
@param broadcast The InetAddress to broadcast to if no ip was given
@return True if a device was found | [
"Try",
"to",
"connect",
"to",
"a",
"device",
"or",
"discover",
"it",
"."
] | f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b | https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/base/Device.java#L117-L177 | train |
SG-O/miIO | src/main/java/de/sg_o/app/miio/base/Device.java | Device.discover | public boolean discover(){
boolean helloResponse = false;
for (int helloRetries = this.retries; helloRetries >= 0; helloRetries--) {
List<InetAddress> broadcast = listAllBroadcastAddresses();
if (broadcast == null) return false;
for (InetAddress i : broadcast) {
if (hello(i)) {
helloResponse = true;
break;
}
}
if (helloResponse) break;
}
return helloResponse;
} | java | public boolean discover(){
boolean helloResponse = false;
for (int helloRetries = this.retries; helloRetries >= 0; helloRetries--) {
List<InetAddress> broadcast = listAllBroadcastAddresses();
if (broadcast == null) return false;
for (InetAddress i : broadcast) {
if (hello(i)) {
helloResponse = true;
break;
}
}
if (helloResponse) break;
}
return helloResponse;
} | [
"public",
"boolean",
"discover",
"(",
")",
"{",
"boolean",
"helloResponse",
"=",
"false",
";",
"for",
"(",
"int",
"helloRetries",
"=",
"this",
".",
"retries",
";",
"helloRetries",
">=",
"0",
";",
"helloRetries",
"--",
")",
"{",
"List",
"<",
"InetAddress",
">",
"broadcast",
"=",
"listAllBroadcastAddresses",
"(",
")",
";",
"if",
"(",
"broadcast",
"==",
"null",
")",
"return",
"false",
";",
"for",
"(",
"InetAddress",
"i",
":",
"broadcast",
")",
"{",
"if",
"(",
"hello",
"(",
"i",
")",
")",
"{",
"helloResponse",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"helloResponse",
")",
"break",
";",
"}",
"return",
"helloResponse",
";",
"}"
] | Connect to a device and send a Hello message. If no IP has been specified, this will try do discover a device on the network.
@return True if the device has been successfully acquired. | [
"Connect",
"to",
"a",
"device",
"and",
"send",
"a",
"Hello",
"message",
".",
"If",
"no",
"IP",
"has",
"been",
"specified",
"this",
"will",
"try",
"do",
"discover",
"a",
"device",
"on",
"the",
"network",
"."
] | f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b | https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/base/Device.java#L183-L197 | train |
SG-O/miIO | src/main/java/de/sg_o/app/miio/base/Device.java | Device.send | public String send(String payload) throws CommandExecutionException {
if (payload == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
if (deviceID == -1 || timeStamp == -1 || token == null || ip == null) {
if (!discover()) throw new CommandExecutionException(CommandExecutionException.Error.DEVICE_NOT_FOUND);
}
if (methodID >= 10000) methodID = 1;
if (ip == null || token == null) throw new CommandExecutionException(CommandExecutionException.Error.IP_OR_TOKEN_UNKNOWN);
if (socket == null) return null;
timeStamp++;
Command msg = new Command(this.token,this.deviceID,timeStamp,this.methodID,"", null);
methodID++;
int retriesLeft = this.retries;
while (true) {
try {
byte[] resp = send(msg.create(payload));
if (!Response.testMessage(resp, this.token)) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
if (resp.length > 0x20) {
byte[] pl = new byte[resp.length - 0x20];
System.arraycopy(resp, 0x20, pl, 0, pl.length);
String payloadString = Response.decryptPayload(pl, this.token);
if (payloadString == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
return payloadString;
}
} catch (CommandExecutionException e) {
if (retriesLeft > 0){
retriesLeft--;
continue;
}
throw e;
}
}
} | java | public String send(String payload) throws CommandExecutionException {
if (payload == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
if (deviceID == -1 || timeStamp == -1 || token == null || ip == null) {
if (!discover()) throw new CommandExecutionException(CommandExecutionException.Error.DEVICE_NOT_FOUND);
}
if (methodID >= 10000) methodID = 1;
if (ip == null || token == null) throw new CommandExecutionException(CommandExecutionException.Error.IP_OR_TOKEN_UNKNOWN);
if (socket == null) return null;
timeStamp++;
Command msg = new Command(this.token,this.deviceID,timeStamp,this.methodID,"", null);
methodID++;
int retriesLeft = this.retries;
while (true) {
try {
byte[] resp = send(msg.create(payload));
if (!Response.testMessage(resp, this.token)) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
if (resp.length > 0x20) {
byte[] pl = new byte[resp.length - 0x20];
System.arraycopy(resp, 0x20, pl, 0, pl.length);
String payloadString = Response.decryptPayload(pl, this.token);
if (payloadString == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
return payloadString;
}
} catch (CommandExecutionException e) {
if (retriesLeft > 0){
retriesLeft--;
continue;
}
throw e;
}
}
} | [
"public",
"String",
"send",
"(",
"String",
"payload",
")",
"throws",
"CommandExecutionException",
"{",
"if",
"(",
"payload",
"==",
"null",
")",
"throw",
"new",
"CommandExecutionException",
"(",
"CommandExecutionException",
".",
"Error",
".",
"INVALID_PARAMETERS",
")",
";",
"if",
"(",
"deviceID",
"==",
"-",
"1",
"||",
"timeStamp",
"==",
"-",
"1",
"||",
"token",
"==",
"null",
"||",
"ip",
"==",
"null",
")",
"{",
"if",
"(",
"!",
"discover",
"(",
")",
")",
"throw",
"new",
"CommandExecutionException",
"(",
"CommandExecutionException",
".",
"Error",
".",
"DEVICE_NOT_FOUND",
")",
";",
"}",
"if",
"(",
"methodID",
">=",
"10000",
")",
"methodID",
"=",
"1",
";",
"if",
"(",
"ip",
"==",
"null",
"||",
"token",
"==",
"null",
")",
"throw",
"new",
"CommandExecutionException",
"(",
"CommandExecutionException",
".",
"Error",
".",
"IP_OR_TOKEN_UNKNOWN",
")",
";",
"if",
"(",
"socket",
"==",
"null",
")",
"return",
"null",
";",
"timeStamp",
"++",
";",
"Command",
"msg",
"=",
"new",
"Command",
"(",
"this",
".",
"token",
",",
"this",
".",
"deviceID",
",",
"timeStamp",
",",
"this",
".",
"methodID",
",",
"\"\"",
",",
"null",
")",
";",
"methodID",
"++",
";",
"int",
"retriesLeft",
"=",
"this",
".",
"retries",
";",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"byte",
"[",
"]",
"resp",
"=",
"send",
"(",
"msg",
".",
"create",
"(",
"payload",
")",
")",
";",
"if",
"(",
"!",
"Response",
".",
"testMessage",
"(",
"resp",
",",
"this",
".",
"token",
")",
")",
"throw",
"new",
"CommandExecutionException",
"(",
"CommandExecutionException",
".",
"Error",
".",
"INVALID_RESPONSE",
")",
";",
"if",
"(",
"resp",
".",
"length",
">",
"0x20",
")",
"{",
"byte",
"[",
"]",
"pl",
"=",
"new",
"byte",
"[",
"resp",
".",
"length",
"-",
"0x20",
"]",
";",
"System",
".",
"arraycopy",
"(",
"resp",
",",
"0x20",
",",
"pl",
",",
"0",
",",
"pl",
".",
"length",
")",
";",
"String",
"payloadString",
"=",
"Response",
".",
"decryptPayload",
"(",
"pl",
",",
"this",
".",
"token",
")",
";",
"if",
"(",
"payloadString",
"==",
"null",
")",
"throw",
"new",
"CommandExecutionException",
"(",
"CommandExecutionException",
".",
"Error",
".",
"INVALID_RESPONSE",
")",
";",
"return",
"payloadString",
";",
"}",
"}",
"catch",
"(",
"CommandExecutionException",
"e",
")",
"{",
"if",
"(",
"retriesLeft",
">",
"0",
")",
"{",
"retriesLeft",
"--",
";",
"continue",
";",
"}",
"throw",
"e",
";",
"}",
"}",
"}"
] | Send an arbitrary string as payload to the device.
@param payload The string to send.
@return The response of the device as an unparsed string.
@throws CommandExecutionException When there has been a error during the communication or the response was invalid. | [
"Send",
"an",
"arbitrary",
"string",
"as",
"payload",
"to",
"the",
"device",
"."
] | f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b | https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/base/Device.java#L237-L268 | train |
SG-O/miIO | src/main/java/de/sg_o/app/miio/base/Device.java | Device.update | public boolean update(String url, String md5) throws CommandExecutionException {
if (url == null || md5 == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
if (md5.length() != 32) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
JSONObject params = new JSONObject();
params.put("mode","normal");
params.put("install", "1");
params.put("app_url", url);
params.put("file_md5", md5);
params.put("proc", "dnld install");
return sendOk("miIO.ota", params);
} | java | public boolean update(String url, String md5) throws CommandExecutionException {
if (url == null || md5 == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
if (md5.length() != 32) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
JSONObject params = new JSONObject();
params.put("mode","normal");
params.put("install", "1");
params.put("app_url", url);
params.put("file_md5", md5);
params.put("proc", "dnld install");
return sendOk("miIO.ota", params);
} | [
"public",
"boolean",
"update",
"(",
"String",
"url",
",",
"String",
"md5",
")",
"throws",
"CommandExecutionException",
"{",
"if",
"(",
"url",
"==",
"null",
"||",
"md5",
"==",
"null",
")",
"throw",
"new",
"CommandExecutionException",
"(",
"CommandExecutionException",
".",
"Error",
".",
"INVALID_PARAMETERS",
")",
";",
"if",
"(",
"md5",
".",
"length",
"(",
")",
"!=",
"32",
")",
"throw",
"new",
"CommandExecutionException",
"(",
"CommandExecutionException",
".",
"Error",
".",
"INVALID_PARAMETERS",
")",
";",
"JSONObject",
"params",
"=",
"new",
"JSONObject",
"(",
")",
";",
"params",
".",
"put",
"(",
"\"mode\"",
",",
"\"normal\"",
")",
";",
"params",
".",
"put",
"(",
"\"install\"",
",",
"\"1\"",
")",
";",
"params",
".",
"put",
"(",
"\"app_url\"",
",",
"url",
")",
";",
"params",
".",
"put",
"(",
"\"file_md5\"",
",",
"md5",
")",
";",
"params",
".",
"put",
"(",
"\"proc\"",
",",
"\"dnld install\"",
")",
";",
"return",
"sendOk",
"(",
"\"miIO.ota\"",
",",
"params",
")",
";",
"}"
] | Command the device to update
@param url The URL to update from
@param md5 The MD5 Checksum for the update
@return True if the command has been received. This does not mean that the update was successful.
@throws CommandExecutionException When there has been a error during the communication or the response was invalid. | [
"Command",
"the",
"device",
"to",
"update"
] | f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b | https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/base/Device.java#L432-L442 | train |
SG-O/miIO | src/main/java/de/sg_o/app/miio/base/Device.java | Device.updateProgress | public int updateProgress() throws CommandExecutionException {
int resp = sendToArray("miIO.get_ota_progress").optInt(0, -1);
if ((resp < 0) || (resp > 100)) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
return resp;
} | java | public int updateProgress() throws CommandExecutionException {
int resp = sendToArray("miIO.get_ota_progress").optInt(0, -1);
if ((resp < 0) || (resp > 100)) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
return resp;
} | [
"public",
"int",
"updateProgress",
"(",
")",
"throws",
"CommandExecutionException",
"{",
"int",
"resp",
"=",
"sendToArray",
"(",
"\"miIO.get_ota_progress\"",
")",
".",
"optInt",
"(",
"0",
",",
"-",
"1",
")",
";",
"if",
"(",
"(",
"resp",
"<",
"0",
")",
"||",
"(",
"resp",
">",
"100",
")",
")",
"throw",
"new",
"CommandExecutionException",
"(",
"CommandExecutionException",
".",
"Error",
".",
"INVALID_RESPONSE",
")",
";",
"return",
"resp",
";",
"}"
] | Request the update progress as a percentage value from 0 to 100
@return The current progress.
@throws CommandExecutionException When there has been a error during the communication or the response was invalid. | [
"Request",
"the",
"update",
"progress",
"as",
"a",
"percentage",
"value",
"from",
"0",
"to",
"100"
] | f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b | https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/base/Device.java#L449-L453 | train |
SG-O/miIO | src/main/java/de/sg_o/app/miio/base/Device.java | Device.updateStatus | public String updateStatus() throws CommandExecutionException {
String resp = sendToArray("miIO.get_ota_state").optString(0, null);
if (resp == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
return resp;
} | java | public String updateStatus() throws CommandExecutionException {
String resp = sendToArray("miIO.get_ota_state").optString(0, null);
if (resp == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
return resp;
} | [
"public",
"String",
"updateStatus",
"(",
")",
"throws",
"CommandExecutionException",
"{",
"String",
"resp",
"=",
"sendToArray",
"(",
"\"miIO.get_ota_state\"",
")",
".",
"optString",
"(",
"0",
",",
"null",
")",
";",
"if",
"(",
"resp",
"==",
"null",
")",
"throw",
"new",
"CommandExecutionException",
"(",
"CommandExecutionException",
".",
"Error",
".",
"INVALID_RESPONSE",
")",
";",
"return",
"resp",
";",
"}"
] | Request the update status.
@return The update status.
@throws CommandExecutionException When there has been a error during the communication or the response was invalid. | [
"Request",
"the",
"update",
"status",
"."
] | f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b | https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/base/Device.java#L460-L464 | train |
SG-O/miIO | src/main/java/de/sg_o/app/miio/base/Device.java | Device.model | public String model() throws CommandExecutionException {
JSONObject in = info();
if (in == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
return in.optString("model");
} | java | public String model() throws CommandExecutionException {
JSONObject in = info();
if (in == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
return in.optString("model");
} | [
"public",
"String",
"model",
"(",
")",
"throws",
"CommandExecutionException",
"{",
"JSONObject",
"in",
"=",
"info",
"(",
")",
";",
"if",
"(",
"in",
"==",
"null",
")",
"throw",
"new",
"CommandExecutionException",
"(",
"CommandExecutionException",
".",
"Error",
".",
"INVALID_RESPONSE",
")",
";",
"return",
"in",
".",
"optString",
"(",
"\"model\"",
")",
";",
"}"
] | Get the devices model id.
@return The devices model id.
@throws CommandExecutionException When there has been a error during the communication or the response was invalid. | [
"Get",
"the",
"devices",
"model",
"id",
"."
] | f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b | https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/base/Device.java#L492-L496 | train |
SG-O/miIO | src/main/java/de/sg_o/app/miio/util/ByteArray.java | ByteArray.hexToBytes | public static byte[] hexToBytes(String s) {
try {
if (s == null) return new byte[0];
s = s.toUpperCase();
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i + 1), 16));
}
return data;
} catch (StringIndexOutOfBoundsException e) {
return null;
}
} | java | public static byte[] hexToBytes(String s) {
try {
if (s == null) return new byte[0];
s = s.toUpperCase();
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i + 1), 16));
}
return data;
} catch (StringIndexOutOfBoundsException e) {
return null;
}
} | [
"public",
"static",
"byte",
"[",
"]",
"hexToBytes",
"(",
"String",
"s",
")",
"{",
"try",
"{",
"if",
"(",
"s",
"==",
"null",
")",
"return",
"new",
"byte",
"[",
"0",
"]",
";",
"s",
"=",
"s",
".",
"toUpperCase",
"(",
")",
";",
"int",
"len",
"=",
"s",
".",
"length",
"(",
")",
";",
"byte",
"[",
"]",
"data",
"=",
"new",
"byte",
"[",
"len",
"/",
"2",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"+=",
"2",
")",
"{",
"data",
"[",
"i",
"/",
"2",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"Character",
".",
"digit",
"(",
"s",
".",
"charAt",
"(",
"i",
")",
",",
"16",
")",
"<<",
"4",
")",
"+",
"Character",
".",
"digit",
"(",
"s",
".",
"charAt",
"(",
"i",
"+",
"1",
")",
",",
"16",
")",
")",
";",
"}",
"return",
"data",
";",
"}",
"catch",
"(",
"StringIndexOutOfBoundsException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Convert a hexadecimal string to a byte array.
@param s The hexadecimal string to convert.
@return The byte array of that string. Null if conversion was not possible. | [
"Convert",
"a",
"hexadecimal",
"string",
"to",
"a",
"byte",
"array",
"."
] | f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b | https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/util/ByteArray.java#L44-L58 | train |
SG-O/miIO | src/main/java/de/sg_o/app/miio/util/ByteArray.java | ByteArray.append | public static byte[] append(byte[] first, byte[] second) {
if ((first == null) || (second == null)) return null;
byte[] output = new byte[first.length + second.length];
System.arraycopy(first, 0, output, 0, first.length);
System.arraycopy(second, 0, output, first.length, second.length);
return output;
} | java | public static byte[] append(byte[] first, byte[] second) {
if ((first == null) || (second == null)) return null;
byte[] output = new byte[first.length + second.length];
System.arraycopy(first, 0, output, 0, first.length);
System.arraycopy(second, 0, output, first.length, second.length);
return output;
} | [
"public",
"static",
"byte",
"[",
"]",
"append",
"(",
"byte",
"[",
"]",
"first",
",",
"byte",
"[",
"]",
"second",
")",
"{",
"if",
"(",
"(",
"first",
"==",
"null",
")",
"||",
"(",
"second",
"==",
"null",
")",
")",
"return",
"null",
";",
"byte",
"[",
"]",
"output",
"=",
"new",
"byte",
"[",
"first",
".",
"length",
"+",
"second",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"first",
",",
"0",
",",
"output",
",",
"0",
",",
"first",
".",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"second",
",",
"0",
",",
"output",
",",
"first",
".",
"length",
",",
"second",
".",
"length",
")",
";",
"return",
"output",
";",
"}"
] | Add two byte arrays to each other.
@param first The first array.
@param second The second byte array that should be appended to the first array.
@return The two arrays appended to ech other. Null if either input is null. | [
"Add",
"two",
"byte",
"arrays",
"to",
"each",
"other",
"."
] | f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b | https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/util/ByteArray.java#L66-L72 | train |
SG-O/miIO | src/main/java/de/sg_o/app/miio/util/ByteArray.java | ByteArray.toBytes | public static byte[] toBytes(long value, int length) {
if (length <= 0) return new byte[0];
if (length > 8) length = 8;
byte[] out = new byte[length];
for (int i = length - 1; i >= 0; i--){
out[i] = (byte)(value & 0xFFL);
value = value >> 8;
}
return out;
} | java | public static byte[] toBytes(long value, int length) {
if (length <= 0) return new byte[0];
if (length > 8) length = 8;
byte[] out = new byte[length];
for (int i = length - 1; i >= 0; i--){
out[i] = (byte)(value & 0xFFL);
value = value >> 8;
}
return out;
} | [
"public",
"static",
"byte",
"[",
"]",
"toBytes",
"(",
"long",
"value",
",",
"int",
"length",
")",
"{",
"if",
"(",
"length",
"<=",
"0",
")",
"return",
"new",
"byte",
"[",
"0",
"]",
";",
"if",
"(",
"length",
">",
"8",
")",
"length",
"=",
"8",
";",
"byte",
"[",
"]",
"out",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"out",
"[",
"i",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
"&",
"0xFF",
"L",
")",
";",
"value",
"=",
"value",
">>",
"8",
";",
"}",
"return",
"out",
";",
"}"
] | Convert a long to a byte array.
@param value The long to convert.
@param length The number of bytes to convert to. This allows for the conversion of shorts and ints.
@return The converted long as a byte array. | [
"Convert",
"a",
"long",
"to",
"a",
"byte",
"array",
"."
] | f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b | https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/util/ByteArray.java#L80-L89 | train |
SG-O/miIO | src/main/java/de/sg_o/app/miio/util/ByteArray.java | ByteArray.fromBytes | public static long fromBytes(byte[] value){
if (value == null) return 0;
long out = 0;
int length = value.length;
if (length > 8) length = 8;
for (int i = 0; i < length; i++){
out = (out << 8) + (value[i] & 0xff);
}
return out;
} | java | public static long fromBytes(byte[] value){
if (value == null) return 0;
long out = 0;
int length = value.length;
if (length > 8) length = 8;
for (int i = 0; i < length; i++){
out = (out << 8) + (value[i] & 0xff);
}
return out;
} | [
"public",
"static",
"long",
"fromBytes",
"(",
"byte",
"[",
"]",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"0",
";",
"long",
"out",
"=",
"0",
";",
"int",
"length",
"=",
"value",
".",
"length",
";",
"if",
"(",
"length",
">",
"8",
")",
"length",
"=",
"8",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"out",
"=",
"(",
"out",
"<<",
"8",
")",
"+",
"(",
"value",
"[",
"i",
"]",
"&",
"0xff",
")",
";",
"}",
"return",
"out",
";",
"}"
] | Convert a byte array to a long.
@param value The array to convert.
@return The long value. | [
"Convert",
"a",
"byte",
"array",
"to",
"a",
"long",
"."
] | f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b | https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/util/ByteArray.java#L96-L105 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/AbstractInsnNode.java | AbstractInsnNode.acceptAnnotations | protected final void acceptAnnotations(final MethodVisitor mv) {
int n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations
.size();
for (int i = 0; i < n; ++i) {
TypeAnnotationNode an = visibleTypeAnnotations.get(i);
an.accept(mv.visitInsnAnnotation(an.typeRef, an.typePath, an.desc,
true));
}
n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations
.size();
for (int i = 0; i < n; ++i) {
TypeAnnotationNode an = invisibleTypeAnnotations.get(i);
an.accept(mv.visitInsnAnnotation(an.typeRef, an.typePath, an.desc,
false));
}
} | java | protected final void acceptAnnotations(final MethodVisitor mv) {
int n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations
.size();
for (int i = 0; i < n; ++i) {
TypeAnnotationNode an = visibleTypeAnnotations.get(i);
an.accept(mv.visitInsnAnnotation(an.typeRef, an.typePath, an.desc,
true));
}
n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations
.size();
for (int i = 0; i < n; ++i) {
TypeAnnotationNode an = invisibleTypeAnnotations.get(i);
an.accept(mv.visitInsnAnnotation(an.typeRef, an.typePath, an.desc,
false));
}
} | [
"protected",
"final",
"void",
"acceptAnnotations",
"(",
"final",
"MethodVisitor",
"mv",
")",
"{",
"int",
"n",
"=",
"visibleTypeAnnotations",
"==",
"null",
"?",
"0",
":",
"visibleTypeAnnotations",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"TypeAnnotationNode",
"an",
"=",
"visibleTypeAnnotations",
".",
"get",
"(",
"i",
")",
";",
"an",
".",
"accept",
"(",
"mv",
".",
"visitInsnAnnotation",
"(",
"an",
".",
"typeRef",
",",
"an",
".",
"typePath",
",",
"an",
".",
"desc",
",",
"true",
")",
")",
";",
"}",
"n",
"=",
"invisibleTypeAnnotations",
"==",
"null",
"?",
"0",
":",
"invisibleTypeAnnotations",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"TypeAnnotationNode",
"an",
"=",
"invisibleTypeAnnotations",
".",
"get",
"(",
"i",
")",
";",
"an",
".",
"accept",
"(",
"mv",
".",
"visitInsnAnnotation",
"(",
"an",
".",
"typeRef",
",",
"an",
".",
"typePath",
",",
"an",
".",
"desc",
",",
"false",
")",
")",
";",
"}",
"}"
] | Makes the given visitor visit the annotations of this instruction.
@param mv
a method visitor. | [
"Makes",
"the",
"given",
"visitor",
"visit",
"the",
"annotations",
"of",
"this",
"instruction",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/AbstractInsnNode.java#L235-L250 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/AbstractInsnNode.java | AbstractInsnNode.cloneAnnotations | protected final AbstractInsnNode cloneAnnotations(
final AbstractInsnNode insn) {
if (insn.visibleTypeAnnotations != null) {
this.visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>();
for (int i = 0; i < insn.visibleTypeAnnotations.size(); ++i) {
TypeAnnotationNode src = insn.visibleTypeAnnotations.get(i);
TypeAnnotationNode ann = new TypeAnnotationNode(src.typeRef,
src.typePath, src.desc);
src.accept(ann);
this.visibleTypeAnnotations.add(ann);
}
}
if (insn.invisibleTypeAnnotations != null) {
this.invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>();
for (int i = 0; i < insn.invisibleTypeAnnotations.size(); ++i) {
TypeAnnotationNode src = insn.invisibleTypeAnnotations.get(i);
TypeAnnotationNode ann = new TypeAnnotationNode(src.typeRef,
src.typePath, src.desc);
src.accept(ann);
this.invisibleTypeAnnotations.add(ann);
}
}
return this;
} | java | protected final AbstractInsnNode cloneAnnotations(
final AbstractInsnNode insn) {
if (insn.visibleTypeAnnotations != null) {
this.visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>();
for (int i = 0; i < insn.visibleTypeAnnotations.size(); ++i) {
TypeAnnotationNode src = insn.visibleTypeAnnotations.get(i);
TypeAnnotationNode ann = new TypeAnnotationNode(src.typeRef,
src.typePath, src.desc);
src.accept(ann);
this.visibleTypeAnnotations.add(ann);
}
}
if (insn.invisibleTypeAnnotations != null) {
this.invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>();
for (int i = 0; i < insn.invisibleTypeAnnotations.size(); ++i) {
TypeAnnotationNode src = insn.invisibleTypeAnnotations.get(i);
TypeAnnotationNode ann = new TypeAnnotationNode(src.typeRef,
src.typePath, src.desc);
src.accept(ann);
this.invisibleTypeAnnotations.add(ann);
}
}
return this;
} | [
"protected",
"final",
"AbstractInsnNode",
"cloneAnnotations",
"(",
"final",
"AbstractInsnNode",
"insn",
")",
"{",
"if",
"(",
"insn",
".",
"visibleTypeAnnotations",
"!=",
"null",
")",
"{",
"this",
".",
"visibleTypeAnnotations",
"=",
"new",
"ArrayList",
"<",
"TypeAnnotationNode",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"insn",
".",
"visibleTypeAnnotations",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"TypeAnnotationNode",
"src",
"=",
"insn",
".",
"visibleTypeAnnotations",
".",
"get",
"(",
"i",
")",
";",
"TypeAnnotationNode",
"ann",
"=",
"new",
"TypeAnnotationNode",
"(",
"src",
".",
"typeRef",
",",
"src",
".",
"typePath",
",",
"src",
".",
"desc",
")",
";",
"src",
".",
"accept",
"(",
"ann",
")",
";",
"this",
".",
"visibleTypeAnnotations",
".",
"add",
"(",
"ann",
")",
";",
"}",
"}",
"if",
"(",
"insn",
".",
"invisibleTypeAnnotations",
"!=",
"null",
")",
"{",
"this",
".",
"invisibleTypeAnnotations",
"=",
"new",
"ArrayList",
"<",
"TypeAnnotationNode",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"insn",
".",
"invisibleTypeAnnotations",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"TypeAnnotationNode",
"src",
"=",
"insn",
".",
"invisibleTypeAnnotations",
".",
"get",
"(",
"i",
")",
";",
"TypeAnnotationNode",
"ann",
"=",
"new",
"TypeAnnotationNode",
"(",
"src",
".",
"typeRef",
",",
"src",
".",
"typePath",
",",
"src",
".",
"desc",
")",
";",
"src",
".",
"accept",
"(",
"ann",
")",
";",
"this",
".",
"invisibleTypeAnnotations",
".",
"add",
"(",
"ann",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] | Clones the annotations of the given instruction into this instruction.
@param insn
the source instruction.
@return this instruction. | [
"Clones",
"the",
"annotations",
"of",
"the",
"given",
"instruction",
"into",
"this",
"instruction",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/AbstractInsnNode.java#L302-L325 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBox.java | BeanBox.getDebugInfo | public String getDebugInfo() {
StringBuilder sb = new StringBuilder("\r\n========BeanBox Debug for " + this + "===========\r\n");
sb.append("target=" + this.target).append("\r\n");
sb.append("pureValue=" + this.pureValue).append("\r\n");
sb.append("type=" + this.type).append("\r\n");
sb.append("required=" + this.required).append("\r\n");
sb.append("beanClass=" + this.beanClass).append("\r\n");
sb.append("singleton=" + this.singleton).append("\r\n");
sb.append("methodAops=" + this.methodAops).append("\r\n");
sb.append("methodAopRules=" + this.aopRules).append("\r\n");
sb.append("constructor=" + this.constructor).append("\r\n");
sb.append("constructorParams=" + this.constructorParams).append("\r\n");
sb.append("postConstructs=" + this.postConstruct).append("\r\n");
sb.append("preDestorys=" + this.preDestroy).append("\r\n");
sb.append("fieldInjects=" + this.fieldInjects).append("\r\n");
sb.append("methodInjects=" + this.methodInjects).append("\r\n");
sb.append("createMethod=" + this.createMethod).append("\r\n");
sb.append("configMethod=" + this.configMethod).append("\r\n");
sb.append("========BeanBox Debug Info End===========");
return sb.toString();
} | java | public String getDebugInfo() {
StringBuilder sb = new StringBuilder("\r\n========BeanBox Debug for " + this + "===========\r\n");
sb.append("target=" + this.target).append("\r\n");
sb.append("pureValue=" + this.pureValue).append("\r\n");
sb.append("type=" + this.type).append("\r\n");
sb.append("required=" + this.required).append("\r\n");
sb.append("beanClass=" + this.beanClass).append("\r\n");
sb.append("singleton=" + this.singleton).append("\r\n");
sb.append("methodAops=" + this.methodAops).append("\r\n");
sb.append("methodAopRules=" + this.aopRules).append("\r\n");
sb.append("constructor=" + this.constructor).append("\r\n");
sb.append("constructorParams=" + this.constructorParams).append("\r\n");
sb.append("postConstructs=" + this.postConstruct).append("\r\n");
sb.append("preDestorys=" + this.preDestroy).append("\r\n");
sb.append("fieldInjects=" + this.fieldInjects).append("\r\n");
sb.append("methodInjects=" + this.methodInjects).append("\r\n");
sb.append("createMethod=" + this.createMethod).append("\r\n");
sb.append("configMethod=" + this.configMethod).append("\r\n");
sb.append("========BeanBox Debug Info End===========");
return sb.toString();
} | [
"public",
"String",
"getDebugInfo",
"(",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"\"\\r\\n========BeanBox Debug for \"",
"+",
"this",
"+",
"\"===========\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"target=\"",
"+",
"this",
".",
"target",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"pureValue=\"",
"+",
"this",
".",
"pureValue",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"type=\"",
"+",
"this",
".",
"type",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"required=\"",
"+",
"this",
".",
"required",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"beanClass=\"",
"+",
"this",
".",
"beanClass",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"singleton=\"",
"+",
"this",
".",
"singleton",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"methodAops=\"",
"+",
"this",
".",
"methodAops",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"methodAopRules=\"",
"+",
"this",
".",
"aopRules",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"constructor=\"",
"+",
"this",
".",
"constructor",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"constructorParams=\"",
"+",
"this",
".",
"constructorParams",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"postConstructs=\"",
"+",
"this",
".",
"postConstruct",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"preDestorys=\"",
"+",
"this",
".",
"preDestroy",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"fieldInjects=\"",
"+",
"this",
".",
"fieldInjects",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"methodInjects=\"",
"+",
"this",
".",
"methodInjects",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"createMethod=\"",
"+",
"this",
".",
"createMethod",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"configMethod=\"",
"+",
"this",
".",
"configMethod",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"========BeanBox Debug Info End===========\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | For debug only, will delete in future version | [
"For",
"debug",
"only",
"will",
"delete",
"in",
"future",
"version"
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBox.java#L121-L141 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBox.java | BeanBox.addBeanAop | public synchronized BeanBox addBeanAop(Object aop, String methodNameRegex) {
checkOrCreateMethodAopRules();
aopRules.add(new Object[] { BeanBoxUtils.checkAOP(aop), methodNameRegex });
return this;
} | java | public synchronized BeanBox addBeanAop(Object aop, String methodNameRegex) {
checkOrCreateMethodAopRules();
aopRules.add(new Object[] { BeanBoxUtils.checkAOP(aop), methodNameRegex });
return this;
} | [
"public",
"synchronized",
"BeanBox",
"addBeanAop",
"(",
"Object",
"aop",
",",
"String",
"methodNameRegex",
")",
"{",
"checkOrCreateMethodAopRules",
"(",
")",
";",
"aopRules",
".",
"add",
"(",
"new",
"Object",
"[",
"]",
"{",
"BeanBoxUtils",
".",
"checkAOP",
"(",
"aop",
")",
",",
"methodNameRegex",
"}",
")",
";",
"return",
"this",
";",
"}"
] | Add an AOP to Bean
@param aop
An AOP alliance interceptor class or instance
@param methodNameRegex
@return | [
"Add",
"an",
"AOP",
"to",
"Bean"
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBox.java#L267-L271 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBox.java | BeanBox.injectField | public BeanBox injectField(String fieldName, Object inject) {
BeanBox box = BeanBoxUtils.wrapParamToBox(inject);
checkOrCreateFieldInjects();
Field f = ReflectionUtils.findField(beanClass, fieldName);
box.setType(f.getType());
ReflectionUtils.makeAccessible(f);
this.getFieldInjects().put(f, box);
return this;
} | java | public BeanBox injectField(String fieldName, Object inject) {
BeanBox box = BeanBoxUtils.wrapParamToBox(inject);
checkOrCreateFieldInjects();
Field f = ReflectionUtils.findField(beanClass, fieldName);
box.setType(f.getType());
ReflectionUtils.makeAccessible(f);
this.getFieldInjects().put(f, box);
return this;
} | [
"public",
"BeanBox",
"injectField",
"(",
"String",
"fieldName",
",",
"Object",
"inject",
")",
"{",
"BeanBox",
"box",
"=",
"BeanBoxUtils",
".",
"wrapParamToBox",
"(",
"inject",
")",
";",
"checkOrCreateFieldInjects",
"(",
")",
";",
"Field",
"f",
"=",
"ReflectionUtils",
".",
"findField",
"(",
"beanClass",
",",
"fieldName",
")",
";",
"box",
".",
"setType",
"(",
"f",
".",
"getType",
"(",
")",
")",
";",
"ReflectionUtils",
".",
"makeAccessible",
"(",
"f",
")",
";",
"this",
".",
"getFieldInjects",
"(",
")",
".",
"put",
"(",
"f",
",",
"box",
")",
";",
"return",
"this",
";",
"}"
] | Inject class, BeanBox class or instance, | [
"Inject",
"class",
"BeanBox",
"class",
"or",
"instance"
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBox.java#L288-L296 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBox.java | BeanBox.injectValue | public BeanBox injectValue(String fieldName, Object constValue) {
checkOrCreateFieldInjects();
Field f = ReflectionUtils.findField(beanClass, fieldName);
BeanBox inject = new BeanBox();
inject.setTarget(constValue);
inject.setType(f.getType());
inject.setPureValue(true);
ReflectionUtils.makeAccessible(f);
this.getFieldInjects().put(f, inject);
return this;
} | java | public BeanBox injectValue(String fieldName, Object constValue) {
checkOrCreateFieldInjects();
Field f = ReflectionUtils.findField(beanClass, fieldName);
BeanBox inject = new BeanBox();
inject.setTarget(constValue);
inject.setType(f.getType());
inject.setPureValue(true);
ReflectionUtils.makeAccessible(f);
this.getFieldInjects().put(f, inject);
return this;
} | [
"public",
"BeanBox",
"injectValue",
"(",
"String",
"fieldName",
",",
"Object",
"constValue",
")",
"{",
"checkOrCreateFieldInjects",
"(",
")",
";",
"Field",
"f",
"=",
"ReflectionUtils",
".",
"findField",
"(",
"beanClass",
",",
"fieldName",
")",
";",
"BeanBox",
"inject",
"=",
"new",
"BeanBox",
"(",
")",
";",
"inject",
".",
"setTarget",
"(",
"constValue",
")",
";",
"inject",
".",
"setType",
"(",
"f",
".",
"getType",
"(",
")",
")",
";",
"inject",
".",
"setPureValue",
"(",
"true",
")",
";",
"ReflectionUtils",
".",
"makeAccessible",
"(",
"f",
")",
";",
"this",
".",
"getFieldInjects",
"(",
")",
".",
"put",
"(",
"f",
",",
"inject",
")",
";",
"return",
"this",
";",
"}"
] | Inject a pure value to Field | [
"Inject",
"a",
"pure",
"value",
"to",
"Field"
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBox.java#L304-L314 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/TryCatchBlockNode.java | TryCatchBlockNode.updateIndex | public void updateIndex(final int index) {
int newTypeRef = 0x42000000 | (index << 8);
if (visibleTypeAnnotations != null) {
for (TypeAnnotationNode tan : visibleTypeAnnotations) {
tan.typeRef = newTypeRef;
}
}
if (invisibleTypeAnnotations != null) {
for (TypeAnnotationNode tan : invisibleTypeAnnotations) {
tan.typeRef = newTypeRef;
}
}
} | java | public void updateIndex(final int index) {
int newTypeRef = 0x42000000 | (index << 8);
if (visibleTypeAnnotations != null) {
for (TypeAnnotationNode tan : visibleTypeAnnotations) {
tan.typeRef = newTypeRef;
}
}
if (invisibleTypeAnnotations != null) {
for (TypeAnnotationNode tan : invisibleTypeAnnotations) {
tan.typeRef = newTypeRef;
}
}
} | [
"public",
"void",
"updateIndex",
"(",
"final",
"int",
"index",
")",
"{",
"int",
"newTypeRef",
"=",
"0x42000000",
"|",
"(",
"index",
"<<",
"8",
")",
";",
"if",
"(",
"visibleTypeAnnotations",
"!=",
"null",
")",
"{",
"for",
"(",
"TypeAnnotationNode",
"tan",
":",
"visibleTypeAnnotations",
")",
"{",
"tan",
".",
"typeRef",
"=",
"newTypeRef",
";",
"}",
"}",
"if",
"(",
"invisibleTypeAnnotations",
"!=",
"null",
")",
"{",
"for",
"(",
"TypeAnnotationNode",
"tan",
":",
"invisibleTypeAnnotations",
")",
"{",
"tan",
".",
"typeRef",
"=",
"newTypeRef",
";",
"}",
"}",
"}"
] | Updates the index of this try catch block in the method's list of try
catch block nodes. This index maybe stored in the 'target' field of the
type annotations of this block.
@param index
the new index of this try catch block in the method's list of
try catch block nodes. | [
"Updates",
"the",
"index",
"of",
"this",
"try",
"catch",
"block",
"in",
"the",
"method",
"s",
"list",
"of",
"try",
"catch",
"block",
"nodes",
".",
"This",
"index",
"maybe",
"stored",
"in",
"the",
"target",
"field",
"of",
"the",
"type",
"annotations",
"of",
"this",
"block",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/TryCatchBlockNode.java#L115-L127 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/TryCatchBlockNode.java | TryCatchBlockNode.accept | public void accept(final MethodVisitor mv) {
mv.visitTryCatchBlock(start.getLabel(), end.getLabel(),
handler == null ? null : handler.getLabel(), type);
int n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations
.size();
for (int i = 0; i < n; ++i) {
TypeAnnotationNode an = visibleTypeAnnotations.get(i);
an.accept(mv.visitTryCatchAnnotation(an.typeRef, an.typePath,
an.desc, true));
}
n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations
.size();
for (int i = 0; i < n; ++i) {
TypeAnnotationNode an = invisibleTypeAnnotations.get(i);
an.accept(mv.visitTryCatchAnnotation(an.typeRef, an.typePath,
an.desc, false));
}
} | java | public void accept(final MethodVisitor mv) {
mv.visitTryCatchBlock(start.getLabel(), end.getLabel(),
handler == null ? null : handler.getLabel(), type);
int n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations
.size();
for (int i = 0; i < n; ++i) {
TypeAnnotationNode an = visibleTypeAnnotations.get(i);
an.accept(mv.visitTryCatchAnnotation(an.typeRef, an.typePath,
an.desc, true));
}
n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations
.size();
for (int i = 0; i < n; ++i) {
TypeAnnotationNode an = invisibleTypeAnnotations.get(i);
an.accept(mv.visitTryCatchAnnotation(an.typeRef, an.typePath,
an.desc, false));
}
} | [
"public",
"void",
"accept",
"(",
"final",
"MethodVisitor",
"mv",
")",
"{",
"mv",
".",
"visitTryCatchBlock",
"(",
"start",
".",
"getLabel",
"(",
")",
",",
"end",
".",
"getLabel",
"(",
")",
",",
"handler",
"==",
"null",
"?",
"null",
":",
"handler",
".",
"getLabel",
"(",
")",
",",
"type",
")",
";",
"int",
"n",
"=",
"visibleTypeAnnotations",
"==",
"null",
"?",
"0",
":",
"visibleTypeAnnotations",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"TypeAnnotationNode",
"an",
"=",
"visibleTypeAnnotations",
".",
"get",
"(",
"i",
")",
";",
"an",
".",
"accept",
"(",
"mv",
".",
"visitTryCatchAnnotation",
"(",
"an",
".",
"typeRef",
",",
"an",
".",
"typePath",
",",
"an",
".",
"desc",
",",
"true",
")",
")",
";",
"}",
"n",
"=",
"invisibleTypeAnnotations",
"==",
"null",
"?",
"0",
":",
"invisibleTypeAnnotations",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"TypeAnnotationNode",
"an",
"=",
"invisibleTypeAnnotations",
".",
"get",
"(",
"i",
")",
";",
"an",
".",
"accept",
"(",
"mv",
".",
"visitTryCatchAnnotation",
"(",
"an",
".",
"typeRef",
",",
"an",
".",
"typePath",
",",
"an",
".",
"desc",
",",
"false",
")",
")",
";",
"}",
"}"
] | Makes the given visitor visit this try catch block.
@param mv
a method visitor. | [
"Makes",
"the",
"given",
"visitor",
"visit",
"this",
"try",
"catch",
"block",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/TryCatchBlockNode.java#L135-L152 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckSignatureAdapter.java | CheckSignatureAdapter.visitFormalTypeParameter | @Override
public void visitFormalTypeParameter(final String name) {
if (type == TYPE_SIGNATURE
|| (state != EMPTY && state != FORMAL && state != BOUND)) {
throw new IllegalStateException();
}
CheckMethodAdapter.checkIdentifier(name, "formal type parameter");
state = FORMAL;
if (sv != null) {
sv.visitFormalTypeParameter(name);
}
} | java | @Override
public void visitFormalTypeParameter(final String name) {
if (type == TYPE_SIGNATURE
|| (state != EMPTY && state != FORMAL && state != BOUND)) {
throw new IllegalStateException();
}
CheckMethodAdapter.checkIdentifier(name, "formal type parameter");
state = FORMAL;
if (sv != null) {
sv.visitFormalTypeParameter(name);
}
} | [
"@",
"Override",
"public",
"void",
"visitFormalTypeParameter",
"(",
"final",
"String",
"name",
")",
"{",
"if",
"(",
"type",
"==",
"TYPE_SIGNATURE",
"||",
"(",
"state",
"!=",
"EMPTY",
"&&",
"state",
"!=",
"FORMAL",
"&&",
"state",
"!=",
"BOUND",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
")",
";",
"}",
"CheckMethodAdapter",
".",
"checkIdentifier",
"(",
"name",
",",
"\"formal type parameter\"",
")",
";",
"state",
"=",
"FORMAL",
";",
"if",
"(",
"sv",
"!=",
"null",
")",
"{",
"sv",
".",
"visitFormalTypeParameter",
"(",
"name",
")",
";",
"}",
"}"
] | class and method signatures | [
"class",
"and",
"method",
"signatures"
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckSignatureAdapter.java#L143-L154 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/ASMifier.java | ASMifier.appendConstant | static void appendConstant(final StringBuffer buf, final Object cst) {
if (cst == null) {
buf.append("null");
} else if (cst instanceof String) {
appendString(buf, (String) cst);
} else if (cst instanceof Type) {
buf.append("Type.getType(\"");
buf.append(((Type) cst).getDescriptor());
buf.append("\")");
} else if (cst instanceof Handle) {
buf.append("new Handle(");
Handle h = (Handle) cst;
buf.append("Opcodes.").append(HANDLE_TAG[h.getTag()])
.append(", \"");
buf.append(h.getOwner()).append("\", \"");
buf.append(h.getName()).append("\", \"");
buf.append(h.getDesc()).append("\")");
} else if (cst instanceof Byte) {
buf.append("new Byte((byte)").append(cst).append(')');
} else if (cst instanceof Boolean) {
buf.append(((Boolean) cst).booleanValue() ? "Boolean.TRUE"
: "Boolean.FALSE");
} else if (cst instanceof Short) {
buf.append("new Short((short)").append(cst).append(')');
} else if (cst instanceof Character) {
int c = ((Character) cst).charValue();
buf.append("new Character((char)").append(c).append(')');
} else if (cst instanceof Integer) {
buf.append("new Integer(").append(cst).append(')');
} else if (cst instanceof Float) {
buf.append("new Float(\"").append(cst).append("\")");
} else if (cst instanceof Long) {
buf.append("new Long(").append(cst).append("L)");
} else if (cst instanceof Double) {
buf.append("new Double(\"").append(cst).append("\")");
} else if (cst instanceof byte[]) {
byte[] v = (byte[]) cst;
buf.append("new byte[] {");
for (int i = 0; i < v.length; i++) {
buf.append(i == 0 ? "" : ",").append(v[i]);
}
buf.append('}');
} | java | static void appendConstant(final StringBuffer buf, final Object cst) {
if (cst == null) {
buf.append("null");
} else if (cst instanceof String) {
appendString(buf, (String) cst);
} else if (cst instanceof Type) {
buf.append("Type.getType(\"");
buf.append(((Type) cst).getDescriptor());
buf.append("\")");
} else if (cst instanceof Handle) {
buf.append("new Handle(");
Handle h = (Handle) cst;
buf.append("Opcodes.").append(HANDLE_TAG[h.getTag()])
.append(", \"");
buf.append(h.getOwner()).append("\", \"");
buf.append(h.getName()).append("\", \"");
buf.append(h.getDesc()).append("\")");
} else if (cst instanceof Byte) {
buf.append("new Byte((byte)").append(cst).append(')');
} else if (cst instanceof Boolean) {
buf.append(((Boolean) cst).booleanValue() ? "Boolean.TRUE"
: "Boolean.FALSE");
} else if (cst instanceof Short) {
buf.append("new Short((short)").append(cst).append(')');
} else if (cst instanceof Character) {
int c = ((Character) cst).charValue();
buf.append("new Character((char)").append(c).append(')');
} else if (cst instanceof Integer) {
buf.append("new Integer(").append(cst).append(')');
} else if (cst instanceof Float) {
buf.append("new Float(\"").append(cst).append("\")");
} else if (cst instanceof Long) {
buf.append("new Long(").append(cst).append("L)");
} else if (cst instanceof Double) {
buf.append("new Double(\"").append(cst).append("\")");
} else if (cst instanceof byte[]) {
byte[] v = (byte[]) cst;
buf.append("new byte[] {");
for (int i = 0; i < v.length; i++) {
buf.append(i == 0 ? "" : ",").append(v[i]);
}
buf.append('}');
} | [
"static",
"void",
"appendConstant",
"(",
"final",
"StringBuffer",
"buf",
",",
"final",
"Object",
"cst",
")",
"{",
"if",
"(",
"cst",
"==",
"null",
")",
"{",
"buf",
".",
"append",
"(",
"\"null\"",
")",
";",
"}",
"else",
"if",
"(",
"cst",
"instanceof",
"String",
")",
"{",
"appendString",
"(",
"buf",
",",
"(",
"String",
")",
"cst",
")",
";",
"}",
"else",
"if",
"(",
"cst",
"instanceof",
"Type",
")",
"{",
"buf",
".",
"append",
"(",
"\"Type.getType(\\\"\"",
")",
";",
"buf",
".",
"append",
"(",
"(",
"(",
"Type",
")",
"cst",
")",
".",
"getDescriptor",
"(",
")",
")",
";",
"buf",
".",
"append",
"(",
"\"\\\")\"",
")",
";",
"}",
"else",
"if",
"(",
"cst",
"instanceof",
"Handle",
")",
"{",
"buf",
".",
"append",
"(",
"\"new Handle(\"",
")",
";",
"Handle",
"h",
"=",
"(",
"Handle",
")",
"cst",
";",
"buf",
".",
"append",
"(",
"\"Opcodes.\"",
")",
".",
"append",
"(",
"HANDLE_TAG",
"[",
"h",
".",
"getTag",
"(",
")",
"]",
")",
".",
"append",
"(",
"\", \\\"\"",
")",
";",
"buf",
".",
"append",
"(",
"h",
".",
"getOwner",
"(",
")",
")",
".",
"append",
"(",
"\"\\\", \\\"\"",
")",
";",
"buf",
".",
"append",
"(",
"h",
".",
"getName",
"(",
")",
")",
".",
"append",
"(",
"\"\\\", \\\"\"",
")",
";",
"buf",
".",
"append",
"(",
"h",
".",
"getDesc",
"(",
")",
")",
".",
"append",
"(",
"\"\\\")\"",
")",
";",
"}",
"else",
"if",
"(",
"cst",
"instanceof",
"Byte",
")",
"{",
"buf",
".",
"append",
"(",
"\"new Byte((byte)\"",
")",
".",
"append",
"(",
"cst",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"else",
"if",
"(",
"cst",
"instanceof",
"Boolean",
")",
"{",
"buf",
".",
"append",
"(",
"(",
"(",
"Boolean",
")",
"cst",
")",
".",
"booleanValue",
"(",
")",
"?",
"\"Boolean.TRUE\"",
":",
"\"Boolean.FALSE\"",
")",
";",
"}",
"else",
"if",
"(",
"cst",
"instanceof",
"Short",
")",
"{",
"buf",
".",
"append",
"(",
"\"new Short((short)\"",
")",
".",
"append",
"(",
"cst",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"else",
"if",
"(",
"cst",
"instanceof",
"Character",
")",
"{",
"int",
"c",
"=",
"(",
"(",
"Character",
")",
"cst",
")",
".",
"charValue",
"(",
")",
";",
"buf",
".",
"append",
"(",
"\"new Character((char)\"",
")",
".",
"append",
"(",
"c",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"else",
"if",
"(",
"cst",
"instanceof",
"Integer",
")",
"{",
"buf",
".",
"append",
"(",
"\"new Integer(\"",
")",
".",
"append",
"(",
"cst",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"else",
"if",
"(",
"cst",
"instanceof",
"Float",
")",
"{",
"buf",
".",
"append",
"(",
"\"new Float(\\\"\"",
")",
".",
"append",
"(",
"cst",
")",
".",
"append",
"(",
"\"\\\")\"",
")",
";",
"}",
"else",
"if",
"(",
"cst",
"instanceof",
"Long",
")",
"{",
"buf",
".",
"append",
"(",
"\"new Long(\"",
")",
".",
"append",
"(",
"cst",
")",
".",
"append",
"(",
"\"L)\"",
")",
";",
"}",
"else",
"if",
"(",
"cst",
"instanceof",
"Double",
")",
"{",
"buf",
".",
"append",
"(",
"\"new Double(\\\"\"",
")",
".",
"append",
"(",
"cst",
")",
".",
"append",
"(",
"\"\\\")\"",
")",
";",
"}",
"else",
"if",
"(",
"cst",
"instanceof",
"byte",
"[",
"]",
")",
"{",
"byte",
"[",
"]",
"v",
"=",
"(",
"byte",
"[",
"]",
")",
"cst",
";",
"buf",
".",
"append",
"(",
"\"new byte[] {\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"v",
".",
"length",
";",
"i",
"++",
")",
"{",
"buf",
".",
"append",
"(",
"i",
"==",
"0",
"?",
"\"\"",
":",
"\",\"",
")",
".",
"append",
"(",
"v",
"[",
"i",
"]",
")",
";",
"}",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"}"
] | Appends a string representation of the given constant to the given
buffer.
@param buf
a string buffer.
@param cst
an {@link Integer}, {@link Float}, {@link Long},
{@link Double} or {@link String} object. May be <tt>null</tt>. | [
"Appends",
"a",
"string",
"representation",
"of",
"the",
"given",
"constant",
"to",
"the",
"given",
"buffer",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/ASMifier.java#L1113-L1155 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.verify | public static void verify(final ClassReader cr, final ClassLoader loader,
final boolean dump, final PrintWriter pw) {
ClassNode cn = new ClassNode();
cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG);
Type syperType = cn.superName == null ? null : Type
.getObjectType(cn.superName);
List<MethodNode> methods = cn.methods;
List<Type> interfaces = new ArrayList<Type>();
for (Iterator<String> i = cn.interfaces.iterator(); i.hasNext();) {
interfaces.add(Type.getObjectType(i.next()));
}
for (int i = 0; i < methods.size(); ++i) {
MethodNode method = methods.get(i);
SimpleVerifier verifier = new SimpleVerifier(
Type.getObjectType(cn.name), syperType, interfaces,
(cn.access & Opcodes.ACC_INTERFACE) != 0);
Analyzer<BasicValue> a = new Analyzer<BasicValue>(verifier);
if (loader != null) {
verifier.setClassLoader(loader);
}
try {
a.analyze(cn.name, method);
if (!dump) {
continue;
}
} catch (Exception e) {
e.printStackTrace(pw);
}
printAnalyzerResult(method, a, pw);
}
pw.flush();
} | java | public static void verify(final ClassReader cr, final ClassLoader loader,
final boolean dump, final PrintWriter pw) {
ClassNode cn = new ClassNode();
cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG);
Type syperType = cn.superName == null ? null : Type
.getObjectType(cn.superName);
List<MethodNode> methods = cn.methods;
List<Type> interfaces = new ArrayList<Type>();
for (Iterator<String> i = cn.interfaces.iterator(); i.hasNext();) {
interfaces.add(Type.getObjectType(i.next()));
}
for (int i = 0; i < methods.size(); ++i) {
MethodNode method = methods.get(i);
SimpleVerifier verifier = new SimpleVerifier(
Type.getObjectType(cn.name), syperType, interfaces,
(cn.access & Opcodes.ACC_INTERFACE) != 0);
Analyzer<BasicValue> a = new Analyzer<BasicValue>(verifier);
if (loader != null) {
verifier.setClassLoader(loader);
}
try {
a.analyze(cn.name, method);
if (!dump) {
continue;
}
} catch (Exception e) {
e.printStackTrace(pw);
}
printAnalyzerResult(method, a, pw);
}
pw.flush();
} | [
"public",
"static",
"void",
"verify",
"(",
"final",
"ClassReader",
"cr",
",",
"final",
"ClassLoader",
"loader",
",",
"final",
"boolean",
"dump",
",",
"final",
"PrintWriter",
"pw",
")",
"{",
"ClassNode",
"cn",
"=",
"new",
"ClassNode",
"(",
")",
";",
"cr",
".",
"accept",
"(",
"new",
"CheckClassAdapter",
"(",
"cn",
",",
"false",
")",
",",
"ClassReader",
".",
"SKIP_DEBUG",
")",
";",
"Type",
"syperType",
"=",
"cn",
".",
"superName",
"==",
"null",
"?",
"null",
":",
"Type",
".",
"getObjectType",
"(",
"cn",
".",
"superName",
")",
";",
"List",
"<",
"MethodNode",
">",
"methods",
"=",
"cn",
".",
"methods",
";",
"List",
"<",
"Type",
">",
"interfaces",
"=",
"new",
"ArrayList",
"<",
"Type",
">",
"(",
")",
";",
"for",
"(",
"Iterator",
"<",
"String",
">",
"i",
"=",
"cn",
".",
"interfaces",
".",
"iterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"interfaces",
".",
"add",
"(",
"Type",
".",
"getObjectType",
"(",
"i",
".",
"next",
"(",
")",
")",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"methods",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"MethodNode",
"method",
"=",
"methods",
".",
"get",
"(",
"i",
")",
";",
"SimpleVerifier",
"verifier",
"=",
"new",
"SimpleVerifier",
"(",
"Type",
".",
"getObjectType",
"(",
"cn",
".",
"name",
")",
",",
"syperType",
",",
"interfaces",
",",
"(",
"cn",
".",
"access",
"&",
"Opcodes",
".",
"ACC_INTERFACE",
")",
"!=",
"0",
")",
";",
"Analyzer",
"<",
"BasicValue",
">",
"a",
"=",
"new",
"Analyzer",
"<",
"BasicValue",
">",
"(",
"verifier",
")",
";",
"if",
"(",
"loader",
"!=",
"null",
")",
"{",
"verifier",
".",
"setClassLoader",
"(",
"loader",
")",
";",
"}",
"try",
"{",
"a",
".",
"analyze",
"(",
"cn",
".",
"name",
",",
"method",
")",
";",
"if",
"(",
"!",
"dump",
")",
"{",
"continue",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
"pw",
")",
";",
"}",
"printAnalyzerResult",
"(",
"method",
",",
"a",
",",
"pw",
")",
";",
"}",
"pw",
".",
"flush",
"(",
")",
";",
"}"
] | Checks a given class.
@param cr
a <code>ClassReader</code> that contains bytecode for the
analysis.
@param loader
a <code>ClassLoader</code> which will be used to load
referenced classes. This is useful if you are verifiying
multiple interdependent classes.
@param dump
true if bytecode should be printed out not only when errors
are found.
@param pw
write where results going to be printed | [
"Checks",
"a",
"given",
"class",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L209-L243 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.verify | public static void verify(final ClassReader cr, final boolean dump,
final PrintWriter pw) {
verify(cr, null, dump, pw);
} | java | public static void verify(final ClassReader cr, final boolean dump,
final PrintWriter pw) {
verify(cr, null, dump, pw);
} | [
"public",
"static",
"void",
"verify",
"(",
"final",
"ClassReader",
"cr",
",",
"final",
"boolean",
"dump",
",",
"final",
"PrintWriter",
"pw",
")",
"{",
"verify",
"(",
"cr",
",",
"null",
",",
"dump",
",",
"pw",
")",
";",
"}"
] | Checks a given class
@param cr
a <code>ClassReader</code> that contains bytecode for the
analysis.
@param dump
true if bytecode should be printed out not only when errors
are found.
@param pw
write where results going to be printed | [
"Checks",
"a",
"given",
"class"
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L257-L260 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkAccess | static void checkAccess(final int access, final int possibleAccess) {
if ((access & ~possibleAccess) != 0) {
throw new IllegalArgumentException("Invalid access flags: "
+ access);
}
int pub = (access & Opcodes.ACC_PUBLIC) == 0 ? 0 : 1;
int pri = (access & Opcodes.ACC_PRIVATE) == 0 ? 0 : 1;
int pro = (access & Opcodes.ACC_PROTECTED) == 0 ? 0 : 1;
if (pub + pri + pro > 1) {
throw new IllegalArgumentException(
"public private and protected are mutually exclusive: "
+ access);
}
int fin = (access & Opcodes.ACC_FINAL) == 0 ? 0 : 1;
int abs = (access & Opcodes.ACC_ABSTRACT) == 0 ? 0 : 1;
if (fin + abs > 1) {
throw new IllegalArgumentException(
"final and abstract are mutually exclusive: " + access);
}
} | java | static void checkAccess(final int access, final int possibleAccess) {
if ((access & ~possibleAccess) != 0) {
throw new IllegalArgumentException("Invalid access flags: "
+ access);
}
int pub = (access & Opcodes.ACC_PUBLIC) == 0 ? 0 : 1;
int pri = (access & Opcodes.ACC_PRIVATE) == 0 ? 0 : 1;
int pro = (access & Opcodes.ACC_PROTECTED) == 0 ? 0 : 1;
if (pub + pri + pro > 1) {
throw new IllegalArgumentException(
"public private and protected are mutually exclusive: "
+ access);
}
int fin = (access & Opcodes.ACC_FINAL) == 0 ? 0 : 1;
int abs = (access & Opcodes.ACC_ABSTRACT) == 0 ? 0 : 1;
if (fin + abs > 1) {
throw new IllegalArgumentException(
"final and abstract are mutually exclusive: " + access);
}
} | [
"static",
"void",
"checkAccess",
"(",
"final",
"int",
"access",
",",
"final",
"int",
"possibleAccess",
")",
"{",
"if",
"(",
"(",
"access",
"&",
"~",
"possibleAccess",
")",
"!=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid access flags: \"",
"+",
"access",
")",
";",
"}",
"int",
"pub",
"=",
"(",
"access",
"&",
"Opcodes",
".",
"ACC_PUBLIC",
")",
"==",
"0",
"?",
"0",
":",
"1",
";",
"int",
"pri",
"=",
"(",
"access",
"&",
"Opcodes",
".",
"ACC_PRIVATE",
")",
"==",
"0",
"?",
"0",
":",
"1",
";",
"int",
"pro",
"=",
"(",
"access",
"&",
"Opcodes",
".",
"ACC_PROTECTED",
")",
"==",
"0",
"?",
"0",
":",
"1",
";",
"if",
"(",
"pub",
"+",
"pri",
"+",
"pro",
">",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"public private and protected are mutually exclusive: \"",
"+",
"access",
")",
";",
"}",
"int",
"fin",
"=",
"(",
"access",
"&",
"Opcodes",
".",
"ACC_FINAL",
")",
"==",
"0",
"?",
"0",
":",
"1",
";",
"int",
"abs",
"=",
"(",
"access",
"&",
"Opcodes",
".",
"ACC_ABSTRACT",
")",
"==",
"0",
"?",
"0",
":",
"1",
";",
"if",
"(",
"fin",
"+",
"abs",
">",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"final and abstract are mutually exclusive: \"",
"+",
"access",
")",
";",
"}",
"}"
] | Checks that the given access flags do not contain invalid flags. This
method also checks that mutually incompatible flags are not set
simultaneously.
@param access
the access flags to be checked
@param possibleAccess
the valid access flags. | [
"Checks",
"that",
"the",
"given",
"access",
"flags",
"do",
"not",
"contain",
"invalid",
"flags",
".",
"This",
"method",
"also",
"checks",
"that",
"mutually",
"incompatible",
"flags",
"are",
"not",
"set",
"simultaneously",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L597-L616 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkClassSignature | public static void checkClassSignature(final String signature) {
// ClassSignature:
// FormalTypeParameters? ClassTypeSignature ClassTypeSignature*
int pos = 0;
if (getChar(signature, 0) == '<') {
pos = checkFormalTypeParameters(signature, pos);
}
pos = checkClassTypeSignature(signature, pos);
while (getChar(signature, pos) == 'L') {
pos = checkClassTypeSignature(signature, pos);
}
if (pos != signature.length()) {
throw new IllegalArgumentException(signature + ": error at index "
+ pos);
}
} | java | public static void checkClassSignature(final String signature) {
// ClassSignature:
// FormalTypeParameters? ClassTypeSignature ClassTypeSignature*
int pos = 0;
if (getChar(signature, 0) == '<') {
pos = checkFormalTypeParameters(signature, pos);
}
pos = checkClassTypeSignature(signature, pos);
while (getChar(signature, pos) == 'L') {
pos = checkClassTypeSignature(signature, pos);
}
if (pos != signature.length()) {
throw new IllegalArgumentException(signature + ": error at index "
+ pos);
}
} | [
"public",
"static",
"void",
"checkClassSignature",
"(",
"final",
"String",
"signature",
")",
"{",
"// ClassSignature:",
"// FormalTypeParameters? ClassTypeSignature ClassTypeSignature*",
"int",
"pos",
"=",
"0",
";",
"if",
"(",
"getChar",
"(",
"signature",
",",
"0",
")",
"==",
"'",
"'",
")",
"{",
"pos",
"=",
"checkFormalTypeParameters",
"(",
"signature",
",",
"pos",
")",
";",
"}",
"pos",
"=",
"checkClassTypeSignature",
"(",
"signature",
",",
"pos",
")",
";",
"while",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
"==",
"'",
"'",
")",
"{",
"pos",
"=",
"checkClassTypeSignature",
"(",
"signature",
",",
"pos",
")",
";",
"}",
"if",
"(",
"pos",
"!=",
"signature",
".",
"length",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"signature",
"+",
"\": error at index \"",
"+",
"pos",
")",
";",
"}",
"}"
] | Checks a class signature.
@param signature
a string containing the signature that must be checked. | [
"Checks",
"a",
"class",
"signature",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L624-L640 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkMethodSignature | public static void checkMethodSignature(final String signature) {
// MethodTypeSignature:
// FormalTypeParameters? ( TypeSignature* ) ( TypeSignature | V ) (
// ^ClassTypeSignature | ^TypeVariableSignature )*
int pos = 0;
if (getChar(signature, 0) == '<') {
pos = checkFormalTypeParameters(signature, pos);
}
pos = checkChar('(', signature, pos);
while ("ZCBSIFJDL[T".indexOf(getChar(signature, pos)) != -1) {
pos = checkTypeSignature(signature, pos);
}
pos = checkChar(')', signature, pos);
if (getChar(signature, pos) == 'V') {
++pos;
} else {
pos = checkTypeSignature(signature, pos);
}
while (getChar(signature, pos) == '^') {
++pos;
if (getChar(signature, pos) == 'L') {
pos = checkClassTypeSignature(signature, pos);
} else {
pos = checkTypeVariableSignature(signature, pos);
}
}
if (pos != signature.length()) {
throw new IllegalArgumentException(signature + ": error at index "
+ pos);
}
} | java | public static void checkMethodSignature(final String signature) {
// MethodTypeSignature:
// FormalTypeParameters? ( TypeSignature* ) ( TypeSignature | V ) (
// ^ClassTypeSignature | ^TypeVariableSignature )*
int pos = 0;
if (getChar(signature, 0) == '<') {
pos = checkFormalTypeParameters(signature, pos);
}
pos = checkChar('(', signature, pos);
while ("ZCBSIFJDL[T".indexOf(getChar(signature, pos)) != -1) {
pos = checkTypeSignature(signature, pos);
}
pos = checkChar(')', signature, pos);
if (getChar(signature, pos) == 'V') {
++pos;
} else {
pos = checkTypeSignature(signature, pos);
}
while (getChar(signature, pos) == '^') {
++pos;
if (getChar(signature, pos) == 'L') {
pos = checkClassTypeSignature(signature, pos);
} else {
pos = checkTypeVariableSignature(signature, pos);
}
}
if (pos != signature.length()) {
throw new IllegalArgumentException(signature + ": error at index "
+ pos);
}
} | [
"public",
"static",
"void",
"checkMethodSignature",
"(",
"final",
"String",
"signature",
")",
"{",
"// MethodTypeSignature:",
"// FormalTypeParameters? ( TypeSignature* ) ( TypeSignature | V ) (",
"// ^ClassTypeSignature | ^TypeVariableSignature )*",
"int",
"pos",
"=",
"0",
";",
"if",
"(",
"getChar",
"(",
"signature",
",",
"0",
")",
"==",
"'",
"'",
")",
"{",
"pos",
"=",
"checkFormalTypeParameters",
"(",
"signature",
",",
"pos",
")",
";",
"}",
"pos",
"=",
"checkChar",
"(",
"'",
"'",
",",
"signature",
",",
"pos",
")",
";",
"while",
"(",
"\"ZCBSIFJDL[T\"",
".",
"indexOf",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
")",
"!=",
"-",
"1",
")",
"{",
"pos",
"=",
"checkTypeSignature",
"(",
"signature",
",",
"pos",
")",
";",
"}",
"pos",
"=",
"checkChar",
"(",
"'",
"'",
",",
"signature",
",",
"pos",
")",
";",
"if",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
"==",
"'",
"'",
")",
"{",
"++",
"pos",
";",
"}",
"else",
"{",
"pos",
"=",
"checkTypeSignature",
"(",
"signature",
",",
"pos",
")",
";",
"}",
"while",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
"==",
"'",
"'",
")",
"{",
"++",
"pos",
";",
"if",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
"==",
"'",
"'",
")",
"{",
"pos",
"=",
"checkClassTypeSignature",
"(",
"signature",
",",
"pos",
")",
";",
"}",
"else",
"{",
"pos",
"=",
"checkTypeVariableSignature",
"(",
"signature",
",",
"pos",
")",
";",
"}",
"}",
"if",
"(",
"pos",
"!=",
"signature",
".",
"length",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"signature",
"+",
"\": error at index \"",
"+",
"pos",
")",
";",
"}",
"}"
] | Checks a method signature.
@param signature
a string containing the signature that must be checked. | [
"Checks",
"a",
"method",
"signature",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L648-L679 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkFieldSignature | public static void checkFieldSignature(final String signature) {
int pos = checkFieldTypeSignature(signature, 0);
if (pos != signature.length()) {
throw new IllegalArgumentException(signature + ": error at index "
+ pos);
}
} | java | public static void checkFieldSignature(final String signature) {
int pos = checkFieldTypeSignature(signature, 0);
if (pos != signature.length()) {
throw new IllegalArgumentException(signature + ": error at index "
+ pos);
}
} | [
"public",
"static",
"void",
"checkFieldSignature",
"(",
"final",
"String",
"signature",
")",
"{",
"int",
"pos",
"=",
"checkFieldTypeSignature",
"(",
"signature",
",",
"0",
")",
";",
"if",
"(",
"pos",
"!=",
"signature",
".",
"length",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"signature",
"+",
"\": error at index \"",
"+",
"pos",
")",
";",
"}",
"}"
] | Checks a field signature.
@param signature
a string containing the signature that must be checked. | [
"Checks",
"a",
"field",
"signature",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L687-L693 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkTypeRefAndPath | static void checkTypeRefAndPath(int typeRef, TypePath typePath) {
int mask = 0;
switch (typeRef >>> 24) {
case TypeReference.CLASS_TYPE_PARAMETER:
case TypeReference.METHOD_TYPE_PARAMETER:
case TypeReference.METHOD_FORMAL_PARAMETER:
mask = 0xFFFF0000;
break;
case TypeReference.FIELD:
case TypeReference.METHOD_RETURN:
case TypeReference.METHOD_RECEIVER:
case TypeReference.LOCAL_VARIABLE:
case TypeReference.RESOURCE_VARIABLE:
case TypeReference.INSTANCEOF:
case TypeReference.NEW:
case TypeReference.CONSTRUCTOR_REFERENCE:
case TypeReference.METHOD_REFERENCE:
mask = 0xFF000000;
break;
case TypeReference.CLASS_EXTENDS:
case TypeReference.CLASS_TYPE_PARAMETER_BOUND:
case TypeReference.METHOD_TYPE_PARAMETER_BOUND:
case TypeReference.THROWS:
case TypeReference.EXCEPTION_PARAMETER:
mask = 0xFFFFFF00;
break;
case TypeReference.CAST:
case TypeReference.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
case TypeReference.METHOD_INVOCATION_TYPE_ARGUMENT:
case TypeReference.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
case TypeReference.METHOD_REFERENCE_TYPE_ARGUMENT:
mask = 0xFF0000FF;
break;
default:
throw new IllegalArgumentException("Invalid type reference sort 0x"
+ Integer.toHexString(typeRef >>> 24));
}
if ((typeRef & ~mask) != 0) {
throw new IllegalArgumentException("Invalid type reference 0x"
+ Integer.toHexString(typeRef));
}
if (typePath != null) {
for (int i = 0; i < typePath.getLength(); ++i) {
int step = typePath.getStep(i);
if (step != TypePath.ARRAY_ELEMENT
&& step != TypePath.INNER_TYPE
&& step != TypePath.TYPE_ARGUMENT
&& step != TypePath.WILDCARD_BOUND) {
throw new IllegalArgumentException(
"Invalid type path step " + i + " in " + typePath);
}
if (step != TypePath.TYPE_ARGUMENT
&& typePath.getStepArgument(i) != 0) {
throw new IllegalArgumentException(
"Invalid type path step argument for step " + i
+ " in " + typePath);
}
}
}
} | java | static void checkTypeRefAndPath(int typeRef, TypePath typePath) {
int mask = 0;
switch (typeRef >>> 24) {
case TypeReference.CLASS_TYPE_PARAMETER:
case TypeReference.METHOD_TYPE_PARAMETER:
case TypeReference.METHOD_FORMAL_PARAMETER:
mask = 0xFFFF0000;
break;
case TypeReference.FIELD:
case TypeReference.METHOD_RETURN:
case TypeReference.METHOD_RECEIVER:
case TypeReference.LOCAL_VARIABLE:
case TypeReference.RESOURCE_VARIABLE:
case TypeReference.INSTANCEOF:
case TypeReference.NEW:
case TypeReference.CONSTRUCTOR_REFERENCE:
case TypeReference.METHOD_REFERENCE:
mask = 0xFF000000;
break;
case TypeReference.CLASS_EXTENDS:
case TypeReference.CLASS_TYPE_PARAMETER_BOUND:
case TypeReference.METHOD_TYPE_PARAMETER_BOUND:
case TypeReference.THROWS:
case TypeReference.EXCEPTION_PARAMETER:
mask = 0xFFFFFF00;
break;
case TypeReference.CAST:
case TypeReference.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
case TypeReference.METHOD_INVOCATION_TYPE_ARGUMENT:
case TypeReference.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
case TypeReference.METHOD_REFERENCE_TYPE_ARGUMENT:
mask = 0xFF0000FF;
break;
default:
throw new IllegalArgumentException("Invalid type reference sort 0x"
+ Integer.toHexString(typeRef >>> 24));
}
if ((typeRef & ~mask) != 0) {
throw new IllegalArgumentException("Invalid type reference 0x"
+ Integer.toHexString(typeRef));
}
if (typePath != null) {
for (int i = 0; i < typePath.getLength(); ++i) {
int step = typePath.getStep(i);
if (step != TypePath.ARRAY_ELEMENT
&& step != TypePath.INNER_TYPE
&& step != TypePath.TYPE_ARGUMENT
&& step != TypePath.WILDCARD_BOUND) {
throw new IllegalArgumentException(
"Invalid type path step " + i + " in " + typePath);
}
if (step != TypePath.TYPE_ARGUMENT
&& typePath.getStepArgument(i) != 0) {
throw new IllegalArgumentException(
"Invalid type path step argument for step " + i
+ " in " + typePath);
}
}
}
} | [
"static",
"void",
"checkTypeRefAndPath",
"(",
"int",
"typeRef",
",",
"TypePath",
"typePath",
")",
"{",
"int",
"mask",
"=",
"0",
";",
"switch",
"(",
"typeRef",
">>>",
"24",
")",
"{",
"case",
"TypeReference",
".",
"CLASS_TYPE_PARAMETER",
":",
"case",
"TypeReference",
".",
"METHOD_TYPE_PARAMETER",
":",
"case",
"TypeReference",
".",
"METHOD_FORMAL_PARAMETER",
":",
"mask",
"=",
"0xFFFF0000",
";",
"break",
";",
"case",
"TypeReference",
".",
"FIELD",
":",
"case",
"TypeReference",
".",
"METHOD_RETURN",
":",
"case",
"TypeReference",
".",
"METHOD_RECEIVER",
":",
"case",
"TypeReference",
".",
"LOCAL_VARIABLE",
":",
"case",
"TypeReference",
".",
"RESOURCE_VARIABLE",
":",
"case",
"TypeReference",
".",
"INSTANCEOF",
":",
"case",
"TypeReference",
".",
"NEW",
":",
"case",
"TypeReference",
".",
"CONSTRUCTOR_REFERENCE",
":",
"case",
"TypeReference",
".",
"METHOD_REFERENCE",
":",
"mask",
"=",
"0xFF000000",
";",
"break",
";",
"case",
"TypeReference",
".",
"CLASS_EXTENDS",
":",
"case",
"TypeReference",
".",
"CLASS_TYPE_PARAMETER_BOUND",
":",
"case",
"TypeReference",
".",
"METHOD_TYPE_PARAMETER_BOUND",
":",
"case",
"TypeReference",
".",
"THROWS",
":",
"case",
"TypeReference",
".",
"EXCEPTION_PARAMETER",
":",
"mask",
"=",
"0xFFFFFF00",
";",
"break",
";",
"case",
"TypeReference",
".",
"CAST",
":",
"case",
"TypeReference",
".",
"CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT",
":",
"case",
"TypeReference",
".",
"METHOD_INVOCATION_TYPE_ARGUMENT",
":",
"case",
"TypeReference",
".",
"CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT",
":",
"case",
"TypeReference",
".",
"METHOD_REFERENCE_TYPE_ARGUMENT",
":",
"mask",
"=",
"0xFF0000FF",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid type reference sort 0x\"",
"+",
"Integer",
".",
"toHexString",
"(",
"typeRef",
">>>",
"24",
")",
")",
";",
"}",
"if",
"(",
"(",
"typeRef",
"&",
"~",
"mask",
")",
"!=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid type reference 0x\"",
"+",
"Integer",
".",
"toHexString",
"(",
"typeRef",
")",
")",
";",
"}",
"if",
"(",
"typePath",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"typePath",
".",
"getLength",
"(",
")",
";",
"++",
"i",
")",
"{",
"int",
"step",
"=",
"typePath",
".",
"getStep",
"(",
"i",
")",
";",
"if",
"(",
"step",
"!=",
"TypePath",
".",
"ARRAY_ELEMENT",
"&&",
"step",
"!=",
"TypePath",
".",
"INNER_TYPE",
"&&",
"step",
"!=",
"TypePath",
".",
"TYPE_ARGUMENT",
"&&",
"step",
"!=",
"TypePath",
".",
"WILDCARD_BOUND",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid type path step \"",
"+",
"i",
"+",
"\" in \"",
"+",
"typePath",
")",
";",
"}",
"if",
"(",
"step",
"!=",
"TypePath",
".",
"TYPE_ARGUMENT",
"&&",
"typePath",
".",
"getStepArgument",
"(",
"i",
")",
"!=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid type path step argument for step \"",
"+",
"i",
"+",
"\" in \"",
"+",
"typePath",
")",
";",
"}",
"}",
"}",
"}"
] | Checks the reference to a type in a type annotation.
@param typeRef
a reference to an annotated type.
@param typePath
the path to the annotated type argument, wildcard bound, array
element type, or static inner type within 'typeRef'. May be
<tt>null</tt> if the annotation targets 'typeRef' as a whole. | [
"Checks",
"the",
"reference",
"to",
"a",
"type",
"in",
"a",
"type",
"annotation",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L705-L764 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkFormalTypeParameters | private static int checkFormalTypeParameters(final String signature, int pos) {
// FormalTypeParameters:
// < FormalTypeParameter+ >
pos = checkChar('<', signature, pos);
pos = checkFormalTypeParameter(signature, pos);
while (getChar(signature, pos) != '>') {
pos = checkFormalTypeParameter(signature, pos);
}
return pos + 1;
} | java | private static int checkFormalTypeParameters(final String signature, int pos) {
// FormalTypeParameters:
// < FormalTypeParameter+ >
pos = checkChar('<', signature, pos);
pos = checkFormalTypeParameter(signature, pos);
while (getChar(signature, pos) != '>') {
pos = checkFormalTypeParameter(signature, pos);
}
return pos + 1;
} | [
"private",
"static",
"int",
"checkFormalTypeParameters",
"(",
"final",
"String",
"signature",
",",
"int",
"pos",
")",
"{",
"// FormalTypeParameters:",
"// < FormalTypeParameter+ >",
"pos",
"=",
"checkChar",
"(",
"'",
"'",
",",
"signature",
",",
"pos",
")",
";",
"pos",
"=",
"checkFormalTypeParameter",
"(",
"signature",
",",
"pos",
")",
";",
"while",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
"!=",
"'",
"'",
")",
"{",
"pos",
"=",
"checkFormalTypeParameter",
"(",
"signature",
",",
"pos",
")",
";",
"}",
"return",
"pos",
"+",
"1",
";",
"}"
] | Checks the formal type parameters of a class or method signature.
@param signature
a string containing the signature that must be checked.
@param pos
index of first character to be checked.
@return the index of the first character after the checked part. | [
"Checks",
"the",
"formal",
"type",
"parameters",
"of",
"a",
"class",
"or",
"method",
"signature",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L775-L785 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkFormalTypeParameter | private static int checkFormalTypeParameter(final String signature, int pos) {
// FormalTypeParameter:
// Identifier : FieldTypeSignature? (: FieldTypeSignature)*
pos = checkIdentifier(signature, pos);
pos = checkChar(':', signature, pos);
if ("L[T".indexOf(getChar(signature, pos)) != -1) {
pos = checkFieldTypeSignature(signature, pos);
}
while (getChar(signature, pos) == ':') {
pos = checkFieldTypeSignature(signature, pos + 1);
}
return pos;
} | java | private static int checkFormalTypeParameter(final String signature, int pos) {
// FormalTypeParameter:
// Identifier : FieldTypeSignature? (: FieldTypeSignature)*
pos = checkIdentifier(signature, pos);
pos = checkChar(':', signature, pos);
if ("L[T".indexOf(getChar(signature, pos)) != -1) {
pos = checkFieldTypeSignature(signature, pos);
}
while (getChar(signature, pos) == ':') {
pos = checkFieldTypeSignature(signature, pos + 1);
}
return pos;
} | [
"private",
"static",
"int",
"checkFormalTypeParameter",
"(",
"final",
"String",
"signature",
",",
"int",
"pos",
")",
"{",
"// FormalTypeParameter:",
"// Identifier : FieldTypeSignature? (: FieldTypeSignature)*",
"pos",
"=",
"checkIdentifier",
"(",
"signature",
",",
"pos",
")",
";",
"pos",
"=",
"checkChar",
"(",
"'",
"'",
",",
"signature",
",",
"pos",
")",
";",
"if",
"(",
"\"L[T\"",
".",
"indexOf",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
")",
"!=",
"-",
"1",
")",
"{",
"pos",
"=",
"checkFieldTypeSignature",
"(",
"signature",
",",
"pos",
")",
";",
"}",
"while",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
"==",
"'",
"'",
")",
"{",
"pos",
"=",
"checkFieldTypeSignature",
"(",
"signature",
",",
"pos",
"+",
"1",
")",
";",
"}",
"return",
"pos",
";",
"}"
] | Checks a formal type parameter of a class or method signature.
@param signature
a string containing the signature that must be checked.
@param pos
index of first character to be checked.
@return the index of the first character after the checked part. | [
"Checks",
"a",
"formal",
"type",
"parameter",
"of",
"a",
"class",
"or",
"method",
"signature",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L796-L809 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkFieldTypeSignature | private static int checkFieldTypeSignature(final String signature, int pos) {
// FieldTypeSignature:
// ClassTypeSignature | ArrayTypeSignature | TypeVariableSignature
//
// ArrayTypeSignature:
// [ TypeSignature
switch (getChar(signature, pos)) {
case 'L':
return checkClassTypeSignature(signature, pos);
case '[':
return checkTypeSignature(signature, pos + 1);
default:
return checkTypeVariableSignature(signature, pos);
}
} | java | private static int checkFieldTypeSignature(final String signature, int pos) {
// FieldTypeSignature:
// ClassTypeSignature | ArrayTypeSignature | TypeVariableSignature
//
// ArrayTypeSignature:
// [ TypeSignature
switch (getChar(signature, pos)) {
case 'L':
return checkClassTypeSignature(signature, pos);
case '[':
return checkTypeSignature(signature, pos + 1);
default:
return checkTypeVariableSignature(signature, pos);
}
} | [
"private",
"static",
"int",
"checkFieldTypeSignature",
"(",
"final",
"String",
"signature",
",",
"int",
"pos",
")",
"{",
"// FieldTypeSignature:",
"// ClassTypeSignature | ArrayTypeSignature | TypeVariableSignature",
"//",
"// ArrayTypeSignature:",
"// [ TypeSignature",
"switch",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
")",
"{",
"case",
"'",
"'",
":",
"return",
"checkClassTypeSignature",
"(",
"signature",
",",
"pos",
")",
";",
"case",
"'",
"'",
":",
"return",
"checkTypeSignature",
"(",
"signature",
",",
"pos",
"+",
"1",
")",
";",
"default",
":",
"return",
"checkTypeVariableSignature",
"(",
"signature",
",",
"pos",
")",
";",
"}",
"}"
] | Checks a field type signature.
@param signature
a string containing the signature that must be checked.
@param pos
index of first character to be checked.
@return the index of the first character after the checked part. | [
"Checks",
"a",
"field",
"type",
"signature",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L820-L835 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkClassTypeSignature | private static int checkClassTypeSignature(final String signature, int pos) {
// ClassTypeSignature:
// L Identifier ( / Identifier )* TypeArguments? ( . Identifier
// TypeArguments? )* ;
pos = checkChar('L', signature, pos);
pos = checkIdentifier(signature, pos);
while (getChar(signature, pos) == '/') {
pos = checkIdentifier(signature, pos + 1);
}
if (getChar(signature, pos) == '<') {
pos = checkTypeArguments(signature, pos);
}
while (getChar(signature, pos) == '.') {
pos = checkIdentifier(signature, pos + 1);
if (getChar(signature, pos) == '<') {
pos = checkTypeArguments(signature, pos);
}
}
return checkChar(';', signature, pos);
} | java | private static int checkClassTypeSignature(final String signature, int pos) {
// ClassTypeSignature:
// L Identifier ( / Identifier )* TypeArguments? ( . Identifier
// TypeArguments? )* ;
pos = checkChar('L', signature, pos);
pos = checkIdentifier(signature, pos);
while (getChar(signature, pos) == '/') {
pos = checkIdentifier(signature, pos + 1);
}
if (getChar(signature, pos) == '<') {
pos = checkTypeArguments(signature, pos);
}
while (getChar(signature, pos) == '.') {
pos = checkIdentifier(signature, pos + 1);
if (getChar(signature, pos) == '<') {
pos = checkTypeArguments(signature, pos);
}
}
return checkChar(';', signature, pos);
} | [
"private",
"static",
"int",
"checkClassTypeSignature",
"(",
"final",
"String",
"signature",
",",
"int",
"pos",
")",
"{",
"// ClassTypeSignature:",
"// L Identifier ( / Identifier )* TypeArguments? ( . Identifier",
"// TypeArguments? )* ;",
"pos",
"=",
"checkChar",
"(",
"'",
"'",
",",
"signature",
",",
"pos",
")",
";",
"pos",
"=",
"checkIdentifier",
"(",
"signature",
",",
"pos",
")",
";",
"while",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
"==",
"'",
"'",
")",
"{",
"pos",
"=",
"checkIdentifier",
"(",
"signature",
",",
"pos",
"+",
"1",
")",
";",
"}",
"if",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
"==",
"'",
"'",
")",
"{",
"pos",
"=",
"checkTypeArguments",
"(",
"signature",
",",
"pos",
")",
";",
"}",
"while",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
"==",
"'",
"'",
")",
"{",
"pos",
"=",
"checkIdentifier",
"(",
"signature",
",",
"pos",
"+",
"1",
")",
";",
"if",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
"==",
"'",
"'",
")",
"{",
"pos",
"=",
"checkTypeArguments",
"(",
"signature",
",",
"pos",
")",
";",
"}",
"}",
"return",
"checkChar",
"(",
"'",
"'",
",",
"signature",
",",
"pos",
")",
";",
"}"
] | Checks a class type signature.
@param signature
a string containing the signature that must be checked.
@param pos
index of first character to be checked.
@return the index of the first character after the checked part. | [
"Checks",
"a",
"class",
"type",
"signature",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L846-L866 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkTypeArguments | private static int checkTypeArguments(final String signature, int pos) {
// TypeArguments:
// < TypeArgument+ >
pos = checkChar('<', signature, pos);
pos = checkTypeArgument(signature, pos);
while (getChar(signature, pos) != '>') {
pos = checkTypeArgument(signature, pos);
}
return pos + 1;
} | java | private static int checkTypeArguments(final String signature, int pos) {
// TypeArguments:
// < TypeArgument+ >
pos = checkChar('<', signature, pos);
pos = checkTypeArgument(signature, pos);
while (getChar(signature, pos) != '>') {
pos = checkTypeArgument(signature, pos);
}
return pos + 1;
} | [
"private",
"static",
"int",
"checkTypeArguments",
"(",
"final",
"String",
"signature",
",",
"int",
"pos",
")",
"{",
"// TypeArguments:",
"// < TypeArgument+ >",
"pos",
"=",
"checkChar",
"(",
"'",
"'",
",",
"signature",
",",
"pos",
")",
";",
"pos",
"=",
"checkTypeArgument",
"(",
"signature",
",",
"pos",
")",
";",
"while",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
"!=",
"'",
"'",
")",
"{",
"pos",
"=",
"checkTypeArgument",
"(",
"signature",
",",
"pos",
")",
";",
"}",
"return",
"pos",
"+",
"1",
";",
"}"
] | Checks the type arguments in a class type signature.
@param signature
a string containing the signature that must be checked.
@param pos
index of first character to be checked.
@return the index of the first character after the checked part. | [
"Checks",
"the",
"type",
"arguments",
"in",
"a",
"class",
"type",
"signature",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L877-L887 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkTypeArgument | private static int checkTypeArgument(final String signature, int pos) {
// TypeArgument:
// * | ( ( + | - )? FieldTypeSignature )
char c = getChar(signature, pos);
if (c == '*') {
return pos + 1;
} else if (c == '+' || c == '-') {
pos++;
}
return checkFieldTypeSignature(signature, pos);
} | java | private static int checkTypeArgument(final String signature, int pos) {
// TypeArgument:
// * | ( ( + | - )? FieldTypeSignature )
char c = getChar(signature, pos);
if (c == '*') {
return pos + 1;
} else if (c == '+' || c == '-') {
pos++;
}
return checkFieldTypeSignature(signature, pos);
} | [
"private",
"static",
"int",
"checkTypeArgument",
"(",
"final",
"String",
"signature",
",",
"int",
"pos",
")",
"{",
"// TypeArgument:",
"// * | ( ( + | - )? FieldTypeSignature )",
"char",
"c",
"=",
"getChar",
"(",
"signature",
",",
"pos",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"return",
"pos",
"+",
"1",
";",
"}",
"else",
"if",
"(",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
")",
"{",
"pos",
"++",
";",
"}",
"return",
"checkFieldTypeSignature",
"(",
"signature",
",",
"pos",
")",
";",
"}"
] | Checks a type argument in a class type signature.
@param signature
a string containing the signature that must be checked.
@param pos
index of first character to be checked.
@return the index of the first character after the checked part. | [
"Checks",
"a",
"type",
"argument",
"in",
"a",
"class",
"type",
"signature",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L898-L909 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkTypeVariableSignature | private static int checkTypeVariableSignature(final String signature,
int pos) {
// TypeVariableSignature:
// T Identifier ;
pos = checkChar('T', signature, pos);
pos = checkIdentifier(signature, pos);
return checkChar(';', signature, pos);
} | java | private static int checkTypeVariableSignature(final String signature,
int pos) {
// TypeVariableSignature:
// T Identifier ;
pos = checkChar('T', signature, pos);
pos = checkIdentifier(signature, pos);
return checkChar(';', signature, pos);
} | [
"private",
"static",
"int",
"checkTypeVariableSignature",
"(",
"final",
"String",
"signature",
",",
"int",
"pos",
")",
"{",
"// TypeVariableSignature:",
"// T Identifier ;",
"pos",
"=",
"checkChar",
"(",
"'",
"'",
",",
"signature",
",",
"pos",
")",
";",
"pos",
"=",
"checkIdentifier",
"(",
"signature",
",",
"pos",
")",
";",
"return",
"checkChar",
"(",
"'",
"'",
",",
"signature",
",",
"pos",
")",
";",
"}"
] | Checks a type variable signature.
@param signature
a string containing the signature that must be checked.
@param pos
index of first character to be checked.
@return the index of the first character after the checked part. | [
"Checks",
"a",
"type",
"variable",
"signature",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L920-L928 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkTypeSignature | private static int checkTypeSignature(final String signature, int pos) {
// TypeSignature:
// Z | C | B | S | I | F | J | D | FieldTypeSignature
switch (getChar(signature, pos)) {
case 'Z':
case 'C':
case 'B':
case 'S':
case 'I':
case 'F':
case 'J':
case 'D':
return pos + 1;
default:
return checkFieldTypeSignature(signature, pos);
}
} | java | private static int checkTypeSignature(final String signature, int pos) {
// TypeSignature:
// Z | C | B | S | I | F | J | D | FieldTypeSignature
switch (getChar(signature, pos)) {
case 'Z':
case 'C':
case 'B':
case 'S':
case 'I':
case 'F':
case 'J':
case 'D':
return pos + 1;
default:
return checkFieldTypeSignature(signature, pos);
}
} | [
"private",
"static",
"int",
"checkTypeSignature",
"(",
"final",
"String",
"signature",
",",
"int",
"pos",
")",
"{",
"// TypeSignature:",
"// Z | C | B | S | I | F | J | D | FieldTypeSignature",
"switch",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
")",
"{",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"return",
"pos",
"+",
"1",
";",
"default",
":",
"return",
"checkFieldTypeSignature",
"(",
"signature",
",",
"pos",
")",
";",
"}",
"}"
] | Checks a type signature.
@param signature
a string containing the signature that must be checked.
@param pos
index of first character to be checked.
@return the index of the first character after the checked part. | [
"Checks",
"a",
"type",
"signature",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L939-L956 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkIdentifier | private static int checkIdentifier(final String signature, int pos) {
if (!Character.isJavaIdentifierStart(getChar(signature, pos))) {
throw new IllegalArgumentException(signature
+ ": identifier expected at index " + pos);
}
++pos;
while (Character.isJavaIdentifierPart(getChar(signature, pos))) {
++pos;
}
return pos;
} | java | private static int checkIdentifier(final String signature, int pos) {
if (!Character.isJavaIdentifierStart(getChar(signature, pos))) {
throw new IllegalArgumentException(signature
+ ": identifier expected at index " + pos);
}
++pos;
while (Character.isJavaIdentifierPart(getChar(signature, pos))) {
++pos;
}
return pos;
} | [
"private",
"static",
"int",
"checkIdentifier",
"(",
"final",
"String",
"signature",
",",
"int",
"pos",
")",
"{",
"if",
"(",
"!",
"Character",
".",
"isJavaIdentifierStart",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"signature",
"+",
"\": identifier expected at index \"",
"+",
"pos",
")",
";",
"}",
"++",
"pos",
";",
"while",
"(",
"Character",
".",
"isJavaIdentifierPart",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
")",
")",
"{",
"++",
"pos",
";",
"}",
"return",
"pos",
";",
"}"
] | Checks an identifier.
@param signature
a string containing the signature that must be checked.
@param pos
index of first character to be checked.
@return the index of the first character after the checked part. | [
"Checks",
"an",
"identifier",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L967-L977 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.checkChar | private static int checkChar(final char c, final String signature, int pos) {
if (getChar(signature, pos) == c) {
return pos + 1;
}
throw new IllegalArgumentException(signature + ": '" + c
+ "' expected at index " + pos);
} | java | private static int checkChar(final char c, final String signature, int pos) {
if (getChar(signature, pos) == c) {
return pos + 1;
}
throw new IllegalArgumentException(signature + ": '" + c
+ "' expected at index " + pos);
} | [
"private",
"static",
"int",
"checkChar",
"(",
"final",
"char",
"c",
",",
"final",
"String",
"signature",
",",
"int",
"pos",
")",
"{",
"if",
"(",
"getChar",
"(",
"signature",
",",
"pos",
")",
"==",
"c",
")",
"{",
"return",
"pos",
"+",
"1",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"signature",
"+",
"\": '\"",
"+",
"c",
"+",
"\"' expected at index \"",
"+",
"pos",
")",
";",
"}"
] | Checks a single character.
@param signature
a string containing the signature that must be checked.
@param pos
index of first character to be checked.
@return the index of the first character after the checked part. | [
"Checks",
"a",
"single",
"character",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L988-L994 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java | CheckClassAdapter.getChar | private static char getChar(final String signature, int pos) {
return pos < signature.length() ? signature.charAt(pos) : (char) 0;
} | java | private static char getChar(final String signature, int pos) {
return pos < signature.length() ? signature.charAt(pos) : (char) 0;
} | [
"private",
"static",
"char",
"getChar",
"(",
"final",
"String",
"signature",
",",
"int",
"pos",
")",
"{",
"return",
"pos",
"<",
"signature",
".",
"length",
"(",
")",
"?",
"signature",
".",
"charAt",
"(",
"pos",
")",
":",
"(",
"char",
")",
"0",
";",
"}"
] | Returns the signature car at the given index.
@param signature
a signature.
@param pos
an index in signature.
@return the character at the given index, or 0 if there is no such
character. | [
"Returns",
"the",
"signature",
"car",
"at",
"the",
"given",
"index",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckClassAdapter.java#L1006-L1008 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/LocalVariableAnnotationNode.java | LocalVariableAnnotationNode.accept | public void accept(final MethodVisitor mv, boolean visible) {
Label[] start = new Label[this.start.size()];
Label[] end = new Label[this.end.size()];
int[] index = new int[this.index.size()];
for (int i = 0; i < start.length; ++i) {
start[i] = this.start.get(i).getLabel();
end[i] = this.end.get(i).getLabel();
index[i] = this.index.get(i);
}
accept(mv.visitLocalVariableAnnotation(typeRef, typePath, start, end,
index, desc, true));
} | java | public void accept(final MethodVisitor mv, boolean visible) {
Label[] start = new Label[this.start.size()];
Label[] end = new Label[this.end.size()];
int[] index = new int[this.index.size()];
for (int i = 0; i < start.length; ++i) {
start[i] = this.start.get(i).getLabel();
end[i] = this.end.get(i).getLabel();
index[i] = this.index.get(i);
}
accept(mv.visitLocalVariableAnnotation(typeRef, typePath, start, end,
index, desc, true));
} | [
"public",
"void",
"accept",
"(",
"final",
"MethodVisitor",
"mv",
",",
"boolean",
"visible",
")",
"{",
"Label",
"[",
"]",
"start",
"=",
"new",
"Label",
"[",
"this",
".",
"start",
".",
"size",
"(",
")",
"]",
";",
"Label",
"[",
"]",
"end",
"=",
"new",
"Label",
"[",
"this",
".",
"end",
".",
"size",
"(",
")",
"]",
";",
"int",
"[",
"]",
"index",
"=",
"new",
"int",
"[",
"this",
".",
"index",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"start",
".",
"length",
";",
"++",
"i",
")",
"{",
"start",
"[",
"i",
"]",
"=",
"this",
".",
"start",
".",
"get",
"(",
"i",
")",
".",
"getLabel",
"(",
")",
";",
"end",
"[",
"i",
"]",
"=",
"this",
".",
"end",
".",
"get",
"(",
"i",
")",
".",
"getLabel",
"(",
")",
";",
"index",
"[",
"i",
"]",
"=",
"this",
".",
"index",
".",
"get",
"(",
"i",
")",
";",
"}",
"accept",
"(",
"mv",
".",
"visitLocalVariableAnnotation",
"(",
"typeRef",
",",
"typePath",
",",
"start",
",",
"end",
",",
"index",
",",
"desc",
",",
"true",
")",
")",
";",
"}"
] | Makes the given visitor visit this type annotation.
@param mv
the visitor that must visit this annotation.
@param visible
<tt>true</tt> if the annotation is visible at runtime. | [
"Makes",
"the",
"given",
"visitor",
"visit",
"this",
"type",
"annotation",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/LocalVariableAnnotationNode.java#L145-L156 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/Printer.java | Printer.appendString | public static void appendString(final StringBuffer buf, final String s) {
buf.append('\"');
for (int i = 0; i < s.length(); ++i) {
char c = s.charAt(i);
if (c == '\n') {
buf.append("\\n");
} else if (c == '\r') {
buf.append("\\r");
} else if (c == '\\') {
buf.append("\\\\");
} else if (c == '"') {
buf.append("\\\"");
} else if (c < 0x20 || c > 0x7f) {
buf.append("\\u");
if (c < 0x10) {
buf.append("000");
} else if (c < 0x100) {
buf.append("00");
} else if (c < 0x1000) {
buf.append('0');
}
buf.append(Integer.toString(c, 16));
} else {
buf.append(c);
}
}
buf.append('\"');
} | java | public static void appendString(final StringBuffer buf, final String s) {
buf.append('\"');
for (int i = 0; i < s.length(); ++i) {
char c = s.charAt(i);
if (c == '\n') {
buf.append("\\n");
} else if (c == '\r') {
buf.append("\\r");
} else if (c == '\\') {
buf.append("\\\\");
} else if (c == '"') {
buf.append("\\\"");
} else if (c < 0x20 || c > 0x7f) {
buf.append("\\u");
if (c < 0x10) {
buf.append("000");
} else if (c < 0x100) {
buf.append("00");
} else if (c < 0x1000) {
buf.append('0');
}
buf.append(Integer.toString(c, 16));
} else {
buf.append(c);
}
}
buf.append('\"');
} | [
"public",
"static",
"void",
"appendString",
"(",
"final",
"StringBuffer",
"buf",
",",
"final",
"String",
"s",
")",
"{",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"s",
".",
"length",
"(",
")",
";",
"++",
"i",
")",
"{",
"char",
"c",
"=",
"s",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"buf",
".",
"append",
"(",
"\"\\\\n\"",
")",
";",
"}",
"else",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"buf",
".",
"append",
"(",
"\"\\\\r\"",
")",
";",
"}",
"else",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"buf",
".",
"append",
"(",
"\"\\\\\\\\\"",
")",
";",
"}",
"else",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"buf",
".",
"append",
"(",
"\"\\\\\\\"\"",
")",
";",
"}",
"else",
"if",
"(",
"c",
"<",
"0x20",
"||",
"c",
">",
"0x7f",
")",
"{",
"buf",
".",
"append",
"(",
"\"\\\\u\"",
")",
";",
"if",
"(",
"c",
"<",
"0x10",
")",
"{",
"buf",
".",
"append",
"(",
"\"000\"",
")",
";",
"}",
"else",
"if",
"(",
"c",
"<",
"0x100",
")",
"{",
"buf",
".",
"append",
"(",
"\"00\"",
")",
";",
"}",
"else",
"if",
"(",
"c",
"<",
"0x1000",
")",
"{",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"buf",
".",
"append",
"(",
"Integer",
".",
"toString",
"(",
"c",
",",
"16",
")",
")",
";",
"}",
"else",
"{",
"buf",
".",
"append",
"(",
"c",
")",
";",
"}",
"}",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"}"
] | Appends a quoted string to a given buffer.
@param buf
the buffer where the string must be added.
@param s
the string to be added. | [
"Appends",
"a",
"quoted",
"string",
"to",
"a",
"given",
"buffer",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/Printer.java#L541-L568 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/Printer.java | Printer.printList | static void printList(final PrintWriter pw, final List<?> l) {
for (int i = 0; i < l.size(); ++i) {
Object o = l.get(i);
if (o instanceof List) {
printList(pw, (List<?>) o);
} else {
pw.print(o.toString());
}
}
} | java | static void printList(final PrintWriter pw, final List<?> l) {
for (int i = 0; i < l.size(); ++i) {
Object o = l.get(i);
if (o instanceof List) {
printList(pw, (List<?>) o);
} else {
pw.print(o.toString());
}
}
} | [
"static",
"void",
"printList",
"(",
"final",
"PrintWriter",
"pw",
",",
"final",
"List",
"<",
"?",
">",
"l",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"l",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"Object",
"o",
"=",
"l",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"o",
"instanceof",
"List",
")",
"{",
"printList",
"(",
"pw",
",",
"(",
"List",
"<",
"?",
">",
")",
"o",
")",
";",
"}",
"else",
"{",
"pw",
".",
"print",
"(",
"o",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Prints the given string tree.
@param pw
the writer to be used to print the tree.
@param l
a string tree, i.e., a string list that can contain other
string lists, and so on recursively. | [
"Prints",
"the",
"given",
"string",
"tree",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/Printer.java#L579-L588 | train |
teknux-org/jetty-bootstrap | jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/JettyBootstrap.java | JettyBootstrap.startServer | public JettyBootstrap startServer(Boolean join) throws JettyBootstrapException {
LOG.info("Starting Server...");
IJettyConfiguration iJettyConfiguration = getInitializedConfiguration();
initServer(iJettyConfiguration);
try {
server.start();
} catch (Exception e) {
throw new JettyBootstrapException(e);
}
// display server addresses
if (iJettyConfiguration.getJettyConnectors().contains(JettyConnector.HTTP)) {
LOG.info("http://{}:{}", iJettyConfiguration.getHost(), iJettyConfiguration.getPort());
}
if (iJettyConfiguration.getJettyConnectors().contains(JettyConnector.HTTPS)) {
LOG.info("https://{}:{}", iJettyConfiguration.getHost(), iJettyConfiguration.getSslPort());
}
if ((join != null && join) || (join == null && iJettyConfiguration.isAutoJoinOnStart())) {
joinServer();
}
return this;
} | java | public JettyBootstrap startServer(Boolean join) throws JettyBootstrapException {
LOG.info("Starting Server...");
IJettyConfiguration iJettyConfiguration = getInitializedConfiguration();
initServer(iJettyConfiguration);
try {
server.start();
} catch (Exception e) {
throw new JettyBootstrapException(e);
}
// display server addresses
if (iJettyConfiguration.getJettyConnectors().contains(JettyConnector.HTTP)) {
LOG.info("http://{}:{}", iJettyConfiguration.getHost(), iJettyConfiguration.getPort());
}
if (iJettyConfiguration.getJettyConnectors().contains(JettyConnector.HTTPS)) {
LOG.info("https://{}:{}", iJettyConfiguration.getHost(), iJettyConfiguration.getSslPort());
}
if ((join != null && join) || (join == null && iJettyConfiguration.isAutoJoinOnStart())) {
joinServer();
}
return this;
} | [
"public",
"JettyBootstrap",
"startServer",
"(",
"Boolean",
"join",
")",
"throws",
"JettyBootstrapException",
"{",
"LOG",
".",
"info",
"(",
"\"Starting Server...\"",
")",
";",
"IJettyConfiguration",
"iJettyConfiguration",
"=",
"getInitializedConfiguration",
"(",
")",
";",
"initServer",
"(",
"iJettyConfiguration",
")",
";",
"try",
"{",
"server",
".",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"JettyBootstrapException",
"(",
"e",
")",
";",
"}",
"// display server addresses",
"if",
"(",
"iJettyConfiguration",
".",
"getJettyConnectors",
"(",
")",
".",
"contains",
"(",
"JettyConnector",
".",
"HTTP",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"http://{}:{}\"",
",",
"iJettyConfiguration",
".",
"getHost",
"(",
")",
",",
"iJettyConfiguration",
".",
"getPort",
"(",
")",
")",
";",
"}",
"if",
"(",
"iJettyConfiguration",
".",
"getJettyConnectors",
"(",
")",
".",
"contains",
"(",
"JettyConnector",
".",
"HTTPS",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"https://{}:{}\"",
",",
"iJettyConfiguration",
".",
"getHost",
"(",
")",
",",
"iJettyConfiguration",
".",
"getSslPort",
"(",
")",
")",
";",
"}",
"if",
"(",
"(",
"join",
"!=",
"null",
"&&",
"join",
")",
"||",
"(",
"join",
"==",
"null",
"&&",
"iJettyConfiguration",
".",
"isAutoJoinOnStart",
"(",
")",
")",
")",
"{",
"joinServer",
"(",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Starts the Jetty Server and join the calling thread.
@param join
<code>true</code> to block the calling thread until the server stops. <code>false</code> otherwise
@return this instance
@throws JettyBootstrapException
if an exception occurs during the initialization | [
"Starts",
"the",
"Jetty",
"Server",
"and",
"join",
"the",
"calling",
"thread",
"."
] | c16e710b833084c650fce35aa8c1ccaf83cd93ef | https://github.com/teknux-org/jetty-bootstrap/blob/c16e710b833084c650fce35aa8c1ccaf83cd93ef/jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/JettyBootstrap.java#L139-L164 | train |
teknux-org/jetty-bootstrap | jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/JettyBootstrap.java | JettyBootstrap.joinServer | public JettyBootstrap joinServer() throws JettyBootstrapException {
try {
if (isServerStarted()) {
LOG.debug("Joining Server...");
server.join();
} else {
LOG.warn("Can't join Server. Not started");
}
} catch (InterruptedException e) {
throw new JettyBootstrapException(e);
}
return this;
} | java | public JettyBootstrap joinServer() throws JettyBootstrapException {
try {
if (isServerStarted()) {
LOG.debug("Joining Server...");
server.join();
} else {
LOG.warn("Can't join Server. Not started");
}
} catch (InterruptedException e) {
throw new JettyBootstrapException(e);
}
return this;
} | [
"public",
"JettyBootstrap",
"joinServer",
"(",
")",
"throws",
"JettyBootstrapException",
"{",
"try",
"{",
"if",
"(",
"isServerStarted",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Joining Server...\"",
")",
";",
"server",
".",
"join",
"(",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"warn",
"(",
"\"Can't join Server. Not started\"",
")",
";",
"}",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"JettyBootstrapException",
"(",
"e",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Blocks the calling thread until the server stops.
@return this instance
@throws JettyBootstrapException
if an exception occurs while blocking the thread | [
"Blocks",
"the",
"calling",
"thread",
"until",
"the",
"server",
"stops",
"."
] | c16e710b833084c650fce35aa8c1ccaf83cd93ef | https://github.com/teknux-org/jetty-bootstrap/blob/c16e710b833084c650fce35aa8c1ccaf83cd93ef/jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/JettyBootstrap.java#L173-L187 | train |
teknux-org/jetty-bootstrap | jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/JettyBootstrap.java | JettyBootstrap.stopServer | public JettyBootstrap stopServer() throws JettyBootstrapException {
LOG.info("Stopping Server...");
try {
if (isServerStarted()) {
handlers.stop();
server.stop();
LOG.info("Server stopped.");
} else {
LOG.warn("Can't stop server. Already stopped");
}
} catch (Exception e) {
throw new JettyBootstrapException(e);
}
return this;
} | java | public JettyBootstrap stopServer() throws JettyBootstrapException {
LOG.info("Stopping Server...");
try {
if (isServerStarted()) {
handlers.stop();
server.stop();
LOG.info("Server stopped.");
} else {
LOG.warn("Can't stop server. Already stopped");
}
} catch (Exception e) {
throw new JettyBootstrapException(e);
}
return this;
} | [
"public",
"JettyBootstrap",
"stopServer",
"(",
")",
"throws",
"JettyBootstrapException",
"{",
"LOG",
".",
"info",
"(",
"\"Stopping Server...\"",
")",
";",
"try",
"{",
"if",
"(",
"isServerStarted",
"(",
")",
")",
"{",
"handlers",
".",
"stop",
"(",
")",
";",
"server",
".",
"stop",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Server stopped.\"",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"warn",
"(",
"\"Can't stop server. Already stopped\"",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"JettyBootstrapException",
"(",
"e",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Stops the Jetty server.
@return this instance
@throws JettyBootstrapException
if an exception occurs while stopping the server or if the server is not started | [
"Stops",
"the",
"Jetty",
"server",
"."
] | c16e710b833084c650fce35aa8c1ccaf83cd93ef | https://github.com/teknux-org/jetty-bootstrap/blob/c16e710b833084c650fce35aa8c1ccaf83cd93ef/jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/JettyBootstrap.java#L205-L222 | train |
teknux-org/jetty-bootstrap | jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/JettyBootstrap.java | JettyBootstrap.addWarApp | public WebAppContext addWarApp(String war, String contextPath) throws JettyBootstrapException {
WarAppJettyHandler warAppJettyHandler = new WarAppJettyHandler(getInitializedConfiguration());
warAppJettyHandler.setWar(war);
warAppJettyHandler.setContextPath(contextPath);
WebAppContext webAppContext = warAppJettyHandler.getHandler();
handlers.addHandler(webAppContext);
return webAppContext;
} | java | public WebAppContext addWarApp(String war, String contextPath) throws JettyBootstrapException {
WarAppJettyHandler warAppJettyHandler = new WarAppJettyHandler(getInitializedConfiguration());
warAppJettyHandler.setWar(war);
warAppJettyHandler.setContextPath(contextPath);
WebAppContext webAppContext = warAppJettyHandler.getHandler();
handlers.addHandler(webAppContext);
return webAppContext;
} | [
"public",
"WebAppContext",
"addWarApp",
"(",
"String",
"war",
",",
"String",
"contextPath",
")",
"throws",
"JettyBootstrapException",
"{",
"WarAppJettyHandler",
"warAppJettyHandler",
"=",
"new",
"WarAppJettyHandler",
"(",
"getInitializedConfiguration",
"(",
")",
")",
";",
"warAppJettyHandler",
".",
"setWar",
"(",
"war",
")",
";",
"warAppJettyHandler",
".",
"setContextPath",
"(",
"contextPath",
")",
";",
"WebAppContext",
"webAppContext",
"=",
"warAppJettyHandler",
".",
"getHandler",
"(",
")",
";",
"handlers",
".",
"addHandler",
"(",
"webAppContext",
")",
";",
"return",
"webAppContext",
";",
"}"
] | Add a War application specifying the context path.
@param war
the path to a war file
@param contextPath
the path (base URL) to make the war available
@return WebAppContext
@throws JettyBootstrapException
on failure | [
"Add",
"a",
"War",
"application",
"specifying",
"the",
"context",
"path",
"."
] | c16e710b833084c650fce35aa8c1ccaf83cd93ef | https://github.com/teknux-org/jetty-bootstrap/blob/c16e710b833084c650fce35aa8c1ccaf83cd93ef/jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/JettyBootstrap.java#L248-L257 | train |
teknux-org/jetty-bootstrap | jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/JettyBootstrap.java | JettyBootstrap.addWarAppFromClasspath | public WebAppContext addWarAppFromClasspath(String warFromClasspath, String contextPath) throws JettyBootstrapException {
WarAppFromClasspathJettyHandler warAppFromClasspathJettyHandler = new WarAppFromClasspathJettyHandler(getInitializedConfiguration());
warAppFromClasspathJettyHandler.setWarFromClasspath(warFromClasspath);
warAppFromClasspathJettyHandler.setContextPath(contextPath);
WebAppContext webAppContext = warAppFromClasspathJettyHandler.getHandler();
handlers.addHandler(webAppContext);
return webAppContext;
} | java | public WebAppContext addWarAppFromClasspath(String warFromClasspath, String contextPath) throws JettyBootstrapException {
WarAppFromClasspathJettyHandler warAppFromClasspathJettyHandler = new WarAppFromClasspathJettyHandler(getInitializedConfiguration());
warAppFromClasspathJettyHandler.setWarFromClasspath(warFromClasspath);
warAppFromClasspathJettyHandler.setContextPath(contextPath);
WebAppContext webAppContext = warAppFromClasspathJettyHandler.getHandler();
handlers.addHandler(webAppContext);
return webAppContext;
} | [
"public",
"WebAppContext",
"addWarAppFromClasspath",
"(",
"String",
"warFromClasspath",
",",
"String",
"contextPath",
")",
"throws",
"JettyBootstrapException",
"{",
"WarAppFromClasspathJettyHandler",
"warAppFromClasspathJettyHandler",
"=",
"new",
"WarAppFromClasspathJettyHandler",
"(",
"getInitializedConfiguration",
"(",
")",
")",
";",
"warAppFromClasspathJettyHandler",
".",
"setWarFromClasspath",
"(",
"warFromClasspath",
")",
";",
"warAppFromClasspathJettyHandler",
".",
"setContextPath",
"(",
"contextPath",
")",
";",
"WebAppContext",
"webAppContext",
"=",
"warAppFromClasspathJettyHandler",
".",
"getHandler",
"(",
")",
";",
"handlers",
".",
"addHandler",
"(",
"webAppContext",
")",
";",
"return",
"webAppContext",
";",
"}"
] | Add a War application from the current classpath specifying the context path.
@param warFromClasspath
the path to a war file in the classpath
@param contextPath
the path (base URL) to make the war available
@return WebAppContext
@throws JettyBootstrapException
on failed | [
"Add",
"a",
"War",
"application",
"from",
"the",
"current",
"classpath",
"specifying",
"the",
"context",
"path",
"."
] | c16e710b833084c650fce35aa8c1ccaf83cd93ef | https://github.com/teknux-org/jetty-bootstrap/blob/c16e710b833084c650fce35aa8c1ccaf83cd93ef/jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/JettyBootstrap.java#L283-L292 | train |
teknux-org/jetty-bootstrap | jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/JettyBootstrap.java | JettyBootstrap.createShutdownHook | private void createShutdownHook() {
LOG.trace("Creating Jetty ShutdownHook...");
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
LOG.debug("Shutting Down...");
stopServer();
} catch (Exception e) {
LOG.error("Shutdown", e);
}
}));
} | java | private void createShutdownHook() {
LOG.trace("Creating Jetty ShutdownHook...");
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
LOG.debug("Shutting Down...");
stopServer();
} catch (Exception e) {
LOG.error("Shutdown", e);
}
}));
} | [
"private",
"void",
"createShutdownHook",
"(",
")",
"{",
"LOG",
".",
"trace",
"(",
"\"Creating Jetty ShutdownHook...\"",
")",
";",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"addShutdownHook",
"(",
"new",
"Thread",
"(",
"(",
")",
"->",
"{",
"try",
"{",
"LOG",
".",
"debug",
"(",
"\"Shutting Down...\"",
")",
";",
"stopServer",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Shutdown\"",
",",
"e",
")",
";",
"}",
"}",
")",
")",
";",
"}"
] | Create Shutdown Hook. | [
"Create",
"Shutdown",
"Hook",
"."
] | c16e710b833084c650fce35aa8c1ccaf83cd93ef | https://github.com/teknux-org/jetty-bootstrap/blob/c16e710b833084c650fce35aa8c1ccaf83cd93ef/jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/JettyBootstrap.java#L688-L699 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/ReflectionUtils.java | ReflectionUtils.getAllDeclaredMethods | public static Method[] getAllDeclaredMethods(Class<?> leafClass) {
final List<Method> methods = new ArrayList<Method>(32);
doWithMethods(leafClass, new MethodCallback() {
public void doWith(Method method) {
methods.add(method);
}
});
return methods.toArray(new Method[methods.size()]);
} | java | public static Method[] getAllDeclaredMethods(Class<?> leafClass) {
final List<Method> methods = new ArrayList<Method>(32);
doWithMethods(leafClass, new MethodCallback() {
public void doWith(Method method) {
methods.add(method);
}
});
return methods.toArray(new Method[methods.size()]);
} | [
"public",
"static",
"Method",
"[",
"]",
"getAllDeclaredMethods",
"(",
"Class",
"<",
"?",
">",
"leafClass",
")",
"{",
"final",
"List",
"<",
"Method",
">",
"methods",
"=",
"new",
"ArrayList",
"<",
"Method",
">",
"(",
"32",
")",
";",
"doWithMethods",
"(",
"leafClass",
",",
"new",
"MethodCallback",
"(",
")",
"{",
"public",
"void",
"doWith",
"(",
"Method",
"method",
")",
"{",
"methods",
".",
"add",
"(",
"method",
")",
";",
"}",
"}",
")",
";",
"return",
"methods",
".",
"toArray",
"(",
"new",
"Method",
"[",
"methods",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] | Get all declared methods on the leaf class and all superclasses. Leaf class methods are included first.
@param leafClass
the class to introspect | [
"Get",
"all",
"declared",
"methods",
"on",
"the",
"leaf",
"class",
"and",
"all",
"superclasses",
".",
"Leaf",
"class",
"methods",
"are",
"included",
"first",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/ReflectionUtils.java#L557-L565 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/ReflectionUtils.java | ReflectionUtils.getSelfAndSuperClassFields | public static List<Field> getSelfAndSuperClassFields(Class<?> clazz) {//YongZ added this method
List<Field> fields = new ArrayList<Field>();
for (Field field : clazz.getDeclaredFields())
fields.add(field);
Class<?> superclass = clazz.getSuperclass();
while (superclass != null) {
if (Object.class.equals(superclass)) {
break;
}
for (Field field : superclass.getDeclaredFields())
fields.add(field);
superclass = superclass.getSuperclass();
}
return fields;
} | java | public static List<Field> getSelfAndSuperClassFields(Class<?> clazz) {//YongZ added this method
List<Field> fields = new ArrayList<Field>();
for (Field field : clazz.getDeclaredFields())
fields.add(field);
Class<?> superclass = clazz.getSuperclass();
while (superclass != null) {
if (Object.class.equals(superclass)) {
break;
}
for (Field field : superclass.getDeclaredFields())
fields.add(field);
superclass = superclass.getSuperclass();
}
return fields;
} | [
"public",
"static",
"List",
"<",
"Field",
">",
"getSelfAndSuperClassFields",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"//YongZ added this method",
"List",
"<",
"Field",
">",
"fields",
"=",
"new",
"ArrayList",
"<",
"Field",
">",
"(",
")",
";",
"for",
"(",
"Field",
"field",
":",
"clazz",
".",
"getDeclaredFields",
"(",
")",
")",
"fields",
".",
"(",
"field",
")",
";",
"Class",
"<",
"?",
">",
"superclass",
"=",
"clazz",
".",
"getSuperclass",
"(",
")",
";",
"while",
"(",
"superclass",
"!=",
"null",
")",
"{",
"if",
"(",
"Object",
".",
"class",
".",
"equals",
"(",
"superclass",
")",
")",
"{",
"break",
";",
"}",
"for",
"(",
"Field",
"field",
":",
"superclass",
".",
"getDeclaredFields",
"(",
")",
")",
"fields",
".",
"(",
"field",
")",
";",
"superclass",
"=",
"superclass",
".",
"getSuperclass",
"(",
")",
";",
"}",
"return",
"fields",
";",
"}"
] | Get all fields of a class includes its super class's fields | [
"Get",
"all",
"fields",
"of",
"a",
"class",
"includes",
"its",
"super",
"class",
"s",
"fields"
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/ReflectionUtils.java#L761-L776 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/MethodNode.java | MethodNode.check | public void check(final int api) {
if (api == Opcodes.ASM4) {
if (visibleTypeAnnotations != null
&& visibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
if (invisibleTypeAnnotations != null
&& invisibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
int n = tryCatchBlocks == null ? 0 : tryCatchBlocks.size();
for (int i = 0; i < n; ++i) {
TryCatchBlockNode tcb = tryCatchBlocks.get(i);
if (tcb.visibleTypeAnnotations != null
&& tcb.visibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
if (tcb.invisibleTypeAnnotations != null
&& tcb.invisibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
}
for (int i = 0; i < instructions.size(); ++i) {
AbstractInsnNode insn = instructions.get(i);
if (insn.visibleTypeAnnotations != null
&& insn.visibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
if (insn.invisibleTypeAnnotations != null
&& insn.invisibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
if (insn instanceof MethodInsnNode) {
boolean itf = ((MethodInsnNode) insn).itf;
if (itf != (insn.opcode == Opcodes.INVOKEINTERFACE)) {
throw new RuntimeException();
}
}
}
if (visibleLocalVariableAnnotations != null
&& visibleLocalVariableAnnotations.size() > 0) {
throw new RuntimeException();
}
if (invisibleLocalVariableAnnotations != null
&& invisibleLocalVariableAnnotations.size() > 0) {
throw new RuntimeException();
}
}
} | java | public void check(final int api) {
if (api == Opcodes.ASM4) {
if (visibleTypeAnnotations != null
&& visibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
if (invisibleTypeAnnotations != null
&& invisibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
int n = tryCatchBlocks == null ? 0 : tryCatchBlocks.size();
for (int i = 0; i < n; ++i) {
TryCatchBlockNode tcb = tryCatchBlocks.get(i);
if (tcb.visibleTypeAnnotations != null
&& tcb.visibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
if (tcb.invisibleTypeAnnotations != null
&& tcb.invisibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
}
for (int i = 0; i < instructions.size(); ++i) {
AbstractInsnNode insn = instructions.get(i);
if (insn.visibleTypeAnnotations != null
&& insn.visibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
if (insn.invisibleTypeAnnotations != null
&& insn.invisibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
if (insn instanceof MethodInsnNode) {
boolean itf = ((MethodInsnNode) insn).itf;
if (itf != (insn.opcode == Opcodes.INVOKEINTERFACE)) {
throw new RuntimeException();
}
}
}
if (visibleLocalVariableAnnotations != null
&& visibleLocalVariableAnnotations.size() > 0) {
throw new RuntimeException();
}
if (invisibleLocalVariableAnnotations != null
&& invisibleLocalVariableAnnotations.size() > 0) {
throw new RuntimeException();
}
}
} | [
"public",
"void",
"check",
"(",
"final",
"int",
"api",
")",
"{",
"if",
"(",
"api",
"==",
"Opcodes",
".",
"ASM4",
")",
"{",
"if",
"(",
"visibleTypeAnnotations",
"!=",
"null",
"&&",
"visibleTypeAnnotations",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"if",
"(",
"invisibleTypeAnnotations",
"!=",
"null",
"&&",
"invisibleTypeAnnotations",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"int",
"n",
"=",
"tryCatchBlocks",
"==",
"null",
"?",
"0",
":",
"tryCatchBlocks",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"TryCatchBlockNode",
"tcb",
"=",
"tryCatchBlocks",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"tcb",
".",
"visibleTypeAnnotations",
"!=",
"null",
"&&",
"tcb",
".",
"visibleTypeAnnotations",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"if",
"(",
"tcb",
".",
"invisibleTypeAnnotations",
"!=",
"null",
"&&",
"tcb",
".",
"invisibleTypeAnnotations",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"instructions",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"AbstractInsnNode",
"insn",
"=",
"instructions",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"insn",
".",
"visibleTypeAnnotations",
"!=",
"null",
"&&",
"insn",
".",
"visibleTypeAnnotations",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"if",
"(",
"insn",
".",
"invisibleTypeAnnotations",
"!=",
"null",
"&&",
"insn",
".",
"invisibleTypeAnnotations",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"if",
"(",
"insn",
"instanceof",
"MethodInsnNode",
")",
"{",
"boolean",
"itf",
"=",
"(",
"(",
"MethodInsnNode",
")",
"insn",
")",
".",
"itf",
";",
"if",
"(",
"itf",
"!=",
"(",
"insn",
".",
"opcode",
"==",
"Opcodes",
".",
"INVOKEINTERFACE",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"}",
"}",
"if",
"(",
"visibleLocalVariableAnnotations",
"!=",
"null",
"&&",
"visibleLocalVariableAnnotations",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"if",
"(",
"invisibleLocalVariableAnnotations",
"!=",
"null",
"&&",
"invisibleLocalVariableAnnotations",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"}",
"}"
] | Checks that this method node is compatible with the given ASM API
version. This methods checks that this node, and all its nodes
recursively, do not contain elements that were introduced in more recent
versions of the ASM API than the given version.
@param api
an ASM API version. Must be one of {@link Opcodes#ASM4} or
{@link Opcodes#ASM5}. | [
"Checks",
"that",
"this",
"method",
"node",
"is",
"compatible",
"with",
"the",
"given",
"ASM",
"API",
"version",
".",
"This",
"methods",
"checks",
"that",
"this",
"node",
"and",
"all",
"its",
"nodes",
"recursively",
"do",
"not",
"contain",
"elements",
"that",
"were",
"introduced",
"in",
"more",
"recent",
"versions",
"of",
"the",
"ASM",
"API",
"than",
"the",
"given",
"version",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/MethodNode.java#L665-L713 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/MethodNode.java | MethodNode.accept | public void accept(final ClassVisitor cv) {
String[] exceptions = new String[this.exceptions.size()];
this.exceptions.toArray(exceptions);
MethodVisitor mv = cv.visitMethod(access, name, desc, signature,
exceptions);
if (mv != null) {
accept(mv);
}
} | java | public void accept(final ClassVisitor cv) {
String[] exceptions = new String[this.exceptions.size()];
this.exceptions.toArray(exceptions);
MethodVisitor mv = cv.visitMethod(access, name, desc, signature,
exceptions);
if (mv != null) {
accept(mv);
}
} | [
"public",
"void",
"accept",
"(",
"final",
"ClassVisitor",
"cv",
")",
"{",
"String",
"[",
"]",
"exceptions",
"=",
"new",
"String",
"[",
"this",
".",
"exceptions",
".",
"size",
"(",
")",
"]",
";",
"this",
".",
"exceptions",
".",
"toArray",
"(",
"exceptions",
")",
";",
"MethodVisitor",
"mv",
"=",
"cv",
".",
"visitMethod",
"(",
"access",
",",
"name",
",",
"desc",
",",
"signature",
",",
"exceptions",
")",
";",
"if",
"(",
"mv",
"!=",
"null",
")",
"{",
"accept",
"(",
"mv",
")",
";",
"}",
"}"
] | Makes the given class visitor visit this method.
@param cv
a class visitor. | [
"Makes",
"the",
"given",
"class",
"visitor",
"visit",
"this",
"method",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/MethodNode.java#L721-L729 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/AnnotationNode.java | AnnotationNode.accept | public void accept(final AnnotationVisitor av) {
if (av != null) {
if (values != null) {
for (int i = 0; i < values.size(); i += 2) {
String name = (String) values.get(i);
Object value = values.get(i + 1);
accept(av, name, value);
}
}
av.visitEnd();
}
} | java | public void accept(final AnnotationVisitor av) {
if (av != null) {
if (values != null) {
for (int i = 0; i < values.size(); i += 2) {
String name = (String) values.get(i);
Object value = values.get(i + 1);
accept(av, name, value);
}
}
av.visitEnd();
}
} | [
"public",
"void",
"accept",
"(",
"final",
"AnnotationVisitor",
"av",
")",
"{",
"if",
"(",
"av",
"!=",
"null",
")",
"{",
"if",
"(",
"values",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"size",
"(",
")",
";",
"i",
"+=",
"2",
")",
"{",
"String",
"name",
"=",
"(",
"String",
")",
"values",
".",
"get",
"(",
"i",
")",
";",
"Object",
"value",
"=",
"values",
".",
"get",
"(",
"i",
"+",
"1",
")",
";",
"accept",
"(",
"av",
",",
"name",
",",
"value",
")",
";",
"}",
"}",
"av",
".",
"visitEnd",
"(",
")",
";",
"}",
"}"
] | Makes the given visitor visit this annotation.
@param av
an annotation visitor. Maybe <tt>null</tt>. | [
"Makes",
"the",
"given",
"visitor",
"visit",
"this",
"annotation",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/AnnotationNode.java#L187-L198 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/AnnotationNode.java | AnnotationNode.accept | static void accept(final AnnotationVisitor av, final String name,
final Object value) {
if (av != null) {
if (value instanceof String[]) {
String[] typeconst = (String[]) value;
av.visitEnum(name, typeconst[0], typeconst[1]);
} else if (value instanceof AnnotationNode) {
AnnotationNode an = (AnnotationNode) value;
an.accept(av.visitAnnotation(name, an.desc));
} else if (value instanceof List) {
AnnotationVisitor v = av.visitArray(name);
List<?> array = (List<?>) value;
for (int j = 0; j < array.size(); ++j) {
accept(v, null, array.get(j));
}
v.visitEnd();
} else {
av.visit(name, value);
}
}
} | java | static void accept(final AnnotationVisitor av, final String name,
final Object value) {
if (av != null) {
if (value instanceof String[]) {
String[] typeconst = (String[]) value;
av.visitEnum(name, typeconst[0], typeconst[1]);
} else if (value instanceof AnnotationNode) {
AnnotationNode an = (AnnotationNode) value;
an.accept(av.visitAnnotation(name, an.desc));
} else if (value instanceof List) {
AnnotationVisitor v = av.visitArray(name);
List<?> array = (List<?>) value;
for (int j = 0; j < array.size(); ++j) {
accept(v, null, array.get(j));
}
v.visitEnd();
} else {
av.visit(name, value);
}
}
} | [
"static",
"void",
"accept",
"(",
"final",
"AnnotationVisitor",
"av",
",",
"final",
"String",
"name",
",",
"final",
"Object",
"value",
")",
"{",
"if",
"(",
"av",
"!=",
"null",
")",
"{",
"if",
"(",
"value",
"instanceof",
"String",
"[",
"]",
")",
"{",
"String",
"[",
"]",
"typeconst",
"=",
"(",
"String",
"[",
"]",
")",
"value",
";",
"av",
".",
"visitEnum",
"(",
"name",
",",
"typeconst",
"[",
"0",
"]",
",",
"typeconst",
"[",
"1",
"]",
")",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"AnnotationNode",
")",
"{",
"AnnotationNode",
"an",
"=",
"(",
"AnnotationNode",
")",
"value",
";",
"an",
".",
"accept",
"(",
"av",
".",
"visitAnnotation",
"(",
"name",
",",
"an",
".",
"desc",
")",
")",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"List",
")",
"{",
"AnnotationVisitor",
"v",
"=",
"av",
".",
"visitArray",
"(",
"name",
")",
";",
"List",
"<",
"?",
">",
"array",
"=",
"(",
"List",
"<",
"?",
">",
")",
"value",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"array",
".",
"size",
"(",
")",
";",
"++",
"j",
")",
"{",
"accept",
"(",
"v",
",",
"null",
",",
"array",
".",
"get",
"(",
"j",
")",
")",
";",
"}",
"v",
".",
"visitEnd",
"(",
")",
";",
"}",
"else",
"{",
"av",
".",
"visit",
"(",
"name",
",",
"value",
")",
";",
"}",
"}",
"}"
] | Makes the given visitor visit a given annotation value.
@param av
an annotation visitor. Maybe <tt>null</tt>.
@param name
the value name.
@param value
the actual value. | [
"Makes",
"the",
"given",
"visitor",
"visit",
"a",
"given",
"annotation",
"value",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/AnnotationNode.java#L210-L230 | train |
teknux-org/jetty-bootstrap | jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/utils/PathUtil.java | PathUtil.getJarDir | public static String getJarDir(Class<?> clazz) {
return decodeUrl(new File(clazz.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent());
} | java | public static String getJarDir(Class<?> clazz) {
return decodeUrl(new File(clazz.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent());
} | [
"public",
"static",
"String",
"getJarDir",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"return",
"decodeUrl",
"(",
"new",
"File",
"(",
"clazz",
".",
"getProtectionDomain",
"(",
")",
".",
"getCodeSource",
"(",
")",
".",
"getLocation",
"(",
")",
".",
"getPath",
"(",
")",
")",
".",
"getParent",
"(",
")",
")",
";",
"}"
] | Get Jar location
@param clazz
Based on class location
@return String | [
"Get",
"Jar",
"location"
] | c16e710b833084c650fce35aa8c1ccaf83cd93ef | https://github.com/teknux-org/jetty-bootstrap/blob/c16e710b833084c650fce35aa8c1ccaf83cd93ef/jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/utils/PathUtil.java#L50-L52 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/LocalVariableNode.java | LocalVariableNode.accept | public void accept(final MethodVisitor mv) {
mv.visitLocalVariable(name, desc, signature, start.getLabel(),
end.getLabel(), index);
} | java | public void accept(final MethodVisitor mv) {
mv.visitLocalVariable(name, desc, signature, start.getLabel(),
end.getLabel(), index);
} | [
"public",
"void",
"accept",
"(",
"final",
"MethodVisitor",
"mv",
")",
"{",
"mv",
".",
"visitLocalVariable",
"(",
"name",
",",
"desc",
",",
"signature",
",",
"start",
".",
"getLabel",
"(",
")",
",",
"end",
".",
"getLabel",
"(",
")",
",",
"index",
")",
";",
"}"
] | Makes the given visitor visit this local variable declaration.
@param mv
a method visitor. | [
"Makes",
"the",
"given",
"visitor",
"visit",
"this",
"local",
"variable",
"declaration",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/LocalVariableNode.java#L108-L111 | train |
lamarios/sherdog-parser | src/main/java/com/ftpix/sherdogparser/parsers/SearchParser.java | SearchParser.parse | public List<SherdogBaseObject> parse(String url) throws IOException {
Document document = ParserUtils.parseDocument(url);
Elements select = document.select(".fightfinder_result tr");
//removing the first one as it's the header
if (select.size() > 0) {
select.remove(0);
}
return select.stream()
.map(e ->
Optional.ofNullable(e.select("td"))
//second element is the fighter name
.filter(t -> t.size() > 1)
.map(td -> td.get(1))
.map(t -> t.select("a"))
.filter(t -> t.size() == 1)
.map(t -> {
return t.get(0);
})
.map(t -> {
//this could be either fighter or event
SherdogBaseObject sherdogObject = new SherdogBaseObject();
sherdogObject.setName(t.text());
sherdogObject.setSherdogUrl(Constants.BASE_URL + t.attr("href"));
return sherdogObject;
})
.filter(f -> f.getName() != null && f.getSherdogUrl() != null)
.orElse(null)
)
.filter(f -> f != null)
.collect(Collectors.toList());
} | java | public List<SherdogBaseObject> parse(String url) throws IOException {
Document document = ParserUtils.parseDocument(url);
Elements select = document.select(".fightfinder_result tr");
//removing the first one as it's the header
if (select.size() > 0) {
select.remove(0);
}
return select.stream()
.map(e ->
Optional.ofNullable(e.select("td"))
//second element is the fighter name
.filter(t -> t.size() > 1)
.map(td -> td.get(1))
.map(t -> t.select("a"))
.filter(t -> t.size() == 1)
.map(t -> {
return t.get(0);
})
.map(t -> {
//this could be either fighter or event
SherdogBaseObject sherdogObject = new SherdogBaseObject();
sherdogObject.setName(t.text());
sherdogObject.setSherdogUrl(Constants.BASE_URL + t.attr("href"));
return sherdogObject;
})
.filter(f -> f.getName() != null && f.getSherdogUrl() != null)
.orElse(null)
)
.filter(f -> f != null)
.collect(Collectors.toList());
} | [
"public",
"List",
"<",
"SherdogBaseObject",
">",
"parse",
"(",
"String",
"url",
")",
"throws",
"IOException",
"{",
"Document",
"document",
"=",
"ParserUtils",
".",
"parseDocument",
"(",
"url",
")",
";",
"Elements",
"select",
"=",
"document",
".",
"select",
"(",
"\".fightfinder_result tr\"",
")",
";",
"//removing the first one as it's the header",
"if",
"(",
"select",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"select",
".",
"remove",
"(",
"0",
")",
";",
"}",
"return",
"select",
".",
"stream",
"(",
")",
".",
"map",
"(",
"e",
"->",
"Optional",
".",
"ofNullable",
"(",
"e",
".",
"select",
"(",
"\"td\"",
")",
")",
"//second element is the fighter name",
".",
"filter",
"(",
"t",
"->",
"t",
".",
"size",
"(",
")",
">",
"1",
")",
".",
"map",
"(",
"td",
"->",
"td",
".",
"get",
"(",
"1",
")",
")",
".",
"map",
"(",
"t",
"->",
"t",
".",
"select",
"(",
"\"a\"",
")",
")",
".",
"filter",
"(",
"t",
"->",
"t",
".",
"size",
"(",
")",
"==",
"1",
")",
".",
"map",
"(",
"t",
"->",
"{",
"return",
"t",
".",
"get",
"(",
"0",
")",
";",
"}",
")",
".",
"map",
"(",
"t",
"->",
"{",
"//this could be either fighter or event",
"SherdogBaseObject",
"sherdogObject",
"=",
"new",
"SherdogBaseObject",
"(",
")",
";",
"sherdogObject",
".",
"setName",
"(",
"t",
".",
"text",
"(",
")",
")",
";",
"sherdogObject",
".",
"setSherdogUrl",
"(",
"Constants",
".",
"BASE_URL",
"+",
"t",
".",
"attr",
"(",
"\"href\"",
")",
")",
";",
"return",
"sherdogObject",
";",
"}",
")",
".",
"filter",
"(",
"f",
"->",
"f",
".",
"getName",
"(",
")",
"!=",
"null",
"&&",
"f",
".",
"getSherdogUrl",
"(",
")",
"!=",
"null",
")",
".",
"orElse",
"(",
"null",
")",
")",
".",
"filter",
"(",
"f",
"->",
"f",
"!=",
"null",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] | PArses a search page results
@param url the search url
@return the results | [
"PArses",
"a",
"search",
"page",
"results"
] | 7cdb36280317caeaaa54db77c04dc4b4e1db053e | https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/parsers/SearchParser.java#L26-L65 | train |
ef-labs/vertx-when | vertx-when/src/main/java/com/englishtown/vertx/promises/impl/DefaultWhenVertx.java | DefaultWhenVertx.undeploy | @Override
public Promise<Void> undeploy(String deploymentID) {
return adapter.toPromise(handler -> vertx.undeploy(deploymentID, handler));
} | java | @Override
public Promise<Void> undeploy(String deploymentID) {
return adapter.toPromise(handler -> vertx.undeploy(deploymentID, handler));
} | [
"@",
"Override",
"public",
"Promise",
"<",
"Void",
">",
"undeploy",
"(",
"String",
"deploymentID",
")",
"{",
"return",
"adapter",
".",
"toPromise",
"(",
"handler",
"->",
"vertx",
".",
"undeploy",
"(",
"deploymentID",
",",
"handler",
")",
")",
";",
"}"
] | Undeploy a verticle
@param deploymentID The deployment ID
@return A promise for undeployment completion | [
"Undeploy",
"a",
"verticle"
] | dc4fde973f58130f2eb2159206ee78b867048f4d | https://github.com/ef-labs/vertx-when/blob/dc4fde973f58130f2eb2159206ee78b867048f4d/vertx-when/src/main/java/com/englishtown/vertx/promises/impl/DefaultWhenVertx.java#L81-L84 | train |
bryonjacob/graphviz-maven-plugin | src/main/java/us/bryon/graphviz/maven/DotmlMojo.java | DotmlMojo.transformInputFile | protected File transformInputFile(File from) throws MojoExecutionException {
// create a temp file
File tempFile;
try {
tempFile = File.createTempFile("dotml-tmp", ".xml");
} catch (IOException e) {
throw new MojoExecutionException(
"error creating temp file to hold DOTML to DOT translation", e);
}
// perform an XSLT transform from the input file to the temp file
Source xml = new StreamSource(from);
Result result = new StreamResult(tempFile);
try {
Source xslt = new StreamSource(
getClass().getClassLoader().getResourceAsStream("dotml/dotml2dot.xsl"));
transformerFactory.newTransformer(xslt).transform(xml, result);
} catch (TransformerException e) {
throw new MojoExecutionException(
String.format("error transforming %s from DOTML to DOT file", from), e);
}
// return the temp file
return tempFile;
} | java | protected File transformInputFile(File from) throws MojoExecutionException {
// create a temp file
File tempFile;
try {
tempFile = File.createTempFile("dotml-tmp", ".xml");
} catch (IOException e) {
throw new MojoExecutionException(
"error creating temp file to hold DOTML to DOT translation", e);
}
// perform an XSLT transform from the input file to the temp file
Source xml = new StreamSource(from);
Result result = new StreamResult(tempFile);
try {
Source xslt = new StreamSource(
getClass().getClassLoader().getResourceAsStream("dotml/dotml2dot.xsl"));
transformerFactory.newTransformer(xslt).transform(xml, result);
} catch (TransformerException e) {
throw new MojoExecutionException(
String.format("error transforming %s from DOTML to DOT file", from), e);
}
// return the temp file
return tempFile;
} | [
"protected",
"File",
"transformInputFile",
"(",
"File",
"from",
")",
"throws",
"MojoExecutionException",
"{",
"// create a temp file",
"File",
"tempFile",
";",
"try",
"{",
"tempFile",
"=",
"File",
".",
"createTempFile",
"(",
"\"dotml-tmp\"",
",",
"\".xml\"",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"error creating temp file to hold DOTML to DOT translation\"",
",",
"e",
")",
";",
"}",
"// perform an XSLT transform from the input file to the temp file",
"Source",
"xml",
"=",
"new",
"StreamSource",
"(",
"from",
")",
";",
"Result",
"result",
"=",
"new",
"StreamResult",
"(",
"tempFile",
")",
";",
"try",
"{",
"Source",
"xslt",
"=",
"new",
"StreamSource",
"(",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"\"dotml/dotml2dot.xsl\"",
")",
")",
";",
"transformerFactory",
".",
"newTransformer",
"(",
"xslt",
")",
".",
"transform",
"(",
"xml",
",",
"result",
")",
";",
"}",
"catch",
"(",
"TransformerException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"String",
".",
"format",
"(",
"\"error transforming %s from DOTML to DOT file\"",
",",
"from",
")",
",",
"e",
")",
";",
"}",
"// return the temp file",
"return",
"tempFile",
";",
"}"
] | when we are using DOTML files, we need to transform them to DOT files first. | [
"when",
"we",
"are",
"using",
"DOTML",
"files",
"we",
"need",
"to",
"transform",
"them",
"to",
"DOT",
"files",
"first",
"."
] | bc64838ff809e61e996a47f04bdfe5ee302cf555 | https://github.com/bryonjacob/graphviz-maven-plugin/blob/bc64838ff809e61e996a47f04bdfe5ee302cf555/src/main/java/us/bryon/graphviz/maven/DotmlMojo.java#L55-L77 | train |
teknux-org/jetty-bootstrap | jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/handler/util/JettyConstraintUtil.java | JettyConstraintUtil.getConstraintSecurityHandlerConfidential | public static ConstraintSecurityHandler getConstraintSecurityHandlerConfidential() {
Constraint constraint = new Constraint();
constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint(constraint);
constraintMapping.setPathSpec("/*");
ConstraintSecurityHandler constraintSecurityHandler = new ConstraintSecurityHandler();
constraintSecurityHandler.addConstraintMapping(constraintMapping);
return constraintSecurityHandler;
} | java | public static ConstraintSecurityHandler getConstraintSecurityHandlerConfidential() {
Constraint constraint = new Constraint();
constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint(constraint);
constraintMapping.setPathSpec("/*");
ConstraintSecurityHandler constraintSecurityHandler = new ConstraintSecurityHandler();
constraintSecurityHandler.addConstraintMapping(constraintMapping);
return constraintSecurityHandler;
} | [
"public",
"static",
"ConstraintSecurityHandler",
"getConstraintSecurityHandlerConfidential",
"(",
")",
"{",
"Constraint",
"constraint",
"=",
"new",
"Constraint",
"(",
")",
";",
"constraint",
".",
"setDataConstraint",
"(",
"Constraint",
".",
"DC_CONFIDENTIAL",
")",
";",
"ConstraintMapping",
"constraintMapping",
"=",
"new",
"ConstraintMapping",
"(",
")",
";",
"constraintMapping",
".",
"setConstraint",
"(",
"constraint",
")",
";",
"constraintMapping",
".",
"setPathSpec",
"(",
"\"/*\"",
")",
";",
"ConstraintSecurityHandler",
"constraintSecurityHandler",
"=",
"new",
"ConstraintSecurityHandler",
"(",
")",
";",
"constraintSecurityHandler",
".",
"addConstraintMapping",
"(",
"constraintMapping",
")",
";",
"return",
"constraintSecurityHandler",
";",
"}"
] | Create constraint which redirect to Secure Port
@return ConstraintSecurityHandler | [
"Create",
"constraint",
"which",
"redirect",
"to",
"Secure",
"Port"
] | c16e710b833084c650fce35aa8c1ccaf83cd93ef | https://github.com/teknux-org/jetty-bootstrap/blob/c16e710b833084c650fce35aa8c1ccaf83cd93ef/jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/handler/util/JettyConstraintUtil.java#L35-L47 | train |
ef-labs/vertx-when | vertx-when/src/main/java/com/englishtown/vertx/promises/impl/DefaultWhenEventBus.java | DefaultWhenEventBus.send | @Override
public <T> Promise<Message<T>> send(String address, Object message) {
return adapter.toPromise(handler -> eventBus.send(address, message, handler));
} | java | @Override
public <T> Promise<Message<T>> send(String address, Object message) {
return adapter.toPromise(handler -> eventBus.send(address, message, handler));
} | [
"@",
"Override",
"public",
"<",
"T",
">",
"Promise",
"<",
"Message",
"<",
"T",
">",
">",
"send",
"(",
"String",
"address",
",",
"Object",
"message",
")",
"{",
"return",
"adapter",
".",
"toPromise",
"(",
"handler",
"->",
"eventBus",
".",
"send",
"(",
"address",
",",
"message",
",",
"handler",
")",
")",
";",
"}"
] | Send a message
@param address The address to send it to
@param message The message, may be {@code null}
@return A promise for a reply | [
"Send",
"a",
"message"
] | dc4fde973f58130f2eb2159206ee78b867048f4d | https://github.com/ef-labs/vertx-when/blob/dc4fde973f58130f2eb2159206ee78b867048f4d/vertx-when/src/main/java/com/englishtown/vertx/promises/impl/DefaultWhenEventBus.java#L87-L90 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/optimizer/Constant.java | Constant.set | void set(final String name, final String desc, final Handle bsm,
final Object[] bsmArgs) {
this.type = 'y';
this.strVal1 = name;
this.strVal2 = desc;
this.objVal3 = bsm;
this.objVals = bsmArgs;
int hashCode = 'y' + name.hashCode() * desc.hashCode() * bsm.hashCode();
for (int i = 0; i < bsmArgs.length; i++) {
hashCode *= bsmArgs[i].hashCode();
}
this.hashCode = 0x7FFFFFFF & hashCode;
} | java | void set(final String name, final String desc, final Handle bsm,
final Object[] bsmArgs) {
this.type = 'y';
this.strVal1 = name;
this.strVal2 = desc;
this.objVal3 = bsm;
this.objVals = bsmArgs;
int hashCode = 'y' + name.hashCode() * desc.hashCode() * bsm.hashCode();
for (int i = 0; i < bsmArgs.length; i++) {
hashCode *= bsmArgs[i].hashCode();
}
this.hashCode = 0x7FFFFFFF & hashCode;
} | [
"void",
"set",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"desc",
",",
"final",
"Handle",
"bsm",
",",
"final",
"Object",
"[",
"]",
"bsmArgs",
")",
"{",
"this",
".",
"type",
"=",
"'",
"'",
";",
"this",
".",
"strVal1",
"=",
"name",
";",
"this",
".",
"strVal2",
"=",
"desc",
";",
"this",
".",
"objVal3",
"=",
"bsm",
";",
"this",
".",
"objVals",
"=",
"bsmArgs",
";",
"int",
"hashCode",
"=",
"'",
"'",
"+",
"name",
".",
"hashCode",
"(",
")",
"*",
"desc",
".",
"hashCode",
"(",
")",
"*",
"bsm",
".",
"hashCode",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"bsmArgs",
".",
"length",
";",
"i",
"++",
")",
"{",
"hashCode",
"*=",
"bsmArgs",
"[",
"i",
"]",
".",
"hashCode",
"(",
")",
";",
"}",
"this",
".",
"hashCode",
"=",
"0x7FFFFFFF",
"&",
"hashCode",
";",
"}"
] | Set this item to an InvokeDynamic item.
@param name
invokedynamic's name.
@param desc
invokedynamic's descriptor.
@param bsm
bootstrap method.
@param bsmArgs
bootstrap method constant arguments. | [
"Set",
"this",
"item",
"to",
"an",
"InvokeDynamic",
"item",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/optimizer/Constant.java#L219-L232 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.checkFrameValue | void checkFrameValue(final Object value) {
if (value == Opcodes.TOP || value == Opcodes.INTEGER
|| value == Opcodes.FLOAT || value == Opcodes.LONG
|| value == Opcodes.DOUBLE || value == Opcodes.NULL
|| value == Opcodes.UNINITIALIZED_THIS) {
return;
}
if (value instanceof String) {
checkInternalName((String) value, "Invalid stack frame value");
return;
}
if (!(value instanceof Label)) {
throw new IllegalArgumentException("Invalid stack frame value: "
+ value);
} else {
usedLabels.add((Label) value);
}
} | java | void checkFrameValue(final Object value) {
if (value == Opcodes.TOP || value == Opcodes.INTEGER
|| value == Opcodes.FLOAT || value == Opcodes.LONG
|| value == Opcodes.DOUBLE || value == Opcodes.NULL
|| value == Opcodes.UNINITIALIZED_THIS) {
return;
}
if (value instanceof String) {
checkInternalName((String) value, "Invalid stack frame value");
return;
}
if (!(value instanceof Label)) {
throw new IllegalArgumentException("Invalid stack frame value: "
+ value);
} else {
usedLabels.add((Label) value);
}
} | [
"void",
"checkFrameValue",
"(",
"final",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"Opcodes",
".",
"TOP",
"||",
"value",
"==",
"Opcodes",
".",
"INTEGER",
"||",
"value",
"==",
"Opcodes",
".",
"FLOAT",
"||",
"value",
"==",
"Opcodes",
".",
"LONG",
"||",
"value",
"==",
"Opcodes",
".",
"DOUBLE",
"||",
"value",
"==",
"Opcodes",
".",
"NULL",
"||",
"value",
"==",
"Opcodes",
".",
"UNINITIALIZED_THIS",
")",
"{",
"return",
";",
"}",
"if",
"(",
"value",
"instanceof",
"String",
")",
"{",
"checkInternalName",
"(",
"(",
"String",
")",
"value",
",",
"\"Invalid stack frame value\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"(",
"value",
"instanceof",
"Label",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid stack frame value: \"",
"+",
"value",
")",
";",
"}",
"else",
"{",
"usedLabels",
".",
"add",
"(",
"(",
"Label",
")",
"value",
")",
";",
"}",
"}"
] | Checks a stack frame value.
@param value
the value to be checked. | [
"Checks",
"a",
"stack",
"frame",
"value",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1069-L1086 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.checkOpcode | static void checkOpcode(final int opcode, final int type) {
if (opcode < 0 || opcode > 199 || TYPE[opcode] != type) {
throw new IllegalArgumentException("Invalid opcode: " + opcode);
}
} | java | static void checkOpcode(final int opcode, final int type) {
if (opcode < 0 || opcode > 199 || TYPE[opcode] != type) {
throw new IllegalArgumentException("Invalid opcode: " + opcode);
}
} | [
"static",
"void",
"checkOpcode",
"(",
"final",
"int",
"opcode",
",",
"final",
"int",
"type",
")",
"{",
"if",
"(",
"opcode",
"<",
"0",
"||",
"opcode",
">",
"199",
"||",
"TYPE",
"[",
"opcode",
"]",
"!=",
"type",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid opcode: \"",
"+",
"opcode",
")",
";",
"}",
"}"
] | Checks that the type of the given opcode is equal to the given type.
@param opcode
the opcode to be checked.
@param type
the expected opcode type. | [
"Checks",
"that",
"the",
"type",
"of",
"the",
"given",
"opcode",
"is",
"equal",
"to",
"the",
"given",
"type",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1096-L1100 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.checkSignedByte | static void checkSignedByte(final int value, final String msg) {
if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
throw new IllegalArgumentException(msg
+ " (must be a signed byte): " + value);
}
} | java | static void checkSignedByte(final int value, final String msg) {
if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
throw new IllegalArgumentException(msg
+ " (must be a signed byte): " + value);
}
} | [
"static",
"void",
"checkSignedByte",
"(",
"final",
"int",
"value",
",",
"final",
"String",
"msg",
")",
"{",
"if",
"(",
"value",
"<",
"Byte",
".",
"MIN_VALUE",
"||",
"value",
">",
"Byte",
".",
"MAX_VALUE",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"msg",
"+",
"\" (must be a signed byte): \"",
"+",
"value",
")",
";",
"}",
"}"
] | Checks that the given value is a signed byte.
@param value
the value to be checked.
@param msg
an message to be used in case of error. | [
"Checks",
"that",
"the",
"given",
"value",
"is",
"a",
"signed",
"byte",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1110-L1115 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.checkSignedShort | static void checkSignedShort(final int value, final String msg) {
if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
throw new IllegalArgumentException(msg
+ " (must be a signed short): " + value);
}
} | java | static void checkSignedShort(final int value, final String msg) {
if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
throw new IllegalArgumentException(msg
+ " (must be a signed short): " + value);
}
} | [
"static",
"void",
"checkSignedShort",
"(",
"final",
"int",
"value",
",",
"final",
"String",
"msg",
")",
"{",
"if",
"(",
"value",
"<",
"Short",
".",
"MIN_VALUE",
"||",
"value",
">",
"Short",
".",
"MAX_VALUE",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"msg",
"+",
"\" (must be a signed short): \"",
"+",
"value",
")",
";",
"}",
"}"
] | Checks that the given value is a signed short.
@param value
the value to be checked.
@param msg
an message to be used in case of error. | [
"Checks",
"that",
"the",
"given",
"value",
"is",
"a",
"signed",
"short",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1125-L1130 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.checkUnqualifiedName | static void checkUnqualifiedName(int version, final String name,
final String msg) {
if ((version & 0xFFFF) < Opcodes.V1_5) {
checkIdentifier(name, msg);
} else {
for (int i = 0; i < name.length(); ++i) {
if (".;[/".indexOf(name.charAt(i)) != -1) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must be a valid unqualified name): " + name);
}
}
}
} | java | static void checkUnqualifiedName(int version, final String name,
final String msg) {
if ((version & 0xFFFF) < Opcodes.V1_5) {
checkIdentifier(name, msg);
} else {
for (int i = 0; i < name.length(); ++i) {
if (".;[/".indexOf(name.charAt(i)) != -1) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must be a valid unqualified name): " + name);
}
}
}
} | [
"static",
"void",
"checkUnqualifiedName",
"(",
"int",
"version",
",",
"final",
"String",
"name",
",",
"final",
"String",
"msg",
")",
"{",
"if",
"(",
"(",
"version",
"&",
"0xFFFF",
")",
"<",
"Opcodes",
".",
"V1_5",
")",
"{",
"checkIdentifier",
"(",
"name",
",",
"msg",
")",
";",
"}",
"else",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"name",
".",
"length",
"(",
")",
";",
"++",
"i",
")",
"{",
"if",
"(",
"\".;[/\"",
".",
"indexOf",
"(",
"name",
".",
"charAt",
"(",
"i",
")",
")",
"!=",
"-",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid \"",
"+",
"msg",
"+",
"\" (must be a valid unqualified name): \"",
"+",
"name",
")",
";",
"}",
"}",
"}",
"}"
] | Checks that the given string is a valid unqualified name.
@param version
the class version.
@param name
the string to be checked.
@param msg
a message to be used in case of error. | [
"Checks",
"that",
"the",
"given",
"string",
"is",
"a",
"valid",
"unqualified",
"name",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1200-L1212 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.checkIdentifier | static void checkIdentifier(final String name, final int start,
final int end, final String msg) {
if (name == null || (end == -1 ? name.length() <= start : end <= start)) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must not be null or empty)");
}
if (!Character.isJavaIdentifierStart(name.charAt(start))) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must be a valid Java identifier): " + name);
}
int max = end == -1 ? name.length() : end;
for (int i = start + 1; i < max; ++i) {
if (!Character.isJavaIdentifierPart(name.charAt(i))) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must be a valid Java identifier): " + name);
}
}
} | java | static void checkIdentifier(final String name, final int start,
final int end, final String msg) {
if (name == null || (end == -1 ? name.length() <= start : end <= start)) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must not be null or empty)");
}
if (!Character.isJavaIdentifierStart(name.charAt(start))) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must be a valid Java identifier): " + name);
}
int max = end == -1 ? name.length() : end;
for (int i = start + 1; i < max; ++i) {
if (!Character.isJavaIdentifierPart(name.charAt(i))) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must be a valid Java identifier): " + name);
}
}
} | [
"static",
"void",
"checkIdentifier",
"(",
"final",
"String",
"name",
",",
"final",
"int",
"start",
",",
"final",
"int",
"end",
",",
"final",
"String",
"msg",
")",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"(",
"end",
"==",
"-",
"1",
"?",
"name",
".",
"length",
"(",
")",
"<=",
"start",
":",
"end",
"<=",
"start",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid \"",
"+",
"msg",
"+",
"\" (must not be null or empty)\"",
")",
";",
"}",
"if",
"(",
"!",
"Character",
".",
"isJavaIdentifierStart",
"(",
"name",
".",
"charAt",
"(",
"start",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid \"",
"+",
"msg",
"+",
"\" (must be a valid Java identifier): \"",
"+",
"name",
")",
";",
"}",
"int",
"max",
"=",
"end",
"==",
"-",
"1",
"?",
"name",
".",
"length",
"(",
")",
":",
"end",
";",
"for",
"(",
"int",
"i",
"=",
"start",
"+",
"1",
";",
"i",
"<",
"max",
";",
"++",
"i",
")",
"{",
"if",
"(",
"!",
"Character",
".",
"isJavaIdentifierPart",
"(",
"name",
".",
"charAt",
"(",
"i",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid \"",
"+",
"msg",
"+",
"\" (must be a valid Java identifier): \"",
"+",
"name",
")",
";",
"}",
"}",
"}"
] | Checks that the given substring is a valid Java identifier.
@param name
the string to be checked.
@param start
index of the first character of the identifier (inclusive).
@param end
index of the last character of the identifier (exclusive). -1
is equivalent to <tt>name.length()</tt> if name is not
<tt>null</tt>.
@param msg
a message to be used in case of error. | [
"Checks",
"that",
"the",
"given",
"substring",
"is",
"a",
"valid",
"Java",
"identifier",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1240-L1257 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.checkMethodIdentifier | static void checkMethodIdentifier(int version, final String name,
final String msg) {
if (name == null || name.length() == 0) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must not be null or empty)");
}
if ((version & 0xFFFF) >= Opcodes.V1_5) {
for (int i = 0; i < name.length(); ++i) {
if (".;[/<>".indexOf(name.charAt(i)) != -1) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must be a valid unqualified name): " + name);
}
}
return;
}
if (!Character.isJavaIdentifierStart(name.charAt(0))) {
throw new IllegalArgumentException(
"Invalid "
+ msg
+ " (must be a '<init>', '<clinit>' or a valid Java identifier): "
+ name);
}
for (int i = 1; i < name.length(); ++i) {
if (!Character.isJavaIdentifierPart(name.charAt(i))) {
throw new IllegalArgumentException(
"Invalid "
+ msg
+ " (must be '<init>' or '<clinit>' or a valid Java identifier): "
+ name);
}
}
} | java | static void checkMethodIdentifier(int version, final String name,
final String msg) {
if (name == null || name.length() == 0) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must not be null or empty)");
}
if ((version & 0xFFFF) >= Opcodes.V1_5) {
for (int i = 0; i < name.length(); ++i) {
if (".;[/<>".indexOf(name.charAt(i)) != -1) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must be a valid unqualified name): " + name);
}
}
return;
}
if (!Character.isJavaIdentifierStart(name.charAt(0))) {
throw new IllegalArgumentException(
"Invalid "
+ msg
+ " (must be a '<init>', '<clinit>' or a valid Java identifier): "
+ name);
}
for (int i = 1; i < name.length(); ++i) {
if (!Character.isJavaIdentifierPart(name.charAt(i))) {
throw new IllegalArgumentException(
"Invalid "
+ msg
+ " (must be '<init>' or '<clinit>' or a valid Java identifier): "
+ name);
}
}
} | [
"static",
"void",
"checkMethodIdentifier",
"(",
"int",
"version",
",",
"final",
"String",
"name",
",",
"final",
"String",
"msg",
")",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid \"",
"+",
"msg",
"+",
"\" (must not be null or empty)\"",
")",
";",
"}",
"if",
"(",
"(",
"version",
"&",
"0xFFFF",
")",
">=",
"Opcodes",
".",
"V1_5",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"name",
".",
"length",
"(",
")",
";",
"++",
"i",
")",
"{",
"if",
"(",
"\".;[/<>\"",
".",
"indexOf",
"(",
"name",
".",
"charAt",
"(",
"i",
")",
")",
"!=",
"-",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid \"",
"+",
"msg",
"+",
"\" (must be a valid unqualified name): \"",
"+",
"name",
")",
";",
"}",
"}",
"return",
";",
"}",
"if",
"(",
"!",
"Character",
".",
"isJavaIdentifierStart",
"(",
"name",
".",
"charAt",
"(",
"0",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid \"",
"+",
"msg",
"+",
"\" (must be a '<init>', '<clinit>' or a valid Java identifier): \"",
"+",
"name",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"name",
".",
"length",
"(",
")",
";",
"++",
"i",
")",
"{",
"if",
"(",
"!",
"Character",
".",
"isJavaIdentifierPart",
"(",
"name",
".",
"charAt",
"(",
"i",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid \"",
"+",
"msg",
"+",
"\" (must be '<init>' or '<clinit>' or a valid Java identifier): \"",
"+",
"name",
")",
";",
"}",
"}",
"}"
] | Checks that the given string is a valid Java identifier.
@param version
the class version.
@param name
the string to be checked.
@param msg
a message to be used in case of error. | [
"Checks",
"that",
"the",
"given",
"string",
"is",
"a",
"valid",
"Java",
"identifier",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1269-L1300 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.checkInternalName | static void checkInternalName(final String name, final String msg) {
if (name == null || name.length() == 0) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must not be null or empty)");
}
if (name.charAt(0) == '[') {
checkDesc(name, false);
} else {
checkInternalName(name, 0, -1, msg);
}
} | java | static void checkInternalName(final String name, final String msg) {
if (name == null || name.length() == 0) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must not be null or empty)");
}
if (name.charAt(0) == '[') {
checkDesc(name, false);
} else {
checkInternalName(name, 0, -1, msg);
}
} | [
"static",
"void",
"checkInternalName",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"msg",
")",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid \"",
"+",
"msg",
"+",
"\" (must not be null or empty)\"",
")",
";",
"}",
"if",
"(",
"name",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
")",
"{",
"checkDesc",
"(",
"name",
",",
"false",
")",
";",
"}",
"else",
"{",
"checkInternalName",
"(",
"name",
",",
"0",
",",
"-",
"1",
",",
"msg",
")",
";",
"}",
"}"
] | Checks that the given string is a valid internal class name.
@param name
the string to be checked.
@param msg
a message to be used in case of error. | [
"Checks",
"that",
"the",
"given",
"string",
"is",
"a",
"valid",
"internal",
"class",
"name",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1310-L1320 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.checkInternalName | static void checkInternalName(final String name, final int start,
final int end, final String msg) {
int max = end == -1 ? name.length() : end;
try {
int begin = start;
int slash;
do {
slash = name.indexOf('/', begin + 1);
if (slash == -1 || slash > max) {
slash = max;
}
checkIdentifier(name, begin, slash, null);
begin = slash + 1;
} while (slash != max);
} catch (IllegalArgumentException unused) {
throw new IllegalArgumentException(
"Invalid "
+ msg
+ " (must be a fully qualified class name in internal form): "
+ name);
}
} | java | static void checkInternalName(final String name, final int start,
final int end, final String msg) {
int max = end == -1 ? name.length() : end;
try {
int begin = start;
int slash;
do {
slash = name.indexOf('/', begin + 1);
if (slash == -1 || slash > max) {
slash = max;
}
checkIdentifier(name, begin, slash, null);
begin = slash + 1;
} while (slash != max);
} catch (IllegalArgumentException unused) {
throw new IllegalArgumentException(
"Invalid "
+ msg
+ " (must be a fully qualified class name in internal form): "
+ name);
}
} | [
"static",
"void",
"checkInternalName",
"(",
"final",
"String",
"name",
",",
"final",
"int",
"start",
",",
"final",
"int",
"end",
",",
"final",
"String",
"msg",
")",
"{",
"int",
"max",
"=",
"end",
"==",
"-",
"1",
"?",
"name",
".",
"length",
"(",
")",
":",
"end",
";",
"try",
"{",
"int",
"begin",
"=",
"start",
";",
"int",
"slash",
";",
"do",
"{",
"slash",
"=",
"name",
".",
"indexOf",
"(",
"'",
"'",
",",
"begin",
"+",
"1",
")",
";",
"if",
"(",
"slash",
"==",
"-",
"1",
"||",
"slash",
">",
"max",
")",
"{",
"slash",
"=",
"max",
";",
"}",
"checkIdentifier",
"(",
"name",
",",
"begin",
",",
"slash",
",",
"null",
")",
";",
"begin",
"=",
"slash",
"+",
"1",
";",
"}",
"while",
"(",
"slash",
"!=",
"max",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"unused",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid \"",
"+",
"msg",
"+",
"\" (must be a fully qualified class name in internal form): \"",
"+",
"name",
")",
";",
"}",
"}"
] | Checks that the given substring is a valid internal class name.
@param name
the string to be checked.
@param start
index of the first character of the identifier (inclusive).
@param end
index of the last character of the identifier (exclusive). -1
is equivalent to <tt>name.length()</tt> if name is not
<tt>null</tt>.
@param msg
a message to be used in case of error. | [
"Checks",
"that",
"the",
"given",
"substring",
"is",
"a",
"valid",
"internal",
"class",
"name",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1336-L1357 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.checkDesc | static void checkDesc(final String desc, final boolean canBeVoid) {
int end = checkDesc(desc, 0, canBeVoid);
if (end != desc.length()) {
throw new IllegalArgumentException("Invalid descriptor: " + desc);
}
} | java | static void checkDesc(final String desc, final boolean canBeVoid) {
int end = checkDesc(desc, 0, canBeVoid);
if (end != desc.length()) {
throw new IllegalArgumentException("Invalid descriptor: " + desc);
}
} | [
"static",
"void",
"checkDesc",
"(",
"final",
"String",
"desc",
",",
"final",
"boolean",
"canBeVoid",
")",
"{",
"int",
"end",
"=",
"checkDesc",
"(",
"desc",
",",
"0",
",",
"canBeVoid",
")",
";",
"if",
"(",
"end",
"!=",
"desc",
".",
"length",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid descriptor: \"",
"+",
"desc",
")",
";",
"}",
"}"
] | Checks that the given string is a valid type descriptor.
@param desc
the string to be checked.
@param canBeVoid
<tt>true</tt> if <tt>V</tt> can be considered valid. | [
"Checks",
"that",
"the",
"given",
"string",
"is",
"a",
"valid",
"type",
"descriptor",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1367-L1372 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.checkDesc | static int checkDesc(final String desc, final int start,
final boolean canBeVoid) {
if (desc == null || start >= desc.length()) {
throw new IllegalArgumentException(
"Invalid type descriptor (must not be null or empty)");
}
int index;
switch (desc.charAt(start)) {
case 'V':
if (canBeVoid) {
return start + 1;
} else {
throw new IllegalArgumentException("Invalid descriptor: "
+ desc);
}
case 'Z':
case 'C':
case 'B':
case 'S':
case 'I':
case 'F':
case 'J':
case 'D':
return start + 1;
case '[':
index = start + 1;
while (index < desc.length() && desc.charAt(index) == '[') {
++index;
}
if (index < desc.length()) {
return checkDesc(desc, index, false);
} else {
throw new IllegalArgumentException("Invalid descriptor: "
+ desc);
}
case 'L':
index = desc.indexOf(';', start);
if (index == -1 || index - start < 2) {
throw new IllegalArgumentException("Invalid descriptor: "
+ desc);
}
try {
checkInternalName(desc, start + 1, index, null);
} catch (IllegalArgumentException unused) {
throw new IllegalArgumentException("Invalid descriptor: "
+ desc);
}
return index + 1;
default:
throw new IllegalArgumentException("Invalid descriptor: " + desc);
}
} | java | static int checkDesc(final String desc, final int start,
final boolean canBeVoid) {
if (desc == null || start >= desc.length()) {
throw new IllegalArgumentException(
"Invalid type descriptor (must not be null or empty)");
}
int index;
switch (desc.charAt(start)) {
case 'V':
if (canBeVoid) {
return start + 1;
} else {
throw new IllegalArgumentException("Invalid descriptor: "
+ desc);
}
case 'Z':
case 'C':
case 'B':
case 'S':
case 'I':
case 'F':
case 'J':
case 'D':
return start + 1;
case '[':
index = start + 1;
while (index < desc.length() && desc.charAt(index) == '[') {
++index;
}
if (index < desc.length()) {
return checkDesc(desc, index, false);
} else {
throw new IllegalArgumentException("Invalid descriptor: "
+ desc);
}
case 'L':
index = desc.indexOf(';', start);
if (index == -1 || index - start < 2) {
throw new IllegalArgumentException("Invalid descriptor: "
+ desc);
}
try {
checkInternalName(desc, start + 1, index, null);
} catch (IllegalArgumentException unused) {
throw new IllegalArgumentException("Invalid descriptor: "
+ desc);
}
return index + 1;
default:
throw new IllegalArgumentException("Invalid descriptor: " + desc);
}
} | [
"static",
"int",
"checkDesc",
"(",
"final",
"String",
"desc",
",",
"final",
"int",
"start",
",",
"final",
"boolean",
"canBeVoid",
")",
"{",
"if",
"(",
"desc",
"==",
"null",
"||",
"start",
">=",
"desc",
".",
"length",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid type descriptor (must not be null or empty)\"",
")",
";",
"}",
"int",
"index",
";",
"switch",
"(",
"desc",
".",
"charAt",
"(",
"start",
")",
")",
"{",
"case",
"'",
"'",
":",
"if",
"(",
"canBeVoid",
")",
"{",
"return",
"start",
"+",
"1",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid descriptor: \"",
"+",
"desc",
")",
";",
"}",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"return",
"start",
"+",
"1",
";",
"case",
"'",
"'",
":",
"index",
"=",
"start",
"+",
"1",
";",
"while",
"(",
"index",
"<",
"desc",
".",
"length",
"(",
")",
"&&",
"desc",
".",
"charAt",
"(",
"index",
")",
"==",
"'",
"'",
")",
"{",
"++",
"index",
";",
"}",
"if",
"(",
"index",
"<",
"desc",
".",
"length",
"(",
")",
")",
"{",
"return",
"checkDesc",
"(",
"desc",
",",
"index",
",",
"false",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid descriptor: \"",
"+",
"desc",
")",
";",
"}",
"case",
"'",
"'",
":",
"index",
"=",
"desc",
".",
"indexOf",
"(",
"'",
"'",
",",
"start",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
"||",
"index",
"-",
"start",
"<",
"2",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid descriptor: \"",
"+",
"desc",
")",
";",
"}",
"try",
"{",
"checkInternalName",
"(",
"desc",
",",
"start",
"+",
"1",
",",
"index",
",",
"null",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"unused",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid descriptor: \"",
"+",
"desc",
")",
";",
"}",
"return",
"index",
"+",
"1",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid descriptor: \"",
"+",
"desc",
")",
";",
"}",
"}"
] | Checks that a the given substring is a valid type descriptor.
@param desc
the string to be checked.
@param start
index of the first character of the identifier (inclusive).
@param canBeVoid
<tt>true</tt> if <tt>V</tt> can be considered valid.
@return the index of the last character of the type decriptor, plus one. | [
"Checks",
"that",
"a",
"the",
"given",
"substring",
"is",
"a",
"valid",
"type",
"descriptor",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1385-L1436 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.checkMethodDesc | static void checkMethodDesc(final String desc) {
if (desc == null || desc.length() == 0) {
throw new IllegalArgumentException(
"Invalid method descriptor (must not be null or empty)");
}
if (desc.charAt(0) != '(' || desc.length() < 3) {
throw new IllegalArgumentException("Invalid descriptor: " + desc);
}
int start = 1;
if (desc.charAt(start) != ')') {
do {
if (desc.charAt(start) == 'V') {
throw new IllegalArgumentException("Invalid descriptor: "
+ desc);
}
start = checkDesc(desc, start, false);
} while (start < desc.length() && desc.charAt(start) != ')');
}
start = checkDesc(desc, start + 1, true);
if (start != desc.length()) {
throw new IllegalArgumentException("Invalid descriptor: " + desc);
}
} | java | static void checkMethodDesc(final String desc) {
if (desc == null || desc.length() == 0) {
throw new IllegalArgumentException(
"Invalid method descriptor (must not be null or empty)");
}
if (desc.charAt(0) != '(' || desc.length() < 3) {
throw new IllegalArgumentException("Invalid descriptor: " + desc);
}
int start = 1;
if (desc.charAt(start) != ')') {
do {
if (desc.charAt(start) == 'V') {
throw new IllegalArgumentException("Invalid descriptor: "
+ desc);
}
start = checkDesc(desc, start, false);
} while (start < desc.length() && desc.charAt(start) != ')');
}
start = checkDesc(desc, start + 1, true);
if (start != desc.length()) {
throw new IllegalArgumentException("Invalid descriptor: " + desc);
}
} | [
"static",
"void",
"checkMethodDesc",
"(",
"final",
"String",
"desc",
")",
"{",
"if",
"(",
"desc",
"==",
"null",
"||",
"desc",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid method descriptor (must not be null or empty)\"",
")",
";",
"}",
"if",
"(",
"desc",
".",
"charAt",
"(",
"0",
")",
"!=",
"'",
"'",
"||",
"desc",
".",
"length",
"(",
")",
"<",
"3",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid descriptor: \"",
"+",
"desc",
")",
";",
"}",
"int",
"start",
"=",
"1",
";",
"if",
"(",
"desc",
".",
"charAt",
"(",
"start",
")",
"!=",
"'",
"'",
")",
"{",
"do",
"{",
"if",
"(",
"desc",
".",
"charAt",
"(",
"start",
")",
"==",
"'",
"'",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid descriptor: \"",
"+",
"desc",
")",
";",
"}",
"start",
"=",
"checkDesc",
"(",
"desc",
",",
"start",
",",
"false",
")",
";",
"}",
"while",
"(",
"start",
"<",
"desc",
".",
"length",
"(",
")",
"&&",
"desc",
".",
"charAt",
"(",
"start",
")",
"!=",
"'",
"'",
")",
";",
"}",
"start",
"=",
"checkDesc",
"(",
"desc",
",",
"start",
"+",
"1",
",",
"true",
")",
";",
"if",
"(",
"start",
"!=",
"desc",
".",
"length",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid descriptor: \"",
"+",
"desc",
")",
";",
"}",
"}"
] | Checks that the given string is a valid method descriptor.
@param desc
the string to be checked. | [
"Checks",
"that",
"the",
"given",
"string",
"is",
"a",
"valid",
"method",
"descriptor",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1444-L1466 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.checkLabel | void checkLabel(final Label label, final boolean checkVisited,
final String msg) {
if (label == null) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must not be null)");
}
if (checkVisited && labels.get(label) == null) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must be visited first)");
}
} | java | void checkLabel(final Label label, final boolean checkVisited,
final String msg) {
if (label == null) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must not be null)");
}
if (checkVisited && labels.get(label) == null) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must be visited first)");
}
} | [
"void",
"checkLabel",
"(",
"final",
"Label",
"label",
",",
"final",
"boolean",
"checkVisited",
",",
"final",
"String",
"msg",
")",
"{",
"if",
"(",
"label",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid \"",
"+",
"msg",
"+",
"\" (must not be null)\"",
")",
";",
"}",
"if",
"(",
"checkVisited",
"&&",
"labels",
".",
"get",
"(",
"label",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid \"",
"+",
"msg",
"+",
"\" (must be visited first)\"",
")",
";",
"}",
"}"
] | Checks that the given label is not null. This method can also check that
the label has been visited.
@param label
the label to be checked.
@param checkVisited
<tt>true</tt> to check that the label has been visited.
@param msg
a message to be used in case of error. | [
"Checks",
"that",
"the",
"given",
"label",
"is",
"not",
"null",
".",
"This",
"method",
"can",
"also",
"check",
"that",
"the",
"label",
"has",
"been",
"visited",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1479-L1489 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.checkNonDebugLabel | private static void checkNonDebugLabel(final Label label) {
Field f = getLabelStatusField();
int status = 0;
try {
status = f == null ? 0 : ((Integer) f.get(label)).intValue();
} catch (IllegalAccessException e) {
throw new Error("Internal error");
}
if ((status & 0x01) != 0) {
throw new IllegalArgumentException(
"Labels used for debug info cannot be reused for control flow");
}
} | java | private static void checkNonDebugLabel(final Label label) {
Field f = getLabelStatusField();
int status = 0;
try {
status = f == null ? 0 : ((Integer) f.get(label)).intValue();
} catch (IllegalAccessException e) {
throw new Error("Internal error");
}
if ((status & 0x01) != 0) {
throw new IllegalArgumentException(
"Labels used for debug info cannot be reused for control flow");
}
} | [
"private",
"static",
"void",
"checkNonDebugLabel",
"(",
"final",
"Label",
"label",
")",
"{",
"Field",
"f",
"=",
"getLabelStatusField",
"(",
")",
";",
"int",
"status",
"=",
"0",
";",
"try",
"{",
"status",
"=",
"f",
"==",
"null",
"?",
"0",
":",
"(",
"(",
"Integer",
")",
"f",
".",
"get",
"(",
"label",
")",
")",
".",
"intValue",
"(",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Internal error\"",
")",
";",
"}",
"if",
"(",
"(",
"status",
"&",
"0x01",
")",
"!=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Labels used for debug info cannot be reused for control flow\"",
")",
";",
"}",
"}"
] | Checks that the given label is not a label used only for debug purposes.
@param label
the label to be checked. | [
"Checks",
"that",
"the",
"given",
"label",
"is",
"not",
"a",
"label",
"used",
"only",
"for",
"debug",
"purposes",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1497-L1509 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.getLabelStatusField | private static Field getLabelStatusField() {
if (labelStatusField == null) {
labelStatusField = getLabelField("a");
if (labelStatusField == null) {
labelStatusField = getLabelField("status");
}
}
return labelStatusField;
} | java | private static Field getLabelStatusField() {
if (labelStatusField == null) {
labelStatusField = getLabelField("a");
if (labelStatusField == null) {
labelStatusField = getLabelField("status");
}
}
return labelStatusField;
} | [
"private",
"static",
"Field",
"getLabelStatusField",
"(",
")",
"{",
"if",
"(",
"labelStatusField",
"==",
"null",
")",
"{",
"labelStatusField",
"=",
"getLabelField",
"(",
"\"a\"",
")",
";",
"if",
"(",
"labelStatusField",
"==",
"null",
")",
"{",
"labelStatusField",
"=",
"getLabelField",
"(",
"\"status\"",
")",
";",
"}",
"}",
"return",
"labelStatusField",
";",
"}"
] | Returns the Field object corresponding to the Label.status field.
@return the Field object corresponding to the Label.status field. | [
"Returns",
"the",
"Field",
"object",
"corresponding",
"to",
"the",
"Label",
".",
"status",
"field",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1516-L1524 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java | CheckMethodAdapter.getLabelField | private static Field getLabelField(final String name) {
try {
Field f = Label.class.getDeclaredField(name);
f.setAccessible(true);
return f;
} catch (NoSuchFieldException e) {
return null;
}
} | java | private static Field getLabelField(final String name) {
try {
Field f = Label.class.getDeclaredField(name);
f.setAccessible(true);
return f;
} catch (NoSuchFieldException e) {
return null;
}
} | [
"private",
"static",
"Field",
"getLabelField",
"(",
"final",
"String",
"name",
")",
"{",
"try",
"{",
"Field",
"f",
"=",
"Label",
".",
"class",
".",
"getDeclaredField",
"(",
"name",
")",
";",
"f",
".",
"setAccessible",
"(",
"true",
")",
";",
"return",
"f",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Returns the field of the Label class whose name is given.
@param name
a field name.
@return the field of the Label class whose name is given, or null. | [
"Returns",
"the",
"field",
"of",
"the",
"Label",
"class",
"whose",
"name",
"is",
"given",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1533-L1541 | train |
epierce/cas-server-extension-token | src/main/java/edu/clayton/cas/support/token/keystore/JSONKeystore.java | JSONKeystore.loadStoreFile | public void loadStoreFile() {
try {
BufferedInputStream bis = new BufferedInputStream(
new FileInputStream(this.storeFile)
);
JSONTokener jsonTokener = new JSONTokener(new InputStreamReader(bis));
JSONArray array = new JSONArray(jsonTokener);
bis.close();
// Init our keys array with the correct size.
this.keys = new ConcurrentHashMap<String, Key>(array.length());
for (int i = 0, j = array.length(); i < j; i += 1) {
JSONObject obj = array.getJSONObject(i);
Key key = new Key(obj.getString("name"), obj.getString("data"));
log.debug("Adding {} key to keystore.", key.name());
this.addKey(key);
}
} catch (FileNotFoundException e) {
log.error("Could not find JSONKeystore file!");
log.debug(e.toString());
} catch (JSONException e) {
log.error("Error parsing JSON!");
log.debug(e.toString());
} catch (IOException e) {
log.error("Could not close JSONKeystore file!");
log.debug(e.toString());
}
} | java | public void loadStoreFile() {
try {
BufferedInputStream bis = new BufferedInputStream(
new FileInputStream(this.storeFile)
);
JSONTokener jsonTokener = new JSONTokener(new InputStreamReader(bis));
JSONArray array = new JSONArray(jsonTokener);
bis.close();
// Init our keys array with the correct size.
this.keys = new ConcurrentHashMap<String, Key>(array.length());
for (int i = 0, j = array.length(); i < j; i += 1) {
JSONObject obj = array.getJSONObject(i);
Key key = new Key(obj.getString("name"), obj.getString("data"));
log.debug("Adding {} key to keystore.", key.name());
this.addKey(key);
}
} catch (FileNotFoundException e) {
log.error("Could not find JSONKeystore file!");
log.debug(e.toString());
} catch (JSONException e) {
log.error("Error parsing JSON!");
log.debug(e.toString());
} catch (IOException e) {
log.error("Could not close JSONKeystore file!");
log.debug(e.toString());
}
} | [
"public",
"void",
"loadStoreFile",
"(",
")",
"{",
"try",
"{",
"BufferedInputStream",
"bis",
"=",
"new",
"BufferedInputStream",
"(",
"new",
"FileInputStream",
"(",
"this",
".",
"storeFile",
")",
")",
";",
"JSONTokener",
"jsonTokener",
"=",
"new",
"JSONTokener",
"(",
"new",
"InputStreamReader",
"(",
"bis",
")",
")",
";",
"JSONArray",
"array",
"=",
"new",
"JSONArray",
"(",
"jsonTokener",
")",
";",
"bis",
".",
"close",
"(",
")",
";",
"// Init our keys array with the correct size.",
"this",
".",
"keys",
"=",
"new",
"ConcurrentHashMap",
"<",
"String",
",",
"Key",
">",
"(",
"array",
".",
"length",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"j",
"=",
"array",
".",
"length",
"(",
")",
";",
"i",
"<",
"j",
";",
"i",
"+=",
"1",
")",
"{",
"JSONObject",
"obj",
"=",
"array",
".",
"getJSONObject",
"(",
"i",
")",
";",
"Key",
"key",
"=",
"new",
"Key",
"(",
"obj",
".",
"getString",
"(",
"\"name\"",
")",
",",
"obj",
".",
"getString",
"(",
"\"data\"",
")",
")",
";",
"log",
".",
"debug",
"(",
"\"Adding {} key to keystore.\"",
",",
"key",
".",
"name",
"(",
")",
")",
";",
"this",
".",
"addKey",
"(",
"key",
")",
";",
"}",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Could not find JSONKeystore file!\"",
")",
";",
"log",
".",
"debug",
"(",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Error parsing JSON!\"",
")",
";",
"log",
".",
"debug",
"(",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Could not close JSONKeystore file!\"",
")",
";",
"log",
".",
"debug",
"(",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | Read the instance's associated keystore file into memory. | [
"Read",
"the",
"instance",
"s",
"associated",
"keystore",
"file",
"into",
"memory",
"."
] | b63399e6b516a25f624d09161466db87fcec974b | https://github.com/epierce/cas-server-extension-token/blob/b63399e6b516a25f624d09161466db87fcec974b/src/main/java/edu/clayton/cas/support/token/keystore/JSONKeystore.java#L77-L106 | train |
lamarios/sherdog-parser | src/main/java/com/ftpix/sherdogparser/models/SearchResults.java | SearchResults.search | private void search() throws IOException {
String url = String.format(SEARCH_URL,
term,
(weightClass != null) ? weightClass.getValue() : "",
page
);
dryEvents = new ArrayList<>();
dryFighters = new ArrayList<>();
List<SherdogBaseObject> parse = new SearchParser().parse(url);
parse.forEach(r -> {
if (r.getSherdogUrl().startsWith(Constants.BASE_URL + "/events/")) {
dryEvents.add(r);
} else if (r.getSherdogUrl().startsWith(Constants.BASE_URL + "/fighter/")) {
dryFighters.add(r);
}
});
} | java | private void search() throws IOException {
String url = String.format(SEARCH_URL,
term,
(weightClass != null) ? weightClass.getValue() : "",
page
);
dryEvents = new ArrayList<>();
dryFighters = new ArrayList<>();
List<SherdogBaseObject> parse = new SearchParser().parse(url);
parse.forEach(r -> {
if (r.getSherdogUrl().startsWith(Constants.BASE_URL + "/events/")) {
dryEvents.add(r);
} else if (r.getSherdogUrl().startsWith(Constants.BASE_URL + "/fighter/")) {
dryFighters.add(r);
}
});
} | [
"private",
"void",
"search",
"(",
")",
"throws",
"IOException",
"{",
"String",
"url",
"=",
"String",
".",
"format",
"(",
"SEARCH_URL",
",",
"term",
",",
"(",
"weightClass",
"!=",
"null",
")",
"?",
"weightClass",
".",
"getValue",
"(",
")",
":",
"\"\"",
",",
"page",
")",
";",
"dryEvents",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"dryFighters",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"SherdogBaseObject",
">",
"parse",
"=",
"new",
"SearchParser",
"(",
")",
".",
"parse",
"(",
"url",
")",
";",
"parse",
".",
"forEach",
"(",
"r",
"->",
"{",
"if",
"(",
"r",
".",
"getSherdogUrl",
"(",
")",
".",
"startsWith",
"(",
"Constants",
".",
"BASE_URL",
"+",
"\"/events/\"",
")",
")",
"{",
"dryEvents",
".",
"add",
"(",
"r",
")",
";",
"}",
"else",
"if",
"(",
"r",
".",
"getSherdogUrl",
"(",
")",
".",
"startsWith",
"(",
"Constants",
".",
"BASE_URL",
"+",
"\"/fighter/\"",
")",
")",
"{",
"dryFighters",
".",
"add",
"(",
"r",
")",
";",
"}",
"}",
")",
";",
"}"
] | Triggers the actual search
@throws IOException if anything goes wrong | [
"Triggers",
"the",
"actual",
"search"
] | 7cdb36280317caeaaa54db77c04dc4b4e1db053e | https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/models/SearchResults.java#L42-L62 | train |
lamarios/sherdog-parser | src/main/java/com/ftpix/sherdogparser/models/SearchResults.java | SearchResults.getFightersWithCompleteData | public List<Fighter> getFightersWithCompleteData() {
return dryFighters.stream()
.map(f -> {
try {
return sherdog.getFighter(f.getSherdogUrl());
} catch (IOException | ParseException | SherdogParserException e) {
return null;
}
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
} | java | public List<Fighter> getFightersWithCompleteData() {
return dryFighters.stream()
.map(f -> {
try {
return sherdog.getFighter(f.getSherdogUrl());
} catch (IOException | ParseException | SherdogParserException e) {
return null;
}
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
} | [
"public",
"List",
"<",
"Fighter",
">",
"getFightersWithCompleteData",
"(",
")",
"{",
"return",
"dryFighters",
".",
"stream",
"(",
")",
".",
"map",
"(",
"f",
"->",
"{",
"try",
"{",
"return",
"sherdog",
".",
"getFighter",
"(",
"f",
".",
"getSherdogUrl",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"|",
"ParseException",
"|",
"SherdogParserException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}",
")",
".",
"filter",
"(",
"Objects",
"::",
"nonNull",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] | Gets the fighter with the full data
This method can be long as it will query each fighter page
@return the list of fighters | [
"Gets",
"the",
"fighter",
"with",
"the",
"full",
"data",
"This",
"method",
"can",
"be",
"long",
"as",
"it",
"will",
"query",
"each",
"fighter",
"page"
] | 7cdb36280317caeaaa54db77c04dc4b4e1db053e | https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/models/SearchResults.java#L106-L118 | train |
lamarios/sherdog-parser | src/main/java/com/ftpix/sherdogparser/models/SearchResults.java | SearchResults.getEventsWithCompleteData | public List<Event> getEventsWithCompleteData() {
return dryEvents.stream()
.map(f -> {
try {
return sherdog.getEvent(f.getSherdogUrl());
} catch (IOException | ParseException | SherdogParserException e) {
return null;
}
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
} | java | public List<Event> getEventsWithCompleteData() {
return dryEvents.stream()
.map(f -> {
try {
return sherdog.getEvent(f.getSherdogUrl());
} catch (IOException | ParseException | SherdogParserException e) {
return null;
}
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
} | [
"public",
"List",
"<",
"Event",
">",
"getEventsWithCompleteData",
"(",
")",
"{",
"return",
"dryEvents",
".",
"stream",
"(",
")",
".",
"map",
"(",
"f",
"->",
"{",
"try",
"{",
"return",
"sherdog",
".",
"getEvent",
"(",
"f",
".",
"getSherdogUrl",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"|",
"ParseException",
"|",
"SherdogParserException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}",
")",
".",
"filter",
"(",
"Objects",
"::",
"nonNull",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] | Gets the events with the full data
This method can be long as it will query each event page
@return the list of events | [
"Gets",
"the",
"events",
"with",
"the",
"full",
"data",
"This",
"method",
"can",
"be",
"long",
"as",
"it",
"will",
"query",
"each",
"event",
"page"
] | 7cdb36280317caeaaa54db77c04dc4b4e1db053e | https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/models/SearchResults.java#L126-L139 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/analysis/Frame.java | Frame.init | public Frame<V> init(final Frame<? extends V> src) {
returnValue = src.returnValue;
System.arraycopy(src.values, 0, values, 0, values.length);
top = src.top;
return this;
} | java | public Frame<V> init(final Frame<? extends V> src) {
returnValue = src.returnValue;
System.arraycopy(src.values, 0, values, 0, values.length);
top = src.top;
return this;
} | [
"public",
"Frame",
"<",
"V",
">",
"init",
"(",
"final",
"Frame",
"<",
"?",
"extends",
"V",
">",
"src",
")",
"{",
"returnValue",
"=",
"src",
".",
"returnValue",
";",
"System",
".",
"arraycopy",
"(",
"src",
".",
"values",
",",
"0",
",",
"values",
",",
"0",
",",
"values",
".",
"length",
")",
";",
"top",
"=",
"src",
".",
"top",
";",
"return",
"this",
";",
"}"
] | Copies the state of the given frame into this frame.
@param src
a frame.
@return this frame. | [
"Copies",
"the",
"state",
"of",
"the",
"given",
"frame",
"into",
"this",
"frame",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/analysis/Frame.java#L110-L115 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/analysis/Frame.java | Frame.setLocal | public void setLocal(final int i, final V value)
throws IndexOutOfBoundsException {
if (i >= locals) {
throw new IndexOutOfBoundsException(
"Trying to access an inexistant local variable " + i);
}
values[i] = value;
} | java | public void setLocal(final int i, final V value)
throws IndexOutOfBoundsException {
if (i >= locals) {
throw new IndexOutOfBoundsException(
"Trying to access an inexistant local variable " + i);
}
values[i] = value;
} | [
"public",
"void",
"setLocal",
"(",
"final",
"int",
"i",
",",
"final",
"V",
"value",
")",
"throws",
"IndexOutOfBoundsException",
"{",
"if",
"(",
"i",
">=",
"locals",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"Trying to access an inexistant local variable \"",
"+",
"i",
")",
";",
"}",
"values",
"[",
"i",
"]",
"=",
"value",
";",
"}"
] | Sets the value of the given local variable.
@param i
a local variable index.
@param value
the new value of this local variable.
@throws IndexOutOfBoundsException
if the variable does not exist. | [
"Sets",
"the",
"value",
"of",
"the",
"given",
"local",
"variable",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/analysis/Frame.java#L173-L180 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/analysis/Frame.java | Frame.push | public void push(final V value) throws IndexOutOfBoundsException {
if (top + locals >= values.length) {
throw new IndexOutOfBoundsException(
"Insufficient maximum stack size.");
}
values[top++ + locals] = value;
} | java | public void push(final V value) throws IndexOutOfBoundsException {
if (top + locals >= values.length) {
throw new IndexOutOfBoundsException(
"Insufficient maximum stack size.");
}
values[top++ + locals] = value;
} | [
"public",
"void",
"push",
"(",
"final",
"V",
"value",
")",
"throws",
"IndexOutOfBoundsException",
"{",
"if",
"(",
"top",
"+",
"locals",
">=",
"values",
".",
"length",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"Insufficient maximum stack size.\"",
")",
";",
"}",
"values",
"[",
"top",
"++",
"+",
"locals",
"]",
"=",
"value",
";",
"}"
] | Pushes a value into the operand stack of this frame.
@param value
the value that must be pushed into the stack.
@throws IndexOutOfBoundsException
if the operand stack is full. | [
"Pushes",
"a",
"value",
"into",
"the",
"operand",
"stack",
"of",
"this",
"frame",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/analysis/Frame.java#L235-L241 | train |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/analysis/Frame.java | Frame.merge | public boolean merge(final Frame<? extends V> frame,
final Interpreter<V> interpreter) throws AnalyzerException {
if (top != frame.top) {
throw new AnalyzerException(null, "Incompatible stack heights");
}
boolean changes = false;
for (int i = 0; i < locals + top; ++i) {
V v = interpreter.merge(values[i], frame.values[i]);
if (!v.equals(values[i])) {
values[i] = v;
changes = true;
}
}
return changes;
} | java | public boolean merge(final Frame<? extends V> frame,
final Interpreter<V> interpreter) throws AnalyzerException {
if (top != frame.top) {
throw new AnalyzerException(null, "Incompatible stack heights");
}
boolean changes = false;
for (int i = 0; i < locals + top; ++i) {
V v = interpreter.merge(values[i], frame.values[i]);
if (!v.equals(values[i])) {
values[i] = v;
changes = true;
}
}
return changes;
} | [
"public",
"boolean",
"merge",
"(",
"final",
"Frame",
"<",
"?",
"extends",
"V",
">",
"frame",
",",
"final",
"Interpreter",
"<",
"V",
">",
"interpreter",
")",
"throws",
"AnalyzerException",
"{",
"if",
"(",
"top",
"!=",
"frame",
".",
"top",
")",
"{",
"throw",
"new",
"AnalyzerException",
"(",
"null",
",",
"\"Incompatible stack heights\"",
")",
";",
"}",
"boolean",
"changes",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"locals",
"+",
"top",
";",
"++",
"i",
")",
"{",
"V",
"v",
"=",
"interpreter",
".",
"merge",
"(",
"values",
"[",
"i",
"]",
",",
"frame",
".",
"values",
"[",
"i",
"]",
")",
";",
"if",
"(",
"!",
"v",
".",
"equals",
"(",
"values",
"[",
"i",
"]",
")",
")",
"{",
"values",
"[",
"i",
"]",
"=",
"v",
";",
"changes",
"=",
"true",
";",
"}",
"}",
"return",
"changes",
";",
"}"
] | Merges this frame with the given frame.
@param frame
a frame.
@param interpreter
the interpreter used to merge values.
@return <tt>true</tt> if this frame has been changed as a result of the
merge operation, or <tt>false</tt> otherwise.
@throws AnalyzerException
if the frames have incompatible sizes. | [
"Merges",
"this",
"frame",
"with",
"the",
"given",
"frame",
"."
] | 01c216599ffa2e5f2d9c01df2adaad0f45567c04 | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/analysis/Frame.java#L684-L698 | train |
SG-O/miIO | src/main/java/de/sg_o/app/miio/base/Token.java | Token.decrypt | public byte[] decrypt(byte[] msg) {
if (msg == null) return null;
try {
Cipher cipher = Cipher.getInstance(ENCRYPTION_ALGORITHM_IMPLEMENTATION);
SecretKeySpec key = new SecretKeySpec(getMd5(), ENCRYPTION_ALGORITHM);
IvParameterSpec iv = new IvParameterSpec(getIv());
cipher.init(Cipher.DECRYPT_MODE, key, iv);
return cipher.doFinal(msg);
} catch (Exception e) {
return null;
}
} | java | public byte[] decrypt(byte[] msg) {
if (msg == null) return null;
try {
Cipher cipher = Cipher.getInstance(ENCRYPTION_ALGORITHM_IMPLEMENTATION);
SecretKeySpec key = new SecretKeySpec(getMd5(), ENCRYPTION_ALGORITHM);
IvParameterSpec iv = new IvParameterSpec(getIv());
cipher.init(Cipher.DECRYPT_MODE, key, iv);
return cipher.doFinal(msg);
} catch (Exception e) {
return null;
}
} | [
"public",
"byte",
"[",
"]",
"decrypt",
"(",
"byte",
"[",
"]",
"msg",
")",
"{",
"if",
"(",
"msg",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"Cipher",
"cipher",
"=",
"Cipher",
".",
"getInstance",
"(",
"ENCRYPTION_ALGORITHM_IMPLEMENTATION",
")",
";",
"SecretKeySpec",
"key",
"=",
"new",
"SecretKeySpec",
"(",
"getMd5",
"(",
")",
",",
"ENCRYPTION_ALGORITHM",
")",
";",
"IvParameterSpec",
"iv",
"=",
"new",
"IvParameterSpec",
"(",
"getIv",
"(",
")",
")",
";",
"cipher",
".",
"init",
"(",
"Cipher",
".",
"DECRYPT_MODE",
",",
"key",
",",
"iv",
")",
";",
"return",
"cipher",
".",
"doFinal",
"(",
"msg",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Decrypt a message with this token.
@param msg The message to decrypt.
@return The encrypted message. Null if decryption failed. | [
"Decrypt",
"a",
"message",
"with",
"this",
"token",
"."
] | f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b | https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/base/Token.java#L133-L144 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.