_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q13500 | CheckClassAdapter.checkFieldTypeSignature | train | 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 | {
"resource": ""
} |
q13501 | CheckClassAdapter.checkClassTypeSignature | train | 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 | {
"resource": ""
} |
q13502 | CheckClassAdapter.checkTypeArguments | train | 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 | {
"resource": ""
} |
q13503 | CheckClassAdapter.checkTypeArgument | train | 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 | {
"resource": ""
} |
q13504 | CheckClassAdapter.checkTypeVariableSignature | train | 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 | {
"resource": ""
} |
q13505 | CheckClassAdapter.checkTypeSignature | train | 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 | {
"resource": ""
} |
q13506 | CheckClassAdapter.checkIdentifier | train | 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 | {
"resource": ""
} |
q13507 | CheckClassAdapter.checkChar | train | 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 | {
"resource": ""
} |
q13508 | CheckClassAdapter.getChar | train | private static char getChar(final String signature, int pos) {
return pos < signature.length() ? signature.charAt(pos) : (char) 0;
} | java | {
"resource": ""
} |
q13509 | LocalVariableAnnotationNode.accept | train | 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 | {
"resource": ""
} |
q13510 | Printer.appendString | train | 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 | {
"resource": ""
} |
q13511 | Printer.printList | train | 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 | {
"resource": ""
} |
q13512 | JettyBootstrap.startServer | train | 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 | {
"resource": ""
} |
q13513 | JettyBootstrap.joinServer | train | 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 | {
"resource": ""
} |
q13514 | JettyBootstrap.stopServer | train | 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 | {
"resource": ""
} |
q13515 | JettyBootstrap.addWarApp | train | 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 | {
"resource": ""
} |
q13516 | JettyBootstrap.addWarAppFromClasspath | train | 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 | {
"resource": ""
} |
q13517 | JettyBootstrap.createShutdownHook | train | 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 | {
"resource": ""
} |
q13518 | ReflectionUtils.getAllDeclaredMethods | train | 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 | {
"resource": ""
} |
q13519 | ReflectionUtils.getSelfAndSuperClassFields | train | 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 | {
"resource": ""
} |
q13520 | MethodNode.check | train | 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 | {
"resource": ""
} |
q13521 | MethodNode.accept | train | 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 | {
"resource": ""
} |
q13522 | AnnotationNode.accept | train | 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 | {
"resource": ""
} |
q13523 | AnnotationNode.accept | train | 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 | {
"resource": ""
} |
q13524 | PathUtil.getJarDir | train | public static String getJarDir(Class<?> clazz) {
return decodeUrl(new File(clazz.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent());
} | java | {
"resource": ""
} |
q13525 | LocalVariableNode.accept | train | public void accept(final MethodVisitor mv) {
mv.visitLocalVariable(name, desc, signature, start.getLabel(),
end.getLabel(), index);
} | java | {
"resource": ""
} |
q13526 | SearchParser.parse | train | 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 | {
"resource": ""
} |
q13527 | DefaultWhenVertx.undeploy | train | @Override
public Promise<Void> undeploy(String deploymentID) {
return adapter.toPromise(handler -> vertx.undeploy(deploymentID, handler));
} | java | {
"resource": ""
} |
q13528 | DotmlMojo.transformInputFile | train | 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 | {
"resource": ""
} |
q13529 | JettyConstraintUtil.getConstraintSecurityHandlerConfidential | train | 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 | {
"resource": ""
} |
q13530 | DefaultWhenEventBus.send | train | @Override
public <T> Promise<Message<T>> send(String address, Object message) {
return adapter.toPromise(handler -> eventBus.send(address, message, handler));
} | java | {
"resource": ""
} |
q13531 | Constant.set | train | 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 | {
"resource": ""
} |
q13532 | CheckMethodAdapter.checkFrameValue | train | 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 | {
"resource": ""
} |
q13533 | CheckMethodAdapter.checkOpcode | train | static void checkOpcode(final int opcode, final int type) {
if (opcode < 0 || opcode > 199 || TYPE[opcode] != type) {
throw new IllegalArgumentException("Invalid opcode: " + opcode);
}
} | java | {
"resource": ""
} |
q13534 | CheckMethodAdapter.checkSignedByte | train | 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 | {
"resource": ""
} |
q13535 | CheckMethodAdapter.checkSignedShort | train | 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 | {
"resource": ""
} |
q13536 | CheckMethodAdapter.checkUnqualifiedName | train | 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 | {
"resource": ""
} |
q13537 | CheckMethodAdapter.checkIdentifier | train | 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 | {
"resource": ""
} |
q13538 | CheckMethodAdapter.checkMethodIdentifier | train | 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 | {
"resource": ""
} |
q13539 | CheckMethodAdapter.checkInternalName | train | 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 | {
"resource": ""
} |
q13540 | CheckMethodAdapter.checkInternalName | train | 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 | {
"resource": ""
} |
q13541 | CheckMethodAdapter.checkDesc | train | 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 | {
"resource": ""
} |
q13542 | CheckMethodAdapter.checkDesc | train | 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 | {
"resource": ""
} |
q13543 | CheckMethodAdapter.checkMethodDesc | train | 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 | {
"resource": ""
} |
q13544 | CheckMethodAdapter.checkLabel | train | 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 | {
"resource": ""
} |
q13545 | CheckMethodAdapter.checkNonDebugLabel | train | 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 | {
"resource": ""
} |
q13546 | CheckMethodAdapter.getLabelStatusField | train | private static Field getLabelStatusField() {
if (labelStatusField == null) {
labelStatusField = getLabelField("a");
if (labelStatusField == null) {
labelStatusField = getLabelField("status");
}
}
return labelStatusField;
} | java | {
"resource": ""
} |
q13547 | CheckMethodAdapter.getLabelField | train | 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 | {
"resource": ""
} |
q13548 | JSONKeystore.loadStoreFile | train | 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 | {
"resource": ""
} |
q13549 | SearchResults.search | train | 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 | {
"resource": ""
} |
q13550 | SearchResults.getFightersWithCompleteData | train | 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 | {
"resource": ""
} |
q13551 | SearchResults.getEventsWithCompleteData | train | 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 | {
"resource": ""
} |
q13552 | Frame.init | train | 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 | {
"resource": ""
} |
q13553 | Frame.setLocal | train | 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 | {
"resource": ""
} |
q13554 | Frame.push | train | 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 | {
"resource": ""
} |
q13555 | Frame.merge | train | 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 | {
"resource": ""
} |
q13556 | Token.decrypt | train | 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 | {
"resource": ""
} |
q13557 | SyllableCounter.getRessourceLines | train | Stream<String> getRessourceLines(Class<?> clazz, String filepath) {
try (final BufferedReader fileReader = new BufferedReader(
new InputStreamReader(clazz.getResourceAsStream(filepath),
StandardCharsets.UTF_8)
)) {
// Collect the read lines before converting back to a Java stream
// so that we can ensure that we close the InputStream and prevent leaks
return fileReader.lines().collect(Collectors.toList()).stream();
} catch (IOException e) {
throw new RuntimeException(e);
}
} | java | {
"resource": ""
} |
q13558 | SyllableCounter.count | train | public int count(final String word) {
if (word == null) {
throw new NullPointerException("the word parameter was null.");
} else if (word.length() == 0) {
return 0;
} else if (word.length() == 1) {
return 1;
}
final String lowerCase = word.toLowerCase(Locale.ENGLISH);
if (exceptions.containsKey(lowerCase)) {
return exceptions.get(lowerCase);
}
final String prunned;
if (lowerCase.charAt(lowerCase.length() - 1) == 'e') {
prunned = lowerCase.substring(0, lowerCase.length() - 1);
} else {
prunned = lowerCase;
}
int count = 0;
boolean prevIsVowel = false;
for (char c : prunned.toCharArray()) {
final boolean isVowel = vowels.contains(c);
if (isVowel && !prevIsVowel) {
++count;
}
prevIsVowel = isVowel;
}
count += addSyls.stream()
.filter(pattern -> pattern.matcher(prunned).find())
.count();
count -= subSyls.stream()
.filter(pattern -> pattern.matcher(prunned).find())
.count();
return count > 0 ? count : 1;
} | java | {
"resource": ""
} |
q13559 | BeanBoxContext.reset | train | public static void reset() {
globalBeanBoxContext.close();
globalNextAllowAnnotation = true;
globalNextAllowSpringJsrAnnotation = true;
globalNextValueTranslator = new DefaultValueTranslator();
CREATE_METHOD = "create";
CONFIG_METHOD = "config";
globalBeanBoxContext = new BeanBoxContext();
} | java | {
"resource": ""
} |
q13560 | BeanBoxContext.close | train | public void close() {
for (Entry<Object, Object> singletons : singletonCache.entrySet()) {
Object key = singletons.getKey();
Object obj = singletons.getValue();
if (key instanceof BeanBox) {
BeanBox box = (BeanBox) key;
if (box.getPreDestroy() != null)
try {
box.getPreDestroy().invoke(obj);
} catch (Exception e) {
// Eat it here, but usually need log it
}
}
}
bindCache.clear();
beanBoxMetaCache.clear();
singletonCache.clear();
} | java | {
"resource": ""
} |
q13561 | RequestOptions.addHeader | train | public RequestOptions addHeader(String name, String value) {
if (headers == null) {
headers = new CaseInsensitiveHeaders();
}
headers.add(name, value);
return this;
} | java | {
"resource": ""
} |
q13562 | ParserUtils.parseDocument | train | public static Document parseDocument(String url) throws IOException {
return Jsoup
.connect(url)
.timeout(Constants.PARSING_TIMEOUT)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
.referrer("http://www.google.com")
.get();
} | java | {
"resource": ""
} |
q13563 | ParserUtils.downloadImageToFile | train | public static void downloadImageToFile(String url, Path file) throws IOException {
if (Files.exists(file.getParent())) {
URL urlObject = new URL(url);
URLConnection connection = urlObject.openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
connection.setRequestProperty("Referer", "http://www.google.com");
FileUtils.copyInputStreamToFile(connection.getInputStream(), file.toFile());
}
} | java | {
"resource": ""
} |
q13564 | ParserUtils.getSherdogPageUrl | train | static String getSherdogPageUrl(Document doc) {
String url = Optional.ofNullable(doc.head())
.map(h -> h.select("meta"))
.map(es -> es.stream().filter(e -> e.attr("property").equalsIgnoreCase("og:url")).findFirst().orElse(null))
.map(m -> m.attr("content"))
.orElse("");
if(url.startsWith("//")){ //2018-10-10 bug in sherdog where ig:url starts with //?
url = url.replaceFirst("//","http://");
}
return url.replace("http://", "https://");
} | java | {
"resource": ""
} |
q13565 | JSRInlinerAdapter.visitJumpInsn | train | @Override
public void visitJumpInsn(final int opcode, final Label lbl) {
super.visitJumpInsn(opcode, lbl);
LabelNode ln = ((JumpInsnNode) instructions.getLast()).label;
if (opcode == JSR && !subroutineHeads.containsKey(ln)) {
subroutineHeads.put(ln, new BitSet());
}
} | java | {
"resource": ""
} |
q13566 | JSRInlinerAdapter.visitEnd | train | @Override
public void visitEnd() {
if (!subroutineHeads.isEmpty()) {
markSubroutines();
if (LOGGING) {
log(mainSubroutine.toString());
Iterator<BitSet> it = subroutineHeads.values().iterator();
while (it.hasNext()) {
BitSet sub = it.next();
log(sub.toString());
}
}
emitCode();
}
// Forward the translate opcodes on if appropriate:
if (mv != null) {
accept(mv);
}
} | java | {
"resource": ""
} |
q13567 | JSRInlinerAdapter.emitCode | train | private void emitCode() {
LinkedList<Instantiation> worklist = new LinkedList<Instantiation>();
// Create an instantiation of the "root" subroutine, which is just the
// main routine
worklist.add(new Instantiation(null, mainSubroutine));
// Emit instantiations of each subroutine we encounter, including the
// main subroutine
InsnList newInstructions = new InsnList();
List<TryCatchBlockNode> newTryCatchBlocks = new ArrayList<TryCatchBlockNode>();
List<LocalVariableNode> newLocalVariables = new ArrayList<LocalVariableNode>();
while (!worklist.isEmpty()) {
Instantiation inst = worklist.removeFirst();
emitSubroutine(inst, worklist, newInstructions, newTryCatchBlocks,
newLocalVariables);
}
instructions = newInstructions;
tryCatchBlocks = newTryCatchBlocks;
localVariables = newLocalVariables;
} | java | {
"resource": ""
} |
q13568 | Type.getDescriptor | train | private static void getDescriptor(final StringBuffer buf, final Class<?> c) {
Class<?> d = c;
while (true) {
if (d.isPrimitive()) {
char car;
if (d == Integer.TYPE) {
car = 'I';
} else if (d == Void.TYPE) {
car = 'V';
} else if (d == Boolean.TYPE) {
car = 'Z';
} else if (d == Byte.TYPE) {
car = 'B';
} else if (d == Character.TYPE) {
car = 'C';
} else if (d == Short.TYPE) {
car = 'S';
} else if (d == Double.TYPE) {
car = 'D';
} else if (d == Float.TYPE) {
car = 'F';
} else /* if (d == Long.TYPE) */{
car = 'J';
}
buf.append(car);
return;
} else if (d.isArray()) {
buf.append('[');
d = d.getComponentType();
} else {
buf.append('L');
String name = d.getName();
int len = name.length();
for (int i = 0; i < len; ++i) {
char car = name.charAt(i);
buf.append(car == '.' ? '/' : car);
}
buf.append(';');
return;
}
}
} | java | {
"resource": ""
} |
q13569 | Handler.remove | train | static Handler remove(Handler h, Label start, Label end) {
if (h == null) {
return null;
} else {
h.next = remove(h.next, start, end);
}
int hstart = h.start.position;
int hend = h.end.position;
int s = start.position;
int e = end == null ? Integer.MAX_VALUE : end.position;
// if [hstart,hend[ and [s,e[ intervals intersect...
if (s < hend && e > hstart) {
if (s <= hstart) {
if (e >= hend) {
// [hstart,hend[ fully included in [s,e[, h removed
h = h.next;
} else {
// [hstart,hend[ minus [s,e[ = [e,hend[
h.start = end;
}
} else if (e >= hend) {
// [hstart,hend[ minus [s,e[ = [hstart,s[
h.end = start;
} else {
// [hstart,hend[ minus [s,e[ = [hstart,s[ + [e,hend[
Handler g = new Handler();
g.start = end;
g.end = h.end;
g.handler = h.handler;
g.desc = h.desc;
g.type = h.type;
g.next = h.next;
h.end = start;
h.next = g;
}
}
return h;
} | java | {
"resource": ""
} |
q13570 | ClassNode.check | train | 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();
}
for (FieldNode f : fields) {
f.check(api);
}
for (MethodNode m : methods) {
m.check(api);
}
}
} | java | {
"resource": ""
} |
q13571 | ClassNode.accept | train | public void accept(final ClassVisitor cv) {
// visits header
String[] interfaces = new String[this.interfaces.size()];
this.interfaces.toArray(interfaces);
cv.visit(version, access, name, signature, superName, interfaces);
// visits source
if (sourceFile != null || sourceDebug != null) {
cv.visitSource(sourceFile, sourceDebug);
}
// visits outer class
if (outerClass != null) {
cv.visitOuterClass(outerClass, outerMethod, outerMethodDesc);
}
// visits attributes
int i, n;
n = visibleAnnotations == null ? 0 : visibleAnnotations.size();
for (i = 0; i < n; ++i) {
AnnotationNode an = visibleAnnotations.get(i);
an.accept(cv.visitAnnotation(an.desc, true));
}
n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size();
for (i = 0; i < n; ++i) {
AnnotationNode an = invisibleAnnotations.get(i);
an.accept(cv.visitAnnotation(an.desc, false));
}
n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size();
for (i = 0; i < n; ++i) {
TypeAnnotationNode an = visibleTypeAnnotations.get(i);
an.accept(cv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc,
true));
}
n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations
.size();
for (i = 0; i < n; ++i) {
TypeAnnotationNode an = invisibleTypeAnnotations.get(i);
an.accept(cv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc,
false));
}
n = attrs == null ? 0 : attrs.size();
for (i = 0; i < n; ++i) {
cv.visitAttribute(attrs.get(i));
}
// visits inner classes
for (i = 0; i < innerClasses.size(); ++i) {
innerClasses.get(i).accept(cv);
}
// visits fields
for (i = 0; i < fields.size(); ++i) {
fields.get(i).accept(cv);
}
// visits methods
for (i = 0; i < methods.size(); ++i) {
methods.get(i).accept(cv);
}
// visits end
cv.visitEnd();
} | java | {
"resource": ""
} |
q13572 | Server.run | train | public void run() {
this.running = true;
while (this.running) {
DatagramPacket packet = new DatagramPacket(this.buf, this.buf.length);
try {
this.socket.receive(packet);
} catch (IOException ignored) {
continue;
}
byte[] worker = new byte[2];
System.arraycopy(this.buf, 2, worker, 0, 2);
int length = (int)ByteArray.fromBytes(worker);
worker = new byte[length];
System.arraycopy(this.buf, 0, worker, 0, length);
Command msg = new Command(worker, tk);
InetAddress address = packet.getAddress();
int port = packet.getPort();
int timeStamp = (int)(System.currentTimeMillis() / 1000L);
Response resp;
if (msg.isHello()){
resp = new Response(this.tk, this.deviceId, timeStamp);
} else {
if (msg.getDeviceID() != this.deviceId) continue;
Object data = executeCommand(msg.getMethod(),msg.getParams());
if (data == null){
data = "unknown_method";
}
resp = new Response(this.tk, this.deviceId, timeStamp, msg.getPayloadID(), data);
}
byte[] respMsg = resp.create();
System.arraycopy(respMsg,0,this.buf,0,respMsg.length);
packet = new DatagramPacket(buf, respMsg.length, address, port);
try {
this.socket.send(packet);
} catch (IOException ignored) {
}
}
this.socket.close();
} | java | {
"resource": ""
} |
q13573 | ASMContentHandler.startElement | train | @Override
public final void startElement(final String ns, final String lName,
final String qName, final Attributes list) throws SAXException {
// the actual element name is either in lName or qName, depending
// on whether the parser is namespace aware
String name = lName == null || lName.length() == 0 ? qName : lName;
// Compute the current matching rule
StringBuffer sb = new StringBuffer(match);
if (match.length() > 0) {
sb.append('/');
}
sb.append(name);
match = sb.toString();
// Fire "begin" events for all relevant rules
Rule r = (Rule) RULES.match(match);
if (r != null) {
r.begin(name, list);
}
} | java | {
"resource": ""
} |
q13574 | ASMContentHandler.endElement | train | @Override
public final void endElement(final String ns, final String lName,
final String qName) throws SAXException {
// the actual element name is either in lName or qName, depending
// on whether the parser is namespace aware
String name = lName == null || lName.length() == 0 ? qName : lName;
// Fire "end" events for all relevant rules in reverse order
Rule r = (Rule) RULES.match(match);
if (r != null) {
r.end(name);
}
// Recover the previous match expression
int slash = match.lastIndexOf('/');
if (slash >= 0) {
match = match.substring(0, slash);
} else {
match = "";
}
} | java | {
"resource": ""
} |
q13575 | InsnList.get | train | public AbstractInsnNode get(final int index) {
if (index < 0 || index >= size) {
throw new IndexOutOfBoundsException();
}
if (cache == null) {
cache = toArray();
}
return cache[index];
} | java | {
"resource": ""
} |
q13576 | InsnList.accept | train | public void accept(final MethodVisitor mv) {
AbstractInsnNode insn = first;
while (insn != null) {
insn.accept(mv);
insn = insn.next;
}
} | java | {
"resource": ""
} |
q13577 | InsnList.toArray | train | public AbstractInsnNode[] toArray() {
int i = 0;
AbstractInsnNode elem = first;
AbstractInsnNode[] insns = new AbstractInsnNode[size];
while (elem != null) {
insns[i] = elem;
elem.index = i++;
elem = elem.next;
}
return insns;
} | java | {
"resource": ""
} |
q13578 | InsnList.set | train | public void set(final AbstractInsnNode location, final AbstractInsnNode insn) {
AbstractInsnNode next = location.next;
insn.next = next;
if (next != null) {
next.prev = insn;
} else {
last = insn;
}
AbstractInsnNode prev = location.prev;
insn.prev = prev;
if (prev != null) {
prev.next = insn;
} else {
first = insn;
}
if (cache != null) {
int index = location.index;
cache[index] = insn;
insn.index = index;
} else {
insn.index = 0; // insn now belongs to an InsnList
}
location.index = -1; // i no longer belongs to an InsnList
location.prev = null;
location.next = null;
} | java | {
"resource": ""
} |
q13579 | InsnList.add | train | public void add(final AbstractInsnNode insn) {
++size;
if (last == null) {
first = insn;
last = insn;
} else {
last.next = insn;
insn.prev = last;
}
last = insn;
cache = null;
insn.index = 0; // insn now belongs to an InsnList
} | java | {
"resource": ""
} |
q13580 | InsnList.insert | train | public void insert(final AbstractInsnNode insn) {
++size;
if (first == null) {
first = insn;
last = insn;
} else {
first.prev = insn;
insn.next = first;
}
first = insn;
cache = null;
insn.index = 0; // insn now belongs to an InsnList
} | java | {
"resource": ""
} |
q13581 | InsnList.insert | train | public void insert(final InsnList insns) {
if (insns.size == 0) {
return;
}
size += insns.size;
if (first == null) {
first = insns.first;
last = insns.last;
} else {
AbstractInsnNode elem = insns.last;
first.prev = elem;
elem.next = first;
first = insns.first;
}
cache = null;
insns.removeAll(false);
} | java | {
"resource": ""
} |
q13582 | InsnList.insert | train | public void insert(final AbstractInsnNode location,
final AbstractInsnNode insn) {
++size;
AbstractInsnNode next = location.next;
if (next == null) {
last = insn;
} else {
next.prev = insn;
}
location.next = insn;
insn.next = next;
insn.prev = location;
cache = null;
insn.index = 0; // insn now belongs to an InsnList
} | java | {
"resource": ""
} |
q13583 | InsnList.insert | train | public void insert(final AbstractInsnNode location, final InsnList insns) {
if (insns.size == 0) {
return;
}
size += insns.size;
AbstractInsnNode ifirst = insns.first;
AbstractInsnNode ilast = insns.last;
AbstractInsnNode next = location.next;
if (next == null) {
last = ilast;
} else {
next.prev = ilast;
}
location.next = ifirst;
ilast.next = next;
ifirst.prev = location;
cache = null;
insns.removeAll(false);
} | java | {
"resource": ""
} |
q13584 | InsnList.insertBefore | train | public void insertBefore(final AbstractInsnNode location,
final AbstractInsnNode insn) {
++size;
AbstractInsnNode prev = location.prev;
if (prev == null) {
first = insn;
} else {
prev.next = insn;
}
location.prev = insn;
insn.next = location;
insn.prev = prev;
cache = null;
insn.index = 0; // insn now belongs to an InsnList
} | java | {
"resource": ""
} |
q13585 | InsnList.insertBefore | train | public void insertBefore(final AbstractInsnNode location,
final InsnList insns) {
if (insns.size == 0) {
return;
}
size += insns.size;
AbstractInsnNode ifirst = insns.first;
AbstractInsnNode ilast = insns.last;
AbstractInsnNode prev = location.prev;
if (prev == null) {
first = ifirst;
} else {
prev.next = ifirst;
}
location.prev = ilast;
ilast.next = location;
ifirst.prev = prev;
cache = null;
insns.removeAll(false);
} | java | {
"resource": ""
} |
q13586 | InsnList.remove | train | public void remove(final AbstractInsnNode insn) {
--size;
AbstractInsnNode next = insn.next;
AbstractInsnNode prev = insn.prev;
if (next == null) {
if (prev == null) {
first = null;
last = null;
} else {
prev.next = null;
last = prev;
}
} else {
if (prev == null) {
first = next;
next.prev = null;
} else {
prev.next = next;
next.prev = prev;
}
}
cache = null;
insn.index = -1; // insn no longer belongs to an InsnList
insn.prev = null;
insn.next = null;
} | java | {
"resource": ""
} |
q13587 | InsnList.removeAll | train | void removeAll(final boolean mark) {
if (mark) {
AbstractInsnNode insn = first;
while (insn != null) {
AbstractInsnNode next = insn.next;
insn.index = -1; // insn no longer belongs to an InsnList
insn.prev = null;
insn.next = null;
insn = next;
}
}
size = 0;
first = null;
last = null;
cache = null;
} | java | {
"resource": ""
} |
q13588 | EventParser.parseDocument | train | @Override
public Event parseDocument(Document doc) {
Event event = new Event();
event.setSherdogUrl(ParserUtils.getSherdogPageUrl(doc));
//getting name
Elements name = doc.select(".header .section_title h1 span[itemprop=\"name\"]");
event.setName(name.html().replace("<br>", " - "));
Elements date = doc.select(".authors_info .date meta[itemprop=\"startDate\"]");
//TODO: get date to proper format
try {
event.setDate(ParserUtils.getDateFromStringToZoneId(date.first().attr("content"), ZONE_ID));
} catch (DateTimeParseException e) {
logger.error("Couldn't parse date", e);
}
getFights(doc, event);
Element org = doc.select(".header .section_title h2 a").get(0);
SherdogBaseObject organization = new SherdogBaseObject();
organization.setSherdogUrl(org.attr("abs:href"));
organization.setName(org.select("span[itemprop=\"name\"]").get(0).html());
event.setOrganization(organization);
return event;
} | java | {
"resource": ""
} |
q13589 | EventParser.getFights | train | private void getFights(Document doc, Event event) {
logger.info("Getting fights for event #{}[{}]", event.getSherdogUrl(), event.getName());
SherdogBaseObject sEvent = new SherdogBaseObject();
sEvent.setName(event.getName());
sEvent.setSherdogUrl(event.getSherdogUrl());
List<Fight> fights = new ArrayList<>();
//Checking on main event
Elements mainFightElement = doc.select(".content.event");
Elements fighters = mainFightElement.select("h3 a");
//First fighter
SherdogBaseObject mainFighter1 = new SherdogBaseObject();
Element mainFighter1Element = fighters.get(0);
mainFighter1.setSherdogUrl(mainFighter1Element.attr("abs:href"));
mainFighter1.setName(mainFighter1Element.select("span[itemprop=\"name\"]").html());
//second fighter
SherdogBaseObject mainFighter2 = new SherdogBaseObject();
Element mainFighter2Element = fighters.get(1);
mainFighter2.setSherdogUrl(mainFighter2Element.attr("abs:href"));
mainFighter2.setName(mainFighter2Element.select("span[itemprop=\"name\"]").html());
Fight mainFight = new Fight();
mainFight.setEvent(sEvent);
mainFight.setFighter1(mainFighter1);
mainFight.setFighter2(mainFighter2);
mainFight.setResult(ParserUtils.getFightResult(mainFightElement.first()));
//getting method
Elements mainTd = mainFightElement.select("td");
if (mainTd.size() > 0) {
mainFight.setWinMethod(mainTd.get(1).html().replaceAll("<em(.*)<br>", "").trim());
mainFight.setWinRound(Integer.parseInt(mainTd.get(3).html().replaceAll("<em(.*)<br>", "").trim()));
mainFight.setWinTime(mainTd.get(4).html().replaceAll("<em(.*)<br>", "").trim());
}
mainFight.setDate(event.getDate());
fights.add(mainFight);
logger.info("Fight added: {}", mainFight);
//Checking on card results
logger.info("Found {} fights", fights.size());
Elements tds = doc.select(".event_match table tr");
fights.addAll(parseEventFights(tds, event));
event.setFights(fights);
} | java | {
"resource": ""
} |
q13590 | EventParser.parseEventFights | train | private List<Fight> parseEventFights(Elements trs, Event event) {
SherdogBaseObject sEvent = new SherdogBaseObject();
sEvent.setName(event.getName());
sEvent.setSherdogUrl(event.getSherdogUrl());
List<Fight> fights = new ArrayList<>();
if (trs.size() > 0) {
trs.remove(0);
trs.forEach(tr -> {
Fight fight = new Fight();
fight.setEvent(sEvent);
fight.setDate(event.getDate());
Elements tds = tr.select("td");
fight.setFighter1(getFighter(tds.get(FIGHTER1_COLUMN)));
fight.setFighter2(getFighter(tds.get(FIGHTER2_COLUMN)));
//parsing old fight, we can get the result
if (tds.size() == 7) {
fight.setResult(getResult(tds.get(FIGHTER1_COLUMN)));
fight.setWinMethod(getMethod(tds.get(METHOD_COLUMN)));
fight.setWinRound(getRound(tds.get(ROUND_COLUMN)));
fight.setWinTime(getTime(tds.get(TIME_COLUMN)));
}
fights.add(fight);
logger.info("Fight added: {}", fight);
});
}
return fights;
} | java | {
"resource": ""
} |
q13591 | EventParser.getFighter | train | private SherdogBaseObject getFighter(Element td) {
Elements name1 = td.select("span[itemprop=\"name\"]");
if (name1.size() > 0) {
String name = name1.get(0).html();
Elements select = td.select("a[itemprop=\"url\"]");
if (select.size() > 0) {
String url = select.get(0).attr("abs:href");
SherdogBaseObject fighter = new SherdogBaseObject();
fighter.setSherdogUrl(url);
fighter.setName(name);
return fighter;
}
}
return null;
} | java | {
"resource": ""
} |
q13592 | OrganizationParser.parseEvent | train | private List<Event> parseEvent(Elements trs, Organization organization) throws ParseException {
List<Event> events = new ArrayList<>();
if (trs.size() > 0) {
trs.remove(0);
SherdogBaseObject sOrg = new SherdogBaseObject();
sOrg.setName(organization.getName());
sOrg.setSherdogUrl(organization.getSherdogUrl());
trs.forEach(tr -> {
Event event = new Event();
boolean addEvent = true;
Elements tds = tr.select("td");
event.setOrganization(sOrg);
event.setName(getEventName(tds.get(NAME_COLUMN)));
event.setSherdogUrl(getEventUrl(tds.get(NAME_COLUMN)));
event.setLocation(getElementLocation(tds.get(LOCATION_COLUMN)));
try {
event.setDate(getEventDate(tds.get(DATE_COLUMN)));
} catch (DateTimeParseException e) {
logger.error("Couldn't fornat date, we shouldn't add the event", e);
addEvent = false;
}
if (addEvent) {
events.add(event);
}
});
}
return events;
} | java | {
"resource": ""
} |
q13593 | VacuumConsumableStatus.reset | train | public void reset(String name){
if (name.equals(Names.MAIN_BRUSH.toString())) mainBrushWorkTime = 0;
if (name.equals(Names.SENSOR.toString())) sensorTimeSinceCleaning = 0;
if (name.equals(Names.SIDE_BRUSH.toString())) sideBrushWorkTime = 0;
if (name.equals(Names.FILTER.toString())) filterWorkTime = 0;
} | java | {
"resource": ""
} |
q13594 | FrameNode.accept | train | @Override
public void accept(final MethodVisitor mv) {
switch (type) {
case Opcodes.F_NEW:
case Opcodes.F_FULL:
mv.visitFrame(type, local.size(), asArray(local), stack.size(),
asArray(stack));
break;
case Opcodes.F_APPEND:
mv.visitFrame(type, local.size(), asArray(local), 0, null);
break;
case Opcodes.F_CHOP:
mv.visitFrame(type, local.size(), null, 0, null);
break;
case Opcodes.F_SAME:
mv.visitFrame(type, 0, null, 0, null);
break;
case Opcodes.F_SAME1:
mv.visitFrame(type, 0, null, 1, asArray(stack));
break;
}
} | java | {
"resource": ""
} |
q13595 | Sherdog.getOrganizationFromHtml | train | public Organization getOrganizationFromHtml(String html) throws IOException, ParseException, SherdogParserException {
return new OrganizationParser(zoneId).parseFromHtml(html);
} | java | {
"resource": ""
} |
q13596 | Sherdog.getEventFromHtml | train | public Event getEventFromHtml(String html) throws IOException, ParseException, SherdogParserException {
return new EventParser(zoneId).parseFromHtml(html);
} | java | {
"resource": ""
} |
q13597 | Sherdog.getEvent | train | public Event getEvent(String sherdogUrl) throws IOException, ParseException, SherdogParserException {
return new EventParser(zoneId).parse(sherdogUrl);
} | java | {
"resource": ""
} |
q13598 | Sherdog.getFighterFromHtml | train | public Fighter getFighterFromHtml(String html) throws IOException, ParseException, SherdogParserException {
return new FighterParser(pictureProcessor, zoneId).parseFromHtml(html);
} | java | {
"resource": ""
} |
q13599 | Sherdog.getFighter | train | public Fighter getFighter(String sherdogUrl) throws IOException, ParseException, SherdogParserException {
return new FighterParser(pictureProcessor, zoneId).parse(sherdogUrl);
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.