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
m09/syllable-counter
src/main/java/eu/crydee/syllablecounter/SyllableCounter.java
SyllableCounter.getRessourceLines
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
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); } }
[ "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", ")", ";", "}", "}" ]
Package protected for testing purposes
[ "Package", "protected", "for", "testing", "purposes" ]
062428d445d46be20fb6a23ec0e67d9823502289
https://github.com/m09/syllable-counter/blob/062428d445d46be20fb6a23ec0e67d9823502289/src/main/java/eu/crydee/syllablecounter/SyllableCounter.java#L59-L70
train
m09/syllable-counter
src/main/java/eu/crydee/syllablecounter/SyllableCounter.java
SyllableCounter.count
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
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; }
[ "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", ")", "==", "'", "'", ")", "{", "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", ";", "}" ]
Main point of this library. Method to count the number of syllables of a word using a fallback method as documented at the class level of this documentation. @param word the word you want to count the syllables of. @return the number of syllables of the word.
[ "Main", "point", "of", "this", "library", ".", "Method", "to", "count", "the", "number", "of", "syllables", "of", "a", "word", "using", "a", "fallback", "method", "as", "documented", "at", "the", "class", "level", "of", "this", "documentation", "." ]
062428d445d46be20fb6a23ec0e67d9823502289
https://github.com/m09/syllable-counter/blob/062428d445d46be20fb6a23ec0e67d9823502289/src/main/java/eu/crydee/syllablecounter/SyllableCounter.java#L105-L144
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBoxContext.java
BeanBoxContext.reset
public static void reset() { globalBeanBoxContext.close(); globalNextAllowAnnotation = true; globalNextAllowSpringJsrAnnotation = true; globalNextValueTranslator = new DefaultValueTranslator(); CREATE_METHOD = "create"; CONFIG_METHOD = "config"; globalBeanBoxContext = new BeanBoxContext(); }
java
public static void reset() { globalBeanBoxContext.close(); globalNextAllowAnnotation = true; globalNextAllowSpringJsrAnnotation = true; globalNextValueTranslator = new DefaultValueTranslator(); CREATE_METHOD = "create"; CONFIG_METHOD = "config"; globalBeanBoxContext = new BeanBoxContext(); }
[ "public", "static", "void", "reset", "(", ")", "{", "globalBeanBoxContext", ".", "close", "(", ")", ";", "globalNextAllowAnnotation", "=", "true", ";", "globalNextAllowSpringJsrAnnotation", "=", "true", ";", "globalNextValueTranslator", "=", "new", "DefaultValueTranslator", "(", ")", ";", "CREATE_METHOD", "=", "\"create\"", ";", "CONFIG_METHOD", "=", "\"config\"", ";", "globalBeanBoxContext", "=", "new", "BeanBoxContext", "(", ")", ";", "}" ]
Reset global variants setting , note this method only close globalBeanBoxContext, if created many BeanBoxContext instance need close them manually
[ "Reset", "global", "variants", "setting", "note", "this", "method", "only", "close", "globalBeanBoxContext", "if", "created", "many", "BeanBoxContext", "instance", "need", "close", "them", "manually" ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBoxContext.java#L82-L91
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBoxContext.java
BeanBoxContext.close
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
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(); }
[ "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", "(", ")", ";", "}" ]
Close current BeanBoxContext, clear singlton cache, call predestory methods for each singleton if they have
[ "Close", "current", "BeanBoxContext", "clear", "singlton", "cache", "call", "predestory", "methods", "for", "each", "singleton", "if", "they", "have" ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBoxContext.java#L97-L114
train
ef-labs/vertx-when
vertx-when/src/main/java/com/englishtown/vertx/promises/RequestOptions.java
RequestOptions.addHeader
public RequestOptions addHeader(String name, String value) { if (headers == null) { headers = new CaseInsensitiveHeaders(); } headers.add(name, value); return this; }
java
public RequestOptions addHeader(String name, String value) { if (headers == null) { headers = new CaseInsensitiveHeaders(); } headers.add(name, value); return this; }
[ "public", "RequestOptions", "addHeader", "(", "String", "name", ",", "String", "value", ")", "{", "if", "(", "headers", "==", "null", ")", "{", "headers", "=", "new", "CaseInsensitiveHeaders", "(", ")", ";", "}", "headers", ".", "add", "(", "name", ",", "value", ")", ";", "return", "this", ";", "}" ]
Add a header to the request. Can be called multiple times to add multiple headers @param name @param value @return
[ "Add", "a", "header", "to", "the", "request", ".", "Can", "be", "called", "multiple", "times", "to", "add", "multiple", "headers" ]
dc4fde973f58130f2eb2159206ee78b867048f4d
https://github.com/ef-labs/vertx-when/blob/dc4fde973f58130f2eb2159206ee78b867048f4d/vertx-when/src/main/java/com/englishtown/vertx/promises/RequestOptions.java#L69-L75
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/parsers/ParserUtils.java
ParserUtils.parseDocument
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
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(); }
[ "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", "(", ")", ";", "}" ]
PArses a URL with all the required parameters @param url of the document to parse @return the jsoup document @throws IOException if the connection fails
[ "PArses", "a", "URL", "with", "all", "the", "required", "parameters" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/parsers/ParserUtils.java#L60-L67
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/parsers/ParserUtils.java
ParserUtils.downloadImageToFile
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
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()); } }
[ "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", "(", ")", ")", ";", "}", "}" ]
Downloads an image to a file with the adequate headers to the http query @param url the url of the image @param file the file to create @throws IOException if the file download fails
[ "Downloads", "an", "image", "to", "a", "file", "with", "the", "adequate", "headers", "to", "the", "http", "query" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/parsers/ParserUtils.java#L115-L127
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/parsers/ParserUtils.java
ParserUtils.getSherdogPageUrl
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
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://"); }
[ "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://\"", ")", ";", "}" ]
Gets the url of a page using the meta tags in head @param doc the jsoup document to extract the page url from @return the url of the document
[ "Gets", "the", "url", "of", "a", "page", "using", "the", "meta", "tags", "in", "head" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/parsers/ParserUtils.java#L183-L195
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/JSRInlinerAdapter.java
JSRInlinerAdapter.visitJumpInsn
@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
@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()); } }
[ "@", "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", "(", ")", ")", ";", "}", "}" ]
Detects a JSR instruction and sets a flag to indicate we will need to do inlining.
[ "Detects", "a", "JSR", "instruction", "and", "sets", "a", "flag", "to", "indicate", "we", "will", "need", "to", "do", "inlining", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/JSRInlinerAdapter.java#L157-L164
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/JSRInlinerAdapter.java
JSRInlinerAdapter.visitEnd
@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
@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); } }
[ "@", "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", ")", ";", "}", "}" ]
If any JSRs were seen, triggers the inlining process. Otherwise, forwards the byte codes untouched.
[ "If", "any", "JSRs", "were", "seen", "triggers", "the", "inlining", "process", ".", "Otherwise", "forwards", "the", "byte", "codes", "untouched", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/JSRInlinerAdapter.java#L170-L189
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/JSRInlinerAdapter.java
JSRInlinerAdapter.emitCode
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
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; }
[ "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", ";", "}" ]
Creates the new instructions, inlining each instantiation of each subroutine until the code is fully elaborated.
[ "Creates", "the", "new", "instructions", "inlining", "each", "instantiation", "of", "each", "subroutine", "until", "the", "code", "is", "fully", "elaborated", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/JSRInlinerAdapter.java#L378-L397
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/Type.java
Type.getDescriptor
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
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; } } }
[ "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", "=", "'", "'", ";", "}", "else", "if", "(", "d", "==", "Void", ".", "TYPE", ")", "{", "car", "=", "'", "'", ";", "}", "else", "if", "(", "d", "==", "Boolean", ".", "TYPE", ")", "{", "car", "=", "'", "'", ";", "}", "else", "if", "(", "d", "==", "Byte", ".", "TYPE", ")", "{", "car", "=", "'", "'", ";", "}", "else", "if", "(", "d", "==", "Character", ".", "TYPE", ")", "{", "car", "=", "'", "'", ";", "}", "else", "if", "(", "d", "==", "Short", ".", "TYPE", ")", "{", "car", "=", "'", "'", ";", "}", "else", "if", "(", "d", "==", "Double", ".", "TYPE", ")", "{", "car", "=", "'", "'", ";", "}", "else", "if", "(", "d", "==", "Float", ".", "TYPE", ")", "{", "car", "=", "'", "'", ";", "}", "else", "/* if (d == Long.TYPE) */", "{", "car", "=", "'", "'", ";", "}", "buf", ".", "append", "(", "car", ")", ";", "return", ";", "}", "else", "if", "(", "d", ".", "isArray", "(", ")", ")", "{", "buf", ".", "append", "(", "'", "'", ")", ";", "d", "=", "d", ".", "getComponentType", "(", ")", ";", "}", "else", "{", "buf", ".", "append", "(", "'", "'", ")", ";", "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", ";", "}", "}", "}" ]
Appends the descriptor of the given class to the given string buffer. @param buf the string buffer to which the descriptor must be appended. @param c the class whose descriptor must be computed.
[ "Appends", "the", "descriptor", "of", "the", "given", "class", "to", "the", "given", "string", "buffer", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/Type.java#L752-L793
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/Handler.java
Handler.remove
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
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; }
[ "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", ";", "}" ]
Removes the range between start and end from the given exception handlers. @param h an exception handler list. @param start the start of the range to be removed. @param end the end of the range to be removed. Maybe null. @return the exception handler list with the start-end range removed.
[ "Removes", "the", "range", "between", "start", "and", "end", "from", "the", "given", "exception", "handlers", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/Handler.java#L83-L120
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/ClassNode.java
ClassNode.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(); } for (FieldNode f : fields) { f.check(api); } for (MethodNode m : methods) { m.check(api); } } }
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(); } for (FieldNode f : fields) { f.check(api); } for (MethodNode m : methods) { m.check(api); } } }
[ "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", ")", ";", "}", "}", "}" ]
Checks that this class 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", "class", "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/ClassNode.java#L335-L352
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/ClassNode.java
ClassNode.accept
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
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(); }
[ "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", "(", ")", ";", "}" ]
Makes the given class visitor visit this class. @param cv a class visitor.
[ "Makes", "the", "given", "class", "visitor", "visit", "this", "class", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/ClassNode.java#L360-L416
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/server/Server.java
Server.run
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
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(); }
[ "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", "(", ")", ";", "}" ]
Start the de.sg_o.app.miio.server.
[ "Start", "the", "de", ".", "sg_o", ".", "app", ".", "miio", ".", "server", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/server/Server.java#L129-L170
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/xml/ASMContentHandler.java
ASMContentHandler.startElement
@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
@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); } }
[ "@", "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", ")", ";", "}", "}" ]
Process notification of the start of an XML element being reached. @param ns - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed. @param lName - The local name (without prefix), or the empty string if Namespace processing is not being performed. @param qName - The qualified name (with prefix), or the empty string if qualified names are not available. @param list - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object. @exception SAXException if a parsing error is to be reported
[ "Process", "notification", "of", "the", "start", "of", "an", "XML", "element", "being", "reached", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/xml/ASMContentHandler.java#L359-L379
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/xml/ASMContentHandler.java
ASMContentHandler.endElement
@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
@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 = ""; } }
[ "@", "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", "=", "\"\"", ";", "}", "}" ]
Process notification of the end of an XML element being reached. @param ns - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed. @param lName - The local name (without prefix), or the empty string if Namespace processing is not being performed. @param qName - The qualified XML 1.0 name (with prefix), or the empty string if qualified names are not available. @exception SAXException if a parsing error is to be reported
[ "Process", "notification", "of", "the", "end", "of", "an", "XML", "element", "being", "reached", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/xml/ASMContentHandler.java#L398-L418
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java
InsnList.get
public AbstractInsnNode get(final int index) { if (index < 0 || index >= size) { throw new IndexOutOfBoundsException(); } if (cache == null) { cache = toArray(); } return cache[index]; }
java
public AbstractInsnNode get(final int index) { if (index < 0 || index >= size) { throw new IndexOutOfBoundsException(); } if (cache == null) { cache = toArray(); } return cache[index]; }
[ "public", "AbstractInsnNode", "get", "(", "final", "int", "index", ")", "{", "if", "(", "index", "<", "0", "||", "index", ">=", "size", ")", "{", "throw", "new", "IndexOutOfBoundsException", "(", ")", ";", "}", "if", "(", "cache", "==", "null", ")", "{", "cache", "=", "toArray", "(", ")", ";", "}", "return", "cache", "[", "index", "]", ";", "}" ]
Returns the instruction whose index is given. This method builds a cache of the instructions in this list to avoid scanning the whole list each time it is called. Once the cache is built, this method run in constant time. This cache is invalidated by all the methods that modify the list. @param index the index of the instruction that must be returned. @return the instruction whose index is given. @throws IndexOutOfBoundsException if (index &lt; 0 || index &gt;= size()).
[ "Returns", "the", "instruction", "whose", "index", "is", "given", ".", "This", "method", "builds", "a", "cache", "of", "the", "instructions", "in", "this", "list", "to", "avoid", "scanning", "the", "whole", "list", "each", "time", "it", "is", "called", ".", "Once", "the", "cache", "is", "built", "this", "method", "run", "in", "constant", "time", ".", "This", "cache", "is", "invalidated", "by", "all", "the", "methods", "that", "modify", "the", "list", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java#L106-L114
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java
InsnList.accept
public void accept(final MethodVisitor mv) { AbstractInsnNode insn = first; while (insn != null) { insn.accept(mv); insn = insn.next; } }
java
public void accept(final MethodVisitor mv) { AbstractInsnNode insn = first; while (insn != null) { insn.accept(mv); insn = insn.next; } }
[ "public", "void", "accept", "(", "final", "MethodVisitor", "mv", ")", "{", "AbstractInsnNode", "insn", "=", "first", ";", "while", "(", "insn", "!=", "null", ")", "{", "insn", ".", "accept", "(", "mv", ")", ";", "insn", "=", "insn", ".", "next", ";", "}", "}" ]
Makes the given visitor visit all of the instructions in this list. @param mv the method visitor that must visit the instructions.
[ "Makes", "the", "given", "visitor", "visit", "all", "of", "the", "instructions", "in", "this", "list", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java#L160-L166
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java
InsnList.toArray
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
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; }
[ "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", ";", "}" ]
Returns an array containing all of the instructions in this list. @return an array containing all of the instructions in this list.
[ "Returns", "an", "array", "containing", "all", "of", "the", "instructions", "in", "this", "list", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java#L191-L201
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java
InsnList.set
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
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; }
[ "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", ";", "}" ]
Replaces an instruction of this list with another instruction. @param location an instruction <i>of this list</i>. @param insn another instruction, <i>which must not belong to any {@link InsnList}</i>.
[ "Replaces", "an", "instruction", "of", "this", "list", "with", "another", "instruction", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java#L212-L237
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java
InsnList.add
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
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 }
[ "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", "}" ]
Adds the given instruction to the end of this list. @param insn an instruction, <i>which must not belong to any {@link InsnList}</i>.
[ "Adds", "the", "given", "instruction", "to", "the", "end", "of", "this", "list", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java#L246-L258
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java
InsnList.insert
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
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 }
[ "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", "}" ]
Inserts the given instruction at the begining of this list. @param insn an instruction, <i>which must not belong to any {@link InsnList}</i>.
[ "Inserts", "the", "given", "instruction", "at", "the", "begining", "of", "this", "list", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java#L292-L304
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java
InsnList.insert
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
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); }
[ "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", ")", ";", "}" ]
Inserts the given instructions at the begining of this list. @param insns an instruction list, which is cleared during the process. This list must be different from 'this'.
[ "Inserts", "the", "given", "instructions", "at", "the", "begining", "of", "this", "list", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java#L313-L329
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java
InsnList.insert
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
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 }
[ "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", "}" ]
Inserts the given instruction after the specified instruction. @param location an instruction <i>of this list</i> after which insn must be inserted. @param insn the instruction to be inserted, <i>which must not belong to any {@link InsnList}</i>.
[ "Inserts", "the", "given", "instruction", "after", "the", "specified", "instruction", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java#L341-L355
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java
InsnList.insert
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
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); }
[ "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", ")", ";", "}" ]
Inserts the given instructions after the specified instruction. @param location an instruction <i>of this list</i> after which the instructions must be inserted. @param insns the instruction list to be inserted, which is cleared during the process. This list must be different from 'this'.
[ "Inserts", "the", "given", "instructions", "after", "the", "specified", "instruction", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java#L367-L385
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java
InsnList.insertBefore
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
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 }
[ "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", "}" ]
Inserts the given instruction before the specified instruction. @param location an instruction <i>of this list</i> before which insn must be inserted. @param insn the instruction to be inserted, <i>which must not belong to any {@link InsnList}</i>.
[ "Inserts", "the", "given", "instruction", "before", "the", "specified", "instruction", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java#L397-L411
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java
InsnList.insertBefore
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
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); }
[ "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", ")", ";", "}" ]
Inserts the given instructions before the specified instruction. @param location an instruction <i>of this list</i> before which the instructions must be inserted. @param insns the instruction list to be inserted, which is cleared during the process. This list must be different from 'this'.
[ "Inserts", "the", "given", "instructions", "before", "the", "specified", "instruction", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java#L423-L442
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java
InsnList.remove
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
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; }
[ "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", ";", "}" ]
Removes the given instruction from this list. @param insn the instruction <i>of this list</i> that must be removed.
[ "Removes", "the", "given", "instruction", "from", "this", "list", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java#L450-L475
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java
InsnList.removeAll
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
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; }
[ "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", ";", "}" ]
Removes all of the instructions of this list. @param mark if the instructions must be marked as no longer belonging to any {@link InsnList}.
[ "Removes", "all", "of", "the", "instructions", "of", "this", "list", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/InsnList.java#L484-L499
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/parsers/EventParser.java
EventParser.parseDocument
@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
@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; }
[ "@", "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", ";", "}" ]
parses an event from a jsoup document @param doc the jsoup document @return a parsed event
[ "parses", "an", "event", "from", "a", "jsoup", "document" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/parsers/EventParser.java#L49-L78
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/parsers/EventParser.java
EventParser.getFights
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
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); }
[ "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", ")", ";", "}" ]
Gets the fight of the event @param doc the jsoup HTML document @param event The current event
[ "Gets", "the", "fight", "of", "the", "event" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/parsers/EventParser.java#L87-L141
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/parsers/EventParser.java
EventParser.parseEventFights
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
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; }
[ "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", ";", "}" ]
Parse fights of an old event
[ "Parse", "fights", "of", "an", "old", "event" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/parsers/EventParser.java#L147-L180
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/parsers/EventParser.java
EventParser.getFighter
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
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; }
[ "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", ";", "}" ]
Get a fighter @param td element from sherdog's table @return return a sherdogbaseobject with the fighter name and url
[ "Get", "a", "fighter" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/parsers/EventParser.java#L188-L209
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/parsers/OrganizationParser.java
OrganizationParser.parseEvent
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
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; }
[ "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", ";", "}" ]
Get all the events of an organization @param trs the JSOUP TR elements from the event table @return a list of events @throws ParseException if something is wrong with sherdog layout
[ "Get", "all", "the", "events", "of", "an", "organization" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/parsers/OrganizationParser.java#L103-L141
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/VacuumConsumableStatus.java
VacuumConsumableStatus.reset
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
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; }
[ "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", ";", "}" ]
Reset a consumable. @param name The consumable to reset.
[ "Reset", "a", "consumable", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/VacuumConsumableStatus.java#L100-L105
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/FrameNode.java
FrameNode.accept
@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
@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; } }
[ "@", "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", ";", "}", "}" ]
Makes the given visitor visit this stack map frame. @param mv a method visitor.
[ "Makes", "the", "given", "visitor", "visit", "this", "stack", "map", "frame", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/FrameNode.java#L143-L164
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/Sherdog.java
Sherdog.getOrganizationFromHtml
public Organization getOrganizationFromHtml(String html) throws IOException, ParseException, SherdogParserException { return new OrganizationParser(zoneId).parseFromHtml(html); }
java
public Organization getOrganizationFromHtml(String html) throws IOException, ParseException, SherdogParserException { return new OrganizationParser(zoneId).parseFromHtml(html); }
[ "public", "Organization", "getOrganizationFromHtml", "(", "String", "html", ")", "throws", "IOException", ",", "ParseException", ",", "SherdogParserException", "{", "return", "new", "OrganizationParser", "(", "zoneId", ")", ".", "parseFromHtml", "(", "html", ")", ";", "}" ]
Gets an organization via it's sherdog page HTML, in case you want to have your own way of getting teh HTML content @param html The web page HTML @return an Organization @throws IOException if connecting to sherdog fails @throws ParseException if the page structure has changed @throws SherdogParserException if anythign related to the parser goes wrong
[ "Gets", "an", "organization", "via", "it", "s", "sherdog", "page", "HTML", "in", "case", "you", "want", "to", "have", "your", "own", "way", "of", "getting", "teh", "HTML", "content" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/Sherdog.java#L73-L75
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/Sherdog.java
Sherdog.getEventFromHtml
public Event getEventFromHtml(String html) throws IOException, ParseException, SherdogParserException { return new EventParser(zoneId).parseFromHtml(html); }
java
public Event getEventFromHtml(String html) throws IOException, ParseException, SherdogParserException { return new EventParser(zoneId).parseFromHtml(html); }
[ "public", "Event", "getEventFromHtml", "(", "String", "html", ")", "throws", "IOException", ",", "ParseException", ",", "SherdogParserException", "{", "return", "new", "EventParser", "(", "zoneId", ")", ".", "parseFromHtml", "(", "html", ")", ";", "}" ]
Gets an event via it's shergog page HTML @param html The web page HTML @return an Event @throws IOException if connecting to sherdog fails @throws ParseException if the page structure has changed @throws SherdogParserException if anythign related to the parser goes wrong
[ "Gets", "an", "event", "via", "it", "s", "shergog", "page", "HTML" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/Sherdog.java#L100-L102
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/Sherdog.java
Sherdog.getEvent
public Event getEvent(String sherdogUrl) throws IOException, ParseException, SherdogParserException { return new EventParser(zoneId).parse(sherdogUrl); }
java
public Event getEvent(String sherdogUrl) throws IOException, ParseException, SherdogParserException { return new EventParser(zoneId).parse(sherdogUrl); }
[ "public", "Event", "getEvent", "(", "String", "sherdogUrl", ")", "throws", "IOException", ",", "ParseException", ",", "SherdogParserException", "{", "return", "new", "EventParser", "(", "zoneId", ")", ".", "parse", "(", "sherdogUrl", ")", ";", "}" ]
Gets an event via it's sherdog URL. @param sherdogUrl Sherdog URL, can be found in the list of event of an organization @return an Event @throws IOException if connecting to sherdog fails @throws ParseException if the page structure has changed @throws SherdogParserException if anythign related to the parser goes wrong
[ "Gets", "an", "event", "via", "it", "s", "sherdog", "URL", "." ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/Sherdog.java#L113-L115
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/Sherdog.java
Sherdog.getFighterFromHtml
public Fighter getFighterFromHtml(String html) throws IOException, ParseException, SherdogParserException { return new FighterParser(pictureProcessor, zoneId).parseFromHtml(html); }
java
public Fighter getFighterFromHtml(String html) throws IOException, ParseException, SherdogParserException { return new FighterParser(pictureProcessor, zoneId).parseFromHtml(html); }
[ "public", "Fighter", "getFighterFromHtml", "(", "String", "html", ")", "throws", "IOException", ",", "ParseException", ",", "SherdogParserException", "{", "return", "new", "FighterParser", "(", "pictureProcessor", ",", "zoneId", ")", ".", "parseFromHtml", "(", "html", ")", ";", "}" ]
Get a fighter via it;s sherdog page HTML @param html The web page HTML @return a Fighter an all his fights @throws IOException if connecting to sherdog fails @throws ParseException if the page structure has changed @throws SherdogParserException if anythign related to the parser goes wrong
[ "Get", "a", "fighter", "via", "it", ";", "s", "sherdog", "page", "HTML" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/Sherdog.java#L127-L129
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/Sherdog.java
Sherdog.getFighter
public Fighter getFighter(String sherdogUrl) throws IOException, ParseException, SherdogParserException { return new FighterParser(pictureProcessor, zoneId).parse(sherdogUrl); }
java
public Fighter getFighter(String sherdogUrl) throws IOException, ParseException, SherdogParserException { return new FighterParser(pictureProcessor, zoneId).parse(sherdogUrl); }
[ "public", "Fighter", "getFighter", "(", "String", "sherdogUrl", ")", "throws", "IOException", ",", "ParseException", ",", "SherdogParserException", "{", "return", "new", "FighterParser", "(", "pictureProcessor", ",", "zoneId", ")", ".", "parse", "(", "sherdogUrl", ")", ";", "}" ]
Get a fighter via it;s sherdog URL. @param sherdogUrl the shergod url of the fighter @return a Fighter an all his fights @throws IOException if connecting to sherdog fails @throws ParseException if the page structure has changed @throws SherdogParserException if anythign related to the parser goes wrong
[ "Get", "a", "fighter", "via", "it", ";", "s", "sherdog", "URL", "." ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/Sherdog.java#L140-L142
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/AopUtils.java
AopUtils.createProxyBean
public static Object createProxyBean(Class<?> clazz, BeanBox box, BeanBoxContext ctx) { BeanBoxException.assureNotNull(clazz, "Try to create a proxy bean, but beanClass not found."); Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(clazz); if (box.getConstructorParams() != null && box.getConstructorParams().length > 0) { BeanBox[] boxes = box.getConstructorParams(); Class<?>[] argsTypes = new Class<?>[boxes.length]; Object[] realArgsValue = new Object[boxes.length]; for (int i = 0; i < boxes.length; i++) { argsTypes[i] = boxes[i].getType(); Object realValue = ctx.getBean(boxes[i]); if (realValue != null && realValue instanceof String) realValue = ctx.getValueTranslator().translate((String) realValue, boxes[i].getType()); realArgsValue[i] = realValue; } enhancer.setCallback(new ProxyBean(box, ctx)); return enhancer.create(argsTypes, realArgsValue); } else { enhancer.setCallback(new ProxyBean(box, ctx)); return enhancer.create(); } }
java
public static Object createProxyBean(Class<?> clazz, BeanBox box, BeanBoxContext ctx) { BeanBoxException.assureNotNull(clazz, "Try to create a proxy bean, but beanClass not found."); Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(clazz); if (box.getConstructorParams() != null && box.getConstructorParams().length > 0) { BeanBox[] boxes = box.getConstructorParams(); Class<?>[] argsTypes = new Class<?>[boxes.length]; Object[] realArgsValue = new Object[boxes.length]; for (int i = 0; i < boxes.length; i++) { argsTypes[i] = boxes[i].getType(); Object realValue = ctx.getBean(boxes[i]); if (realValue != null && realValue instanceof String) realValue = ctx.getValueTranslator().translate((String) realValue, boxes[i].getType()); realArgsValue[i] = realValue; } enhancer.setCallback(new ProxyBean(box, ctx)); return enhancer.create(argsTypes, realArgsValue); } else { enhancer.setCallback(new ProxyBean(box, ctx)); return enhancer.create(); } }
[ "public", "static", "Object", "createProxyBean", "(", "Class", "<", "?", ">", "clazz", ",", "BeanBox", "box", ",", "BeanBoxContext", "ctx", ")", "{", "BeanBoxException", ".", "assureNotNull", "(", "clazz", ",", "\"Try to create a proxy bean, but beanClass not found.\"", ")", ";", "Enhancer", "enhancer", "=", "new", "Enhancer", "(", ")", ";", "enhancer", ".", "setSuperclass", "(", "clazz", ")", ";", "if", "(", "box", ".", "getConstructorParams", "(", ")", "!=", "null", "&&", "box", ".", "getConstructorParams", "(", ")", ".", "length", ">", "0", ")", "{", "BeanBox", "[", "]", "boxes", "=", "box", ".", "getConstructorParams", "(", ")", ";", "Class", "<", "?", ">", "[", "]", "argsTypes", "=", "new", "Class", "<", "?", ">", "[", "boxes", ".", "length", "]", ";", "Object", "[", "]", "realArgsValue", "=", "new", "Object", "[", "boxes", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "boxes", ".", "length", ";", "i", "++", ")", "{", "argsTypes", "[", "i", "]", "=", "boxes", "[", "i", "]", ".", "getType", "(", ")", ";", "Object", "realValue", "=", "ctx", ".", "getBean", "(", "boxes", "[", "i", "]", ")", ";", "if", "(", "realValue", "!=", "null", "&&", "realValue", "instanceof", "String", ")", "realValue", "=", "ctx", ".", "getValueTranslator", "(", ")", ".", "translate", "(", "(", "String", ")", "realValue", ",", "boxes", "[", "i", "]", ".", "getType", "(", ")", ")", ";", "realArgsValue", "[", "i", "]", "=", "realValue", ";", "}", "enhancer", ".", "setCallback", "(", "new", "ProxyBean", "(", "box", ",", "ctx", ")", ")", ";", "return", "enhancer", ".", "create", "(", "argsTypes", ",", "realArgsValue", ")", ";", "}", "else", "{", "enhancer", ".", "setCallback", "(", "new", "ProxyBean", "(", "box", ",", "ctx", ")", ")", ";", "return", "enhancer", ".", "create", "(", ")", ";", "}", "}" ]
Create a ProxyBean @param clazz The target class @param box The BeanBox of target class @param ctx The BeanBoxContext @return A Proxy Bean with AOP support
[ "Create", "a", "ProxyBean" ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/AopUtils.java#L34-L55
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/yeelight/Light.java
Light.getProps
public Map<Prop.Names, String> getProps(Prop.Names[] props) throws CommandExecutionException { Prop prop = new Prop(props); return prop.parseResponse(sendToArray("get_prop", prop.getRequestArray())); }
java
public Map<Prop.Names, String> getProps(Prop.Names[] props) throws CommandExecutionException { Prop prop = new Prop(props); return prop.parseResponse(sendToArray("get_prop", prop.getRequestArray())); }
[ "public", "Map", "<", "Prop", ".", "Names", ",", "String", ">", "getProps", "(", "Prop", ".", "Names", "[", "]", "props", ")", "throws", "CommandExecutionException", "{", "Prop", "prop", "=", "new", "Prop", "(", "props", ")", ";", "return", "prop", ".", "parseResponse", "(", "sendToArray", "(", "\"get_prop\"", ",", "prop", ".", "getRequestArray", "(", ")", ")", ")", ";", "}" ]
Get several property values at once from the device. @param props The properties to get. @return The property names and values. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Get", "several", "property", "values", "at", "once", "from", "the", "device", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/yeelight/Light.java#L50-L53
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/yeelight/Light.java
Light.getSingleProp
public String getSingleProp(Prop.Names prop) throws CommandExecutionException { Map<Prop.Names, String> value = getProps(new Prop.Names[]{prop}); String valueString = value.get(prop); if (valueString == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); return valueString; }
java
public String getSingleProp(Prop.Names prop) throws CommandExecutionException { Map<Prop.Names, String> value = getProps(new Prop.Names[]{prop}); String valueString = value.get(prop); if (valueString == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); return valueString; }
[ "public", "String", "getSingleProp", "(", "Prop", ".", "Names", "prop", ")", "throws", "CommandExecutionException", "{", "Map", "<", "Prop", ".", "Names", ",", "String", ">", "value", "=", "getProps", "(", "new", "Prop", ".", "Names", "[", "]", "{", "prop", "}", ")", ";", "String", "valueString", "=", "value", ".", "get", "(", "prop", ")", ";", "if", "(", "valueString", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_RESPONSE", ")", ";", "return", "valueString", ";", "}" ]
Get a single property value from the device. @param prop The property to get. @return The value of the specified property name. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Get", "a", "single", "property", "value", "from", "the", "device", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/yeelight/Light.java#L61-L66
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/yeelight/Light.java
Light.getIntProp
public int getIntProp(Prop.Names prop) throws CommandExecutionException { String value = getSingleProp(prop); if (value.equals("")) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); try { return Integer.valueOf(value); } catch (Exception e){ throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); } }
java
public int getIntProp(Prop.Names prop) throws CommandExecutionException { String value = getSingleProp(prop); if (value.equals("")) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); try { return Integer.valueOf(value); } catch (Exception e){ throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); } }
[ "public", "int", "getIntProp", "(", "Prop", ".", "Names", "prop", ")", "throws", "CommandExecutionException", "{", "String", "value", "=", "getSingleProp", "(", "prop", ")", ";", "if", "(", "value", ".", "equals", "(", "\"\"", ")", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_RESPONSE", ")", ";", "try", "{", "return", "Integer", ".", "valueOf", "(", "value", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_RESPONSE", ")", ";", "}", "}" ]
Get a single property value and try to convert it to an int. @param prop The property to get. @return The value of the specified property name. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Get", "a", "single", "property", "value", "and", "try", "to", "convert", "it", "to", "an", "int", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/yeelight/Light.java#L74-L82
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/yeelight/Light.java
Light.powerOffAfterTime
public boolean powerOffAfterTime(int minutes) throws CommandExecutionException { JSONArray col = new JSONArray(); col.put(0); col.put(minutes); return sendOk("cron_add", col); }
java
public boolean powerOffAfterTime(int minutes) throws CommandExecutionException { JSONArray col = new JSONArray(); col.put(0); col.put(minutes); return sendOk("cron_add", col); }
[ "public", "boolean", "powerOffAfterTime", "(", "int", "minutes", ")", "throws", "CommandExecutionException", "{", "JSONArray", "col", "=", "new", "JSONArray", "(", ")", ";", "col", ".", "put", "(", "0", ")", ";", "col", ".", "put", "(", "minutes", ")", ";", "return", "sendOk", "(", "\"cron_add\"", ",", "col", ")", ";", "}" ]
Power the device off after some time. @param minutes The time until the device is turned off in minutes. @return True if the command was received successfully. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Power", "the", "device", "off", "after", "some", "time", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/yeelight/Light.java#L254-L259
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBoxUtils.java
BeanBoxUtils.getUniqueBeanBox
public static BeanBox getUniqueBeanBox(BeanBoxContext ctx, Class<?> clazz) { BeanBoxException.assureNotNull(clazz, "Target class can not be null"); BeanBox box = ctx.beanBoxMetaCache.get(clazz); if (box != null) return box; if (BeanBox.class.isAssignableFrom(clazz)) try { box = (BeanBox) clazz.newInstance(); if (box.singleton == null) box.singleton = true; } catch (Exception e) { BeanBoxException.throwEX(e); } else box = doCreateBeanBox(ctx, clazz); ctx.beanBoxMetaCache.put(clazz, box); return box; }
java
public static BeanBox getUniqueBeanBox(BeanBoxContext ctx, Class<?> clazz) { BeanBoxException.assureNotNull(clazz, "Target class can not be null"); BeanBox box = ctx.beanBoxMetaCache.get(clazz); if (box != null) return box; if (BeanBox.class.isAssignableFrom(clazz)) try { box = (BeanBox) clazz.newInstance(); if (box.singleton == null) box.singleton = true; } catch (Exception e) { BeanBoxException.throwEX(e); } else box = doCreateBeanBox(ctx, clazz); ctx.beanBoxMetaCache.put(clazz, box); return box; }
[ "public", "static", "BeanBox", "getUniqueBeanBox", "(", "BeanBoxContext", "ctx", ",", "Class", "<", "?", ">", "clazz", ")", "{", "BeanBoxException", ".", "assureNotNull", "(", "clazz", ",", "\"Target class can not be null\"", ")", ";", "BeanBox", "box", "=", "ctx", ".", "beanBoxMetaCache", ".", "get", "(", "clazz", ")", ";", "if", "(", "box", "!=", "null", ")", "return", "box", ";", "if", "(", "BeanBox", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "try", "{", "box", "=", "(", "BeanBox", ")", "clazz", ".", "newInstance", "(", ")", ";", "if", "(", "box", ".", "singleton", "==", "null", ")", "box", ".", "singleton", "=", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "BeanBoxException", ".", "throwEX", "(", "e", ")", ";", "}", "else", "box", "=", "doCreateBeanBox", "(", "ctx", ",", "clazz", ")", ";", "ctx", ".", "beanBoxMetaCache", ".", "put", "(", "clazz", ",", "box", ")", ";", "return", "box", ";", "}" ]
Translate a BeanBox class or normal class to a readOnly BeanBox instance
[ "Translate", "a", "BeanBox", "class", "or", "normal", "class", "to", "a", "readOnly", "BeanBox", "instance" ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBoxUtils.java#L45-L62
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBoxUtils.java
BeanBoxUtils.getAnnotations
private static Annotation[] getAnnotations(Object targetClass) { if (targetClass instanceof Field) return ((Field) targetClass).getAnnotations(); else if (targetClass instanceof Method) return ((Method) targetClass).getAnnotations(); else if (targetClass instanceof Constructor) return ((Constructor<?>) targetClass).getAnnotations(); else if (targetClass instanceof Class) return ((Class<?>) targetClass).getAnnotations(); else return BeanBoxException.throwEX("targetClass should be Field, Method, Constructor or Class"); }
java
private static Annotation[] getAnnotations(Object targetClass) { if (targetClass instanceof Field) return ((Field) targetClass).getAnnotations(); else if (targetClass instanceof Method) return ((Method) targetClass).getAnnotations(); else if (targetClass instanceof Constructor) return ((Constructor<?>) targetClass).getAnnotations(); else if (targetClass instanceof Class) return ((Class<?>) targetClass).getAnnotations(); else return BeanBoxException.throwEX("targetClass should be Field, Method, Constructor or Class"); }
[ "private", "static", "Annotation", "[", "]", "getAnnotations", "(", "Object", "targetClass", ")", "{", "if", "(", "targetClass", "instanceof", "Field", ")", "return", "(", "(", "Field", ")", "targetClass", ")", ".", "getAnnotations", "(", ")", ";", "else", "if", "(", "targetClass", "instanceof", "Method", ")", "return", "(", "(", "Method", ")", "targetClass", ")", ".", "getAnnotations", "(", ")", ";", "else", "if", "(", "targetClass", "instanceof", "Constructor", ")", "return", "(", "(", "Constructor", "<", "?", ">", ")", "targetClass", ")", ".", "getAnnotations", "(", ")", ";", "else", "if", "(", "targetClass", "instanceof", "Class", ")", "return", "(", "(", "Class", "<", "?", ">", ")", "targetClass", ")", ".", "getAnnotations", "(", ")", ";", "else", "return", "BeanBoxException", ".", "throwEX", "(", "\"targetClass should be Field, Method, Constructor or Class\"", ")", ";", "}" ]
give a class or Field or Method, return annotations
[ "give", "a", "class", "or", "Field", "or", "Method", "return", "annotations" ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBoxUtils.java#L274-L285
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBoxUtils.java
BeanBoxUtils.getAnnoAsMap
private static Map<String, Object> getAnnoAsMap(Object targetClass, String annoFullName) { Annotation[] anno = getAnnotations(targetClass); for (Annotation a : anno) { Class<? extends Annotation> type = a.annotationType(); if (annoFullName.equals(type.getName())) return changeAnnotationValuesToMap(a); } return null; }
java
private static Map<String, Object> getAnnoAsMap(Object targetClass, String annoFullName) { Annotation[] anno = getAnnotations(targetClass); for (Annotation a : anno) { Class<? extends Annotation> type = a.annotationType(); if (annoFullName.equals(type.getName())) return changeAnnotationValuesToMap(a); } return null; }
[ "private", "static", "Map", "<", "String", ",", "Object", ">", "getAnnoAsMap", "(", "Object", "targetClass", ",", "String", "annoFullName", ")", "{", "Annotation", "[", "]", "anno", "=", "getAnnotations", "(", "targetClass", ")", ";", "for", "(", "Annotation", "a", ":", "anno", ")", "{", "Class", "<", "?", "extends", "Annotation", ">", "type", "=", "a", ".", "annotationType", "(", ")", ";", "if", "(", "annoFullName", ".", "equals", "(", "type", ".", "getName", "(", ")", ")", ")", "return", "changeAnnotationValuesToMap", "(", "a", ")", ";", "}", "return", "null", ";", "}" ]
Return all annotations for Class or Field
[ "Return", "all", "annotations", "for", "Class", "or", "Field" ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBoxUtils.java#L288-L296
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBoxUtils.java
BeanBoxUtils.checkAnnoExist
private static boolean checkAnnoExist(Object targetClass, Class<?> annoClass) { Annotation[] anno = getAnnotations(targetClass); for (Annotation annotation : anno) { Class<? extends Annotation> type = annotation.annotationType(); if (annoClass.equals(type)) return true; } return false; }
java
private static boolean checkAnnoExist(Object targetClass, Class<?> annoClass) { Annotation[] anno = getAnnotations(targetClass); for (Annotation annotation : anno) { Class<? extends Annotation> type = annotation.annotationType(); if (annoClass.equals(type)) return true; } return false; }
[ "private", "static", "boolean", "checkAnnoExist", "(", "Object", "targetClass", ",", "Class", "<", "?", ">", "annoClass", ")", "{", "Annotation", "[", "]", "anno", "=", "getAnnotations", "(", "targetClass", ")", ";", "for", "(", "Annotation", "annotation", ":", "anno", ")", "{", "Class", "<", "?", "extends", "Annotation", ">", "type", "=", "annotation", ".", "annotationType", "(", ")", ";", "if", "(", "annoClass", ".", "equals", "(", "type", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if annotation exist in Class or Field
[ "Check", "if", "annotation", "exist", "in", "Class", "or", "Field" ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBoxUtils.java#L299-L307
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBoxUtils.java
BeanBoxUtils.wrapParamToBox
protected static BeanBox wrapParamToBox(Object param) { if (param != null) { if (param instanceof Class) return new BeanBox().setTarget(param); if (param instanceof BeanBox) return (BeanBox) param; } return new BeanBox().setAsValue(param); }
java
protected static BeanBox wrapParamToBox(Object param) { if (param != null) { if (param instanceof Class) return new BeanBox().setTarget(param); if (param instanceof BeanBox) return (BeanBox) param; } return new BeanBox().setAsValue(param); }
[ "protected", "static", "BeanBox", "wrapParamToBox", "(", "Object", "param", ")", "{", "if", "(", "param", "!=", "null", ")", "{", "if", "(", "param", "instanceof", "Class", ")", "return", "new", "BeanBox", "(", ")", ".", "setTarget", "(", "param", ")", ";", "if", "(", "param", "instanceof", "BeanBox", ")", "return", "(", "BeanBox", ")", "param", ";", "}", "return", "new", "BeanBox", "(", ")", ".", "setAsValue", "(", "param", ")", ";", "}" ]
If param is class, wrap it to BeanBox, if param is BeanBox instance, direct return it, otherwise wrap it as pure Value BeanBox
[ "If", "param", "is", "class", "wrap", "it", "to", "BeanBox", "if", "param", "is", "BeanBox", "instance", "direct", "return", "it", "otherwise", "wrap", "it", "as", "pure", "Value", "BeanBox" ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/jbeanbox/BeanBoxUtils.java#L356-L364
train
teknux-org/jetty-bootstrap
jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/handler/util/AdditionalWebAppJettyConfigurationUtil.java
AdditionalWebAppJettyConfigurationUtil.addConfigurationClasses
public static String[] addConfigurationClasses(String[] configurationClasses, AdditionalWebAppJettyConfigurationClass[] optionalAdditionalsWebappConfigurationClasses) { List<String> newConfigurationClasses = new ArrayList<>(Arrays.asList(configurationClasses)); for (AdditionalWebAppJettyConfigurationClass additionalWebappConfigurationClass : optionalAdditionalsWebappConfigurationClasses) { if (additionalWebappConfigurationClass.getClasses() == null || additionalWebappConfigurationClass.getPosition() == null) { LOG.warn("Bad support class name"); } else { if (ClassUtil.classesExists(additionalWebappConfigurationClass.getClasses())) { int index = 0; if (additionalWebappConfigurationClass.getReferenceClass() == null) { if (additionalWebappConfigurationClass.getPosition() == Position.AFTER) { index = newConfigurationClasses.size(); } } else { index = newConfigurationClasses.indexOf(additionalWebappConfigurationClass.getReferenceClass()); if (index == -1) { if (additionalWebappConfigurationClass.getPosition() == Position.AFTER) { LOG.warn("[{}] reference unreachable, add at the end", additionalWebappConfigurationClass.getReferenceClass()); index = newConfigurationClasses.size(); } else { LOG.warn("[{}] reference unreachable, add at the top", additionalWebappConfigurationClass.getReferenceClass()); index = 0; } } else { if (additionalWebappConfigurationClass.getPosition() == Position.AFTER) { index++; } } } newConfigurationClasses.addAll(index, additionalWebappConfigurationClass.getClasses()); for (String className : additionalWebappConfigurationClass.getClasses()) { LOG.debug("[{}] support added", className); } } else { for (String className : additionalWebappConfigurationClass.getClasses()) { LOG.debug("[{}] not available", className); } } } } // List configurations for (String configurationClasse : newConfigurationClasses) { LOG.trace("Jetty WebAppContext Configuration => " + configurationClasse); } return newConfigurationClasses.toArray(new String[newConfigurationClasses.size()]); }
java
public static String[] addConfigurationClasses(String[] configurationClasses, AdditionalWebAppJettyConfigurationClass[] optionalAdditionalsWebappConfigurationClasses) { List<String> newConfigurationClasses = new ArrayList<>(Arrays.asList(configurationClasses)); for (AdditionalWebAppJettyConfigurationClass additionalWebappConfigurationClass : optionalAdditionalsWebappConfigurationClasses) { if (additionalWebappConfigurationClass.getClasses() == null || additionalWebappConfigurationClass.getPosition() == null) { LOG.warn("Bad support class name"); } else { if (ClassUtil.classesExists(additionalWebappConfigurationClass.getClasses())) { int index = 0; if (additionalWebappConfigurationClass.getReferenceClass() == null) { if (additionalWebappConfigurationClass.getPosition() == Position.AFTER) { index = newConfigurationClasses.size(); } } else { index = newConfigurationClasses.indexOf(additionalWebappConfigurationClass.getReferenceClass()); if (index == -1) { if (additionalWebappConfigurationClass.getPosition() == Position.AFTER) { LOG.warn("[{}] reference unreachable, add at the end", additionalWebappConfigurationClass.getReferenceClass()); index = newConfigurationClasses.size(); } else { LOG.warn("[{}] reference unreachable, add at the top", additionalWebappConfigurationClass.getReferenceClass()); index = 0; } } else { if (additionalWebappConfigurationClass.getPosition() == Position.AFTER) { index++; } } } newConfigurationClasses.addAll(index, additionalWebappConfigurationClass.getClasses()); for (String className : additionalWebappConfigurationClass.getClasses()) { LOG.debug("[{}] support added", className); } } else { for (String className : additionalWebappConfigurationClass.getClasses()) { LOG.debug("[{}] not available", className); } } } } // List configurations for (String configurationClasse : newConfigurationClasses) { LOG.trace("Jetty WebAppContext Configuration => " + configurationClasse); } return newConfigurationClasses.toArray(new String[newConfigurationClasses.size()]); }
[ "public", "static", "String", "[", "]", "addConfigurationClasses", "(", "String", "[", "]", "configurationClasses", ",", "AdditionalWebAppJettyConfigurationClass", "[", "]", "optionalAdditionalsWebappConfigurationClasses", ")", "{", "List", "<", "String", ">", "newConfigurationClasses", "=", "new", "ArrayList", "<>", "(", "Arrays", ".", "asList", "(", "configurationClasses", ")", ")", ";", "for", "(", "AdditionalWebAppJettyConfigurationClass", "additionalWebappConfigurationClass", ":", "optionalAdditionalsWebappConfigurationClasses", ")", "{", "if", "(", "additionalWebappConfigurationClass", ".", "getClasses", "(", ")", "==", "null", "||", "additionalWebappConfigurationClass", ".", "getPosition", "(", ")", "==", "null", ")", "{", "LOG", ".", "warn", "(", "\"Bad support class name\"", ")", ";", "}", "else", "{", "if", "(", "ClassUtil", ".", "classesExists", "(", "additionalWebappConfigurationClass", ".", "getClasses", "(", ")", ")", ")", "{", "int", "index", "=", "0", ";", "if", "(", "additionalWebappConfigurationClass", ".", "getReferenceClass", "(", ")", "==", "null", ")", "{", "if", "(", "additionalWebappConfigurationClass", ".", "getPosition", "(", ")", "==", "Position", ".", "AFTER", ")", "{", "index", "=", "newConfigurationClasses", ".", "size", "(", ")", ";", "}", "}", "else", "{", "index", "=", "newConfigurationClasses", ".", "indexOf", "(", "additionalWebappConfigurationClass", ".", "getReferenceClass", "(", ")", ")", ";", "if", "(", "index", "==", "-", "1", ")", "{", "if", "(", "additionalWebappConfigurationClass", ".", "getPosition", "(", ")", "==", "Position", ".", "AFTER", ")", "{", "LOG", ".", "warn", "(", "\"[{}] reference unreachable, add at the end\"", ",", "additionalWebappConfigurationClass", ".", "getReferenceClass", "(", ")", ")", ";", "index", "=", "newConfigurationClasses", ".", "size", "(", ")", ";", "}", "else", "{", "LOG", ".", "warn", "(", "\"[{}] reference unreachable, add at the top\"", ",", "additionalWebappConfigurationClass", ".", "getReferenceClass", "(", ")", ")", ";", "index", "=", "0", ";", "}", "}", "else", "{", "if", "(", "additionalWebappConfigurationClass", ".", "getPosition", "(", ")", "==", "Position", ".", "AFTER", ")", "{", "index", "++", ";", "}", "}", "}", "newConfigurationClasses", ".", "addAll", "(", "index", ",", "additionalWebappConfigurationClass", ".", "getClasses", "(", ")", ")", ";", "for", "(", "String", "className", ":", "additionalWebappConfigurationClass", ".", "getClasses", "(", ")", ")", "{", "LOG", ".", "debug", "(", "\"[{}] support added\"", ",", "className", ")", ";", "}", "}", "else", "{", "for", "(", "String", "className", ":", "additionalWebappConfigurationClass", ".", "getClasses", "(", ")", ")", "{", "LOG", ".", "debug", "(", "\"[{}] not available\"", ",", "className", ")", ";", "}", "}", "}", "}", "// List configurations", "for", "(", "String", "configurationClasse", ":", "newConfigurationClasses", ")", "{", "LOG", ".", "trace", "(", "\"Jetty WebAppContext Configuration => \"", "+", "configurationClasse", ")", ";", "}", "return", "newConfigurationClasses", ".", "toArray", "(", "new", "String", "[", "newConfigurationClasses", ".", "size", "(", ")", "]", ")", ";", "}" ]
Add the optionalAdditionalsWebappConfigurationClasses to the configurationClasses if available @param configurationClasses Class Name array @param optionalAdditionalsWebappConfigurationClasses Class Name array @return String[]
[ "Add", "the", "optionalAdditionalsWebappConfigurationClasses", "to", "the", "configurationClasses", "if", "available" ]
c16e710b833084c650fce35aa8c1ccaf83cd93ef
https://github.com/teknux-org/jetty-bootstrap/blob/c16e710b833084c650fce35aa8c1ccaf83cd93ef/jetty-bootstrap/src/main/java/org/teknux/jettybootstrap/handler/util/AdditionalWebAppJettyConfigurationUtil.java#L65-L116
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/GeneratorAdapter.java
GeneratorAdapter.catchException
public void catchException(final Label start, final Label end, final Type exception) { if (exception == null) { mv.visitTryCatchBlock(start, end, mark(), null); } else { mv.visitTryCatchBlock(start, end, mark(), exception.getInternalName()); } }
java
public void catchException(final Label start, final Label end, final Type exception) { if (exception == null) { mv.visitTryCatchBlock(start, end, mark(), null); } else { mv.visitTryCatchBlock(start, end, mark(), exception.getInternalName()); } }
[ "public", "void", "catchException", "(", "final", "Label", "start", ",", "final", "Label", "end", ",", "final", "Type", "exception", ")", "{", "if", "(", "exception", "==", "null", ")", "{", "mv", ".", "visitTryCatchBlock", "(", "start", ",", "end", ",", "mark", "(", ")", ",", "null", ")", ";", "}", "else", "{", "mv", ".", "visitTryCatchBlock", "(", "start", ",", "end", ",", "mark", "(", ")", ",", "exception", ".", "getInternalName", "(", ")", ")", ";", "}", "}" ]
Marks the start of an exception handler. @param start beginning of the exception handler's scope (inclusive). @param end end of the exception handler's scope (exclusive). @param exception internal name of the type of exceptions handled by the handler.
[ "Marks", "the", "start", "of", "an", "exception", "handler", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/GeneratorAdapter.java#L1619-L1627
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/cglib3_2_0/util/StringSwitcher.java
StringSwitcher.create
public static StringSwitcher create(String[] strings, int[] ints, boolean fixedInput) { Generator gen = new Generator(); gen.setStrings(strings); gen.setInts(ints); gen.setFixedInput(fixedInput); return gen.create(); }
java
public static StringSwitcher create(String[] strings, int[] ints, boolean fixedInput) { Generator gen = new Generator(); gen.setStrings(strings); gen.setInts(ints); gen.setFixedInput(fixedInput); return gen.create(); }
[ "public", "static", "StringSwitcher", "create", "(", "String", "[", "]", "strings", ",", "int", "[", "]", "ints", ",", "boolean", "fixedInput", ")", "{", "Generator", "gen", "=", "new", "Generator", "(", ")", ";", "gen", ".", "setStrings", "(", "strings", ")", ";", "gen", ".", "setInts", "(", "ints", ")", ";", "gen", ".", "setFixedInput", "(", "fixedInput", ")", ";", "return", "gen", ".", "create", "(", ")", ";", "}" ]
Helper method to create a StringSwitcher. For finer control over the generated instance, use a new instance of StringSwitcher.Generator instead of this static method. @param strings the array of String keys; must be the same length as the value array @param ints the array of integer results; must be the same length as the key array @param fixedInput if false, an unknown key will be returned from {@link #intValue} as <code>-1</code>; if true, the result will be undefined, and the resulting code will be faster
[ "Helper", "method", "to", "create", "a", "StringSwitcher", ".", "For", "finer", "control", "over", "the", "generated", "instance", "use", "a", "new", "instance", "of", "StringSwitcher", ".", "Generator", "instead", "of", "this", "static", "method", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/cglib3_2_0/util/StringSwitcher.java#L60-L66
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/cglib3_2_0/proxy/BridgeMethodResolver.java
BridgeMethodResolver.resolveAll
public Map/*<Signature, Signature>*/resolveAll() { Map resolved = new HashMap(); for (Iterator entryIter = declToBridge.entrySet().iterator(); entryIter.hasNext(); ) { Map.Entry entry = (Map.Entry)entryIter.next(); Class owner = (Class)entry.getKey(); Set bridges = (Set)entry.getValue(); try { new ClassReader(owner.getName()) .accept(new BridgedFinder(bridges, resolved), ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG); } catch(IOException ignored) {} } return resolved; }
java
public Map/*<Signature, Signature>*/resolveAll() { Map resolved = new HashMap(); for (Iterator entryIter = declToBridge.entrySet().iterator(); entryIter.hasNext(); ) { Map.Entry entry = (Map.Entry)entryIter.next(); Class owner = (Class)entry.getKey(); Set bridges = (Set)entry.getValue(); try { new ClassReader(owner.getName()) .accept(new BridgedFinder(bridges, resolved), ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG); } catch(IOException ignored) {} } return resolved; }
[ "public", "Map", "/*<Signature, Signature>*/", "resolveAll", "(", ")", "{", "Map", "resolved", "=", "new", "HashMap", "(", ")", ";", "for", "(", "Iterator", "entryIter", "=", "declToBridge", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "entryIter", ".", "hasNext", "(", ")", ";", ")", "{", "Map", ".", "Entry", "entry", "=", "(", "Map", ".", "Entry", ")", "entryIter", ".", "next", "(", ")", ";", "Class", "owner", "=", "(", "Class", ")", "entry", ".", "getKey", "(", ")", ";", "Set", "bridges", "=", "(", "Set", ")", "entry", ".", "getValue", "(", ")", ";", "try", "{", "new", "ClassReader", "(", "owner", ".", "getName", "(", ")", ")", ".", "accept", "(", "new", "BridgedFinder", "(", "bridges", ",", "resolved", ")", ",", "ClassReader", ".", "SKIP_FRAMES", "|", "ClassReader", ".", "SKIP_DEBUG", ")", ";", "}", "catch", "(", "IOException", "ignored", ")", "{", "}", "}", "return", "resolved", ";", "}" ]
Finds all bridge methods that are being called with invokespecial & returns them.
[ "Finds", "all", "bridge", "methods", "that", "are", "being", "called", "with", "invokespecial", "&", "returns", "them", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/cglib3_2_0/proxy/BridgeMethodResolver.java#L50-L63
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/FieldNode.java
FieldNode.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(); } } }
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(); } } }
[ "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", "(", ")", ";", "}", "}", "}" ]
Checks that this field 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", "field", "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/FieldNode.java#L253-L264
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/FieldNode.java
FieldNode.accept
public void accept(final ClassVisitor cv) { FieldVisitor fv = cv.visitField(access, name, desc, signature, value); if (fv == null) { return; } int i, n; n = visibleAnnotations == null ? 0 : visibleAnnotations.size(); for (i = 0; i < n; ++i) { AnnotationNode an = visibleAnnotations.get(i); an.accept(fv.visitAnnotation(an.desc, true)); } n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size(); for (i = 0; i < n; ++i) { AnnotationNode an = invisibleAnnotations.get(i); an.accept(fv.visitAnnotation(an.desc, false)); } n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size(); for (i = 0; i < n; ++i) { TypeAnnotationNode an = visibleTypeAnnotations.get(i); an.accept(fv.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(fv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, false)); } n = attrs == null ? 0 : attrs.size(); for (i = 0; i < n; ++i) { fv.visitAttribute(attrs.get(i)); } fv.visitEnd(); }
java
public void accept(final ClassVisitor cv) { FieldVisitor fv = cv.visitField(access, name, desc, signature, value); if (fv == null) { return; } int i, n; n = visibleAnnotations == null ? 0 : visibleAnnotations.size(); for (i = 0; i < n; ++i) { AnnotationNode an = visibleAnnotations.get(i); an.accept(fv.visitAnnotation(an.desc, true)); } n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size(); for (i = 0; i < n; ++i) { AnnotationNode an = invisibleAnnotations.get(i); an.accept(fv.visitAnnotation(an.desc, false)); } n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size(); for (i = 0; i < n; ++i) { TypeAnnotationNode an = visibleTypeAnnotations.get(i); an.accept(fv.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(fv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, false)); } n = attrs == null ? 0 : attrs.size(); for (i = 0; i < n; ++i) { fv.visitAttribute(attrs.get(i)); } fv.visitEnd(); }
[ "public", "void", "accept", "(", "final", "ClassVisitor", "cv", ")", "{", "FieldVisitor", "fv", "=", "cv", ".", "visitField", "(", "access", ",", "name", ",", "desc", ",", "signature", ",", "value", ")", ";", "if", "(", "fv", "==", "null", ")", "{", "return", ";", "}", "int", "i", ",", "n", ";", "n", "=", "visibleAnnotations", "==", "null", "?", "0", ":", "visibleAnnotations", ".", "size", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "n", ";", "++", "i", ")", "{", "AnnotationNode", "an", "=", "visibleAnnotations", ".", "get", "(", "i", ")", ";", "an", ".", "accept", "(", "fv", ".", "visitAnnotation", "(", "an", ".", "desc", ",", "true", ")", ")", ";", "}", "n", "=", "invisibleAnnotations", "==", "null", "?", "0", ":", "invisibleAnnotations", ".", "size", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "n", ";", "++", "i", ")", "{", "AnnotationNode", "an", "=", "invisibleAnnotations", ".", "get", "(", "i", ")", ";", "an", ".", "accept", "(", "fv", ".", "visitAnnotation", "(", "an", ".", "desc", ",", "false", ")", ")", ";", "}", "n", "=", "visibleTypeAnnotations", "==", "null", "?", "0", ":", "visibleTypeAnnotations", ".", "size", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "n", ";", "++", "i", ")", "{", "TypeAnnotationNode", "an", "=", "visibleTypeAnnotations", ".", "get", "(", "i", ")", ";", "an", ".", "accept", "(", "fv", ".", "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", "(", "fv", ".", "visitTypeAnnotation", "(", "an", ".", "typeRef", ",", "an", ".", "typePath", ",", "an", ".", "desc", ",", "false", ")", ")", ";", "}", "n", "=", "attrs", "==", "null", "?", "0", ":", "attrs", ".", "size", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "n", ";", "++", "i", ")", "{", "fv", ".", "visitAttribute", "(", "attrs", ".", "get", "(", "i", ")", ")", ";", "}", "fv", ".", "visitEnd", "(", ")", ";", "}" ]
Makes the given class visitor visit this field. @param cv a class visitor.
[ "Makes", "the", "given", "class", "visitor", "visit", "this", "field", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/tree/FieldNode.java#L272-L306
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/SerialVersionUIDAdder.java
SerialVersionUIDAdder.computeSVUID
protected long computeSVUID() throws IOException { ByteArrayOutputStream bos; DataOutputStream dos = null; long svuid = 0; try { bos = new ByteArrayOutputStream(); dos = new DataOutputStream(bos); /* * 1. The class name written using UTF encoding. */ dos.writeUTF(name.replace('/', '.')); /* * 2. The class modifiers written as a 32-bit integer. */ dos.writeInt(access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT)); /* * 3. The name of each interface sorted by name written using UTF * encoding. */ Arrays.sort(interfaces); for (int i = 0; i < interfaces.length; i++) { dos.writeUTF(interfaces[i].replace('/', '.')); } /* * 4. For each field of the class sorted by field name (except * private static and private transient fields): * * 1. The name of the field in UTF encoding. 2. The modifiers of the * field written as a 32-bit integer. 3. The descriptor of the field * in UTF encoding * * Note that field signatures are not dot separated. Method and * constructor signatures are dot separated. Go figure... */ writeItems(svuidFields, dos, false); /* * 5. If a class initializer exists, write out the following: 1. The * name of the method, <clinit>, in UTF encoding. 2. The modifier of * the method, java.lang.reflect.Modifier.STATIC, written as a * 32-bit integer. 3. The descriptor of the method, ()V, in UTF * encoding. */ if (hasStaticInitializer) { dos.writeUTF("<clinit>"); dos.writeInt(Opcodes.ACC_STATIC); dos.writeUTF("()V"); } // if.. /* * 6. For each non-private constructor sorted by method name and * signature: 1. The name of the method, <init>, in UTF encoding. 2. * The modifiers of the method written as a 32-bit integer. 3. The * descriptor of the method in UTF encoding. */ writeItems(svuidConstructors, dos, true); /* * 7. For each non-private method sorted by method name and * signature: 1. The name of the method in UTF encoding. 2. The * modifiers of the method written as a 32-bit integer. 3. The * descriptor of the method in UTF encoding. */ writeItems(svuidMethods, dos, true); dos.flush(); /* * 8. The SHA-1 algorithm is executed on the stream of bytes * produced by DataOutputStream and produces five 32-bit values * sha[0..4]. */ byte[] hashBytes = computeSHAdigest(bos.toByteArray()); /* * 9. The hash value is assembled from the first and second 32-bit * values of the SHA-1 message digest. If the result of the message * digest, the five 32-bit words H0 H1 H2 H3 H4, is in an array of * five int values named sha, the hash value would be computed as * follows: * * long hash = ((sha[0] >>> 24) & 0xFF) | ((sha[0] >>> 16) & 0xFF) * << 8 | ((sha[0] >>> 8) & 0xFF) << 16 | ((sha[0] >>> 0) & 0xFF) << * 24 | ((sha[1] >>> 24) & 0xFF) << 32 | ((sha[1] >>> 16) & 0xFF) << * 40 | ((sha[1] >>> 8) & 0xFF) << 48 | ((sha[1] >>> 0) & 0xFF) << * 56; */ for (int i = Math.min(hashBytes.length, 8) - 1; i >= 0; i--) { svuid = (svuid << 8) | (hashBytes[i] & 0xFF); } } finally { // close the stream (if open) if (dos != null) { dos.close(); } } return svuid; }
java
protected long computeSVUID() throws IOException { ByteArrayOutputStream bos; DataOutputStream dos = null; long svuid = 0; try { bos = new ByteArrayOutputStream(); dos = new DataOutputStream(bos); /* * 1. The class name written using UTF encoding. */ dos.writeUTF(name.replace('/', '.')); /* * 2. The class modifiers written as a 32-bit integer. */ dos.writeInt(access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT)); /* * 3. The name of each interface sorted by name written using UTF * encoding. */ Arrays.sort(interfaces); for (int i = 0; i < interfaces.length; i++) { dos.writeUTF(interfaces[i].replace('/', '.')); } /* * 4. For each field of the class sorted by field name (except * private static and private transient fields): * * 1. The name of the field in UTF encoding. 2. The modifiers of the * field written as a 32-bit integer. 3. The descriptor of the field * in UTF encoding * * Note that field signatures are not dot separated. Method and * constructor signatures are dot separated. Go figure... */ writeItems(svuidFields, dos, false); /* * 5. If a class initializer exists, write out the following: 1. The * name of the method, <clinit>, in UTF encoding. 2. The modifier of * the method, java.lang.reflect.Modifier.STATIC, written as a * 32-bit integer. 3. The descriptor of the method, ()V, in UTF * encoding. */ if (hasStaticInitializer) { dos.writeUTF("<clinit>"); dos.writeInt(Opcodes.ACC_STATIC); dos.writeUTF("()V"); } // if.. /* * 6. For each non-private constructor sorted by method name and * signature: 1. The name of the method, <init>, in UTF encoding. 2. * The modifiers of the method written as a 32-bit integer. 3. The * descriptor of the method in UTF encoding. */ writeItems(svuidConstructors, dos, true); /* * 7. For each non-private method sorted by method name and * signature: 1. The name of the method in UTF encoding. 2. The * modifiers of the method written as a 32-bit integer. 3. The * descriptor of the method in UTF encoding. */ writeItems(svuidMethods, dos, true); dos.flush(); /* * 8. The SHA-1 algorithm is executed on the stream of bytes * produced by DataOutputStream and produces five 32-bit values * sha[0..4]. */ byte[] hashBytes = computeSHAdigest(bos.toByteArray()); /* * 9. The hash value is assembled from the first and second 32-bit * values of the SHA-1 message digest. If the result of the message * digest, the five 32-bit words H0 H1 H2 H3 H4, is in an array of * five int values named sha, the hash value would be computed as * follows: * * long hash = ((sha[0] >>> 24) & 0xFF) | ((sha[0] >>> 16) & 0xFF) * << 8 | ((sha[0] >>> 8) & 0xFF) << 16 | ((sha[0] >>> 0) & 0xFF) << * 24 | ((sha[1] >>> 24) & 0xFF) << 32 | ((sha[1] >>> 16) & 0xFF) << * 40 | ((sha[1] >>> 8) & 0xFF) << 48 | ((sha[1] >>> 0) & 0xFF) << * 56; */ for (int i = Math.min(hashBytes.length, 8) - 1; i >= 0; i--) { svuid = (svuid << 8) | (hashBytes[i] & 0xFF); } } finally { // close the stream (if open) if (dos != null) { dos.close(); } } return svuid; }
[ "protected", "long", "computeSVUID", "(", ")", "throws", "IOException", "{", "ByteArrayOutputStream", "bos", ";", "DataOutputStream", "dos", "=", "null", ";", "long", "svuid", "=", "0", ";", "try", "{", "bos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "dos", "=", "new", "DataOutputStream", "(", "bos", ")", ";", "/*\n * 1. The class name written using UTF encoding.\n */", "dos", ".", "writeUTF", "(", "name", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ")", ";", "/*\n * 2. The class modifiers written as a 32-bit integer.\n */", "dos", ".", "writeInt", "(", "access", "&", "(", "Opcodes", ".", "ACC_PUBLIC", "|", "Opcodes", ".", "ACC_FINAL", "|", "Opcodes", ".", "ACC_INTERFACE", "|", "Opcodes", ".", "ACC_ABSTRACT", ")", ")", ";", "/*\n * 3. The name of each interface sorted by name written using UTF\n * encoding.\n */", "Arrays", ".", "sort", "(", "interfaces", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "interfaces", ".", "length", ";", "i", "++", ")", "{", "dos", ".", "writeUTF", "(", "interfaces", "[", "i", "]", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ")", ";", "}", "/*\n * 4. For each field of the class sorted by field name (except\n * private static and private transient fields):\n * \n * 1. The name of the field in UTF encoding. 2. The modifiers of the\n * field written as a 32-bit integer. 3. The descriptor of the field\n * in UTF encoding\n * \n * Note that field signatures are not dot separated. Method and\n * constructor signatures are dot separated. Go figure...\n */", "writeItems", "(", "svuidFields", ",", "dos", ",", "false", ")", ";", "/*\n * 5. If a class initializer exists, write out the following: 1. The\n * name of the method, <clinit>, in UTF encoding. 2. The modifier of\n * the method, java.lang.reflect.Modifier.STATIC, written as a\n * 32-bit integer. 3. The descriptor of the method, ()V, in UTF\n * encoding.\n */", "if", "(", "hasStaticInitializer", ")", "{", "dos", ".", "writeUTF", "(", "\"<clinit>\"", ")", ";", "dos", ".", "writeInt", "(", "Opcodes", ".", "ACC_STATIC", ")", ";", "dos", ".", "writeUTF", "(", "\"()V\"", ")", ";", "}", "// if..", "/*\n * 6. For each non-private constructor sorted by method name and\n * signature: 1. The name of the method, <init>, in UTF encoding. 2.\n * The modifiers of the method written as a 32-bit integer. 3. The\n * descriptor of the method in UTF encoding.\n */", "writeItems", "(", "svuidConstructors", ",", "dos", ",", "true", ")", ";", "/*\n * 7. For each non-private method sorted by method name and\n * signature: 1. The name of the method in UTF encoding. 2. The\n * modifiers of the method written as a 32-bit integer. 3. The\n * descriptor of the method in UTF encoding.\n */", "writeItems", "(", "svuidMethods", ",", "dos", ",", "true", ")", ";", "dos", ".", "flush", "(", ")", ";", "/*\n * 8. The SHA-1 algorithm is executed on the stream of bytes\n * produced by DataOutputStream and produces five 32-bit values\n * sha[0..4].\n */", "byte", "[", "]", "hashBytes", "=", "computeSHAdigest", "(", "bos", ".", "toByteArray", "(", ")", ")", ";", "/*\n * 9. The hash value is assembled from the first and second 32-bit\n * values of the SHA-1 message digest. If the result of the message\n * digest, the five 32-bit words H0 H1 H2 H3 H4, is in an array of\n * five int values named sha, the hash value would be computed as\n * follows:\n * \n * long hash = ((sha[0] >>> 24) & 0xFF) | ((sha[0] >>> 16) & 0xFF)\n * << 8 | ((sha[0] >>> 8) & 0xFF) << 16 | ((sha[0] >>> 0) & 0xFF) <<\n * 24 | ((sha[1] >>> 24) & 0xFF) << 32 | ((sha[1] >>> 16) & 0xFF) <<\n * 40 | ((sha[1] >>> 8) & 0xFF) << 48 | ((sha[1] >>> 0) & 0xFF) <<\n * 56;\n */", "for", "(", "int", "i", "=", "Math", ".", "min", "(", "hashBytes", ".", "length", ",", "8", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "svuid", "=", "(", "svuid", "<<", "8", ")", "|", "(", "hashBytes", "[", "i", "]", "&", "0xFF", ")", ";", "}", "}", "finally", "{", "// close the stream (if open)", "if", "(", "dos", "!=", "null", ")", "{", "dos", ".", "close", "(", ")", ";", "}", "}", "return", "svuid", ";", "}" ]
Computes and returns the value of SVUID. @return Returns the serial version UID @throws IOException if an I/O error occurs
[ "Computes", "and", "returns", "the", "value", "of", "SVUID", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/SerialVersionUIDAdder.java#L354-L459
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/SerialVersionUIDAdder.java
SerialVersionUIDAdder.computeSHAdigest
protected byte[] computeSHAdigest(final byte[] value) { try { return MessageDigest.getInstance("SHA").digest(value); } catch (Exception e) { throw new UnsupportedOperationException(e.toString()); } }
java
protected byte[] computeSHAdigest(final byte[] value) { try { return MessageDigest.getInstance("SHA").digest(value); } catch (Exception e) { throw new UnsupportedOperationException(e.toString()); } }
[ "protected", "byte", "[", "]", "computeSHAdigest", "(", "final", "byte", "[", "]", "value", ")", "{", "try", "{", "return", "MessageDigest", ".", "getInstance", "(", "\"SHA\"", ")", ".", "digest", "(", "value", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "e", ".", "toString", "(", ")", ")", ";", "}", "}" ]
Returns the SHA-1 message digest of the given value. @param value the value whose SHA message digest must be computed. @return the SHA-1 message digest of the given value.
[ "Returns", "the", "SHA", "-", "1", "message", "digest", "of", "the", "given", "value", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/SerialVersionUIDAdder.java#L468-L474
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/SerialVersionUIDAdder.java
SerialVersionUIDAdder.writeItems
private static void writeItems(final Collection<Item> itemCollection, final DataOutput dos, final boolean dotted) throws IOException { int size = itemCollection.size(); Item[] items = itemCollection.toArray(new Item[size]); Arrays.sort(items); for (int i = 0; i < size; i++) { dos.writeUTF(items[i].name); dos.writeInt(items[i].access); dos.writeUTF(dotted ? items[i].desc.replace('/', '.') : items[i].desc); } }
java
private static void writeItems(final Collection<Item> itemCollection, final DataOutput dos, final boolean dotted) throws IOException { int size = itemCollection.size(); Item[] items = itemCollection.toArray(new Item[size]); Arrays.sort(items); for (int i = 0; i < size; i++) { dos.writeUTF(items[i].name); dos.writeInt(items[i].access); dos.writeUTF(dotted ? items[i].desc.replace('/', '.') : items[i].desc); } }
[ "private", "static", "void", "writeItems", "(", "final", "Collection", "<", "Item", ">", "itemCollection", ",", "final", "DataOutput", "dos", ",", "final", "boolean", "dotted", ")", "throws", "IOException", "{", "int", "size", "=", "itemCollection", ".", "size", "(", ")", ";", "Item", "[", "]", "items", "=", "itemCollection", ".", "toArray", "(", "new", "Item", "[", "size", "]", ")", ";", "Arrays", ".", "sort", "(", "items", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "dos", ".", "writeUTF", "(", "items", "[", "i", "]", ".", "name", ")", ";", "dos", ".", "writeInt", "(", "items", "[", "i", "]", ".", "access", ")", ";", "dos", ".", "writeUTF", "(", "dotted", "?", "items", "[", "i", "]", ".", "desc", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ":", "items", "[", "i", "]", ".", "desc", ")", ";", "}", "}" ]
Sorts the items in the collection and writes it to the data output stream @param itemCollection collection of items @param dos a <code>DataOutputStream</code> value @param dotted a <code>boolean</code> value @exception IOException if an error occurs
[ "Sorts", "the", "items", "in", "the", "collection", "and", "writes", "it", "to", "the", "data", "output", "stream" ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/SerialVersionUIDAdder.java#L488-L499
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.status
public VacuumStatus status() throws CommandExecutionException { JSONArray resp = sendToArray("get_status"); JSONObject stat = resp.optJSONObject(0); if (stat == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); return new VacuumStatus(stat); }
java
public VacuumStatus status() throws CommandExecutionException { JSONArray resp = sendToArray("get_status"); JSONObject stat = resp.optJSONObject(0); if (stat == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); return new VacuumStatus(stat); }
[ "public", "VacuumStatus", "status", "(", ")", "throws", "CommandExecutionException", "{", "JSONArray", "resp", "=", "sendToArray", "(", "\"get_status\"", ")", ";", "JSONObject", "stat", "=", "resp", ".", "optJSONObject", "(", "0", ")", ";", "if", "(", "stat", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_RESPONSE", ")", ";", "return", "new", "VacuumStatus", "(", "stat", ")", ";", "}" ]
Get the vacuums status. @return The vacuums status. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Get", "the", "vacuums", "status", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L49-L54
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.getTimezone
public TimeZone getTimezone() throws CommandExecutionException { JSONArray resp = sendToArray("get_timezone"); String zone = resp.optString(0, null); if (zone == null ) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); return TimeZone.getTimeZone(zone); }
java
public TimeZone getTimezone() throws CommandExecutionException { JSONArray resp = sendToArray("get_timezone"); String zone = resp.optString(0, null); if (zone == null ) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); return TimeZone.getTimeZone(zone); }
[ "public", "TimeZone", "getTimezone", "(", ")", "throws", "CommandExecutionException", "{", "JSONArray", "resp", "=", "sendToArray", "(", "\"get_timezone\"", ")", ";", "String", "zone", "=", "resp", ".", "optString", "(", "0", ",", "null", ")", ";", "if", "(", "zone", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_RESPONSE", ")", ";", "return", "TimeZone", ".", "getTimeZone", "(", "zone", ")", ";", "}" ]
Get the vacuums current timezone. @return The current timezone. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Get", "the", "vacuums", "current", "timezone", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L61-L66
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.setTimezone
public boolean setTimezone(TimeZone zone) throws CommandExecutionException { if (zone == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONArray tz = new JSONArray(); tz.put(zone.getID()); return sendOk("set_timezone", tz); }
java
public boolean setTimezone(TimeZone zone) throws CommandExecutionException { if (zone == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONArray tz = new JSONArray(); tz.put(zone.getID()); return sendOk("set_timezone", tz); }
[ "public", "boolean", "setTimezone", "(", "TimeZone", "zone", ")", "throws", "CommandExecutionException", "{", "if", "(", "zone", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_PARAMETERS", ")", ";", "JSONArray", "tz", "=", "new", "JSONArray", "(", ")", ";", "tz", ".", "put", "(", "zone", ".", "getID", "(", ")", ")", ";", "return", "sendOk", "(", "\"set_timezone\"", ",", "tz", ")", ";", "}" ]
Set the vacuums timezone @param zone The new timezone to set. @return True if the command has been received successfully. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Set", "the", "vacuums", "timezone" ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L74-L79
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.consumableStatus
public VacuumConsumableStatus consumableStatus() throws CommandExecutionException { JSONArray resp = sendToArray("get_consumable"); JSONObject stat = resp.optJSONObject(0); if (stat == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); return new VacuumConsumableStatus(stat); }
java
public VacuumConsumableStatus consumableStatus() throws CommandExecutionException { JSONArray resp = sendToArray("get_consumable"); JSONObject stat = resp.optJSONObject(0); if (stat == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); return new VacuumConsumableStatus(stat); }
[ "public", "VacuumConsumableStatus", "consumableStatus", "(", ")", "throws", "CommandExecutionException", "{", "JSONArray", "resp", "=", "sendToArray", "(", "\"get_consumable\"", ")", ";", "JSONObject", "stat", "=", "resp", ".", "optJSONObject", "(", "0", ")", ";", "if", "(", "stat", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_RESPONSE", ")", ";", "return", "new", "VacuumConsumableStatus", "(", "stat", ")", ";", "}" ]
Get the vacuums consumables status. @return The consumables status. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Get", "the", "vacuums", "consumables", "status", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L86-L91
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.resetConsumable
public boolean resetConsumable(VacuumConsumableStatus.Names consumable) throws CommandExecutionException { if (consumable == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONArray params = new JSONArray(); params.put(consumable.toString()); return sendOk("reset_consumable", params); }
java
public boolean resetConsumable(VacuumConsumableStatus.Names consumable) throws CommandExecutionException { if (consumable == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONArray params = new JSONArray(); params.put(consumable.toString()); return sendOk("reset_consumable", params); }
[ "public", "boolean", "resetConsumable", "(", "VacuumConsumableStatus", ".", "Names", "consumable", ")", "throws", "CommandExecutionException", "{", "if", "(", "consumable", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_PARAMETERS", ")", ";", "JSONArray", "params", "=", "new", "JSONArray", "(", ")", ";", "params", ".", "put", "(", "consumable", ".", "toString", "(", ")", ")", ";", "return", "sendOk", "(", "\"reset_consumable\"", ",", "params", ")", ";", "}" ]
Reset a vacuums consumable. @param consumable The consumable to reset @return True if the consumable has been reset. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Reset", "a", "vacuums", "consumable", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L99-L104
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.getFanSpeed
public int getFanSpeed() throws CommandExecutionException { int resp = sendToArray("get_custom_mode").optInt(0, -1); if ((resp < 0) || (resp > 100)) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); return resp; }
java
public int getFanSpeed() throws CommandExecutionException { int resp = sendToArray("get_custom_mode").optInt(0, -1); if ((resp < 0) || (resp > 100)) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); return resp; }
[ "public", "int", "getFanSpeed", "(", ")", "throws", "CommandExecutionException", "{", "int", "resp", "=", "sendToArray", "(", "\"get_custom_mode\"", ")", ".", "optInt", "(", "0", ",", "-", "1", ")", ";", "if", "(", "(", "resp", "<", "0", ")", "||", "(", "resp", ">", "100", ")", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_RESPONSE", ")", ";", "return", "resp", ";", "}" ]
Get the vacuums current fan speed setting. @return The fan speed. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Get", "the", "vacuums", "current", "fan", "speed", "setting", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L166-L170
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.setFanSpeed
public boolean setFanSpeed(int speed) throws CommandExecutionException { if (speed < 0 || speed > 100) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONArray params = new JSONArray(); params.put(speed); return sendOk("set_custom_mode", params); }
java
public boolean setFanSpeed(int speed) throws CommandExecutionException { if (speed < 0 || speed > 100) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONArray params = new JSONArray(); params.put(speed); return sendOk("set_custom_mode", params); }
[ "public", "boolean", "setFanSpeed", "(", "int", "speed", ")", "throws", "CommandExecutionException", "{", "if", "(", "speed", "<", "0", "||", "speed", ">", "100", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_PARAMETERS", ")", ";", "JSONArray", "params", "=", "new", "JSONArray", "(", ")", ";", "params", ".", "put", "(", "speed", ")", ";", "return", "sendOk", "(", "\"set_custom_mode\"", ",", "params", ")", ";", "}" ]
Set the vacuums fan speed setting. @param speed The new speed to set. @return True if the command has been received correctly. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Set", "the", "vacuums", "fan", "speed", "setting", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L178-L183
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.getTimers
public VacuumTimer[] getTimers() throws CommandExecutionException { JSONArray tm = sendToArray("get_timer"); if (tm == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); VacuumTimer[] timers = new VacuumTimer[tm.length()]; for (int i = 0; i < tm.length(); i++){ timers[i] = new VacuumTimer(tm.optJSONArray(i)); } return timers; }
java
public VacuumTimer[] getTimers() throws CommandExecutionException { JSONArray tm = sendToArray("get_timer"); if (tm == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); VacuumTimer[] timers = new VacuumTimer[tm.length()]; for (int i = 0; i < tm.length(); i++){ timers[i] = new VacuumTimer(tm.optJSONArray(i)); } return timers; }
[ "public", "VacuumTimer", "[", "]", "getTimers", "(", ")", "throws", "CommandExecutionException", "{", "JSONArray", "tm", "=", "sendToArray", "(", "\"get_timer\"", ")", ";", "if", "(", "tm", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_RESPONSE", ")", ";", "VacuumTimer", "[", "]", "timers", "=", "new", "VacuumTimer", "[", "tm", ".", "length", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "tm", ".", "length", "(", ")", ";", "i", "++", ")", "{", "timers", "[", "i", "]", "=", "new", "VacuumTimer", "(", "tm", ".", "optJSONArray", "(", "i", ")", ")", ";", "}", "return", "timers", ";", "}" ]
Get all stored scheduled cleanups. @return An array with all timers. Is empty if no timer has been set on the device. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Get", "all", "stored", "scheduled", "cleanups", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L190-L198
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.addTimer
public boolean addTimer(VacuumTimer timer) throws CommandExecutionException { if (timer == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONArray tm = timer.construct(); if (tm == null) return false; JSONArray payload = new JSONArray(); payload.put(tm); return sendOk("set_timer", payload); }
java
public boolean addTimer(VacuumTimer timer) throws CommandExecutionException { if (timer == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONArray tm = timer.construct(); if (tm == null) return false; JSONArray payload = new JSONArray(); payload.put(tm); return sendOk("set_timer", payload); }
[ "public", "boolean", "addTimer", "(", "VacuumTimer", "timer", ")", "throws", "CommandExecutionException", "{", "if", "(", "timer", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_PARAMETERS", ")", ";", "JSONArray", "tm", "=", "timer", ".", "construct", "(", ")", ";", "if", "(", "tm", "==", "null", ")", "return", "false", ";", "JSONArray", "payload", "=", "new", "JSONArray", "(", ")", ";", "payload", ".", "put", "(", "tm", ")", ";", "return", "sendOk", "(", "\"set_timer\"", ",", "payload", ")", ";", "}" ]
Add a new scheduled cleanup. @param timer The new timer to set. @return True if the command was received successfully. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Add", "a", "new", "scheduled", "cleanup", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L206-L213
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.setTimerEnabled
public boolean setTimerEnabled(VacuumTimer timer) throws CommandExecutionException { if (timer == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONArray payload = new JSONArray(); payload.put(timer.getID()); payload.put(timer.getOnOff()); return sendOk("upd_timer", payload); }
java
public boolean setTimerEnabled(VacuumTimer timer) throws CommandExecutionException { if (timer == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONArray payload = new JSONArray(); payload.put(timer.getID()); payload.put(timer.getOnOff()); return sendOk("upd_timer", payload); }
[ "public", "boolean", "setTimerEnabled", "(", "VacuumTimer", "timer", ")", "throws", "CommandExecutionException", "{", "if", "(", "timer", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_PARAMETERS", ")", ";", "JSONArray", "payload", "=", "new", "JSONArray", "(", ")", ";", "payload", ".", "put", "(", "timer", ".", "getID", "(", ")", ")", ";", "payload", ".", "put", "(", "timer", ".", "getOnOff", "(", ")", ")", ";", "return", "sendOk", "(", "\"upd_timer\"", ",", "payload", ")", ";", "}" ]
Enable or disable a scheduled cleanup. @param timer The timer to update. @return True if the command was received successfully. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Enable", "or", "disable", "a", "scheduled", "cleanup", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L221-L227
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.removeTimer
public boolean removeTimer(VacuumTimer timer) throws CommandExecutionException { if (timer == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONArray payload = new JSONArray(); payload.put(timer.getID()); return sendOk("del_timer", payload); }
java
public boolean removeTimer(VacuumTimer timer) throws CommandExecutionException { if (timer == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONArray payload = new JSONArray(); payload.put(timer.getID()); return sendOk("del_timer", payload); }
[ "public", "boolean", "removeTimer", "(", "VacuumTimer", "timer", ")", "throws", "CommandExecutionException", "{", "if", "(", "timer", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_PARAMETERS", ")", ";", "JSONArray", "payload", "=", "new", "JSONArray", "(", ")", ";", "payload", ".", "put", "(", "timer", ".", "getID", "(", ")", ")", ";", "return", "sendOk", "(", "\"del_timer\"", ",", "payload", ")", ";", "}" ]
Delete a scheduled cleanup. @param timer The timer to remove. @return True if the command was received successfully. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Delete", "a", "scheduled", "cleanup", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L235-L240
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.setDoNotDisturb
public boolean setDoNotDisturb(VacuumDoNotDisturb dnd) throws CommandExecutionException { if (dnd == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); return sendOk("set_dnd_timer", dnd.construct()); }
java
public boolean setDoNotDisturb(VacuumDoNotDisturb dnd) throws CommandExecutionException { if (dnd == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); return sendOk("set_dnd_timer", dnd.construct()); }
[ "public", "boolean", "setDoNotDisturb", "(", "VacuumDoNotDisturb", "dnd", ")", "throws", "CommandExecutionException", "{", "if", "(", "dnd", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_PARAMETERS", ")", ";", "return", "sendOk", "(", "\"set_dnd_timer\"", ",", "dnd", ".", "construct", "(", ")", ")", ";", "}" ]
Set the do not disturb timer. @param dnd The new settings to set. @return True if the command was received successfully. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Set", "the", "do", "not", "disturb", "timer", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L257-L260
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.goTo
public boolean goTo(int[] p) throws CommandExecutionException { if (p == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); if (p.length != 2) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONArray payload = new JSONArray(); payload.put(p[0]); payload.put(p[1]); return sendOk("app_goto_target" , payload); }
java
public boolean goTo(int[] p) throws CommandExecutionException { if (p == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); if (p.length != 2) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONArray payload = new JSONArray(); payload.put(p[0]); payload.put(p[1]); return sendOk("app_goto_target" , payload); }
[ "public", "boolean", "goTo", "(", "int", "[", "]", "p", ")", "throws", "CommandExecutionException", "{", "if", "(", "p", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_PARAMETERS", ")", ";", "if", "(", "p", ".", "length", "!=", "2", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_PARAMETERS", ")", ";", "JSONArray", "payload", "=", "new", "JSONArray", "(", ")", ";", "payload", ".", "put", "(", "p", "[", "0", "]", ")", ";", "payload", ".", "put", "(", "p", "[", "1", "]", ")", ";", "return", "sendOk", "(", "\"app_goto_target\"", ",", "payload", ")", ";", "}" ]
Go to the specified position on the map. @param p The position to move to in millimeters. 25600 millimeter both in x and y is the center of the map. The origin of the map is 0 millimeters in x and y. @return True if the command has been received correctly. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Go", "to", "the", "specified", "position", "on", "the", "map", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L301-L308
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.getAllCleanups
public VacuumCleanup[] getAllCleanups() throws CommandExecutionException { JSONArray cleanupIDs = getCleaningSummary().optJSONArray(3); if (cleanupIDs == null) return null; VacuumCleanup[] res = new VacuumCleanup[cleanupIDs.length()]; for (int i = 0; i < cleanupIDs.length(); i++){ JSONArray send = new JSONArray(); send.put(cleanupIDs.optLong(i)); JSONArray ar = sendToArray("get_clean_record", send).optJSONArray(0); res[i] = new VacuumCleanup(ar); } return res; }
java
public VacuumCleanup[] getAllCleanups() throws CommandExecutionException { JSONArray cleanupIDs = getCleaningSummary().optJSONArray(3); if (cleanupIDs == null) return null; VacuumCleanup[] res = new VacuumCleanup[cleanupIDs.length()]; for (int i = 0; i < cleanupIDs.length(); i++){ JSONArray send = new JSONArray(); send.put(cleanupIDs.optLong(i)); JSONArray ar = sendToArray("get_clean_record", send).optJSONArray(0); res[i] = new VacuumCleanup(ar); } return res; }
[ "public", "VacuumCleanup", "[", "]", "getAllCleanups", "(", ")", "throws", "CommandExecutionException", "{", "JSONArray", "cleanupIDs", "=", "getCleaningSummary", "(", ")", ".", "optJSONArray", "(", "3", ")", ";", "if", "(", "cleanupIDs", "==", "null", ")", "return", "null", ";", "VacuumCleanup", "[", "]", "res", "=", "new", "VacuumCleanup", "[", "cleanupIDs", ".", "length", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cleanupIDs", ".", "length", "(", ")", ";", "i", "++", ")", "{", "JSONArray", "send", "=", "new", "JSONArray", "(", ")", ";", "send", ".", "put", "(", "cleanupIDs", ".", "optLong", "(", "i", ")", ")", ";", "JSONArray", "ar", "=", "sendToArray", "(", "\"get_clean_record\"", ",", "send", ")", ".", "optJSONArray", "(", "0", ")", ";", "res", "[", "i", "]", "=", "new", "VacuumCleanup", "(", "ar", ")", ";", "}", "return", "res", ";", "}" ]
Get an array with the details of all cleanups. @return An array with the details of all cleanups. Empty if no cleanups were performed. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Get", "an", "array", "with", "the", "details", "of", "all", "cleanups", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L414-L425
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.getSoundVolume
public int getSoundVolume() throws CommandExecutionException { JSONArray res = sendToArray("get_sound_volume"); if (res == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); int vol = res.optInt(0, -1); if (vol < 0) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); return vol; }
java
public int getSoundVolume() throws CommandExecutionException { JSONArray res = sendToArray("get_sound_volume"); if (res == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); int vol = res.optInt(0, -1); if (vol < 0) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE); return vol; }
[ "public", "int", "getSoundVolume", "(", ")", "throws", "CommandExecutionException", "{", "JSONArray", "res", "=", "sendToArray", "(", "\"get_sound_volume\"", ")", ";", "if", "(", "res", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_RESPONSE", ")", ";", "int", "vol", "=", "res", ".", "optInt", "(", "0", ",", "-", "1", ")", ";", "if", "(", "vol", "<", "0", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_RESPONSE", ")", ";", "return", "vol", ";", "}" ]
Get the current volume. @return The current set volume of the device between 0 and 100. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Get", "the", "current", "volume", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L432-L438
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.setSoundVolume
public boolean setSoundVolume(int volume) throws CommandExecutionException { if (volume < 0) volume = 0; if (volume > 100) volume = 100; JSONArray payload = new JSONArray(); payload.put(volume); return sendOk("change_sound_volume", payload); }
java
public boolean setSoundVolume(int volume) throws CommandExecutionException { if (volume < 0) volume = 0; if (volume > 100) volume = 100; JSONArray payload = new JSONArray(); payload.put(volume); return sendOk("change_sound_volume", payload); }
[ "public", "boolean", "setSoundVolume", "(", "int", "volume", ")", "throws", "CommandExecutionException", "{", "if", "(", "volume", "<", "0", ")", "volume", "=", "0", ";", "if", "(", "volume", ">", "100", ")", "volume", "=", "100", ";", "JSONArray", "payload", "=", "new", "JSONArray", "(", ")", ";", "payload", ".", "put", "(", "volume", ")", ";", "return", "sendOk", "(", "\"change_sound_volume\"", ",", "payload", ")", ";", "}" ]
Set the vacuums volume. @param volume The volume between 0 and 100. @return True if the command was received successfully. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Set", "the", "vacuums", "volume", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L446-L452
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.manualControlMove
public boolean manualControlMove(float rotationSpeed, float speed, int runDuration) throws CommandExecutionException { if (manualControlSequence < 1) manualControlStart(); JSONObject payload = new JSONObject(); if (rotationSpeed > 180.0f) rotationSpeed = 180.0f; if (rotationSpeed < -180.0f) rotationSpeed = -180.0f; float rotationRadians = Math.round((rotationSpeed / 180.0f) * 272.0d) / 100.0f; //Found out after LOADS of tests. payload.put("omega", rotationRadians); if (speed >= 0.3f) speed = 0.29f; if (speed <= -0.3f) speed = -0.29f; payload.put("velocity", speed); if (runDuration < 0) runDuration = 1000; payload.put("duration", runDuration); payload.put("seqnum", manualControlSequence); manualControlSequence++; JSONArray send = new JSONArray(); send.put(payload); return sendOk("app_rc_move", send); }
java
public boolean manualControlMove(float rotationSpeed, float speed, int runDuration) throws CommandExecutionException { if (manualControlSequence < 1) manualControlStart(); JSONObject payload = new JSONObject(); if (rotationSpeed > 180.0f) rotationSpeed = 180.0f; if (rotationSpeed < -180.0f) rotationSpeed = -180.0f; float rotationRadians = Math.round((rotationSpeed / 180.0f) * 272.0d) / 100.0f; //Found out after LOADS of tests. payload.put("omega", rotationRadians); if (speed >= 0.3f) speed = 0.29f; if (speed <= -0.3f) speed = -0.29f; payload.put("velocity", speed); if (runDuration < 0) runDuration = 1000; payload.put("duration", runDuration); payload.put("seqnum", manualControlSequence); manualControlSequence++; JSONArray send = new JSONArray(); send.put(payload); return sendOk("app_rc_move", send); }
[ "public", "boolean", "manualControlMove", "(", "float", "rotationSpeed", ",", "float", "speed", ",", "int", "runDuration", ")", "throws", "CommandExecutionException", "{", "if", "(", "manualControlSequence", "<", "1", ")", "manualControlStart", "(", ")", ";", "JSONObject", "payload", "=", "new", "JSONObject", "(", ")", ";", "if", "(", "rotationSpeed", ">", "180.0f", ")", "rotationSpeed", "=", "180.0f", ";", "if", "(", "rotationSpeed", "<", "-", "180.0f", ")", "rotationSpeed", "=", "-", "180.0f", ";", "float", "rotationRadians", "=", "Math", ".", "round", "(", "(", "rotationSpeed", "/", "180.0f", ")", "*", "272.0d", ")", "/", "100.0f", ";", "//Found out after LOADS of tests.", "payload", ".", "put", "(", "\"omega\"", ",", "rotationRadians", ")", ";", "if", "(", "speed", ">=", "0.3f", ")", "speed", "=", "0.29f", ";", "if", "(", "speed", "<=", "-", "0.3f", ")", "speed", "=", "-", "0.29f", ";", "payload", ".", "put", "(", "\"velocity\"", ",", "speed", ")", ";", "if", "(", "runDuration", "<", "0", ")", "runDuration", "=", "1000", ";", "payload", ".", "put", "(", "\"duration\"", ",", "runDuration", ")", ";", "payload", ".", "put", "(", "\"seqnum\"", ",", "manualControlSequence", ")", ";", "manualControlSequence", "++", ";", "JSONArray", "send", "=", "new", "JSONArray", "(", ")", ";", "send", ".", "put", "(", "payload", ")", ";", "return", "sendOk", "(", "\"app_rc_move\"", ",", "send", ")", ";", "}" ]
Manually control the robot @param rotationSpeed The speed of rotation in deg/s. @param speed The speed of the robot in m/s. Must be greater then -0.3 and less then 0.3. @param runDuration The time to run the command in ms. Values less than 0 will be replaced by a default value of 1000ms. @return True if the command has been received correctly. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Manually", "control", "the", "robot" ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L490-L507
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.installSoundpack
public VacuumSounpackInstallState installSoundpack(String url, String md5, int soundId) throws CommandExecutionException { if (url == null || md5 == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONObject install = new JSONObject(); install.put("url", url); install.put("md5", md5); install.put("sid", soundId); JSONArray ret = sendToArray("dnld_install_sound", install); if (ret == null) return null; return new VacuumSounpackInstallState(ret.optJSONObject(0)); }
java
public VacuumSounpackInstallState installSoundpack(String url, String md5, int soundId) throws CommandExecutionException { if (url == null || md5 == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS); JSONObject install = new JSONObject(); install.put("url", url); install.put("md5", md5); install.put("sid", soundId); JSONArray ret = sendToArray("dnld_install_sound", install); if (ret == null) return null; return new VacuumSounpackInstallState(ret.optJSONObject(0)); }
[ "public", "VacuumSounpackInstallState", "installSoundpack", "(", "String", "url", ",", "String", "md5", ",", "int", "soundId", ")", "throws", "CommandExecutionException", "{", "if", "(", "url", "==", "null", "||", "md5", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "CommandExecutionException", ".", "Error", ".", "INVALID_PARAMETERS", ")", ";", "JSONObject", "install", "=", "new", "JSONObject", "(", ")", ";", "install", ".", "put", "(", "\"url\"", ",", "url", ")", ";", "install", ".", "put", "(", "\"md5\"", ",", "md5", ")", ";", "install", ".", "put", "(", "\"sid\"", ",", "soundId", ")", ";", "JSONArray", "ret", "=", "sendToArray", "(", "\"dnld_install_sound\"", ",", "install", ")", ";", "if", "(", "ret", "==", "null", ")", "return", "null", ";", "return", "new", "VacuumSounpackInstallState", "(", "ret", ".", "optJSONObject", "(", "0", ")", ")", ";", "}" ]
Install a new soundpack to the device. @param url The url the soundpack should be downloaded from. @param md5 The md5 checksum of the new soundpack. @param soundId The ID of the soundpacks language. @return The current installation status. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Install", "a", "new", "soundpack", "to", "the", "device", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L517-L526
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.soundpackInstallStatus
public VacuumSounpackInstallState soundpackInstallStatus() throws CommandExecutionException { JSONArray ret = sendToArray("get_sound_progress"); if (ret == null) return null; return new VacuumSounpackInstallState(ret.optJSONObject(0)); }
java
public VacuumSounpackInstallState soundpackInstallStatus() throws CommandExecutionException { JSONArray ret = sendToArray("get_sound_progress"); if (ret == null) return null; return new VacuumSounpackInstallState(ret.optJSONObject(0)); }
[ "public", "VacuumSounpackInstallState", "soundpackInstallStatus", "(", ")", "throws", "CommandExecutionException", "{", "JSONArray", "ret", "=", "sendToArray", "(", "\"get_sound_progress\"", ")", ";", "if", "(", "ret", "==", "null", ")", "return", "null", ";", "return", "new", "VacuumSounpackInstallState", "(", "ret", ".", "optJSONObject", "(", "0", ")", ")", ";", "}" ]
Get the current soundpack installation status. @return The current soundpack installation status. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Get", "the", "current", "soundpack", "installation", "status", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L533-L537
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.getCarpetModeState
public JSONObject getCarpetModeState() throws CommandExecutionException { JSONArray ret = sendToArray("get_carpet_mode"); if (ret == null) return null; return ret.optJSONObject(0); }
java
public JSONObject getCarpetModeState() throws CommandExecutionException { JSONArray ret = sendToArray("get_carpet_mode"); if (ret == null) return null; return ret.optJSONObject(0); }
[ "public", "JSONObject", "getCarpetModeState", "(", ")", "throws", "CommandExecutionException", "{", "JSONArray", "ret", "=", "sendToArray", "(", "\"get_carpet_mode\"", ")", ";", "if", "(", "ret", "==", "null", ")", "return", "null", ";", "return", "ret", ".", "optJSONObject", "(", "0", ")", ";", "}" ]
Get the current carpet cleaning settings. @return The current carpet cleaning settings. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Get", "the", "current", "carpet", "cleaning", "settings", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L544-L548
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.setCarpetMode
public boolean setCarpetMode(boolean enabled, int high, int low, int integral, int stallTime) throws CommandExecutionException { JSONObject payload = new JSONObject(); payload.put("enable", enabled ? 1:0); payload.put("current_high", high); payload.put("current_low", low); payload.put("current_integral", integral); payload.put("stall_time", stallTime); JSONArray send = new JSONArray(); send.put(payload); return sendOk("set_carpet_mode", send); }
java
public boolean setCarpetMode(boolean enabled, int high, int low, int integral, int stallTime) throws CommandExecutionException { JSONObject payload = new JSONObject(); payload.put("enable", enabled ? 1:0); payload.put("current_high", high); payload.put("current_low", low); payload.put("current_integral", integral); payload.put("stall_time", stallTime); JSONArray send = new JSONArray(); send.put(payload); return sendOk("set_carpet_mode", send); }
[ "public", "boolean", "setCarpetMode", "(", "boolean", "enabled", ",", "int", "high", ",", "int", "low", ",", "int", "integral", ",", "int", "stallTime", ")", "throws", "CommandExecutionException", "{", "JSONObject", "payload", "=", "new", "JSONObject", "(", ")", ";", "payload", ".", "put", "(", "\"enable\"", ",", "enabled", "?", "1", ":", "0", ")", ";", "payload", ".", "put", "(", "\"current_high\"", ",", "high", ")", ";", "payload", ".", "put", "(", "\"current_low\"", ",", "low", ")", ";", "payload", ".", "put", "(", "\"current_integral\"", ",", "integral", ")", ";", "payload", ".", "put", "(", "\"stall_time\"", ",", "stallTime", ")", ";", "JSONArray", "send", "=", "new", "JSONArray", "(", ")", ";", "send", ".", "put", "(", "payload", ")", ";", "return", "sendOk", "(", "\"set_carpet_mode\"", ",", "send", ")", ";", "}" ]
Change the carped cleaning settings. @param enabled Weather the carped cleanup mode should be enabled. @param high The high parameter of the carped cleanup. @param low The low parameter of the carped cleanup. @param integral The integral parameter of the carped cleanup. @param stallTime The stall time parameter of the carped cleanup. @return True if the command has been received successfully. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Change", "the", "carped", "cleaning", "settings", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L560-L570
train
SG-O/miIO
src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java
Vacuum.getSerialnumber
public String getSerialnumber() throws CommandExecutionException { JSONArray ret = sendToArray("get_serial_number"); if (ret == null) return null; return ret.optJSONObject(0).optString("serial_number"); }
java
public String getSerialnumber() throws CommandExecutionException { JSONArray ret = sendToArray("get_serial_number"); if (ret == null) return null; return ret.optJSONObject(0).optString("serial_number"); }
[ "public", "String", "getSerialnumber", "(", ")", "throws", "CommandExecutionException", "{", "JSONArray", "ret", "=", "sendToArray", "(", "\"get_serial_number\"", ")", ";", "if", "(", "ret", "==", "null", ")", "return", "null", ";", "return", "ret", ".", "optJSONObject", "(", "0", ")", ".", "optString", "(", "\"serial_number\"", ")", ";", "}" ]
Get the vacuums serial number. @return The vacuums serial number. @throws CommandExecutionException When there has been a error during the communication or the response was invalid.
[ "Get", "the", "vacuums", "serial", "number", "." ]
f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b
https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L577-L581
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/LocalVariablesSorter.java
LocalVariablesSorter.newLocal
public int newLocal(final Type type) { Object t; switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: case Type.INT: t = Opcodes.INTEGER; break; case Type.FLOAT: t = Opcodes.FLOAT; break; case Type.LONG: t = Opcodes.LONG; break; case Type.DOUBLE: t = Opcodes.DOUBLE; break; case Type.ARRAY: t = type.getDescriptor(); break; // case Type.OBJECT: default: t = type.getInternalName(); break; } int local = newLocalMapping(type); setLocalType(local, type); setFrameLocal(local, t); changed = true; return local; }
java
public int newLocal(final Type type) { Object t; switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: case Type.INT: t = Opcodes.INTEGER; break; case Type.FLOAT: t = Opcodes.FLOAT; break; case Type.LONG: t = Opcodes.LONG; break; case Type.DOUBLE: t = Opcodes.DOUBLE; break; case Type.ARRAY: t = type.getDescriptor(); break; // case Type.OBJECT: default: t = type.getInternalName(); break; } int local = newLocalMapping(type); setLocalType(local, type); setFrameLocal(local, t); changed = true; return local; }
[ "public", "int", "newLocal", "(", "final", "Type", "type", ")", "{", "Object", "t", ";", "switch", "(", "type", ".", "getSort", "(", ")", ")", "{", "case", "Type", ".", "BOOLEAN", ":", "case", "Type", ".", "CHAR", ":", "case", "Type", ".", "BYTE", ":", "case", "Type", ".", "SHORT", ":", "case", "Type", ".", "INT", ":", "t", "=", "Opcodes", ".", "INTEGER", ";", "break", ";", "case", "Type", ".", "FLOAT", ":", "t", "=", "Opcodes", ".", "FLOAT", ";", "break", ";", "case", "Type", ".", "LONG", ":", "t", "=", "Opcodes", ".", "LONG", ";", "break", ";", "case", "Type", ".", "DOUBLE", ":", "t", "=", "Opcodes", ".", "DOUBLE", ";", "break", ";", "case", "Type", ".", "ARRAY", ":", "t", "=", "type", ".", "getDescriptor", "(", ")", ";", "break", ";", "// case Type.OBJECT:", "default", ":", "t", "=", "type", ".", "getInternalName", "(", ")", ";", "break", ";", "}", "int", "local", "=", "newLocalMapping", "(", "type", ")", ";", "setLocalType", "(", "local", ",", "type", ")", ";", "setFrameLocal", "(", "local", ",", "t", ")", ";", "changed", "=", "true", ";", "return", "local", ";", "}" ]
Creates a new local variable of the given type. @param type the type of the local variable to be created. @return the identifier of the newly created local variable.
[ "Creates", "a", "new", "local", "variable", "of", "the", "given", "type", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/commons/LocalVariablesSorter.java#L272-L304
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/parsers/FighterParser.java
FighterParser.getFights
private List<Fight> getFights(Elements trs, Fighter fighter) throws ArrayIndexOutOfBoundsException { List<Fight> fights = new ArrayList<>(); logger.info("{} TRs to parse through", trs.size()); SherdogBaseObject sFighter = new SherdogBaseObject(); sFighter.setName(fighter.getName()); sFighter.setSherdogUrl(fighter.getSherdogUrl()); // removing header row... if (trs.size() > 0) { trs.remove(0); trs.forEach(tr -> { Fight fight = new Fight(); fight.setFighter1(sFighter); Elements tds = tr.select("td"); fight.setResult(getFightResult(tds.get(COLUMN_RESULT))); fight.setFighter2(getOpponent(tds.get(COLUMN_OPPONENT))); fight.setEvent(getEvent(tds.get(COLUMN_EVENT))); fight.setDate(getDate(tds.get(COLUMN_EVENT))); fight.setWinMethod(getWinMethod(tds.get(COLUMN_METHOD))); fight.setWinRound(getWinRound(tds.get(COLUMN_ROUND))); fight.setWinTime(getWinTime(tds.get(COLUMN_TIME))); fights.add(fight); logger.info("{}", fight); }); } return fights; }
java
private List<Fight> getFights(Elements trs, Fighter fighter) throws ArrayIndexOutOfBoundsException { List<Fight> fights = new ArrayList<>(); logger.info("{} TRs to parse through", trs.size()); SherdogBaseObject sFighter = new SherdogBaseObject(); sFighter.setName(fighter.getName()); sFighter.setSherdogUrl(fighter.getSherdogUrl()); // removing header row... if (trs.size() > 0) { trs.remove(0); trs.forEach(tr -> { Fight fight = new Fight(); fight.setFighter1(sFighter); Elements tds = tr.select("td"); fight.setResult(getFightResult(tds.get(COLUMN_RESULT))); fight.setFighter2(getOpponent(tds.get(COLUMN_OPPONENT))); fight.setEvent(getEvent(tds.get(COLUMN_EVENT))); fight.setDate(getDate(tds.get(COLUMN_EVENT))); fight.setWinMethod(getWinMethod(tds.get(COLUMN_METHOD))); fight.setWinRound(getWinRound(tds.get(COLUMN_ROUND))); fight.setWinTime(getWinTime(tds.get(COLUMN_TIME))); fights.add(fight); logger.info("{}", fight); }); } return fights; }
[ "private", "List", "<", "Fight", ">", "getFights", "(", "Elements", "trs", ",", "Fighter", "fighter", ")", "throws", "ArrayIndexOutOfBoundsException", "{", "List", "<", "Fight", ">", "fights", "=", "new", "ArrayList", "<>", "(", ")", ";", "logger", ".", "info", "(", "\"{} TRs to parse through\"", ",", "trs", ".", "size", "(", ")", ")", ";", "SherdogBaseObject", "sFighter", "=", "new", "SherdogBaseObject", "(", ")", ";", "sFighter", ".", "setName", "(", "fighter", ".", "getName", "(", ")", ")", ";", "sFighter", ".", "setSherdogUrl", "(", "fighter", ".", "getSherdogUrl", "(", ")", ")", ";", "// removing header row...", "if", "(", "trs", ".", "size", "(", ")", ">", "0", ")", "{", "trs", ".", "remove", "(", "0", ")", ";", "trs", ".", "forEach", "(", "tr", "->", "{", "Fight", "fight", "=", "new", "Fight", "(", ")", ";", "fight", ".", "setFighter1", "(", "sFighter", ")", ";", "Elements", "tds", "=", "tr", ".", "select", "(", "\"td\"", ")", ";", "fight", ".", "setResult", "(", "getFightResult", "(", "tds", ".", "get", "(", "COLUMN_RESULT", ")", ")", ")", ";", "fight", ".", "setFighter2", "(", "getOpponent", "(", "tds", ".", "get", "(", "COLUMN_OPPONENT", ")", ")", ")", ";", "fight", ".", "setEvent", "(", "getEvent", "(", "tds", ".", "get", "(", "COLUMN_EVENT", ")", ")", ")", ";", "fight", ".", "setDate", "(", "getDate", "(", "tds", ".", "get", "(", "COLUMN_EVENT", ")", ")", ")", ";", "fight", ".", "setWinMethod", "(", "getWinMethod", "(", "tds", ".", "get", "(", "COLUMN_METHOD", ")", ")", ")", ";", "fight", ".", "setWinRound", "(", "getWinRound", "(", "tds", ".", "get", "(", "COLUMN_ROUND", ")", ")", ")", ";", "fight", ".", "setWinTime", "(", "getWinTime", "(", "tds", ".", "get", "(", "COLUMN_TIME", ")", ")", ")", ";", "fights", ".", "add", "(", "fight", ")", ";", "logger", ".", "info", "(", "\"{}\"", ",", "fight", ")", ";", "}", ")", ";", "}", "return", "fights", ";", "}" ]
Get a fighter fights @param trs JSOUP TRs document @param fighter a fighter to parse against
[ "Get", "a", "fighter", "fights" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/parsers/FighterParser.java#L256-L289
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/parsers/FighterParser.java
FighterParser.getOpponent
private SherdogBaseObject getOpponent(Element td) { SherdogBaseObject opponent = new SherdogBaseObject(); Element opponentLink = td.select("a").get(0); opponent.setName(opponentLink.html()); opponent.setSherdogUrl(opponentLink.attr("abs:href")); return opponent; }
java
private SherdogBaseObject getOpponent(Element td) { SherdogBaseObject opponent = new SherdogBaseObject(); Element opponentLink = td.select("a").get(0); opponent.setName(opponentLink.html()); opponent.setSherdogUrl(opponentLink.attr("abs:href")); return opponent; }
[ "private", "SherdogBaseObject", "getOpponent", "(", "Element", "td", ")", "{", "SherdogBaseObject", "opponent", "=", "new", "SherdogBaseObject", "(", ")", ";", "Element", "opponentLink", "=", "td", ".", "select", "(", "\"a\"", ")", ".", "get", "(", "0", ")", ";", "opponent", ".", "setName", "(", "opponentLink", ".", "html", "(", ")", ")", ";", "opponent", ".", "setSherdogUrl", "(", "opponentLink", ".", "attr", "(", "\"abs:href\"", ")", ")", ";", "return", "opponent", ";", "}" ]
Get the fight result @param td a td from sherdogs table @return a fight result enum
[ "Get", "the", "fight", "result" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/parsers/FighterParser.java#L309-L316
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/parsers/FighterParser.java
FighterParser.getEvent
private SherdogBaseObject getEvent(Element td) { Element link = td.select("a").get(0); SherdogBaseObject event = new SherdogBaseObject(); event.setName(link.html().replaceAll("<span itemprop=\"award\">|</span>", "")); event.setSherdogUrl(link.attr("abs:href")); return event; }
java
private SherdogBaseObject getEvent(Element td) { Element link = td.select("a").get(0); SherdogBaseObject event = new SherdogBaseObject(); event.setName(link.html().replaceAll("<span itemprop=\"award\">|</span>", "")); event.setSherdogUrl(link.attr("abs:href")); return event; }
[ "private", "SherdogBaseObject", "getEvent", "(", "Element", "td", ")", "{", "Element", "link", "=", "td", ".", "select", "(", "\"a\"", ")", ".", "get", "(", "0", ")", ";", "SherdogBaseObject", "event", "=", "new", "SherdogBaseObject", "(", ")", ";", "event", ".", "setName", "(", "link", ".", "html", "(", ")", ".", "replaceAll", "(", "\"<span itemprop=\\\"award\\\">|</span>\"", ",", "\"\"", ")", ")", ";", "event", ".", "setSherdogUrl", "(", "link", ".", "attr", "(", "\"abs:href\"", ")", ")", ";", "return", "event", ";", "}" ]
Get the fight event @param td a td from sherdogs table @return a sherdog base object with url and name
[ "Get", "the", "fight", "event" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/parsers/FighterParser.java#L325-L334
train
lamarios/sherdog-parser
src/main/java/com/ftpix/sherdogparser/parsers/FighterParser.java
FighterParser.getDate
private ZonedDateTime getDate(Element td) { //date Element date = td.select("span.sub_line").first(); return ParserUtils.getDateFromStringToZoneId(date.html(), ZONE_ID, DateTimeFormatter.ofPattern("MMM / dd / yyyy", Locale.US)); }
java
private ZonedDateTime getDate(Element td) { //date Element date = td.select("span.sub_line").first(); return ParserUtils.getDateFromStringToZoneId(date.html(), ZONE_ID, DateTimeFormatter.ofPattern("MMM / dd / yyyy", Locale.US)); }
[ "private", "ZonedDateTime", "getDate", "(", "Element", "td", ")", "{", "//date", "Element", "date", "=", "td", ".", "select", "(", "\"span.sub_line\"", ")", ".", "first", "(", ")", ";", "return", "ParserUtils", ".", "getDateFromStringToZoneId", "(", "date", ".", "html", "(", ")", ",", "ZONE_ID", ",", "DateTimeFormatter", ".", "ofPattern", "(", "\"MMM / dd / yyyy\"", ",", "Locale", ".", "US", ")", ")", ";", "}" ]
Get the date of the fight @param td a td from sherdogs table @return the zonedatetime of the fight
[ "Get", "the", "date", "of", "the", "fight" ]
7cdb36280317caeaaa54db77c04dc4b4e1db053e
https://github.com/lamarios/sherdog-parser/blob/7cdb36280317caeaaa54db77c04dc4b4e1db053e/src/main/java/com/ftpix/sherdogparser/parsers/FighterParser.java#L342-L347
train
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/signature/SignatureReader.java
SignatureReader.parseType
private static int parseType(final String signature, int pos, final SignatureVisitor v) { char c; int start, end; boolean visited, inner; String name; switch (c = signature.charAt(pos++)) { case 'Z': case 'C': case 'B': case 'S': case 'I': case 'F': case 'J': case 'D': case 'V': v.visitBaseType(c); return pos; case '[': return parseType(signature, pos, v.visitArrayType()); case 'T': end = signature.indexOf(';', pos); v.visitTypeVariable(signature.substring(pos, end)); return end + 1; default: // case 'L': start = pos; visited = false; inner = false; for (;;) { switch (c = signature.charAt(pos++)) { case '.': case ';': if (!visited) { name = signature.substring(start, pos - 1); if (inner) { v.visitInnerClassType(name); } else { v.visitClassType(name); } } if (c == ';') { v.visitEnd(); return pos; } start = pos; visited = false; inner = true; break; case '<': name = signature.substring(start, pos - 1); if (inner) { v.visitInnerClassType(name); } else { v.visitClassType(name); } visited = true; top: for (;;) { switch (c = signature.charAt(pos)) { case '>': break top; case '*': ++pos; v.visitTypeArgument(); break; case '+': case '-': pos = parseType(signature, pos + 1, v.visitTypeArgument(c)); break; default: pos = parseType(signature, pos, v.visitTypeArgument('=')); break; } } } } } }
java
private static int parseType(final String signature, int pos, final SignatureVisitor v) { char c; int start, end; boolean visited, inner; String name; switch (c = signature.charAt(pos++)) { case 'Z': case 'C': case 'B': case 'S': case 'I': case 'F': case 'J': case 'D': case 'V': v.visitBaseType(c); return pos; case '[': return parseType(signature, pos, v.visitArrayType()); case 'T': end = signature.indexOf(';', pos); v.visitTypeVariable(signature.substring(pos, end)); return end + 1; default: // case 'L': start = pos; visited = false; inner = false; for (;;) { switch (c = signature.charAt(pos++)) { case '.': case ';': if (!visited) { name = signature.substring(start, pos - 1); if (inner) { v.visitInnerClassType(name); } else { v.visitClassType(name); } } if (c == ';') { v.visitEnd(); return pos; } start = pos; visited = false; inner = true; break; case '<': name = signature.substring(start, pos - 1); if (inner) { v.visitInnerClassType(name); } else { v.visitClassType(name); } visited = true; top: for (;;) { switch (c = signature.charAt(pos)) { case '>': break top; case '*': ++pos; v.visitTypeArgument(); break; case '+': case '-': pos = parseType(signature, pos + 1, v.visitTypeArgument(c)); break; default: pos = parseType(signature, pos, v.visitTypeArgument('=')); break; } } } } } }
[ "private", "static", "int", "parseType", "(", "final", "String", "signature", ",", "int", "pos", ",", "final", "SignatureVisitor", "v", ")", "{", "char", "c", ";", "int", "start", ",", "end", ";", "boolean", "visited", ",", "inner", ";", "String", "name", ";", "switch", "(", "c", "=", "signature", ".", "charAt", "(", "pos", "++", ")", ")", "{", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "v", ".", "visitBaseType", "(", "c", ")", ";", "return", "pos", ";", "case", "'", "'", ":", "return", "parseType", "(", "signature", ",", "pos", ",", "v", ".", "visitArrayType", "(", ")", ")", ";", "case", "'", "'", ":", "end", "=", "signature", ".", "indexOf", "(", "'", "'", ",", "pos", ")", ";", "v", ".", "visitTypeVariable", "(", "signature", ".", "substring", "(", "pos", ",", "end", ")", ")", ";", "return", "end", "+", "1", ";", "default", ":", "// case 'L':", "start", "=", "pos", ";", "visited", "=", "false", ";", "inner", "=", "false", ";", "for", "(", ";", ";", ")", "{", "switch", "(", "c", "=", "signature", ".", "charAt", "(", "pos", "++", ")", ")", "{", "case", "'", "'", ":", "case", "'", "'", ":", "if", "(", "!", "visited", ")", "{", "name", "=", "signature", ".", "substring", "(", "start", ",", "pos", "-", "1", ")", ";", "if", "(", "inner", ")", "{", "v", ".", "visitInnerClassType", "(", "name", ")", ";", "}", "else", "{", "v", ".", "visitClassType", "(", "name", ")", ";", "}", "}", "if", "(", "c", "==", "'", "'", ")", "{", "v", ".", "visitEnd", "(", ")", ";", "return", "pos", ";", "}", "start", "=", "pos", ";", "visited", "=", "false", ";", "inner", "=", "true", ";", "break", ";", "case", "'", "'", ":", "name", "=", "signature", ".", "substring", "(", "start", ",", "pos", "-", "1", ")", ";", "if", "(", "inner", ")", "{", "v", ".", "visitInnerClassType", "(", "name", ")", ";", "}", "else", "{", "v", ".", "visitClassType", "(", "name", ")", ";", "}", "visited", "=", "true", ";", "top", ":", "for", "(", ";", ";", ")", "{", "switch", "(", "c", "=", "signature", ".", "charAt", "(", "pos", ")", ")", "{", "case", "'", "'", ":", "break", "top", ";", "case", "'", "'", ":", "++", "pos", ";", "v", ".", "visitTypeArgument", "(", ")", ";", "break", ";", "case", "'", "'", ":", "case", "'", "'", ":", "pos", "=", "parseType", "(", "signature", ",", "pos", "+", "1", ",", "v", ".", "visitTypeArgument", "(", "c", ")", ")", ";", "break", ";", "default", ":", "pos", "=", "parseType", "(", "signature", ",", "pos", ",", "v", ".", "visitTypeArgument", "(", "'", "'", ")", ")", ";", "break", ";", "}", "}", "}", "}", "}", "}" ]
Parses a field type signature and makes the given visitor visit it. @param signature a string containing the signature that must be parsed. @param pos index of the first character of the signature to parsed. @param v the visitor that must visit this signature. @return the index of the first character after the parsed signature.
[ "Parses", "a", "field", "type", "signature", "and", "makes", "the", "given", "visitor", "visit", "it", "." ]
01c216599ffa2e5f2d9c01df2adaad0f45567c04
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/signature/SignatureReader.java#L144-L227
train
payneteasy/superfly
superfly-web/src/main/java/com/payneteasy/superfly/web/wicket/repeater/IndexedSortableDataProvider.java
IndexedSortableDataProvider.getSortFieldIndex
protected int getSortFieldIndex() { SortParam sp = getSort(); Integer index = fieldNameToIndex.get(sp.getProperty()); if (index == null) { index = 1; } return index; }
java
protected int getSortFieldIndex() { SortParam sp = getSort(); Integer index = fieldNameToIndex.get(sp.getProperty()); if (index == null) { index = 1; } return index; }
[ "protected", "int", "getSortFieldIndex", "(", ")", "{", "SortParam", "sp", "=", "getSort", "(", ")", ";", "Integer", "index", "=", "fieldNameToIndex", ".", "get", "(", "sp", ".", "getProperty", "(", ")", ")", ";", "if", "(", "index", "==", "null", ")", "{", "index", "=", "1", ";", "}", "return", "index", ";", "}" ]
Returns an index of the currently selected sort field. @return field index (beginning with 1) or 1 if not found in mapping
[ "Returns", "an", "index", "of", "the", "currently", "selected", "sort", "field", "." ]
4cad6d0f8e951a61f3c302c49b13a51d179076f8
https://github.com/payneteasy/superfly/blob/4cad6d0f8e951a61f3c302c49b13a51d179076f8/superfly-web/src/main/java/com/payneteasy/superfly/web/wicket/repeater/IndexedSortableDataProvider.java#L51-L58
train
deephacks/confit
core/src/main/java/org/deephacks/confit/internal/core/config/DefaultBeanManager.java
DefaultBeanManager.getBeanToValidate
@Override public Map<BeanId, Bean> getBeanToValidate(Collection<Bean> beans) throws AbortRuntimeException { Map<BeanId, Bean> beansToValidate = new HashMap<>(); for (Bean bean : beans) { Map<BeanId, Bean> predecessors = new HashMap<>(); // beans read from xml storage will only have their basic properties initialized... // ... but we also need set the direct references/predecessors for beans to validate Map<BeanId, Bean> beansToValidateSubset = getDirectSuccessors(bean); beansToValidateSubset.put(bean.getId(), bean); for (Bean toValidate : beansToValidateSubset.values()) { predecessors.putAll(getDirectPredecessors(toValidate)); } for (Bean predecessor : predecessors.values()) { for (BeanId ref : predecessor.getReferences()) { Bean b = storage.get(ref); if (b == null) { throw CFG301_MISSING_RUNTIME_REF(predecessor.getId()); } ref.setBean(b); } } for (Bean toValidate : beansToValidateSubset.values()) { // list references of beansToValidate should now // be available in predecessors. for (BeanId ref : toValidate.getReferences()) { Bean predecessor = predecessors.get(ref); if (predecessor == null) { throw new IllegalStateException("Bug in algorithm. Reference [" + ref + "] of [" + toValidate.getId() + "] should be available in predecessors."); } ref.setBean(predecessor); } } beansToValidate.putAll(predecessors); } return beansToValidate; }
java
@Override public Map<BeanId, Bean> getBeanToValidate(Collection<Bean> beans) throws AbortRuntimeException { Map<BeanId, Bean> beansToValidate = new HashMap<>(); for (Bean bean : beans) { Map<BeanId, Bean> predecessors = new HashMap<>(); // beans read from xml storage will only have their basic properties initialized... // ... but we also need set the direct references/predecessors for beans to validate Map<BeanId, Bean> beansToValidateSubset = getDirectSuccessors(bean); beansToValidateSubset.put(bean.getId(), bean); for (Bean toValidate : beansToValidateSubset.values()) { predecessors.putAll(getDirectPredecessors(toValidate)); } for (Bean predecessor : predecessors.values()) { for (BeanId ref : predecessor.getReferences()) { Bean b = storage.get(ref); if (b == null) { throw CFG301_MISSING_RUNTIME_REF(predecessor.getId()); } ref.setBean(b); } } for (Bean toValidate : beansToValidateSubset.values()) { // list references of beansToValidate should now // be available in predecessors. for (BeanId ref : toValidate.getReferences()) { Bean predecessor = predecessors.get(ref); if (predecessor == null) { throw new IllegalStateException("Bug in algorithm. Reference [" + ref + "] of [" + toValidate.getId() + "] should be available in predecessors."); } ref.setBean(predecessor); } } beansToValidate.putAll(predecessors); } return beansToValidate; }
[ "@", "Override", "public", "Map", "<", "BeanId", ",", "Bean", ">", "getBeanToValidate", "(", "Collection", "<", "Bean", ">", "beans", ")", "throws", "AbortRuntimeException", "{", "Map", "<", "BeanId", ",", "Bean", ">", "beansToValidate", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "Bean", "bean", ":", "beans", ")", "{", "Map", "<", "BeanId", ",", "Bean", ">", "predecessors", "=", "new", "HashMap", "<>", "(", ")", ";", "// beans read from xml storage will only have their basic properties initialized...", "// ... but we also need set the direct references/predecessors for beans to validate", "Map", "<", "BeanId", ",", "Bean", ">", "beansToValidateSubset", "=", "getDirectSuccessors", "(", "bean", ")", ";", "beansToValidateSubset", ".", "put", "(", "bean", ".", "getId", "(", ")", ",", "bean", ")", ";", "for", "(", "Bean", "toValidate", ":", "beansToValidateSubset", ".", "values", "(", ")", ")", "{", "predecessors", ".", "putAll", "(", "getDirectPredecessors", "(", "toValidate", ")", ")", ";", "}", "for", "(", "Bean", "predecessor", ":", "predecessors", ".", "values", "(", ")", ")", "{", "for", "(", "BeanId", "ref", ":", "predecessor", ".", "getReferences", "(", ")", ")", "{", "Bean", "b", "=", "storage", ".", "get", "(", "ref", ")", ";", "if", "(", "b", "==", "null", ")", "{", "throw", "CFG301_MISSING_RUNTIME_REF", "(", "predecessor", ".", "getId", "(", ")", ")", ";", "}", "ref", ".", "setBean", "(", "b", ")", ";", "}", "}", "for", "(", "Bean", "toValidate", ":", "beansToValidateSubset", ".", "values", "(", ")", ")", "{", "// list references of beansToValidate should now", "// be available in predecessors.", "for", "(", "BeanId", "ref", ":", "toValidate", ".", "getReferences", "(", ")", ")", "{", "Bean", "predecessor", "=", "predecessors", ".", "get", "(", "ref", ")", ";", "if", "(", "predecessor", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Bug in algorithm. Reference [\"", "+", "ref", "+", "\"] of [\"", "+", "toValidate", ".", "getId", "(", ")", "+", "\"] should be available in predecessors.\"", ")", ";", "}", "ref", ".", "setBean", "(", "predecessor", ")", ";", "}", "}", "beansToValidate", ".", "putAll", "(", "predecessors", ")", ";", "}", "return", "beansToValidate", ";", "}" ]
The direct, but no further, successors that references this bean will also be fetched and initialized with their direct, but no further, predecessors.
[ "The", "direct", "but", "no", "further", "successors", "that", "references", "this", "bean", "will", "also", "be", "fetched", "and", "initialized", "with", "their", "direct", "but", "no", "further", "predecessors", "." ]
4e6d4ee5fed32cbc5104433e61de1bcf1b360832
https://github.com/deephacks/confit/blob/4e6d4ee5fed32cbc5104433e61de1bcf1b360832/core/src/main/java/org/deephacks/confit/internal/core/config/DefaultBeanManager.java#L96-L134
train
payneteasy/superfly
superfly-service/src/main/java/com/payneteasy/superfly/service/job/BaseJob.java
BaseJob.getApplicationContext
protected ApplicationContext getApplicationContext(JobExecutionContext context) throws SchedulerException { final SchedulerContext schedulerContext = context.getScheduler().getContext(); ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY); // show keys in context if(applicationContext==null) { logger.error(APPLICATION_CONTEXT_KEY+" is empty in "+ schedulerContext+":"); if(schedulerContext.getKeys()!=null) { for (String key : schedulerContext.getKeys()) { Object value = schedulerContext.get(key); String valueText = value!=null ? value.toString() : "<NULL>"; logger.info(" {} = {}", key, valueText); } } } return applicationContext; }
java
protected ApplicationContext getApplicationContext(JobExecutionContext context) throws SchedulerException { final SchedulerContext schedulerContext = context.getScheduler().getContext(); ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY); // show keys in context if(applicationContext==null) { logger.error(APPLICATION_CONTEXT_KEY+" is empty in "+ schedulerContext+":"); if(schedulerContext.getKeys()!=null) { for (String key : schedulerContext.getKeys()) { Object value = schedulerContext.get(key); String valueText = value!=null ? value.toString() : "<NULL>"; logger.info(" {} = {}", key, valueText); } } } return applicationContext; }
[ "protected", "ApplicationContext", "getApplicationContext", "(", "JobExecutionContext", "context", ")", "throws", "SchedulerException", "{", "final", "SchedulerContext", "schedulerContext", "=", "context", ".", "getScheduler", "(", ")", ".", "getContext", "(", ")", ";", "ApplicationContext", "applicationContext", "=", "(", "ApplicationContext", ")", "schedulerContext", ".", "get", "(", "APPLICATION_CONTEXT_KEY", ")", ";", "// show keys in context", "if", "(", "applicationContext", "==", "null", ")", "{", "logger", ".", "error", "(", "APPLICATION_CONTEXT_KEY", "+", "\" is empty in \"", "+", "schedulerContext", "+", "\":\"", ")", ";", "if", "(", "schedulerContext", ".", "getKeys", "(", ")", "!=", "null", ")", "{", "for", "(", "String", "key", ":", "schedulerContext", ".", "getKeys", "(", ")", ")", "{", "Object", "value", "=", "schedulerContext", ".", "get", "(", "key", ")", ";", "String", "valueText", "=", "value", "!=", "null", "?", "value", ".", "toString", "(", ")", ":", "\"<NULL>\"", ";", "logger", ".", "info", "(", "\" {} = {}\"", ",", "key", ",", "valueText", ")", ";", "}", "}", "}", "return", "applicationContext", ";", "}" ]
Obtains Spring's application context. @param context job execution context @return application context @throws SchedulerException
[ "Obtains", "Spring", "s", "application", "context", "." ]
4cad6d0f8e951a61f3c302c49b13a51d179076f8
https://github.com/payneteasy/superfly/blob/4cad6d0f8e951a61f3c302c49b13a51d179076f8/superfly-service/src/main/java/com/payneteasy/superfly/service/job/BaseJob.java#L33-L52
train
mojohaus/mrm
mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/plugin/ConsoleScanner.java
ConsoleScanner.checkSystemInput
private void checkSystemInput() throws IOException { while ( System.in.available() > 0 ) { int input = System.in.read(); if ( input >= 0 ) { char c = (char) input; if ( c == '\n' ) { synchronized ( lock ) { finished = true; lock.notifyAll(); } } } else { synchronized ( lock ) { finished = true; lock.notifyAll(); } } } }
java
private void checkSystemInput() throws IOException { while ( System.in.available() > 0 ) { int input = System.in.read(); if ( input >= 0 ) { char c = (char) input; if ( c == '\n' ) { synchronized ( lock ) { finished = true; lock.notifyAll(); } } } else { synchronized ( lock ) { finished = true; lock.notifyAll(); } } } }
[ "private", "void", "checkSystemInput", "(", ")", "throws", "IOException", "{", "while", "(", "System", ".", "in", ".", "available", "(", ")", ">", "0", ")", "{", "int", "input", "=", "System", ".", "in", ".", "read", "(", ")", ";", "if", "(", "input", ">=", "0", ")", "{", "char", "c", "=", "(", "char", ")", "input", ";", "if", "(", "c", "==", "'", "'", ")", "{", "synchronized", "(", "lock", ")", "{", "finished", "=", "true", ";", "lock", ".", "notifyAll", "(", ")", ";", "}", "}", "}", "else", "{", "synchronized", "(", "lock", ")", "{", "finished", "=", "true", ";", "lock", ".", "notifyAll", "(", ")", ";", "}", "}", "}", "}" ]
Checks for the user pressing Enter. @throws IOException if something went wrong.
[ "Checks", "for", "the", "user", "pressing", "Enter", "." ]
ecbe54a1866f210c10bf2e9274b63d4804d6a151
https://github.com/mojohaus/mrm/blob/ecbe54a1866f210c10bf2e9274b63d4804d6a151/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/plugin/ConsoleScanner.java#L93-L120
train
payneteasy/superfly
superfly-demo/src/main/java/com/payneteasy/superfly/demo/web/utils/CommonsHttpInvokerRequestExecutor.java
CommonsHttpInvokerRequestExecutor.executePostMethod
protected void executePostMethod( HttpInvokerClientConfiguration config, HttpClient httpClient, PostMethod postMethod) throws IOException { httpClient.executeMethod(postMethod); }
java
protected void executePostMethod( HttpInvokerClientConfiguration config, HttpClient httpClient, PostMethod postMethod) throws IOException { httpClient.executeMethod(postMethod); }
[ "protected", "void", "executePostMethod", "(", "HttpInvokerClientConfiguration", "config", ",", "HttpClient", "httpClient", ",", "PostMethod", "postMethod", ")", "throws", "IOException", "{", "httpClient", ".", "executeMethod", "(", "postMethod", ")", ";", "}" ]
Execute the given PostMethod instance. @param config the HTTP invoker configuration that specifies the target service @param httpClient the HttpClient to execute on @param postMethod the PostMethod to execute @throws IOException if thrown by I/O methods @see org.apache.commons.httpclient.HttpClient#executeMethod(org.apache.commons.httpclient.HttpMethod)
[ "Execute", "the", "given", "PostMethod", "instance", "." ]
4cad6d0f8e951a61f3c302c49b13a51d179076f8
https://github.com/payneteasy/superfly/blob/4cad6d0f8e951a61f3c302c49b13a51d179076f8/superfly-demo/src/main/java/com/payneteasy/superfly/demo/web/utils/CommonsHttpInvokerRequestExecutor.java#L187-L192
train
deephacks/confit
provider-hbase/src/main/java/org/deephacks/confit/internal/hbase/HBeanReferences.java
HBeanReferences.getReferenceKeyValue
public static KeyValue getReferenceKeyValue(byte[] rowkey, String propertyName, String schemaName, List<BeanId> refs, UniqueIds uids) { final byte[] pid = uids.getUsid().getId(propertyName); final byte[] sid = uids.getUsid().getId(schemaName); final byte[] qual = new byte[] { sid[0], sid[1], pid[0], pid[1] }; final byte[] iids = getIids2(refs, uids); return new KeyValue(rowkey, REF_COLUMN_FAMILY, qual, iids); }
java
public static KeyValue getReferenceKeyValue(byte[] rowkey, String propertyName, String schemaName, List<BeanId> refs, UniqueIds uids) { final byte[] pid = uids.getUsid().getId(propertyName); final byte[] sid = uids.getUsid().getId(schemaName); final byte[] qual = new byte[] { sid[0], sid[1], pid[0], pid[1] }; final byte[] iids = getIids2(refs, uids); return new KeyValue(rowkey, REF_COLUMN_FAMILY, qual, iids); }
[ "public", "static", "KeyValue", "getReferenceKeyValue", "(", "byte", "[", "]", "rowkey", ",", "String", "propertyName", ",", "String", "schemaName", ",", "List", "<", "BeanId", ">", "refs", ",", "UniqueIds", "uids", ")", "{", "final", "byte", "[", "]", "pid", "=", "uids", ".", "getUsid", "(", ")", ".", "getId", "(", "propertyName", ")", ";", "final", "byte", "[", "]", "sid", "=", "uids", ".", "getUsid", "(", ")", ".", "getId", "(", "schemaName", ")", ";", "final", "byte", "[", "]", "qual", "=", "new", "byte", "[", "]", "{", "sid", "[", "0", "]", ",", "sid", "[", "1", "]", ",", "pid", "[", "0", "]", ",", "pid", "[", "1", "]", "}", ";", "final", "byte", "[", "]", "iids", "=", "getIids2", "(", "refs", ",", "uids", ")", ";", "return", "new", "KeyValue", "(", "rowkey", ",", "REF_COLUMN_FAMILY", ",", "qual", ",", "iids", ")", ";", "}" ]
Get a particular type of references identified by propertyName into key value form. @param schemaName
[ "Get", "a", "particular", "type", "of", "references", "identified", "by", "propertyName", "into", "key", "value", "form", "." ]
4e6d4ee5fed32cbc5104433e61de1bcf1b360832
https://github.com/deephacks/confit/blob/4e6d4ee5fed32cbc5104433e61de1bcf1b360832/provider-hbase/src/main/java/org/deephacks/confit/internal/hbase/HBeanReferences.java#L82-L89
train
deephacks/confit
provider-hbase/src/main/java/org/deephacks/confit/internal/hbase/HBeanReferences.java
HBeanReferences.setReferencesOn
public void setReferencesOn(Bean bean) { for (KeyValue ref : references.values()) { final byte[] sidpid = ref.getQualifier(); final byte[] iids = ref.getValue(); final byte[] sid = new byte[] { sidpid[0], sidpid[1] }; final byte[] pid = new byte[] { sidpid[2], sidpid[3] }; final String schemaName = uids.getUsid().getName(sid); final String propertyName = uids.getUsid().getName(pid); for (int i = 0; i < iids.length; i += IID_WIDTH) { final byte[] iid = new byte[] { iids[i], iids[i + 1], iids[i + 2], iids[i + 3] }; final String instanceId = uids.getUiid().getName(iid); bean.addReference(propertyName, BeanId.create(instanceId, schemaName)); } } }
java
public void setReferencesOn(Bean bean) { for (KeyValue ref : references.values()) { final byte[] sidpid = ref.getQualifier(); final byte[] iids = ref.getValue(); final byte[] sid = new byte[] { sidpid[0], sidpid[1] }; final byte[] pid = new byte[] { sidpid[2], sidpid[3] }; final String schemaName = uids.getUsid().getName(sid); final String propertyName = uids.getUsid().getName(pid); for (int i = 0; i < iids.length; i += IID_WIDTH) { final byte[] iid = new byte[] { iids[i], iids[i + 1], iids[i + 2], iids[i + 3] }; final String instanceId = uids.getUiid().getName(iid); bean.addReference(propertyName, BeanId.create(instanceId, schemaName)); } } }
[ "public", "void", "setReferencesOn", "(", "Bean", "bean", ")", "{", "for", "(", "KeyValue", "ref", ":", "references", ".", "values", "(", ")", ")", "{", "final", "byte", "[", "]", "sidpid", "=", "ref", ".", "getQualifier", "(", ")", ";", "final", "byte", "[", "]", "iids", "=", "ref", ".", "getValue", "(", ")", ";", "final", "byte", "[", "]", "sid", "=", "new", "byte", "[", "]", "{", "sidpid", "[", "0", "]", ",", "sidpid", "[", "1", "]", "}", ";", "final", "byte", "[", "]", "pid", "=", "new", "byte", "[", "]", "{", "sidpid", "[", "2", "]", ",", "sidpid", "[", "3", "]", "}", ";", "final", "String", "schemaName", "=", "uids", ".", "getUsid", "(", ")", ".", "getName", "(", "sid", ")", ";", "final", "String", "propertyName", "=", "uids", ".", "getUsid", "(", ")", ".", "getName", "(", "pid", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "iids", ".", "length", ";", "i", "+=", "IID_WIDTH", ")", "{", "final", "byte", "[", "]", "iid", "=", "new", "byte", "[", "]", "{", "iids", "[", "i", "]", ",", "iids", "[", "i", "+", "1", "]", ",", "iids", "[", "i", "+", "2", "]", ",", "iids", "[", "i", "+", "3", "]", "}", ";", "final", "String", "instanceId", "=", "uids", ".", "getUiid", "(", ")", ".", "getName", "(", "iid", ")", ";", "bean", ".", "addReference", "(", "propertyName", ",", "BeanId", ".", "create", "(", "instanceId", ",", "schemaName", ")", ")", ";", "}", "}", "}" ]
Set references on a bean using a set of key values containing references.
[ "Set", "references", "on", "a", "bean", "using", "a", "set", "of", "key", "values", "containing", "references", "." ]
4e6d4ee5fed32cbc5104433e61de1bcf1b360832
https://github.com/deephacks/confit/blob/4e6d4ee5fed32cbc5104433e61de1bcf1b360832/provider-hbase/src/main/java/org/deephacks/confit/internal/hbase/HBeanReferences.java#L215-L231
train
deephacks/confit
provider-hbase/src/main/java/org/deephacks/confit/internal/hbase/HBeanReferences.java
HBeanReferences.isReference
public static boolean isReference(KeyValue kv) { if (Bytes.equals(kv.getFamily(), REF_COLUMN_FAMILY)) { return true; } return false; }
java
public static boolean isReference(KeyValue kv) { if (Bytes.equals(kv.getFamily(), REF_COLUMN_FAMILY)) { return true; } return false; }
[ "public", "static", "boolean", "isReference", "(", "KeyValue", "kv", ")", "{", "if", "(", "Bytes", ".", "equals", "(", "kv", ".", "getFamily", "(", ")", ",", "REF_COLUMN_FAMILY", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
If this key value is of reference familiy type.
[ "If", "this", "key", "value", "is", "of", "reference", "familiy", "type", "." ]
4e6d4ee5fed32cbc5104433e61de1bcf1b360832
https://github.com/deephacks/confit/blob/4e6d4ee5fed32cbc5104433e61de1bcf1b360832/provider-hbase/src/main/java/org/deephacks/confit/internal/hbase/HBeanReferences.java#L254-L259
train
deephacks/confit
provider-hbase/src/main/java/org/deephacks/confit/internal/hbase/HBeanReferences.java
HBeanReferences.getIids
public static byte[] getIids(final List<String> ids, final UniqueIds uids) { final int size = ids.size(); final byte[] iids = new byte[IID_WIDTH * size]; for (int i = 0; i < size; i++) { final String instanceId = ids.get(i); final byte[] iid = uids.getUiid().getId(instanceId); System.arraycopy(iid, 0, iids, i * IID_WIDTH, IID_WIDTH); } return iids; }
java
public static byte[] getIids(final List<String> ids, final UniqueIds uids) { final int size = ids.size(); final byte[] iids = new byte[IID_WIDTH * size]; for (int i = 0; i < size; i++) { final String instanceId = ids.get(i); final byte[] iid = uids.getUiid().getId(instanceId); System.arraycopy(iid, 0, iids, i * IID_WIDTH, IID_WIDTH); } return iids; }
[ "public", "static", "byte", "[", "]", "getIids", "(", "final", "List", "<", "String", ">", "ids", ",", "final", "UniqueIds", "uids", ")", "{", "final", "int", "size", "=", "ids", ".", "size", "(", ")", ";", "final", "byte", "[", "]", "iids", "=", "new", "byte", "[", "IID_WIDTH", "*", "size", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "final", "String", "instanceId", "=", "ids", ".", "get", "(", "i", ")", ";", "final", "byte", "[", "]", "iid", "=", "uids", ".", "getUiid", "(", ")", ".", "getId", "(", "instanceId", ")", ";", "System", ".", "arraycopy", "(", "iid", ",", "0", ",", "iids", ",", "i", "*", "IID_WIDTH", ",", "IID_WIDTH", ")", ";", "}", "return", "iids", ";", "}" ]
Compress a set of instances ids into a byte array where each id consist of 4 bytes each.
[ "Compress", "a", "set", "of", "instances", "ids", "into", "a", "byte", "array", "where", "each", "id", "consist", "of", "4", "bytes", "each", "." ]
4e6d4ee5fed32cbc5104433e61de1bcf1b360832
https://github.com/deephacks/confit/blob/4e6d4ee5fed32cbc5104433e61de1bcf1b360832/provider-hbase/src/main/java/org/deephacks/confit/internal/hbase/HBeanReferences.java#L270-L279
train
deephacks/confit
provider-hbase/src/main/java/org/deephacks/confit/internal/hbase/HBeanReferences.java
HBeanReferences.getIids2
private static byte[] getIids2(final List<BeanId> ids, final UniqueIds uids) { if (ids == null) { return new byte[0]; } final AbstractList<String> list = new AbstractList<String>() { @Override public String get(int index) { return ids.get(index).getInstanceId(); } @Override public int size() { return ids.size(); } }; return getIids(list, uids); }
java
private static byte[] getIids2(final List<BeanId> ids, final UniqueIds uids) { if (ids == null) { return new byte[0]; } final AbstractList<String> list = new AbstractList<String>() { @Override public String get(int index) { return ids.get(index).getInstanceId(); } @Override public int size() { return ids.size(); } }; return getIids(list, uids); }
[ "private", "static", "byte", "[", "]", "getIids2", "(", "final", "List", "<", "BeanId", ">", "ids", ",", "final", "UniqueIds", "uids", ")", "{", "if", "(", "ids", "==", "null", ")", "{", "return", "new", "byte", "[", "0", "]", ";", "}", "final", "AbstractList", "<", "String", ">", "list", "=", "new", "AbstractList", "<", "String", ">", "(", ")", "{", "@", "Override", "public", "String", "get", "(", "int", "index", ")", "{", "return", "ids", ".", "get", "(", "index", ")", ".", "getInstanceId", "(", ")", ";", "}", "@", "Override", "public", "int", "size", "(", ")", "{", "return", "ids", ".", "size", "(", ")", ";", "}", "}", ";", "return", "getIids", "(", "list", ",", "uids", ")", ";", "}" ]
Second version of getIids that takes a set of bean ids instead.
[ "Second", "version", "of", "getIids", "that", "takes", "a", "set", "of", "bean", "ids", "instead", "." ]
4e6d4ee5fed32cbc5104433e61de1bcf1b360832
https://github.com/deephacks/confit/blob/4e6d4ee5fed32cbc5104433e61de1bcf1b360832/provider-hbase/src/main/java/org/deephacks/confit/internal/hbase/HBeanReferences.java#L284-L301
train