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
legsem/legstar.avro
legstar.avro.cob2avro/src/main/java/com/legstar/avro/cob2avro/io/AbstractZosDatumReader.java
AbstractZosDatumReader.read
public int read(byte b[], int off, int len) throws IOException { return IOUtils.read(inStream, b, off, len); }
java
public int read(byte b[], int off, int len) throws IOException { return IOUtils.read(inStream, b, off, len); }
[ "public", "int", "read", "(", "byte", "b", "[", "]", ",", "int", "off", ",", "int", "len", ")", "throws", "IOException", "{", "return", "IOUtils", ".", "read", "(", "inStream", ",", "b", ",", "off", ",", "len", ")", ";", "}" ]
Same as above but does not throw an exception at end of file, just returns the actual data read. @param b the buffer to bill @param off offset in buffer where to start filling @param len how many bytes we should read @return the total number of bytes read @throws IOException if a read error occurs
[ "Same", "as", "above", "but", "does", "not", "throw", "an", "exception", "at", "end", "of", "file", "just", "returns", "the", "actual", "data", "read", "." ]
bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b
https://github.com/legsem/legstar.avro/blob/bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b/legstar.avro.cob2avro/src/main/java/com/legstar/avro/cob2avro/io/AbstractZosDatumReader.java#L270-L272
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/command/core/param/CommandParamsContext.java
CommandParamsContext.addNamedParam
public void addNamedParam(final String name, final ParamInfo paramInfo) { check(!named.containsKey(name), "Duplicate parameter %s declaration at position %s", name, paramInfo.position); named.put(name, paramInfo); }
java
public void addNamedParam(final String name, final ParamInfo paramInfo) { check(!named.containsKey(name), "Duplicate parameter %s declaration at position %s", name, paramInfo.position); named.put(name, paramInfo); }
[ "public", "void", "addNamedParam", "(", "final", "String", "name", ",", "final", "ParamInfo", "paramInfo", ")", "{", "check", "(", "!", "named", ".", "containsKey", "(", "name", ")", ",", "\"Duplicate parameter %s declaration at position %s\"", ",", "name", ",", ...
Register parameter as named. @param name parameter name @param paramInfo parameter object
[ "Register", "parameter", "as", "named", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/command/core/param/CommandParamsContext.java#L48-L52
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/command/core/param/CommandParamsContext.java
CommandParamsContext.addStaticElVarValue
public void addStaticElVarValue(final String name, final String value) { check(!staticElValues.containsKey(name), "Duplicate el variable %s value declaration: %s (original: %s)", name, value, staticElValues.get(name)); check(!dynamicElValues.contains(name), "El variable %s can't be registered as static, because dynamic declaration already defined", name); staticElValues.put(name, value); }
java
public void addStaticElVarValue(final String name, final String value) { check(!staticElValues.containsKey(name), "Duplicate el variable %s value declaration: %s (original: %s)", name, value, staticElValues.get(name)); check(!dynamicElValues.contains(name), "El variable %s can't be registered as static, because dynamic declaration already defined", name); staticElValues.put(name, value); }
[ "public", "void", "addStaticElVarValue", "(", "final", "String", "name", ",", "final", "String", "value", ")", "{", "check", "(", "!", "staticElValues", ".", "containsKey", "(", "name", ")", ",", "\"Duplicate el variable %s value declaration: %s (original: %s)\"", ","...
Register static query el variable value. @param name variable name @param value variable value
[ "Register", "static", "query", "el", "variable", "value", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/command/core/param/CommandParamsContext.java#L60-L68
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/command/core/param/CommandParamsContext.java
CommandParamsContext.addDynamicElVarValue
public void addDynamicElVarValue(final String name) { check(!dynamicElValues.contains(name), "Duplicate dynamic el variable %s declaration", name); check(!staticElValues.containsKey(name), "El variable %s can't be registered as dynamic, because static declaration already defined", name); dynamicElValues.add(name); }
java
public void addDynamicElVarValue(final String name) { check(!dynamicElValues.contains(name), "Duplicate dynamic el variable %s declaration", name); check(!staticElValues.containsKey(name), "El variable %s can't be registered as dynamic, because static declaration already defined", name); dynamicElValues.add(name); }
[ "public", "void", "addDynamicElVarValue", "(", "final", "String", "name", ")", "{", "check", "(", "!", "dynamicElValues", ".", "contains", "(", "name", ")", ",", "\"Duplicate dynamic el variable %s declaration\"", ",", "name", ")", ";", "check", "(", "!", "stati...
Register dynamic query el variable value. Variable will be completely handled by extension. Registration is required to validated not handled variables. @param name variable name
[ "Register", "dynamic", "query", "el", "variable", "value", ".", "Variable", "will", "be", "completely", "handled", "by", "extension", ".", "Registration", "is", "required", "to", "validated", "not", "handled", "variables", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/command/core/param/CommandParamsContext.java#L76-L83
train
legsem/legstar.avro
legstar.avro.generator/src/main/java/com/legstar/avro/generator/Cob2AvroGenerator.java
Cob2AvroGenerator.generateXmlSchema
private String generateXmlSchema(Reader cobolReader, String targetNamespace, String targetXmlSchemaName, final String xsltFileName) { log.debug("XML schema {} generation started", targetXmlSchemaName + XSD_FILE_EXTENSION); String xmlSchemaSource = cob2xsd.translate(cobolReader, NamespaceUtils.toNamespace(targetNamespace), xsltFileName); if (log.isDebugEnabled()) { log.debug("Generated Cobol-annotated XML Schema: "); log.debug(xmlSchemaSource); } log.debug("XML schema {} generation ended", targetXmlSchemaName + XSD_FILE_EXTENSION); return xmlSchemaSource; }
java
private String generateXmlSchema(Reader cobolReader, String targetNamespace, String targetXmlSchemaName, final String xsltFileName) { log.debug("XML schema {} generation started", targetXmlSchemaName + XSD_FILE_EXTENSION); String xmlSchemaSource = cob2xsd.translate(cobolReader, NamespaceUtils.toNamespace(targetNamespace), xsltFileName); if (log.isDebugEnabled()) { log.debug("Generated Cobol-annotated XML Schema: "); log.debug(xmlSchemaSource); } log.debug("XML schema {} generation ended", targetXmlSchemaName + XSD_FILE_EXTENSION); return xmlSchemaSource; }
[ "private", "String", "generateXmlSchema", "(", "Reader", "cobolReader", ",", "String", "targetNamespace", ",", "String", "targetXmlSchemaName", ",", "final", "String", "xsltFileName", ")", "{", "log", ".", "debug", "(", "\"XML schema {} generation started\"", ",", "ta...
Translate the COBOL copybook to XML Schema. @param cobolReader the input COBOL copybook (as a reader) @param targetNamespace the target XML schema namespace @param targetXmlSchemaName the target XML schema name @param xsltFileName an optional XSLT to apply on the XML schema @return the XML schema source
[ "Translate", "the", "COBOL", "copybook", "to", "XML", "Schema", "." ]
bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b
https://github.com/legsem/legstar.avro/blob/bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b/legstar.avro.generator/src/main/java/com/legstar/avro/generator/Cob2AvroGenerator.java#L172-L188
train
legsem/legstar.avro
legstar.avro.generator/src/main/java/com/legstar/avro/generator/Cob2AvroGenerator.java
Cob2AvroGenerator.generateConverterClasses
private Map < String, String > generateConverterClasses( String xmlSchemaSource, String targetPackageName) { log.debug("Converter support classes generation started"); Map < String, String > codeMap = xsd2CobolTypes.generate( new StringReader(xmlSchemaSource), targetPackageName); if (log.isDebugEnabled()) { log.debug("Generated converter support classes: "); for (String code : codeMap.values()) { log.debug(code); log.debug("\n"); } } log.debug("Converter support classes generation ended"); return codeMap; }
java
private Map < String, String > generateConverterClasses( String xmlSchemaSource, String targetPackageName) { log.debug("Converter support classes generation started"); Map < String, String > codeMap = xsd2CobolTypes.generate( new StringReader(xmlSchemaSource), targetPackageName); if (log.isDebugEnabled()) { log.debug("Generated converter support classes: "); for (String code : codeMap.values()) { log.debug(code); log.debug("\n"); } } log.debug("Converter support classes generation ended"); return codeMap; }
[ "private", "Map", "<", "String", ",", "String", ">", "generateConverterClasses", "(", "String", "xmlSchemaSource", ",", "String", "targetPackageName", ")", "{", "log", ".", "debug", "(", "\"Converter support classes generation started\"", ")", ";", "Map", "<", "Stri...
Produce the LegStar converter support classes. @param xmlSchemaSource the XML schema source @param targetPackageName the target Avro package name @return a map of lass names associated with their code
[ "Produce", "the", "LegStar", "converter", "support", "classes", "." ]
bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b
https://github.com/legsem/legstar.avro/blob/bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b/legstar.avro.generator/src/main/java/com/legstar/avro/generator/Cob2AvroGenerator.java#L197-L212
train
legsem/legstar.avro
legstar.avro.generator/src/main/java/com/legstar/avro/generator/Cob2AvroGenerator.java
Cob2AvroGenerator.generateAvroSchema
private String generateAvroSchema(String xmlSchemaSource, String targetPackageName, String targetAvroSchemaName) throws IOException { log.debug("Avro schema {} generation started", targetAvroSchemaName + AVSC_FILE_EXTENSION); String avroSchemaSource = cob2AvroTranslator.translate( new StringReader(xmlSchemaSource), targetPackageName, targetAvroSchemaName); if (log.isDebugEnabled()) { log.debug("Generated Avro Schema: "); log.debug(avroSchemaSource); } log.debug("Avro schema {} generation ended", targetAvroSchemaName + AVSC_FILE_EXTENSION); return avroSchemaSource; }
java
private String generateAvroSchema(String xmlSchemaSource, String targetPackageName, String targetAvroSchemaName) throws IOException { log.debug("Avro schema {} generation started", targetAvroSchemaName + AVSC_FILE_EXTENSION); String avroSchemaSource = cob2AvroTranslator.translate( new StringReader(xmlSchemaSource), targetPackageName, targetAvroSchemaName); if (log.isDebugEnabled()) { log.debug("Generated Avro Schema: "); log.debug(avroSchemaSource); } log.debug("Avro schema {} generation ended", targetAvroSchemaName + AVSC_FILE_EXTENSION); return avroSchemaSource; }
[ "private", "String", "generateAvroSchema", "(", "String", "xmlSchemaSource", ",", "String", "targetPackageName", ",", "String", "targetAvroSchemaName", ")", "throws", "IOException", "{", "log", ".", "debug", "(", "\"Avro schema {} generation started\"", ",", "targetAvroSc...
Produce the avro schema. @param xmlSchemaSource the XML schema source @param targetPackageName the target Avro package name @param targetAvroSchemaName the target Avro schema name @return the generated Avro schema @throws IOException if serialization fails
[ "Produce", "the", "avro", "schema", "." ]
bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b
https://github.com/legsem/legstar.avro/blob/bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b/legstar.avro.generator/src/main/java/com/legstar/avro/generator/Cob2AvroGenerator.java#L232-L248
train
legsem/legstar.avro
legstar.avro.generator/src/main/java/com/legstar/avro/generator/Cob2AvroGenerator.java
Cob2AvroGenerator.avroCompile
private void avroCompile(String avroSchemaSource, File avroSchemaFile, File javaTargetFolder) throws IOException { log.debug("Avro compiler started for: {}", avroSchemaFile); Schema.Parser parser = new Schema.Parser(); Schema schema = parser.parse(avroSchemaSource); SpecificCompiler compiler = new CustomSpecificCompiler(schema); compiler.setStringType(StringType.CharSequence); compiler.compileToDestination(avroSchemaFile, javaTargetFolder); log.debug("Avro compiler ended for: {}", avroSchemaFile); }
java
private void avroCompile(String avroSchemaSource, File avroSchemaFile, File javaTargetFolder) throws IOException { log.debug("Avro compiler started for: {}", avroSchemaFile); Schema.Parser parser = new Schema.Parser(); Schema schema = parser.parse(avroSchemaSource); SpecificCompiler compiler = new CustomSpecificCompiler(schema); compiler.setStringType(StringType.CharSequence); compiler.compileToDestination(avroSchemaFile, javaTargetFolder); log.debug("Avro compiler ended for: {}", avroSchemaFile); }
[ "private", "void", "avroCompile", "(", "String", "avroSchemaSource", ",", "File", "avroSchemaFile", ",", "File", "javaTargetFolder", ")", "throws", "IOException", "{", "log", ".", "debug", "(", "\"Avro compiler started for: {}\"", ",", "avroSchemaFile", ")", ";", "S...
Given an Avro schema produce java specific classes. @param avroSchemaFile the Avro schema file (used by avro for timestamp checking) @param avroSchemaSource the Avro schema source @param javaTargetFolder the target folder for java classes @throws IOException if compilation fails
[ "Given", "an", "Avro", "schema", "produce", "java", "specific", "classes", "." ]
bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b
https://github.com/legsem/legstar.avro/blob/bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b/legstar.avro.generator/src/main/java/com/legstar/avro/generator/Cob2AvroGenerator.java#L259-L271
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/db/transaction/internal/AnnotationTxConfigBuilder.java
AnnotationTxConfigBuilder.buildConfig
public static TxConfig buildConfig(final Class<?> type, final Method method, final boolean useDefaults) { final Transactional transactional = findAnnotation(type, method, Transactional.class, useDefaults); TxConfig res = null; if (transactional != null) { final TxType txType = findAnnotation(type, method, TxType.class, true); res = new TxConfig(wrapExceptions(transactional.rollbackOn()), wrapExceptions(transactional.ignore()), txType.value()); } return res; }
java
public static TxConfig buildConfig(final Class<?> type, final Method method, final boolean useDefaults) { final Transactional transactional = findAnnotation(type, method, Transactional.class, useDefaults); TxConfig res = null; if (transactional != null) { final TxType txType = findAnnotation(type, method, TxType.class, true); res = new TxConfig(wrapExceptions(transactional.rollbackOn()), wrapExceptions(transactional.ignore()), txType.value()); } return res; }
[ "public", "static", "TxConfig", "buildConfig", "(", "final", "Class", "<", "?", ">", "type", ",", "final", "Method", "method", ",", "final", "boolean", "useDefaults", ")", "{", "final", "Transactional", "transactional", "=", "findAnnotation", "(", "type", ",",...
Build transaction config for type. @param type type to analyze @param method method to analyze @param useDefaults true to build default config if annotation not found @return tx config for found annotation, null if useDefaults false and default config otherwise
[ "Build", "transaction", "config", "for", "type", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/db/transaction/internal/AnnotationTxConfigBuilder.java#L33-L42
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/db/transaction/internal/AnnotationTxConfigBuilder.java
AnnotationTxConfigBuilder.wrapExceptions
private static List<Class<? extends Exception>> wrapExceptions(final Class<? extends Exception>... list) { return list.length == 0 ? null : Arrays.asList(list); }
java
private static List<Class<? extends Exception>> wrapExceptions(final Class<? extends Exception>... list) { return list.length == 0 ? null : Arrays.asList(list); }
[ "private", "static", "List", "<", "Class", "<", "?", "extends", "Exception", ">", ">", "wrapExceptions", "(", "final", "Class", "<", "?", "extends", "Exception", ">", "...", "list", ")", "{", "return", "list", ".", "length", "==", "0", "?", "null", ":"...
Avoid creation of empty list. @param list array of exceptions @return converted list or null if array os empty
[ "Avoid", "creation", "of", "empty", "list", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/db/transaction/internal/AnnotationTxConfigBuilder.java#L67-L69
train
caduandrade/japura-gui
src/main/java/org/japura/gui/TitleBar.java
TitleBar.setTitleGaps
public void setTitleGaps(int gapBetweenIconAndTitle, int gapBetweenTitleAndComponents, int gapBetweenComponents) { gapBetweenIconAndTitle = Math.max(gapBetweenIconAndTitle, 0); gapBetweenTitleAndComponents = Math.max(gapBetweenTitleAndComponents, 0); gapBetweenComponents = Math.max(gapBetweenComponents, 0); rebuild(); }
java
public void setTitleGaps(int gapBetweenIconAndTitle, int gapBetweenTitleAndComponents, int gapBetweenComponents) { gapBetweenIconAndTitle = Math.max(gapBetweenIconAndTitle, 0); gapBetweenTitleAndComponents = Math.max(gapBetweenTitleAndComponents, 0); gapBetweenComponents = Math.max(gapBetweenComponents, 0); rebuild(); }
[ "public", "void", "setTitleGaps", "(", "int", "gapBetweenIconAndTitle", ",", "int", "gapBetweenTitleAndComponents", ",", "int", "gapBetweenComponents", ")", "{", "gapBetweenIconAndTitle", "=", "Math", ".", "max", "(", "gapBetweenIconAndTitle", ",", "0", ")", ";", "g...
Defines the title gaps @param gapBetweenIconAndTitle gap between the icon and title @param gapBetweenTitleAndComponents gap between the title and title components @param gapBetweenComponents gap between title components
[ "Defines", "the", "title", "gaps" ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/TitleBar.java#L139-L145
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/core/MethodExecutionException.java
MethodExecutionException.checkExec
public static void checkExec(final boolean condition, final String message, final Object... args) { if (!condition) { throw new MethodExecutionException(String.format(message, args)); } }
java
public static void checkExec(final boolean condition, final String message, final Object... args) { if (!condition) { throw new MethodExecutionException(String.format(message, args)); } }
[ "public", "static", "void", "checkExec", "(", "final", "boolean", "condition", ",", "final", "String", "message", ",", "final", "Object", "...", "args", ")", "{", "if", "(", "!", "condition", ")", "{", "throw", "new", "MethodExecutionException", "(", "String...
Shortcut to check and throw execution exception. @param condition condition to validate @param message fail message @param args fail message arguments
[ "Shortcut", "to", "check", "and", "throw", "execution", "exception", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/core/MethodExecutionException.java#L28-L32
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/command/core/el/ElUtils.java
ElUtils.findVars
public static List<String> findVars(final String str) { final List<String> vars = new ArrayList<String>(); final char[] strArray = str.toCharArray(); int i = 0; while (i < strArray.length - 1) { if (strArray[i] == VAR_START && strArray[i + 1] == VAR_LEFT_BOUND) { i = i + 2; final int begin = i; while (strArray[i] != VAR_RIGHT_BOUND) { ++i; } final String var = str.substring(begin, i++); if (!vars.contains(var)) { vars.add(var); } } else { ++i; } } return vars; }
java
public static List<String> findVars(final String str) { final List<String> vars = new ArrayList<String>(); final char[] strArray = str.toCharArray(); int i = 0; while (i < strArray.length - 1) { if (strArray[i] == VAR_START && strArray[i + 1] == VAR_LEFT_BOUND) { i = i + 2; final int begin = i; while (strArray[i] != VAR_RIGHT_BOUND) { ++i; } final String var = str.substring(begin, i++); if (!vars.contains(var)) { vars.add(var); } } else { ++i; } } return vars; }
[ "public", "static", "List", "<", "String", ">", "findVars", "(", "final", "String", "str", ")", "{", "final", "List", "<", "String", ">", "vars", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "final", "char", "[", "]", "strArray", "=", ...
Analyze string for variables. @param str string to analyze @return found variable names
[ "Analyze", "string", "for", "variables", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/command/core/el/ElUtils.java#L33-L53
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/command/core/el/ElUtils.java
ElUtils.replace
public static String replace(final String str, final Map<String, String> params) { final StringBuilder sb = new StringBuilder(str.length()); final char[] strArray = str.toCharArray(); int i = 0; while (i < strArray.length - 1) { if (strArray[i] == VAR_START && strArray[i + 1] == VAR_LEFT_BOUND) { i = i + 2; final int begin = i; while (strArray[i] != VAR_RIGHT_BOUND) { ++i; } final String var = str.substring(begin, i++); Preconditions.checkState(params.containsKey(var), "No value provided for variable '%s' " + "in string '%s'", var, str); final String value = params.get(var).trim(); sb.append(value); } else { sb.append(strArray[i]); ++i; } } if (i < strArray.length) { sb.append(strArray[i]); } return sb.toString(); }
java
public static String replace(final String str, final Map<String, String> params) { final StringBuilder sb = new StringBuilder(str.length()); final char[] strArray = str.toCharArray(); int i = 0; while (i < strArray.length - 1) { if (strArray[i] == VAR_START && strArray[i + 1] == VAR_LEFT_BOUND) { i = i + 2; final int begin = i; while (strArray[i] != VAR_RIGHT_BOUND) { ++i; } final String var = str.substring(begin, i++); Preconditions.checkState(params.containsKey(var), "No value provided for variable '%s' " + "in string '%s'", var, str); final String value = params.get(var).trim(); sb.append(value); } else { sb.append(strArray[i]); ++i; } } if (i < strArray.length) { sb.append(strArray[i]); } return sb.toString(); }
[ "public", "static", "String", "replace", "(", "final", "String", "str", ",", "final", "Map", "<", "String", ",", "String", ">", "params", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "str", ".", "length", "(", ")", ")", "...
Replace placeholders in string. @param str string to replace placeholders @param params placeholder values map @return string with replaced placeholders @throws java.lang.IllegalStateException if string placeholder value is null or not provided
[ "Replace", "placeholders", "in", "string", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/command/core/el/ElUtils.java#L63-L88
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/command/core/el/ElUtils.java
ElUtils.validate
public static void validate(final String string, final List<String> params) { final List<String> vars = findVars(string); for (String param : params) { Preconditions.checkState(vars.contains(param), "Variable '%s' not found in target string '%s'", param, string); } vars.removeAll(params); Preconditions.checkState(vars.isEmpty(), "No parameter binding defined for variables '%s' from string '%s'", Joiner.on(',').join(vars), string); }
java
public static void validate(final String string, final List<String> params) { final List<String> vars = findVars(string); for (String param : params) { Preconditions.checkState(vars.contains(param), "Variable '%s' not found in target string '%s'", param, string); } vars.removeAll(params); Preconditions.checkState(vars.isEmpty(), "No parameter binding defined for variables '%s' from string '%s'", Joiner.on(',').join(vars), string); }
[ "public", "static", "void", "validate", "(", "final", "String", "string", ",", "final", "List", "<", "String", ">", "params", ")", "{", "final", "List", "<", "String", ">", "vars", "=", "findVars", "(", "string", ")", ";", "for", "(", "String", "param"...
Validate string variables and declared values for correctness. @param string template string @param params provided param names
[ "Validate", "string", "variables", "and", "declared", "values", "for", "correctness", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/command/core/el/ElUtils.java#L96-L106
train
caduandrade/japura-gui
src/main/java/org/japura/gui/CollapsiblePanel.java
CollapsiblePanel.expand
private void expand(boolean immediately) { if (locked == false && inAction == false && collapsed) { inAction = true; CollapsiblePanelListener[] array = listeners.getListeners(CollapsiblePanelListener.class); for (CollapsiblePanelListener cpl : array) { cpl.panelWillExpand(new CollapsiblePanelEvent(this)); } pixels = incremental; if (isAnimationEnabled() && immediately == false) { calculatedHeight = getSize().height; if (isFillMode()) { setEndHeights(); } else { endHeight = getPreferredSize(false).height; } getExpandTimer().start(); } else { changeStatus(); } } }
java
private void expand(boolean immediately) { if (locked == false && inAction == false && collapsed) { inAction = true; CollapsiblePanelListener[] array = listeners.getListeners(CollapsiblePanelListener.class); for (CollapsiblePanelListener cpl : array) { cpl.panelWillExpand(new CollapsiblePanelEvent(this)); } pixels = incremental; if (isAnimationEnabled() && immediately == false) { calculatedHeight = getSize().height; if (isFillMode()) { setEndHeights(); } else { endHeight = getPreferredSize(false).height; } getExpandTimer().start(); } else { changeStatus(); } } }
[ "private", "void", "expand", "(", "boolean", "immediately", ")", "{", "if", "(", "locked", "==", "false", "&&", "inAction", "==", "false", "&&", "collapsed", ")", "{", "inAction", "=", "true", ";", "CollapsiblePanelListener", "[", "]", "array", "=", "liste...
Expand the panel. @param immediately a boolean value, where true expand immediately the panel and false not.
[ "Expand", "the", "panel", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/CollapsiblePanel.java#L759-L780
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/LinearLayoutManager.java
LinearLayoutManager.setReverseLayout
public void setReverseLayout(boolean reverseLayout) { if (mPendingSavedState != null && mPendingSavedState.mReverseLayout != reverseLayout) { // override pending state mPendingSavedState.mReverseLayout = reverseLayout; } if (reverseLayout == mReverseLayout) { return; } mReverseLayout = reverseLayout; requestLayout(); }
java
public void setReverseLayout(boolean reverseLayout) { if (mPendingSavedState != null && mPendingSavedState.mReverseLayout != reverseLayout) { // override pending state mPendingSavedState.mReverseLayout = reverseLayout; } if (reverseLayout == mReverseLayout) { return; } mReverseLayout = reverseLayout; requestLayout(); }
[ "public", "void", "setReverseLayout", "(", "boolean", "reverseLayout", ")", "{", "if", "(", "mPendingSavedState", "!=", "null", "&&", "mPendingSavedState", ".", "mReverseLayout", "!=", "reverseLayout", ")", "{", "// override pending state", "mPendingSavedState", ".", ...
Used to reverse item traversal and layout order. This behaves similar to the layout change for RTL views. When set to true, first item is rendered at the end of the UI, second item is render before it etc. For horizontal layouts, it depends on the layout direction. When set to true, If {@link com.twotoasters.android.support.v7.widget.RecyclerView} is LTR, than it will render from RTL, if {@link com.twotoasters.android.support.v7.widget.RecyclerView}} is RTL, it will render from LTR. If you are looking for the exact same behavior of {@link android.widget.AbsListView#setStackFromBottom(boolean)}, use {@link #setStackFromEnd(boolean)}
[ "Used", "to", "reverse", "item", "traversal", "and", "layout", "order", ".", "This", "behaves", "similar", "to", "the", "layout", "change", "for", "RTL", "views", ".", "When", "set", "to", "true", "first", "item", "is", "rendered", "at", "the", "end", "o...
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/LinearLayoutManager.java#L296-L306
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/db/scheme/initializer/core/util/SchemeUtils.java
SchemeUtils.command
public static void command(final ODatabaseObject db, final String command, final Object... args) { db.command(new OCommandSQL(String.format(command, args))).execute(); }
java
public static void command(final ODatabaseObject db, final String command, final Object... args) { db.command(new OCommandSQL(String.format(command, args))).execute(); }
[ "public", "static", "void", "command", "(", "final", "ODatabaseObject", "db", ",", "final", "String", "command", ",", "final", "Object", "...", "args", ")", "{", "db", ".", "command", "(", "new", "OCommandSQL", "(", "String", ".", "format", "(", "command",...
Calls schema change sql command. @param db database object @param command command with string format placeholders @param args string format placeholders args (important: not query args!)
[ "Calls", "schema", "change", "sql", "command", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/db/scheme/initializer/core/util/SchemeUtils.java#L82-L84
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/db/scheme/initializer/core/util/SchemeUtils.java
SchemeUtils.dropIndex
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT") public static void dropIndex(final ODatabaseObject db, final String indexName) { // Separated to overcome findbugs false positive "RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" for dropIndex method. db.getMetadata().getIndexManager().dropIndex(indexName); }
java
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT") public static void dropIndex(final ODatabaseObject db, final String indexName) { // Separated to overcome findbugs false positive "RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" for dropIndex method. db.getMetadata().getIndexManager().dropIndex(indexName); }
[ "@", "SuppressFBWarnings", "(", "\"RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT\"", ")", "public", "static", "void", "dropIndex", "(", "final", "ODatabaseObject", "db", ",", "final", "String", "indexName", ")", "{", "// Separated to overcome findbugs false positive \"RV_RETURN_VALUE_...
Drops named index. Safe to call even if index not exist. @param db database object @param indexName index name @see com.orientechnologies.orient.core.index.OIndexManagerProxy#dropIndex(java.lang.String)
[ "Drops", "named", "index", ".", "Safe", "to", "call", "even", "if", "index", "not", "exist", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/db/scheme/initializer/core/util/SchemeUtils.java#L93-L97
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/OrientModule.java
OrientModule.configureCustomTypes
private void configureCustomTypes() { // empty binding is required in any case final Multibinder<OObjectSerializer> typesBinder = Multibinder.newSetBinder(binder(), OObjectSerializer.class); if (!customTypes.isEmpty()) { for (Class<? extends OObjectSerializer> type : customTypes) { bind(type).in(Singleton.class); typesBinder.addBinding().to(type); } } }
java
private void configureCustomTypes() { // empty binding is required in any case final Multibinder<OObjectSerializer> typesBinder = Multibinder.newSetBinder(binder(), OObjectSerializer.class); if (!customTypes.isEmpty()) { for (Class<? extends OObjectSerializer> type : customTypes) { bind(type).in(Singleton.class); typesBinder.addBinding().to(type); } } }
[ "private", "void", "configureCustomTypes", "(", ")", "{", "// empty binding is required in any case", "final", "Multibinder", "<", "OObjectSerializer", ">", "typesBinder", "=", "Multibinder", ".", "newSetBinder", "(", "binder", "(", ")", ",", "OObjectSerializer", ".", ...
Binds registered custom types as guice singletons and register them with multibinder.
[ "Binds", "registered", "custom", "types", "as", "guice", "singletons", "and", "register", "them", "with", "multibinder", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/OrientModule.java#L298-L308
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/OrientModule.java
OrientModule.loadOptionalPool
protected void loadOptionalPool(final String poolBinder) { try { final Method bindPool = OrientModule.class.getDeclaredMethod("bindPool", Class.class, Class.class); bindPool.setAccessible(true); try { Class.forName(poolBinder) .getConstructor(OrientModule.class, Method.class, Binder.class) .newInstance(this, bindPool, binder()); } finally { bindPool.setAccessible(false); } } catch (Exception ignored) { if (logger.isTraceEnabled()) { logger.trace("Failed to process pool loader " + poolBinder, ignored); } } }
java
protected void loadOptionalPool(final String poolBinder) { try { final Method bindPool = OrientModule.class.getDeclaredMethod("bindPool", Class.class, Class.class); bindPool.setAccessible(true); try { Class.forName(poolBinder) .getConstructor(OrientModule.class, Method.class, Binder.class) .newInstance(this, bindPool, binder()); } finally { bindPool.setAccessible(false); } } catch (Exception ignored) { if (logger.isTraceEnabled()) { logger.trace("Failed to process pool loader " + poolBinder, ignored); } } }
[ "protected", "void", "loadOptionalPool", "(", "final", "String", "poolBinder", ")", "{", "try", "{", "final", "Method", "bindPool", "=", "OrientModule", ".", "class", ".", "getDeclaredMethod", "(", "\"bindPool\"", ",", "Class", ".", "class", ",", "Class", ".",...
Allows to load pool only if required jars are in classpath. For example, no need for graph dependencies if only object db is used. @param poolBinder pool binder class @see ru.vyarus.guice.persist.orient.support.pool.ObjectPoolBinder as example
[ "Allows", "to", "load", "pool", "only", "if", "required", "jars", "are", "in", "classpath", ".", "For", "example", "no", "need", "for", "graph", "dependencies", "if", "only", "object", "db", "is", "used", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/OrientModule.java#L357-L373
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/delegate/method/TargetMethodAnalyzer.java
TargetMethodAnalyzer.isParametersCompatible
@SuppressWarnings("unchecked") private static boolean isParametersCompatible(final List<Class<?>> params, final List<ParamInfo> ordinalParamInfos) { boolean resolution = params.size() == ordinalParamInfos.size(); if (resolution && !params.isEmpty()) { final Iterator<Class<?>> paramsIt = params.iterator(); final Iterator<ParamInfo> targetIt = ordinalParamInfos.iterator(); while (paramsIt.hasNext()) { final Class<?> type = paramsIt.next(); final ParamInfo paramInfo = targetIt.next(); if (!paramInfo.type.isAssignableFrom(type)) { resolution = false; break; } } } return resolution; }
java
@SuppressWarnings("unchecked") private static boolean isParametersCompatible(final List<Class<?>> params, final List<ParamInfo> ordinalParamInfos) { boolean resolution = params.size() == ordinalParamInfos.size(); if (resolution && !params.isEmpty()) { final Iterator<Class<?>> paramsIt = params.iterator(); final Iterator<ParamInfo> targetIt = ordinalParamInfos.iterator(); while (paramsIt.hasNext()) { final Class<?> type = paramsIt.next(); final ParamInfo paramInfo = targetIt.next(); if (!paramInfo.type.isAssignableFrom(type)) { resolution = false; break; } } } return resolution; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "static", "boolean", "isParametersCompatible", "(", "final", "List", "<", "Class", "<", "?", ">", ">", "params", ",", "final", "List", "<", "ParamInfo", ">", "ordinalParamInfos", ")", "{", "boolean...
Checking method parameters compatibility. @param params repository method params to check against @param ordinalParamInfos target method ordinal params (excluding extension parameters) @return true if method is compatible, false otherwise
[ "Checking", "method", "parameters", "compatibility", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/delegate/method/TargetMethodAnalyzer.java#L127-L144
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/command/core/el/ElAnalyzer.java
ElAnalyzer.analyzeQuery
public static ElDescriptor analyzeQuery(final GenericsContext genericsContext, final String query) { final List<String> vars = ElUtils.findVars(query); ElDescriptor descriptor = null; if (!vars.isEmpty()) { descriptor = new ElDescriptor(vars); checkGenericVars(descriptor, genericsContext); } return descriptor; }
java
public static ElDescriptor analyzeQuery(final GenericsContext genericsContext, final String query) { final List<String> vars = ElUtils.findVars(query); ElDescriptor descriptor = null; if (!vars.isEmpty()) { descriptor = new ElDescriptor(vars); checkGenericVars(descriptor, genericsContext); } return descriptor; }
[ "public", "static", "ElDescriptor", "analyzeQuery", "(", "final", "GenericsContext", "genericsContext", ",", "final", "String", "query", ")", "{", "final", "List", "<", "String", ">", "vars", "=", "ElUtils", ".", "findVars", "(", "query", ")", ";", "ElDescript...
Analyze query string for variables. @param genericsContext generics context (set to the method owner type) @param query query string @return descriptor object if variables found, null otherwise
[ "Analyze", "query", "string", "for", "variables", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/command/core/el/ElAnalyzer.java#L31-L39
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/core/MethodDefinitionException.java
MethodDefinitionException.check
public static void check(final boolean condition, final String message, final Object... args) { if (!condition) { throw new MethodDefinitionException(String.format(message, args)); } }
java
public static void check(final boolean condition, final String message, final Object... args) { if (!condition) { throw new MethodDefinitionException(String.format(message, args)); } }
[ "public", "static", "void", "check", "(", "final", "boolean", "condition", ",", "final", "String", "message", ",", "final", "Object", "...", "args", ")", "{", "if", "(", "!", "condition", ")", "{", "throw", "new", "MethodDefinitionException", "(", "String", ...
Shortcut to check and throw definition exception. @param condition condition to validate @param message fail message @param args fail message arguments
[ "Shortcut", "to", "check", "and", "throw", "definition", "exception", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/core/MethodDefinitionException.java#L28-L32
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/service/result/converter/Optionals.java
Optionals.jdk8
private static Object jdk8(final Class<?> type, final Object object) { try { // a bit faster than resolving it each time if (jdk8OptionalFactory == null) { lookupOptionalFactoryMethod(type); } return jdk8OptionalFactory.invoke(null, object); } catch (Exception e) { throw new IllegalStateException("Failed to instantiate jdk Optional", e); } }
java
private static Object jdk8(final Class<?> type, final Object object) { try { // a bit faster than resolving it each time if (jdk8OptionalFactory == null) { lookupOptionalFactoryMethod(type); } return jdk8OptionalFactory.invoke(null, object); } catch (Exception e) { throw new IllegalStateException("Failed to instantiate jdk Optional", e); } }
[ "private", "static", "Object", "jdk8", "(", "final", "Class", "<", "?", ">", "type", ",", "final", "Object", "object", ")", "{", "try", "{", "// a bit faster than resolving it each time", "if", "(", "jdk8OptionalFactory", "==", "null", ")", "{", "lookupOptionalF...
Only this will cause optional class loading and fail for earlier jdk. @param object object for conversion @return optional instance
[ "Only", "this", "will", "cause", "optional", "class", "loading", "and", "fail", "for", "earlier", "jdk", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/service/result/converter/Optionals.java#L49-L59
train
rythmengine/spring-rythm
src/main/java/org/rythmengine/spring/RythmEngineFactory.java
RythmEngineFactory.setEngineConfigMap
public void setEngineConfigMap(Map<String, Object> engineConfigMap) { if (engineConfigMap != null) { this.engineConfig.putAll(engineConfigMap); } }
java
public void setEngineConfigMap(Map<String, Object> engineConfigMap) { if (engineConfigMap != null) { this.engineConfig.putAll(engineConfigMap); } }
[ "public", "void", "setEngineConfigMap", "(", "Map", "<", "String", ",", "Object", ">", "engineConfigMap", ")", "{", "if", "(", "engineConfigMap", "!=", "null", ")", "{", "this", ".", "engineConfig", ".", "putAll", "(", "engineConfigMap", ")", ";", "}", "}"...
Set Rythm properties as Map, to allow for non-String values like "ds.resource.loader.instance". @see #setEngineConfig
[ "Set", "Rythm", "properties", "as", "Map", "to", "allow", "for", "non", "-", "String", "values", "like", "ds", ".", "resource", ".", "loader", ".", "instance", "." ]
a654016371c72dabaea50ac9a57626da7614d236
https://github.com/rythmengine/spring-rythm/blob/a654016371c72dabaea50ac9a57626da7614d236/src/main/java/org/rythmengine/spring/RythmEngineFactory.java#L115-L119
train
rythmengine/spring-rythm
src/main/java/org/rythmengine/spring/RythmEngineFactory.java
RythmEngineFactory.createRythmEngine
public RythmEngine createRythmEngine() throws IOException, RythmException { Map<String, Object> p = new HashMap<String, Object>(); p.put(RythmConfigurationKey.ENGINE_PLUGIN_VERSION.getKey(), Version.VALUE); // Load config file if set. if (this.configLocation != null) { logger.info("Loading Rythm config from [%s]", this.configLocation); CollectionUtils.mergePropertiesIntoMap(PropertiesLoaderUtils.loadProperties(this.configLocation), p); } // Merge local properties if set. if (!this.engineConfig.isEmpty()) { p.putAll(this.engineConfig); } // Set dev mode if (null == devMode) { // check if devMode is set in engineConfig String k = RythmConfigurationKey.ENGINE_MODE.getKey(); if (p.containsKey(k)) { String s = p.get(k).toString(); devMode = Rythm.Mode.dev.name().equalsIgnoreCase(s); } else { devMode = getDevModeFromDevModeSensor(); } } Rythm.Mode mode = devMode ? Rythm.Mode.dev : Rythm.Mode.prod; p.put(RythmConfigurationKey.ENGINE_MODE.getKey(), mode); // Cache p.put(RythmConfigurationKey.CACHE_ENABLED.getKey(), enableCache); // Set a resource loader path, if required. List<ITemplateResourceLoader> loaders = null; if (this.resourceLoaderPath != null) { loaders = new ArrayList<ITemplateResourceLoader>(); String[] paths = StringUtils.commaDelimitedListToStringArray(resourceLoaderPath); for (String path : paths) { loaders.add(new SpringResourceLoader(path, resourceLoader)); } p.put(RythmConfigurationKey.RESOURCE_LOADER_IMPLS.getKey(), loaders); p.put(RythmConfigurationKey.RESOURCE_DEF_LOADER_ENABLED.getKey(), false); } // the i18 message resolver ApplicationContext ctx = getApplicationContext(); if (null != ctx) { SpringI18nMessageResolver i18n = new SpringI18nMessageResolver(); i18n.setApplicationContext(getApplicationContext()); p.put(RythmConfigurationKey.I18N_MESSAGE_RESOLVER.getKey(), i18n); } configRythm(p); // Apply properties to RythmEngine. RythmEngine engine = newRythmEngine(p); if (null != loaders) { for (ITemplateResourceLoader loader : loaders) { loader.setEngine(engine); } } postProcessRythmEngine(engine); return engine; }
java
public RythmEngine createRythmEngine() throws IOException, RythmException { Map<String, Object> p = new HashMap<String, Object>(); p.put(RythmConfigurationKey.ENGINE_PLUGIN_VERSION.getKey(), Version.VALUE); // Load config file if set. if (this.configLocation != null) { logger.info("Loading Rythm config from [%s]", this.configLocation); CollectionUtils.mergePropertiesIntoMap(PropertiesLoaderUtils.loadProperties(this.configLocation), p); } // Merge local properties if set. if (!this.engineConfig.isEmpty()) { p.putAll(this.engineConfig); } // Set dev mode if (null == devMode) { // check if devMode is set in engineConfig String k = RythmConfigurationKey.ENGINE_MODE.getKey(); if (p.containsKey(k)) { String s = p.get(k).toString(); devMode = Rythm.Mode.dev.name().equalsIgnoreCase(s); } else { devMode = getDevModeFromDevModeSensor(); } } Rythm.Mode mode = devMode ? Rythm.Mode.dev : Rythm.Mode.prod; p.put(RythmConfigurationKey.ENGINE_MODE.getKey(), mode); // Cache p.put(RythmConfigurationKey.CACHE_ENABLED.getKey(), enableCache); // Set a resource loader path, if required. List<ITemplateResourceLoader> loaders = null; if (this.resourceLoaderPath != null) { loaders = new ArrayList<ITemplateResourceLoader>(); String[] paths = StringUtils.commaDelimitedListToStringArray(resourceLoaderPath); for (String path : paths) { loaders.add(new SpringResourceLoader(path, resourceLoader)); } p.put(RythmConfigurationKey.RESOURCE_LOADER_IMPLS.getKey(), loaders); p.put(RythmConfigurationKey.RESOURCE_DEF_LOADER_ENABLED.getKey(), false); } // the i18 message resolver ApplicationContext ctx = getApplicationContext(); if (null != ctx) { SpringI18nMessageResolver i18n = new SpringI18nMessageResolver(); i18n.setApplicationContext(getApplicationContext()); p.put(RythmConfigurationKey.I18N_MESSAGE_RESOLVER.getKey(), i18n); } configRythm(p); // Apply properties to RythmEngine. RythmEngine engine = newRythmEngine(p); if (null != loaders) { for (ITemplateResourceLoader loader : loaders) { loader.setEngine(engine); } } postProcessRythmEngine(engine); return engine; }
[ "public", "RythmEngine", "createRythmEngine", "(", ")", "throws", "IOException", ",", "RythmException", "{", "Map", "<", "String", ",", "Object", ">", "p", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "p", ".", "put", "(", "...
Prepare the RythmEngine instance and return it. @return the RythmEngine instance @throws java.io.IOException if the config file wasn't found @throws RythmException on Rythm initialization failure
[ "Prepare", "the", "RythmEngine", "instance", "and", "return", "it", "." ]
a654016371c72dabaea50ac9a57626da7614d236
https://github.com/rythmengine/spring-rythm/blob/a654016371c72dabaea50ac9a57626da7614d236/src/main/java/org/rythmengine/spring/RythmEngineFactory.java#L208-L276
train
legsem/legstar.avro
legstar.avro.cob2avro/src/main/java/com/legstar/avro/cob2avro/io/ZosVarRdwDatumReader.java
ZosVarRdwDatumReader.getRecordLen
private static int getRecordLen(byte[] hostData, int start, int length) { int len = getRawRdw(hostData, start, length); if (len < RDW_LEN || len > hostData.length) { throw new IllegalArgumentException( "Record does not start with a Record Descriptor Word"); } /* Beware that raw rdw accounts for the rdw length (4 bytes) */ return len - RDW_LEN; }
java
private static int getRecordLen(byte[] hostData, int start, int length) { int len = getRawRdw(hostData, start, length); if (len < RDW_LEN || len > hostData.length) { throw new IllegalArgumentException( "Record does not start with a Record Descriptor Word"); } /* Beware that raw rdw accounts for the rdw length (4 bytes) */ return len - RDW_LEN; }
[ "private", "static", "int", "getRecordLen", "(", "byte", "[", "]", "hostData", ",", "int", "start", ",", "int", "length", ")", "{", "int", "len", "=", "getRawRdw", "(", "hostData", ",", "start", ",", "length", ")", ";", "if", "(", "len", "<", "RDW_LE...
RDW is a 4 bytes numeric stored in Big Endian as a binary 2's complement. @param hostData the mainframe data @param start where the RDW starts @param length the total size of the mainframe data @return the size of the record (actual data without the rdw itself)
[ "RDW", "is", "a", "4", "bytes", "numeric", "stored", "in", "Big", "Endian", "as", "a", "binary", "2", "s", "complement", "." ]
bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b
https://github.com/legsem/legstar.avro/blob/bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b/legstar.avro.cob2avro/src/main/java/com/legstar/avro/cob2avro/io/ZosVarRdwDatumReader.java#L96-L105
train
legsem/legstar.avro
legstar.avro.translator/src/main/java/com/legstar/avro/translator/Xsd2AvroTranslator.java
Xsd2AvroTranslator.translate
public String translate(XmlSchema xmlSchema, String avroNamespace, String avroSchemaName) throws Xsd2AvroTranslatorException { log.debug("XML Schema to Avro Schema translator started"); final Map < QName, XmlSchemaElement > items = xmlSchema.getElements(); ObjectNode rootAvroSchema = null; final ArrayNode avroFields = MAPPER.createArrayNode(); if (items.size() > 1) { // More then one root, create an aggregate record for (Entry < QName, XmlSchemaElement > entry : items.entrySet()) { visit(xmlSchema, entry.getValue(), 1, avroFields); } rootAvroSchema = buildAvroRecordType(avroSchemaName, avroFields); } else if (items.size() == 1) { XmlSchemaElement xsdElement = (XmlSchemaElement) items.values() .iterator().next(); if (xsdElement.getSchemaType() instanceof XmlSchemaComplexType) { XmlSchemaComplexType xsdType = (XmlSchemaComplexType) xsdElement .getSchemaType(); visit(xmlSchema, xsdType, 1, avroFields); rootAvroSchema = buildAvroRecordType(getAvroTypeName(xsdType), avroFields); } else { throw new Xsd2AvroTranslatorException( "XML schema does contain a root element but it is not a complex type"); } } else { throw new Xsd2AvroTranslatorException( "XML schema does not contain a root element"); } rootAvroSchema.put("namespace", avroNamespace == null ? "" : avroNamespace); log.debug("XML Schema to Avro Schema translator ended"); return rootAvroSchema.toString(); }
java
public String translate(XmlSchema xmlSchema, String avroNamespace, String avroSchemaName) throws Xsd2AvroTranslatorException { log.debug("XML Schema to Avro Schema translator started"); final Map < QName, XmlSchemaElement > items = xmlSchema.getElements(); ObjectNode rootAvroSchema = null; final ArrayNode avroFields = MAPPER.createArrayNode(); if (items.size() > 1) { // More then one root, create an aggregate record for (Entry < QName, XmlSchemaElement > entry : items.entrySet()) { visit(xmlSchema, entry.getValue(), 1, avroFields); } rootAvroSchema = buildAvroRecordType(avroSchemaName, avroFields); } else if (items.size() == 1) { XmlSchemaElement xsdElement = (XmlSchemaElement) items.values() .iterator().next(); if (xsdElement.getSchemaType() instanceof XmlSchemaComplexType) { XmlSchemaComplexType xsdType = (XmlSchemaComplexType) xsdElement .getSchemaType(); visit(xmlSchema, xsdType, 1, avroFields); rootAvroSchema = buildAvroRecordType(getAvroTypeName(xsdType), avroFields); } else { throw new Xsd2AvroTranslatorException( "XML schema does contain a root element but it is not a complex type"); } } else { throw new Xsd2AvroTranslatorException( "XML schema does not contain a root element"); } rootAvroSchema.put("namespace", avroNamespace == null ? "" : avroNamespace); log.debug("XML Schema to Avro Schema translator ended"); return rootAvroSchema.toString(); }
[ "public", "String", "translate", "(", "XmlSchema", "xmlSchema", ",", "String", "avroNamespace", ",", "String", "avroSchemaName", ")", "throws", "Xsd2AvroTranslatorException", "{", "log", ".", "debug", "(", "\"XML Schema to Avro Schema translator started\"", ")", ";", "f...
Translate the input XML Schema. @param xmlSchema the input XML Schema @param avroNamespace the target Avro namespace @param avroSchemaName the target Avro schema name @return the Avro schema as a JSON string @throws Xsd2AvroTranslatorException if translation fails
[ "Translate", "the", "input", "XML", "Schema", "." ]
bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b
https://github.com/legsem/legstar.avro/blob/bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b/legstar.avro.translator/src/main/java/com/legstar/avro/translator/Xsd2AvroTranslator.java#L149-L189
train
legsem/legstar.avro
legstar.avro.translator/src/main/java/com/legstar/avro/translator/Xsd2AvroTranslator.java
Xsd2AvroTranslator.visit
private void visit(XmlSchema xmlSchema, final XmlSchemaElement xsdElement, final int level, final ArrayNode avroFields) throws Xsd2AvroTranslatorException { /* * If this element is referencing another, it might not be useful to * process it. */ if (xsdElement.getRef().getTarget() != null) { return; } log.debug("process started for element = " + xsdElement.getName()); if (xsdElement.getSchemaType() instanceof XmlSchemaComplexType) { XmlSchemaComplexType xsdType = (XmlSchemaComplexType) xsdElement .getSchemaType(); int nextLevel = level + 1; final ArrayNode avroChildrenFields = MAPPER.createArrayNode(); visit(xmlSchema, xsdType, nextLevel, avroChildrenFields); ContainerNode avroRecordType = buildAvroCompositeType( getAvroTypeName(xsdType), avroChildrenFields, xsdElement.getMaxOccurs() > 1, xsdElement.getMinOccurs() == 0 && xsdElement.getMaxOccurs() == 1); ObjectNode avroRecordElement = MAPPER.createObjectNode(); avroRecordElement.put("type", avroRecordType); avroRecordElement.put("name", getAvroFieldName(xsdElement)); avroFields.add(avroRecordElement); } else if (xsdElement.getSchemaType() instanceof XmlSchemaSimpleType) { visit((XmlSchemaSimpleType) xsdElement.getSchemaType(), level, getAvroFieldName(xsdElement), xsdElement.getMinOccurs(), xsdElement.getMaxOccurs(), avroFields); } log.debug("process ended for element = " + xsdElement.getName()); }
java
private void visit(XmlSchema xmlSchema, final XmlSchemaElement xsdElement, final int level, final ArrayNode avroFields) throws Xsd2AvroTranslatorException { /* * If this element is referencing another, it might not be useful to * process it. */ if (xsdElement.getRef().getTarget() != null) { return; } log.debug("process started for element = " + xsdElement.getName()); if (xsdElement.getSchemaType() instanceof XmlSchemaComplexType) { XmlSchemaComplexType xsdType = (XmlSchemaComplexType) xsdElement .getSchemaType(); int nextLevel = level + 1; final ArrayNode avroChildrenFields = MAPPER.createArrayNode(); visit(xmlSchema, xsdType, nextLevel, avroChildrenFields); ContainerNode avroRecordType = buildAvroCompositeType( getAvroTypeName(xsdType), avroChildrenFields, xsdElement.getMaxOccurs() > 1, xsdElement.getMinOccurs() == 0 && xsdElement.getMaxOccurs() == 1); ObjectNode avroRecordElement = MAPPER.createObjectNode(); avroRecordElement.put("type", avroRecordType); avroRecordElement.put("name", getAvroFieldName(xsdElement)); avroFields.add(avroRecordElement); } else if (xsdElement.getSchemaType() instanceof XmlSchemaSimpleType) { visit((XmlSchemaSimpleType) xsdElement.getSchemaType(), level, getAvroFieldName(xsdElement), xsdElement.getMinOccurs(), xsdElement.getMaxOccurs(), avroFields); } log.debug("process ended for element = " + xsdElement.getName()); }
[ "private", "void", "visit", "(", "XmlSchema", "xmlSchema", ",", "final", "XmlSchemaElement", "xsdElement", ",", "final", "int", "level", ",", "final", "ArrayNode", "avroFields", ")", "throws", "Xsd2AvroTranslatorException", "{", "/*\n * If this element is referenc...
Process a regular XML schema element. @param xmlSchema the input XML schema @param xsdElement the XML Schema element to process @param level the current level in the elements hierarchy. @param avroFields array of fields being populated @throws Xsd2AvroTranslatorException if processing fails
[ "Process", "a", "regular", "XML", "schema", "element", "." ]
bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b
https://github.com/legsem/legstar.avro/blob/bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b/legstar.avro.translator/src/main/java/com/legstar/avro/translator/Xsd2AvroTranslator.java#L232-L269
train
legsem/legstar.avro
legstar.avro.translator/src/main/java/com/legstar/avro/translator/Xsd2AvroTranslator.java
Xsd2AvroTranslator.visit
private void visit(XmlSchema xmlSchema, XmlSchemaComplexType xsdType, final int level, final ArrayNode avroFields) { visit(xmlSchema, xsdType.getParticle(), level, avroFields); }
java
private void visit(XmlSchema xmlSchema, XmlSchemaComplexType xsdType, final int level, final ArrayNode avroFields) { visit(xmlSchema, xsdType.getParticle(), level, avroFields); }
[ "private", "void", "visit", "(", "XmlSchema", "xmlSchema", ",", "XmlSchemaComplexType", "xsdType", ",", "final", "int", "level", ",", "final", "ArrayNode", "avroFields", ")", "{", "visit", "(", "xmlSchema", ",", "xsdType", ".", "getParticle", "(", ")", ",", ...
Create an avro complex type field using an XML schema type. @param xsdType the XML schema complex type @param level the depth in the hierarchy @param avroFields array of avro fields being populated @throws Xsd2AvroTranslatorException if something abnormal in the xsd
[ "Create", "an", "avro", "complex", "type", "field", "using", "an", "XML", "schema", "type", "." ]
bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b
https://github.com/legsem/legstar.avro/blob/bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b/legstar.avro.translator/src/main/java/com/legstar/avro/translator/Xsd2AvroTranslator.java#L279-L284
train
legsem/legstar.avro
legstar.avro.translator/src/main/java/com/legstar/avro/translator/Xsd2AvroTranslator.java
Xsd2AvroTranslator.visit
private void visit(XmlSchemaSimpleType xsdType, final int level, final String avroFieldName, long minOccurs, long maxOccurs, ArrayNode avroFields) throws Xsd2AvroTranslatorException { Object avroType = getAvroPrimitiveType(avroFieldName, xsdType, maxOccurs > 1, minOccurs == 0 && maxOccurs == 1); ObjectNode avroField = MAPPER.createObjectNode(); avroField.put("name", avroFieldName); if (avroType != null) { if (avroType instanceof String) { avroField.put("type", (String) avroType); } else if (avroType instanceof JsonNode) { avroField.put("type", (JsonNode) avroType); } } avroFields.add(avroField); }
java
private void visit(XmlSchemaSimpleType xsdType, final int level, final String avroFieldName, long minOccurs, long maxOccurs, ArrayNode avroFields) throws Xsd2AvroTranslatorException { Object avroType = getAvroPrimitiveType(avroFieldName, xsdType, maxOccurs > 1, minOccurs == 0 && maxOccurs == 1); ObjectNode avroField = MAPPER.createObjectNode(); avroField.put("name", avroFieldName); if (avroType != null) { if (avroType instanceof String) { avroField.put("type", (String) avroType); } else if (avroType instanceof JsonNode) { avroField.put("type", (JsonNode) avroType); } } avroFields.add(avroField); }
[ "private", "void", "visit", "(", "XmlSchemaSimpleType", "xsdType", ",", "final", "int", "level", ",", "final", "String", "avroFieldName", ",", "long", "minOccurs", ",", "long", "maxOccurs", ",", "ArrayNode", "avroFields", ")", "throws", "Xsd2AvroTranslatorException"...
Create an avro primitive type field using an XML schema type. @param xsdType the XML schema simple type @param level the depth in the hierarchy @param avroFieldName to use as the field name for this avro field @param minOccurs lower dimension for arrays & zero for optional fields @param maxOccurs dimension for arrays @param avroFields array of avro fields being populated @throws Xsd2AvroTranslatorException if something abnormal in the xsd
[ "Create", "an", "avro", "primitive", "type", "field", "using", "an", "XML", "schema", "type", "." ]
bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b
https://github.com/legsem/legstar.avro/blob/bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b/legstar.avro.translator/src/main/java/com/legstar/avro/translator/Xsd2AvroTranslator.java#L297-L315
train
legsem/legstar.avro
legstar.avro.generator/src/main/java/com/legstar/avro/generator/CustomSpecificCompiler.java
CustomSpecificCompiler.isBigDecimal
public static boolean isBigDecimal(Schema schema) { if (Type.BYTES == schema.getType()) { JsonNode logicalTypeNode = schema.getJsonProp("logicalType"); if (logicalTypeNode != null && "decimal".equals(logicalTypeNode.asText())) { return true; } } return false; }
java
public static boolean isBigDecimal(Schema schema) { if (Type.BYTES == schema.getType()) { JsonNode logicalTypeNode = schema.getJsonProp("logicalType"); if (logicalTypeNode != null && "decimal".equals(logicalTypeNode.asText())) { return true; } } return false; }
[ "public", "static", "boolean", "isBigDecimal", "(", "Schema", "schema", ")", "{", "if", "(", "Type", ".", "BYTES", "==", "schema", ".", "getType", "(", ")", ")", "{", "JsonNode", "logicalTypeNode", "=", "schema", ".", "getJsonProp", "(", "\"logicalType\"", ...
Tests whether a field is to be externalized as a BigDecimal
[ "Tests", "whether", "a", "field", "is", "to", "be", "externalized", "as", "a", "BigDecimal" ]
bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b
https://github.com/legsem/legstar.avro/blob/bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b/legstar.avro.generator/src/main/java/com/legstar/avro/generator/CustomSpecificCompiler.java#L36-L45
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/RepositoryModule.java
RepositoryModule.configureAop
protected void configureAop() { final RepositoryMethodInterceptor proxy = new RepositoryMethodInterceptor(); requestInjection(proxy); // repository specific method annotations (query, function, delegate, etc.) bindInterceptor(Matchers.any(), new AbstractMatcher<Method>() { @Override public boolean matches(final Method method) { // this will throw error if two or more annotations specified (fail fast) try { return ExtUtils.findMethodAnnotation(method) != null; } catch (Exception ex) { throw new MethodDefinitionException(String.format("Error declaration on method %s", RepositoryUtils.methodToString(method)), ex); } } }, proxy); }
java
protected void configureAop() { final RepositoryMethodInterceptor proxy = new RepositoryMethodInterceptor(); requestInjection(proxy); // repository specific method annotations (query, function, delegate, etc.) bindInterceptor(Matchers.any(), new AbstractMatcher<Method>() { @Override public boolean matches(final Method method) { // this will throw error if two or more annotations specified (fail fast) try { return ExtUtils.findMethodAnnotation(method) != null; } catch (Exception ex) { throw new MethodDefinitionException(String.format("Error declaration on method %s", RepositoryUtils.methodToString(method)), ex); } } }, proxy); }
[ "protected", "void", "configureAop", "(", ")", "{", "final", "RepositoryMethodInterceptor", "proxy", "=", "new", "RepositoryMethodInterceptor", "(", ")", ";", "requestInjection", "(", "proxy", ")", ";", "// repository specific method annotations (query, function, delegate, et...
Configures repository annotations interceptor.
[ "Configures", "repository", "annotations", "interceptor", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/RepositoryModule.java#L108-L124
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/RepositoryModule.java
RepositoryModule.bindExecutor
protected void bindExecutor(final Class<? extends RepositoryExecutor> executor) { bind(executor).in(Singleton.class); executorsMultibinder.addBinding().to(executor); }
java
protected void bindExecutor(final Class<? extends RepositoryExecutor> executor) { bind(executor).in(Singleton.class); executorsMultibinder.addBinding().to(executor); }
[ "protected", "void", "bindExecutor", "(", "final", "Class", "<", "?", "extends", "RepositoryExecutor", ">", "executor", ")", "{", "bind", "(", "executor", ")", ".", "in", "(", "Singleton", ".", "class", ")", ";", "executorsMultibinder", ".", "addBinding", "(...
Register executor for specific connection type. @param executor executor type
[ "Register", "executor", "for", "specific", "connection", "type", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/RepositoryModule.java#L142-L145
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/RepositoryModule.java
RepositoryModule.loadOptionalExecutor
protected void loadOptionalExecutor(final String executorBinder) { try { final Method bindExecutor = RepositoryModule.class.getDeclaredMethod("bindExecutor", Class.class); bindExecutor.setAccessible(true); try { Class.forName(executorBinder) .getConstructor(RepositoryModule.class, Method.class) .newInstance(this, bindExecutor); } finally { bindExecutor.setAccessible(false); } } catch (Exception ignore) { if (logger.isTraceEnabled()) { logger.trace("Failed to process executor loader " + executorBinder, ignore); } } }
java
protected void loadOptionalExecutor(final String executorBinder) { try { final Method bindExecutor = RepositoryModule.class.getDeclaredMethod("bindExecutor", Class.class); bindExecutor.setAccessible(true); try { Class.forName(executorBinder) .getConstructor(RepositoryModule.class, Method.class) .newInstance(this, bindExecutor); } finally { bindExecutor.setAccessible(false); } } catch (Exception ignore) { if (logger.isTraceEnabled()) { logger.trace("Failed to process executor loader " + executorBinder, ignore); } } }
[ "protected", "void", "loadOptionalExecutor", "(", "final", "String", "executorBinder", ")", "{", "try", "{", "final", "Method", "bindExecutor", "=", "RepositoryModule", ".", "class", ".", "getDeclaredMethod", "(", "\"bindExecutor\"", ",", "Class", ".", "class", ")...
Allows to load executor only if required jars are in classpath. For example, no need for graph dependencies if only object db is used. @param executorBinder executor binder class @see ru.vyarus.guice.persist.orient.support.repository.ObjectExecutorBinder as example
[ "Allows", "to", "load", "executor", "only", "if", "required", "jars", "are", "in", "classpath", ".", "For", "example", "no", "need", "for", "graph", "dependencies", "if", "only", "object", "db", "is", "used", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/RepositoryModule.java#L154-L170
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java
RecyclerView.setAdapter
public void setAdapter(Adapter adapter) { if (mAdapter != null) { mAdapter.unregisterAdapterDataObserver(mObserver); } // end all running animations if (mItemAnimator != null) { mItemAnimator.endAnimations(); } // Since animations are ended, mLayout.children should be equal to recyclerView.children. // This may not be true if item animator's end does not work as expected. (e.g. not release // children instantly). It is safer to use mLayout's child count. if (mLayout != null) { mLayout.removeAndRecycleAllViews(mRecycler); mLayout.removeAndRecycleScrapInt(mRecycler, true); } final Adapter oldAdapter = mAdapter; mAdapter = adapter; if (adapter != null) { adapter.registerAdapterDataObserver(mObserver); } if (mLayout != null) { mLayout.onAdapterChanged(oldAdapter, mAdapter); } mRecycler.onAdapterChanged(oldAdapter, mAdapter); mState.mStructureChanged = true; markKnownViewsInvalid(); requestLayout(); }
java
public void setAdapter(Adapter adapter) { if (mAdapter != null) { mAdapter.unregisterAdapterDataObserver(mObserver); } // end all running animations if (mItemAnimator != null) { mItemAnimator.endAnimations(); } // Since animations are ended, mLayout.children should be equal to recyclerView.children. // This may not be true if item animator's end does not work as expected. (e.g. not release // children instantly). It is safer to use mLayout's child count. if (mLayout != null) { mLayout.removeAndRecycleAllViews(mRecycler); mLayout.removeAndRecycleScrapInt(mRecycler, true); } final Adapter oldAdapter = mAdapter; mAdapter = adapter; if (adapter != null) { adapter.registerAdapterDataObserver(mObserver); } if (mLayout != null) { mLayout.onAdapterChanged(oldAdapter, mAdapter); } mRecycler.onAdapterChanged(oldAdapter, mAdapter); mState.mStructureChanged = true; markKnownViewsInvalid(); requestLayout(); }
[ "public", "void", "setAdapter", "(", "Adapter", "adapter", ")", "{", "if", "(", "mAdapter", "!=", "null", ")", "{", "mAdapter", ".", "unregisterAdapterDataObserver", "(", "mObserver", ")", ";", "}", "// end all running animations", "if", "(", "mItemAnimator", "!...
Set a new adapter to provide child views on demand. @param adapter The new adapter to set, or null to set no adapter.
[ "Set", "a", "new", "adapter", "to", "provide", "child", "views", "on", "demand", "." ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java#L290-L318
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java
RecyclerView.addAnimatingView
private void addAnimatingView(View view) { boolean alreadyAdded = false; if (mNumAnimatingViews > 0) { for (int i = mAnimatingViewIndex; i < getChildCount(); ++i) { if (getChildAt(i) == view) { alreadyAdded = true; break; } } } if (!alreadyAdded) { if (mNumAnimatingViews == 0) { mAnimatingViewIndex = getChildCount(); } ++mNumAnimatingViews; addView(view); } mRecycler.unscrapView(getChildViewHolder(view)); }
java
private void addAnimatingView(View view) { boolean alreadyAdded = false; if (mNumAnimatingViews > 0) { for (int i = mAnimatingViewIndex; i < getChildCount(); ++i) { if (getChildAt(i) == view) { alreadyAdded = true; break; } } } if (!alreadyAdded) { if (mNumAnimatingViews == 0) { mAnimatingViewIndex = getChildCount(); } ++mNumAnimatingViews; addView(view); } mRecycler.unscrapView(getChildViewHolder(view)); }
[ "private", "void", "addAnimatingView", "(", "View", "view", ")", "{", "boolean", "alreadyAdded", "=", "false", ";", "if", "(", "mNumAnimatingViews", ">", "0", ")", "{", "for", "(", "int", "i", "=", "mAnimatingViewIndex", ";", "i", "<", "getChildCount", "("...
Adds a view to the animatingViews list. mAnimatingViews holds the child views that are currently being kept around purely for the purpose of being animated out of view. They are drawn as a regular part of the child list of the RecyclerView, but they are invisible to the LayoutManager as they are managed separately from the regular child views. @param view The view to be removed
[ "Adds", "a", "view", "to", "the", "animatingViews", "list", ".", "mAnimatingViews", "holds", "the", "child", "views", "that", "are", "currently", "being", "kept", "around", "purely", "for", "the", "purpose", "of", "being", "animated", "out", "of", "view", "....
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java#L414-L432
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java
RecyclerView.removeAnimatingView
private void removeAnimatingView(View view) { if (mNumAnimatingViews > 0) { for (int i = mAnimatingViewIndex; i < getChildCount(); ++i) { if (getChildAt(i) == view) { removeViewAt(i); --mNumAnimatingViews; if (mNumAnimatingViews == 0) { mAnimatingViewIndex = -1; } mRecycler.recycleView(view); return; } } } }
java
private void removeAnimatingView(View view) { if (mNumAnimatingViews > 0) { for (int i = mAnimatingViewIndex; i < getChildCount(); ++i) { if (getChildAt(i) == view) { removeViewAt(i); --mNumAnimatingViews; if (mNumAnimatingViews == 0) { mAnimatingViewIndex = -1; } mRecycler.recycleView(view); return; } } } }
[ "private", "void", "removeAnimatingView", "(", "View", "view", ")", "{", "if", "(", "mNumAnimatingViews", ">", "0", ")", "{", "for", "(", "int", "i", "=", "mAnimatingViewIndex", ";", "i", "<", "getChildCount", "(", ")", ";", "++", "i", ")", "{", "if", ...
Removes a view from the animatingViews list. @param view The view to be removed @see #addAnimatingView(android.view.View)
[ "Removes", "a", "view", "from", "the", "animatingViews", "list", "." ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java#L439-L453
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java
RecyclerView.scrollByInternal
void scrollByInternal(int x, int y) { int overscrollX = 0, overscrollY = 0; consumePendingUpdateOperations(); if (mAdapter != null) { eatRequestLayout(); if (x != 0) { final int hresult = mLayout.scrollHorizontallyBy(x, mRecycler, mState); overscrollX = x - hresult; } if (y != 0) { final int vresult = mLayout.scrollVerticallyBy(y, mRecycler, mState); overscrollY = y - vresult; } resumeRequestLayout(false); } if (!mItemDecorations.isEmpty()) { invalidate(); } if (ViewCompat.getOverScrollMode(this) != ViewCompat.OVER_SCROLL_NEVER) { pullGlows(overscrollX, overscrollY); } if (mScrollListener != null && (x != 0 || y != 0)) { mScrollListener.onScrolled(x, y); } if (!awakenScrollBars()) { invalidate(); } }
java
void scrollByInternal(int x, int y) { int overscrollX = 0, overscrollY = 0; consumePendingUpdateOperations(); if (mAdapter != null) { eatRequestLayout(); if (x != 0) { final int hresult = mLayout.scrollHorizontallyBy(x, mRecycler, mState); overscrollX = x - hresult; } if (y != 0) { final int vresult = mLayout.scrollVerticallyBy(y, mRecycler, mState); overscrollY = y - vresult; } resumeRequestLayout(false); } if (!mItemDecorations.isEmpty()) { invalidate(); } if (ViewCompat.getOverScrollMode(this) != ViewCompat.OVER_SCROLL_NEVER) { pullGlows(overscrollX, overscrollY); } if (mScrollListener != null && (x != 0 || y != 0)) { mScrollListener.onScrolled(x, y); } if (!awakenScrollBars()) { invalidate(); } }
[ "void", "scrollByInternal", "(", "int", "x", ",", "int", "y", ")", "{", "int", "overscrollX", "=", "0", ",", "overscrollY", "=", "0", ";", "consumePendingUpdateOperations", "(", ")", ";", "if", "(", "mAdapter", "!=", "null", ")", "{", "eatRequestLayout", ...
Does not perform bounds checking. Used by internal methods that have already validated input.
[ "Does", "not", "perform", "bounds", "checking", ".", "Used", "by", "internal", "methods", "that", "have", "already", "validated", "input", "." ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java#L686-L714
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java
RecyclerView.fling
public boolean fling(int velocityX, int velocityY) { if (Math.abs(velocityX) < mMinFlingVelocity) { velocityX = 0; } if (Math.abs(velocityY) < mMinFlingVelocity) { velocityY = 0; } velocityX = Math.max(-mMaxFlingVelocity, Math.min(velocityX, mMaxFlingVelocity)); velocityY = Math.max(-mMaxFlingVelocity, Math.min(velocityY, mMaxFlingVelocity)); if (velocityX != 0 || velocityY != 0) { mViewFlinger.fling(velocityX, velocityY); return true; } return false; }
java
public boolean fling(int velocityX, int velocityY) { if (Math.abs(velocityX) < mMinFlingVelocity) { velocityX = 0; } if (Math.abs(velocityY) < mMinFlingVelocity) { velocityY = 0; } velocityX = Math.max(-mMaxFlingVelocity, Math.min(velocityX, mMaxFlingVelocity)); velocityY = Math.max(-mMaxFlingVelocity, Math.min(velocityY, mMaxFlingVelocity)); if (velocityX != 0 || velocityY != 0) { mViewFlinger.fling(velocityX, velocityY); return true; } return false; }
[ "public", "boolean", "fling", "(", "int", "velocityX", ",", "int", "velocityY", ")", "{", "if", "(", "Math", ".", "abs", "(", "velocityX", ")", "<", "mMinFlingVelocity", ")", "{", "velocityX", "=", "0", ";", "}", "if", "(", "Math", ".", "abs", "(", ...
Begin a standard fling with an initial velocity along each axis in pixels per second. If the velocity given is below the system-defined minimum this method will return false and no fling will occur. @param velocityX Initial horizontal velocity in pixels per second @param velocityY Initial vertical velocity in pixels per second @return true if the fling was started, false if the velocity was too low to fling
[ "Begin", "a", "standard", "fling", "with", "an", "initial", "velocity", "along", "each", "axis", "in", "pixels", "per", "second", ".", "If", "the", "velocity", "given", "is", "below", "the", "system", "-", "defined", "minimum", "this", "method", "will", "r...
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java#L885-L899
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java
RecyclerView.pullGlows
private void pullGlows(int overscrollX, int overscrollY) { if (overscrollX < 0) { if (mLeftGlow == null) { mLeftGlow = new EdgeEffectCompat(getContext()); mLeftGlow.setSize(getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), getMeasuredWidth() - getPaddingLeft() - getPaddingRight()); } mLeftGlow.onPull(-overscrollX / (float) getWidth()); } else if (overscrollX > 0) { if (mRightGlow == null) { mRightGlow = new EdgeEffectCompat(getContext()); mRightGlow.setSize(getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), getMeasuredWidth() - getPaddingLeft() - getPaddingRight()); } mRightGlow.onPull(overscrollX / (float) getWidth()); } if (overscrollY < 0) { if (mTopGlow == null) { mTopGlow = new EdgeEffectCompat(getContext()); mTopGlow.setSize(getMeasuredWidth() - getPaddingLeft() - getPaddingRight(), getMeasuredHeight() - getPaddingTop() - getPaddingBottom()); } mTopGlow.onPull(-overscrollY / (float) getHeight()); } else if (overscrollY > 0) { if (mBottomGlow == null) { mBottomGlow = new EdgeEffectCompat(getContext()); mBottomGlow.setSize(getMeasuredWidth() - getPaddingLeft() - getPaddingRight(), getMeasuredHeight() - getPaddingTop() - getPaddingBottom()); } mBottomGlow.onPull(overscrollY / (float) getHeight()); } if (overscrollX != 0 || overscrollY != 0) { ViewCompat.postInvalidateOnAnimation(this); } }
java
private void pullGlows(int overscrollX, int overscrollY) { if (overscrollX < 0) { if (mLeftGlow == null) { mLeftGlow = new EdgeEffectCompat(getContext()); mLeftGlow.setSize(getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), getMeasuredWidth() - getPaddingLeft() - getPaddingRight()); } mLeftGlow.onPull(-overscrollX / (float) getWidth()); } else if (overscrollX > 0) { if (mRightGlow == null) { mRightGlow = new EdgeEffectCompat(getContext()); mRightGlow.setSize(getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), getMeasuredWidth() - getPaddingLeft() - getPaddingRight()); } mRightGlow.onPull(overscrollX / (float) getWidth()); } if (overscrollY < 0) { if (mTopGlow == null) { mTopGlow = new EdgeEffectCompat(getContext()); mTopGlow.setSize(getMeasuredWidth() - getPaddingLeft() - getPaddingRight(), getMeasuredHeight() - getPaddingTop() - getPaddingBottom()); } mTopGlow.onPull(-overscrollY / (float) getHeight()); } else if (overscrollY > 0) { if (mBottomGlow == null) { mBottomGlow = new EdgeEffectCompat(getContext()); mBottomGlow.setSize(getMeasuredWidth() - getPaddingLeft() - getPaddingRight(), getMeasuredHeight() - getPaddingTop() - getPaddingBottom()); } mBottomGlow.onPull(overscrollY / (float) getHeight()); } if (overscrollX != 0 || overscrollY != 0) { ViewCompat.postInvalidateOnAnimation(this); } }
[ "private", "void", "pullGlows", "(", "int", "overscrollX", ",", "int", "overscrollY", ")", "{", "if", "(", "overscrollX", "<", "0", ")", "{", "if", "(", "mLeftGlow", "==", "null", ")", "{", "mLeftGlow", "=", "new", "EdgeEffectCompat", "(", "getContext", ...
Apply a pull to relevant overscroll glow effects
[ "Apply", "a", "pull", "to", "relevant", "overscroll", "glow", "effects" ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java#L913-L949
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java
RecyclerView.viewRangeUpdate
void viewRangeUpdate(int positionStart, int itemCount) { final int childCount = getChildCount(); final int positionEnd = positionStart + itemCount; for (int i = 0; i < childCount; i++) { final ViewHolder holder = getChildViewHolderInt(getChildAt(i)); if (holder == null) { continue; } final int position = holder.getPosition(); if (position >= positionStart && position < positionEnd) { holder.addFlags(ViewHolder.FLAG_UPDATE); // Binding an attached view will request a layout if needed. mAdapter.bindViewHolder(holder, holder.getPosition()); } } mRecycler.viewRangeUpdate(positionStart, itemCount); }
java
void viewRangeUpdate(int positionStart, int itemCount) { final int childCount = getChildCount(); final int positionEnd = positionStart + itemCount; for (int i = 0; i < childCount; i++) { final ViewHolder holder = getChildViewHolderInt(getChildAt(i)); if (holder == null) { continue; } final int position = holder.getPosition(); if (position >= positionStart && position < positionEnd) { holder.addFlags(ViewHolder.FLAG_UPDATE); // Binding an attached view will request a layout if needed. mAdapter.bindViewHolder(holder, holder.getPosition()); } } mRecycler.viewRangeUpdate(positionStart, itemCount); }
[ "void", "viewRangeUpdate", "(", "int", "positionStart", ",", "int", "itemCount", ")", "{", "final", "int", "childCount", "=", "getChildCount", "(", ")", ";", "final", "int", "positionEnd", "=", "positionStart", "+", "itemCount", ";", "for", "(", "int", "i", ...
Rebind existing views for the given range, or create as needed. @param positionStart Adapter position to start at @param itemCount Number of views that must explicitly be rebound
[ "Rebind", "existing", "views", "for", "the", "given", "range", "or", "create", "as", "needed", "." ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java#L1880-L1898
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java
RecyclerView.markKnownViewsInvalid
void markKnownViewsInvalid() { final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final ViewHolder holder = getChildViewHolderInt(getChildAt(i)); if (holder != null) { holder.addFlags(ViewHolder.FLAG_UPDATE | ViewHolder.FLAG_INVALID); } } mRecycler.markKnownViewsInvalid(); }
java
void markKnownViewsInvalid() { final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final ViewHolder holder = getChildViewHolderInt(getChildAt(i)); if (holder != null) { holder.addFlags(ViewHolder.FLAG_UPDATE | ViewHolder.FLAG_INVALID); } } mRecycler.markKnownViewsInvalid(); }
[ "void", "markKnownViewsInvalid", "(", ")", "{", "final", "int", "childCount", "=", "getChildCount", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "childCount", ";", "i", "++", ")", "{", "final", "ViewHolder", "holder", "=", "getChildV...
Mark all known views as invalid. Used in response to a, "the whole world might have changed" data change event.
[ "Mark", "all", "known", "views", "as", "invalid", ".", "Used", "in", "response", "to", "a", "the", "whole", "world", "might", "have", "changed", "data", "change", "event", "." ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java#L1904-L1914
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java
RecyclerView.postAdapterUpdate
void postAdapterUpdate(UpdateOp op) { mPendingUpdates.add(op); if (mPendingUpdates.size() == 1) { if (mPostUpdatesOnAnimation && mHasFixedSize && mIsAttached) { ViewCompat.postOnAnimation(this, mUpdateChildViewsRunnable); } else { mAdapterUpdateDuringMeasure = true; requestLayout(); } } }
java
void postAdapterUpdate(UpdateOp op) { mPendingUpdates.add(op); if (mPendingUpdates.size() == 1) { if (mPostUpdatesOnAnimation && mHasFixedSize && mIsAttached) { ViewCompat.postOnAnimation(this, mUpdateChildViewsRunnable); } else { mAdapterUpdateDuringMeasure = true; requestLayout(); } } }
[ "void", "postAdapterUpdate", "(", "UpdateOp", "op", ")", "{", "mPendingUpdates", ".", "add", "(", "op", ")", ";", "if", "(", "mPendingUpdates", ".", "size", "(", ")", "==", "1", ")", "{", "if", "(", "mPostUpdatesOnAnimation", "&&", "mHasFixedSize", "&&", ...
Schedule an update of data from the adapter to occur on the next frame. On newer platform versions this happens via the postOnAnimation mechanism and RecyclerView attempts to avoid relayouts if possible. On older platform versions the RecyclerView requests a layout the same way ListView does.
[ "Schedule", "an", "update", "of", "data", "from", "the", "adapter", "to", "occur", "on", "the", "next", "frame", ".", "On", "newer", "platform", "versions", "this", "happens", "via", "the", "postOnAnimation", "mechanism", "and", "RecyclerView", "attempts", "to...
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java#L1922-L1932
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java
RecyclerView.getChildPosition
public int getChildPosition(View child) { final ViewHolder holder = getChildViewHolderInt(child); return holder != null ? holder.getPosition() : NO_POSITION; }
java
public int getChildPosition(View child) { final ViewHolder holder = getChildViewHolderInt(child); return holder != null ? holder.getPosition() : NO_POSITION; }
[ "public", "int", "getChildPosition", "(", "View", "child", ")", "{", "final", "ViewHolder", "holder", "=", "getChildViewHolderInt", "(", "child", ")", ";", "return", "holder", "!=", "null", "?", "holder", ".", "getPosition", "(", ")", ":", "NO_POSITION", ";"...
Return the adapter position that the given child view corresponds to. @param child Child View to query @return Adapter position corresponding to the given view or {@link #NO_POSITION}
[ "Return", "the", "adapter", "position", "that", "the", "given", "child", "view", "corresponds", "to", "." ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java#L1962-L1965
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java
RecyclerView.getChildItemId
public long getChildItemId(View child) { if (mAdapter == null || !mAdapter.hasStableIds()) { return NO_ID; } final ViewHolder holder = getChildViewHolderInt(child); return holder != null ? holder.getItemId() : NO_ID; }
java
public long getChildItemId(View child) { if (mAdapter == null || !mAdapter.hasStableIds()) { return NO_ID; } final ViewHolder holder = getChildViewHolderInt(child); return holder != null ? holder.getItemId() : NO_ID; }
[ "public", "long", "getChildItemId", "(", "View", "child", ")", "{", "if", "(", "mAdapter", "==", "null", "||", "!", "mAdapter", ".", "hasStableIds", "(", ")", ")", "{", "return", "NO_ID", ";", "}", "final", "ViewHolder", "holder", "=", "getChildViewHolderI...
Return the stable item id that the given child view corresponds to. @param child Child View to query @return Item id corresponding to the given view or {@link #NO_ID}
[ "Return", "the", "stable", "item", "id", "that", "the", "given", "child", "view", "corresponds", "to", "." ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java#L1973-L1979
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java
RecyclerView.findChildViewUnder
public View findChildViewUnder(float x, float y) { final int count = getChildCount(); for (int i = count - 1; i >= 0; i--) { final View child = getChildAt(i); final float translationX = ViewCompat.getTranslationX(child); final float translationY = ViewCompat.getTranslationY(child); if (x >= child.getLeft() + translationX && x <= child.getRight() + translationX && y >= child.getTop() + translationY && y <= child.getBottom() + translationY) { return child; } } return null; }
java
public View findChildViewUnder(float x, float y) { final int count = getChildCount(); for (int i = count - 1; i >= 0; i--) { final View child = getChildAt(i); final float translationX = ViewCompat.getTranslationX(child); final float translationY = ViewCompat.getTranslationY(child); if (x >= child.getLeft() + translationX && x <= child.getRight() + translationX && y >= child.getTop() + translationY && y <= child.getBottom() + translationY) { return child; } } return null; }
[ "public", "View", "findChildViewUnder", "(", "float", "x", ",", "float", "y", ")", "{", "final", "int", "count", "=", "getChildCount", "(", ")", ";", "for", "(", "int", "i", "=", "count", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", ...
Find the topmost view under the given point. @param x Horizontal position in pixels to search @param y Vertical position in pixels to search @return The child view under (x, y) or null if no matching child is found
[ "Find", "the", "topmost", "view", "under", "the", "given", "point", "." ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java#L2035-L2049
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/LinearSmoothScroller.java
LinearSmoothScroller.getHorizontalSnapPreference
protected int getHorizontalSnapPreference() { return mTargetVector == null || mTargetVector.x == 0 ? SNAP_TO_ANY : mTargetVector.x > 0 ? SNAP_TO_END : SNAP_TO_START; }
java
protected int getHorizontalSnapPreference() { return mTargetVector == null || mTargetVector.x == 0 ? SNAP_TO_ANY : mTargetVector.x > 0 ? SNAP_TO_END : SNAP_TO_START; }
[ "protected", "int", "getHorizontalSnapPreference", "(", ")", "{", "return", "mTargetVector", "==", "null", "||", "mTargetVector", ".", "x", "==", "0", "?", "SNAP_TO_ANY", ":", "mTargetVector", ".", "x", ">", "0", "?", "SNAP_TO_END", ":", "SNAP_TO_START", ";", ...
When scrolling towards a child view, this method defines whether we should align the left or the right edge of the child with the parent RecyclerView. @return SNAP_TO_START, SNAP_TO_END or SNAP_TO_ANY; depending on the current target vector @see #SNAP_TO_START @see #SNAP_TO_END @see #SNAP_TO_ANY
[ "When", "scrolling", "towards", "a", "child", "view", "this", "method", "defines", "whether", "we", "should", "align", "the", "left", "or", "the", "right", "edge", "of", "the", "child", "with", "the", "parent", "RecyclerView", "." ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/LinearSmoothScroller.java#L199-L202
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/LinearSmoothScroller.java
LinearSmoothScroller.getVerticalSnapPreference
protected int getVerticalSnapPreference() { return mTargetVector == null || mTargetVector.y == 0 ? SNAP_TO_ANY : mTargetVector.y > 0 ? SNAP_TO_END : SNAP_TO_START; }
java
protected int getVerticalSnapPreference() { return mTargetVector == null || mTargetVector.y == 0 ? SNAP_TO_ANY : mTargetVector.y > 0 ? SNAP_TO_END : SNAP_TO_START; }
[ "protected", "int", "getVerticalSnapPreference", "(", ")", "{", "return", "mTargetVector", "==", "null", "||", "mTargetVector", ".", "y", "==", "0", "?", "SNAP_TO_ANY", ":", "mTargetVector", ".", "y", ">", "0", "?", "SNAP_TO_END", ":", "SNAP_TO_START", ";", ...
When scrolling towards a child view, this method defines whether we should align the top or the bottom edge of the child with the parent RecyclerView. @return SNAP_TO_START, SNAP_TO_END or SNAP_TO_ANY; depending on the current target vector @see #SNAP_TO_START @see #SNAP_TO_END @see #SNAP_TO_ANY
[ "When", "scrolling", "towards", "a", "child", "view", "this", "method", "defines", "whether", "we", "should", "align", "the", "top", "or", "the", "bottom", "edge", "of", "the", "child", "with", "the", "parent", "RecyclerView", "." ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/LinearSmoothScroller.java#L213-L216
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/LinearSmoothScroller.java
LinearSmoothScroller.updateActionForInterimTarget
protected void updateActionForInterimTarget(Action action) { // find an interim target position PointF scrollVector = computeScrollVectorForPosition(getTargetPosition()); if (scrollVector == null || (scrollVector.x == 0 && scrollVector.y == 0)) { Log.e(TAG, "To support smooth scrolling, you should override \n" + "LayoutManager#computeScrollVectorForPosition.\n" + "Falling back to instant scroll"); final int target = getTargetPosition(); stop(); instantScrollToPosition(target); return; } normalize(scrollVector); mTargetVector = scrollVector; mInterimTargetDx = (int) (TARGET_SEEK_SCROLL_DISTANCE_PX * scrollVector.x); mInterimTargetDy = (int) (TARGET_SEEK_SCROLL_DISTANCE_PX * scrollVector.y); final int time = calculateTimeForScrolling(TARGET_SEEK_SCROLL_DISTANCE_PX); // To avoid UI hiccups, trigger a smooth scroll to a distance little further than the // interim target. Since we track the distance travelled in onSeekTargetStep callback, it // won't actually scroll more than what we need. action.update((int) (mInterimTargetDx * TARGET_SEEK_EXTRA_SCROLL_RATIO) , (int) (mInterimTargetDy * TARGET_SEEK_EXTRA_SCROLL_RATIO) , (int) (time * TARGET_SEEK_EXTRA_SCROLL_RATIO), mLinearInterpolator); }
java
protected void updateActionForInterimTarget(Action action) { // find an interim target position PointF scrollVector = computeScrollVectorForPosition(getTargetPosition()); if (scrollVector == null || (scrollVector.x == 0 && scrollVector.y == 0)) { Log.e(TAG, "To support smooth scrolling, you should override \n" + "LayoutManager#computeScrollVectorForPosition.\n" + "Falling back to instant scroll"); final int target = getTargetPosition(); stop(); instantScrollToPosition(target); return; } normalize(scrollVector); mTargetVector = scrollVector; mInterimTargetDx = (int) (TARGET_SEEK_SCROLL_DISTANCE_PX * scrollVector.x); mInterimTargetDy = (int) (TARGET_SEEK_SCROLL_DISTANCE_PX * scrollVector.y); final int time = calculateTimeForScrolling(TARGET_SEEK_SCROLL_DISTANCE_PX); // To avoid UI hiccups, trigger a smooth scroll to a distance little further than the // interim target. Since we track the distance travelled in onSeekTargetStep callback, it // won't actually scroll more than what we need. action.update((int) (mInterimTargetDx * TARGET_SEEK_EXTRA_SCROLL_RATIO) , (int) (mInterimTargetDy * TARGET_SEEK_EXTRA_SCROLL_RATIO) , (int) (time * TARGET_SEEK_EXTRA_SCROLL_RATIO), mLinearInterpolator); }
[ "protected", "void", "updateActionForInterimTarget", "(", "Action", "action", ")", "{", "// find an interim target position", "PointF", "scrollVector", "=", "computeScrollVectorForPosition", "(", "getTargetPosition", "(", ")", ")", ";", "if", "(", "scrollVector", "==", ...
When the target scroll position is not a child of the RecyclerView, this method calculates a direction vector towards that child and triggers a smooth scroll. @see #computeScrollVectorForPosition(int)
[ "When", "the", "target", "scroll", "position", "is", "not", "a", "child", "of", "the", "RecyclerView", "this", "method", "calculates", "a", "direction", "vector", "towards", "that", "child", "and", "triggers", "a", "smooth", "scroll", "." ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/LinearSmoothScroller.java#L224-L248
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/LinearSmoothScroller.java
LinearSmoothScroller.calculateDyToMakeVisible
public int calculateDyToMakeVisible(View view, int snapPreference) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (!layoutManager.canScrollVertically()) { return 0; } final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); final int top = layoutManager.getDecoratedTop(view) - params.topMargin; final int bottom = layoutManager.getDecoratedBottom(view) + params.bottomMargin; final int start = layoutManager.getPaddingTop(); final int end = layoutManager.getHeight() - layoutManager.getPaddingBottom(); return calculateDtToFit(top, bottom, start, end, snapPreference); }
java
public int calculateDyToMakeVisible(View view, int snapPreference) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (!layoutManager.canScrollVertically()) { return 0; } final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); final int top = layoutManager.getDecoratedTop(view) - params.topMargin; final int bottom = layoutManager.getDecoratedBottom(view) + params.bottomMargin; final int start = layoutManager.getPaddingTop(); final int end = layoutManager.getHeight() - layoutManager.getPaddingBottom(); return calculateDtToFit(top, bottom, start, end, snapPreference); }
[ "public", "int", "calculateDyToMakeVisible", "(", "View", "view", ",", "int", "snapPreference", ")", "{", "final", "RecyclerView", ".", "LayoutManager", "layoutManager", "=", "getLayoutManager", "(", ")", ";", "if", "(", "!", "layoutManager", ".", "canScrollVertic...
Calculates the vertical scroll amount necessary to make the given view fully visible inside the RecyclerView. @param view The view which we want to make fully visible @param snapPreference The edge which the view should snap to when entering the visible area. One of {@link #SNAP_TO_START}, {@link #SNAP_TO_END} or {@link #SNAP_TO_END}. @return The vertical scroll amount necessary to make the view visible with the given snap preference.
[ "Calculates", "the", "vertical", "scroll", "amount", "necessary", "to", "make", "the", "given", "view", "fully", "visible", "inside", "the", "RecyclerView", "." ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/LinearSmoothScroller.java#L298-L310
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/android/support/v7/widget/LinearSmoothScroller.java
LinearSmoothScroller.calculateDxToMakeVisible
public int calculateDxToMakeVisible(View view, int snapPreference) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (!layoutManager.canScrollHorizontally()) { return 0; } final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); final int left = layoutManager.getDecoratedLeft(view) - params.leftMargin; final int right = layoutManager.getDecoratedRight(view) + params.rightMargin; final int start = layoutManager.getPaddingLeft(); final int end = layoutManager.getWidth() - layoutManager.getPaddingRight(); return calculateDtToFit(left, right, start, end, snapPreference); }
java
public int calculateDxToMakeVisible(View view, int snapPreference) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (!layoutManager.canScrollHorizontally()) { return 0; } final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); final int left = layoutManager.getDecoratedLeft(view) - params.leftMargin; final int right = layoutManager.getDecoratedRight(view) + params.rightMargin; final int start = layoutManager.getPaddingLeft(); final int end = layoutManager.getWidth() - layoutManager.getPaddingRight(); return calculateDtToFit(left, right, start, end, snapPreference); }
[ "public", "int", "calculateDxToMakeVisible", "(", "View", "view", ",", "int", "snapPreference", ")", "{", "final", "RecyclerView", ".", "LayoutManager", "layoutManager", "=", "getLayoutManager", "(", ")", ";", "if", "(", "!", "layoutManager", ".", "canScrollHorizo...
Calculates the horizontal scroll amount necessary to make the given view fully visible inside the RecyclerView. @param view The view which we want to make fully visible @param snapPreference The edge which the view should snap to when entering the visible area. One of {@link #SNAP_TO_START}, {@link #SNAP_TO_END} or {@link #SNAP_TO_END} @return The vertical scroll amount necessary to make the view visible with the given snap preference.
[ "Calculates", "the", "horizontal", "scroll", "amount", "necessary", "to", "make", "the", "given", "view", "fully", "visible", "inside", "the", "RecyclerView", "." ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/LinearSmoothScroller.java#L323-L335
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/command/ext/listen/ListenParamExtension.java
ListenParamExtension.resolveTargetType
private Class<?> resolveTargetType(final Class<?> listenerType, final Class<?> declaredTargetType) { Class<?> target = null; if (RequiresRecordConversion.class.isAssignableFrom(listenerType)) { target = GenericsResolver.resolve(listenerType) .type(RequiresRecordConversion.class).generic("T"); // if generic could not be resolved from listener instance, use method parameter declaration (last resort) if (Object.class.equals(target)) { target = declaredTargetType; } } return target; }
java
private Class<?> resolveTargetType(final Class<?> listenerType, final Class<?> declaredTargetType) { Class<?> target = null; if (RequiresRecordConversion.class.isAssignableFrom(listenerType)) { target = GenericsResolver.resolve(listenerType) .type(RequiresRecordConversion.class).generic("T"); // if generic could not be resolved from listener instance, use method parameter declaration (last resort) if (Object.class.equals(target)) { target = declaredTargetType; } } return target; }
[ "private", "Class", "<", "?", ">", "resolveTargetType", "(", "final", "Class", "<", "?", ">", "listenerType", ",", "final", "Class", "<", "?", ">", "declaredTargetType", ")", "{", "Class", "<", "?", ">", "target", "=", "null", ";", "if", "(", "Requires...
Resolve target conversion type either from listener instance or, if its not possible, from listener parameter declaration. @param listenerType listener instance type @param declaredTargetType listener generic declared in method declaration @return target conversion type or null if conversion is not required
[ "Resolve", "target", "conversion", "type", "either", "from", "listener", "instance", "or", "if", "its", "not", "possible", "from", "listener", "parameter", "declaration", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/command/ext/listen/ListenParamExtension.java#L147-L159
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/core/util/RepositoryUtils.java
RepositoryUtils.methodToString
public static String methodToString(final Class<?> type, final Method method) { final StringBuilder res = new StringBuilder(); res.append(type.getSimpleName()).append('#').append(method.getName()).append('('); int i = 0; for (Class<?> param : method.getParameterTypes()) { if (i > 0) { res.append(", "); } final Type generic = method.getGenericParameterTypes()[i]; if (generic instanceof TypeVariable) { // using generic name, because its simpler to search visually in code res.append('<').append(((TypeVariable) generic).getName()).append('>'); } else { res.append(param.getSimpleName()); } i++; } res.append(')'); return res.toString(); }
java
public static String methodToString(final Class<?> type, final Method method) { final StringBuilder res = new StringBuilder(); res.append(type.getSimpleName()).append('#').append(method.getName()).append('('); int i = 0; for (Class<?> param : method.getParameterTypes()) { if (i > 0) { res.append(", "); } final Type generic = method.getGenericParameterTypes()[i]; if (generic instanceof TypeVariable) { // using generic name, because its simpler to search visually in code res.append('<').append(((TypeVariable) generic).getName()).append('>'); } else { res.append(param.getSimpleName()); } i++; } res.append(')'); return res.toString(); }
[ "public", "static", "String", "methodToString", "(", "final", "Class", "<", "?", ">", "type", ",", "final", "Method", "method", ")", "{", "final", "StringBuilder", "res", "=", "new", "StringBuilder", "(", ")", ";", "res", ".", "append", "(", "type", ".",...
Converts method signature to human readable string. @param type root type (method may be called not from declaring class) @param method method to print @return string representation for method
[ "Converts", "method", "signature", "to", "human", "readable", "string", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/core/util/RepositoryUtils.java#L57-L76
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/util/ExtCompatibilityUtils.java
ExtCompatibilityUtils.checkParamExtensionCompatibility
public static void checkParamExtensionCompatibility( final Class<? extends RepositoryMethodDescriptor> descriptorType, final Class<? extends MethodParamExtension> paramExtType) { check(isCompatible(paramExtType, MethodParamExtension.class, descriptorType), "Param extension %s is incompatible with descriptor %s", paramExtType.getSimpleName(), descriptorType.getSimpleName()); }
java
public static void checkParamExtensionCompatibility( final Class<? extends RepositoryMethodDescriptor> descriptorType, final Class<? extends MethodParamExtension> paramExtType) { check(isCompatible(paramExtType, MethodParamExtension.class, descriptorType), "Param extension %s is incompatible with descriptor %s", paramExtType.getSimpleName(), descriptorType.getSimpleName()); }
[ "public", "static", "void", "checkParamExtensionCompatibility", "(", "final", "Class", "<", "?", "extends", "RepositoryMethodDescriptor", ">", "descriptorType", ",", "final", "Class", "<", "?", "extends", "MethodParamExtension", ">", "paramExtType", ")", "{", "check",...
Checks that parameter extension is compatible with descriptor and throws error if extension incompatible. @param descriptorType method descriptor type @param paramExtType parameter extension type
[ "Checks", "that", "parameter", "extension", "is", "compatible", "with", "descriptor", "and", "throws", "error", "if", "extension", "incompatible", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/util/ExtCompatibilityUtils.java#L43-L49
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/util/ExtCompatibilityUtils.java
ExtCompatibilityUtils.checkAmendExtensionsCompatibility
public static void checkAmendExtensionsCompatibility( final Class<? extends RepositoryMethodDescriptor> descriptorType, final List<Annotation> extensions) { final List<Class<? extends AmendMethodExtension>> exts = Lists.transform(extensions, new Function<Annotation, Class<? extends AmendMethodExtension>>() { @Nonnull @Override public Class<? extends AmendMethodExtension> apply(@Nonnull final Annotation input) { return input.annotationType().getAnnotation(AmendMethod.class).value(); } }); for (Class<? extends AmendMethodExtension> ext : exts) { check(isCompatible(ext, AmendMethodExtension.class, descriptorType), "Amend extension %s is incompatible with descriptor %s", ext.getSimpleName(), descriptorType.getSimpleName()); } }
java
public static void checkAmendExtensionsCompatibility( final Class<? extends RepositoryMethodDescriptor> descriptorType, final List<Annotation> extensions) { final List<Class<? extends AmendMethodExtension>> exts = Lists.transform(extensions, new Function<Annotation, Class<? extends AmendMethodExtension>>() { @Nonnull @Override public Class<? extends AmendMethodExtension> apply(@Nonnull final Annotation input) { return input.annotationType().getAnnotation(AmendMethod.class).value(); } }); for (Class<? extends AmendMethodExtension> ext : exts) { check(isCompatible(ext, AmendMethodExtension.class, descriptorType), "Amend extension %s is incompatible with descriptor %s", ext.getSimpleName(), descriptorType.getSimpleName()); } }
[ "public", "static", "void", "checkAmendExtensionsCompatibility", "(", "final", "Class", "<", "?", "extends", "RepositoryMethodDescriptor", ">", "descriptorType", ",", "final", "List", "<", "Annotation", ">", "extensions", ")", "{", "final", "List", "<", "Class", "...
Checks that amend extensions strictly compatible with descriptor object. Used for amend annotations defined on method. @param descriptorType method descriptor type @param extensions amend extension annotations
[ "Checks", "that", "amend", "extensions", "strictly", "compatible", "with", "descriptor", "object", ".", "Used", "for", "amend", "annotations", "defined", "on", "method", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/util/ExtCompatibilityUtils.java#L58-L74
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/util/ExtCompatibilityUtils.java
ExtCompatibilityUtils.filterCompatibleExtensions
public static List<AmendExecutionExtension> filterCompatibleExtensions( final List<AmendExecutionExtension> extensions, final Class<? extends RepositoryMethodDescriptor> descriptorType) { @SuppressWarnings("unchecked") final Class<? extends AmendExecutionExtension> supportedExtension = (Class<? extends AmendExecutionExtension>) GenericsResolver.resolve(descriptorType) .type(RepositoryMethodDescriptor.class).generic("E"); return Lists.newArrayList(Iterables.filter(extensions, new Predicate<AmendExecutionExtension>() { @Override public boolean apply(@Nonnull final AmendExecutionExtension ext) { final Class<?> rawExtType = RepositoryUtils.resolveRepositoryClass(ext); final boolean compatible = supportedExtension.isAssignableFrom(rawExtType); if (!compatible) { LOGGER.debug("Extension {} ignored, because it doesn't implement required extension " + "interface {}", rawExtType.getSimpleName(), supportedExtension.getSimpleName()); } return compatible; } })); }
java
public static List<AmendExecutionExtension> filterCompatibleExtensions( final List<AmendExecutionExtension> extensions, final Class<? extends RepositoryMethodDescriptor> descriptorType) { @SuppressWarnings("unchecked") final Class<? extends AmendExecutionExtension> supportedExtension = (Class<? extends AmendExecutionExtension>) GenericsResolver.resolve(descriptorType) .type(RepositoryMethodDescriptor.class).generic("E"); return Lists.newArrayList(Iterables.filter(extensions, new Predicate<AmendExecutionExtension>() { @Override public boolean apply(@Nonnull final AmendExecutionExtension ext) { final Class<?> rawExtType = RepositoryUtils.resolveRepositoryClass(ext); final boolean compatible = supportedExtension.isAssignableFrom(rawExtType); if (!compatible) { LOGGER.debug("Extension {} ignored, because it doesn't implement required extension " + "interface {}", rawExtType.getSimpleName(), supportedExtension.getSimpleName()); } return compatible; } })); }
[ "public", "static", "List", "<", "AmendExecutionExtension", ">", "filterCompatibleExtensions", "(", "final", "List", "<", "AmendExecutionExtension", ">", "extensions", ",", "final", "Class", "<", "?", "extends", "RepositoryMethodDescriptor", ">", "descriptorType", ")", ...
Checks resolved amend extensions compatibility with method specific extension type. Extension may be universal and support some methods and doesn't support other. @param extensions extensions to check @param descriptorType repository method descriptor type @return filtered extensions list (safe to use by method extension)
[ "Checks", "resolved", "amend", "extensions", "compatibility", "with", "method", "specific", "extension", "type", ".", "Extension", "may", "be", "universal", "and", "support", "some", "methods", "and", "doesn", "t", "support", "other", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/util/ExtCompatibilityUtils.java#L99-L118
train
caduandrade/japura-gui
src/main/java/org/japura/gui/ToolTipButton.java
ToolTipButton.disposeTooltip
public void disposeTooltip() { if (popup != null) { timer.stop(); popup.setVisible(false); popup = null; } }
java
public void disposeTooltip() { if (popup != null) { timer.stop(); popup.setVisible(false); popup = null; } }
[ "public", "void", "disposeTooltip", "(", ")", "{", "if", "(", "popup", "!=", "null", ")", "{", "timer", ".", "stop", "(", ")", ";", "popup", ".", "setVisible", "(", "false", ")", ";", "popup", "=", "null", ";", "}", "}" ]
Dispose the tooltip
[ "Dispose", "the", "tooltip" ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/ToolTipButton.java#L271-L277
train
caduandrade/japura-gui
src/main/java/org/japura/gui/ToolTipButton.java
ToolTipButton.showTooltip
private void showTooltip() { Wrap tooltipLabel = new Wrap(toolTipWrapWidth); tooltipLabel.setForeground(getForeground()); tooltipLabel.setFont(ToolTipButton.this.getFont()); tooltipLabel.setText(text); JPanel panel = new JPanel(); panel.setBackground(toolTipBackground); panel.setLayout(new BorderLayout()); panel.add(tooltipLabel, BorderLayout.CENTER); if (extraComponent != null && extraComponentAnchor != null) { if (extraComponentAnchor.equals(ToolTipButtonAnchor.SOUTH)) { panel.add(extraComponent, BorderLayout.SOUTH); } else if (extraComponentAnchor.equals(ToolTipButtonAnchor.NORTH)) { panel.add(extraComponent, BorderLayout.NORTH); } else if (extraComponentAnchor.equals(ToolTipButtonAnchor.EAST)) { panel.add(extraComponent, BorderLayout.EAST); } else if (extraComponentAnchor.equals(ToolTipButtonAnchor.WEST)) { panel.add(extraComponent, BorderLayout.WEST); } } Border out = BorderFactory.createLineBorder(borderColor, borderThickness); Border in = BorderFactory.createEmptyBorder(margin.top, margin.left, margin.bottom, margin.right); Border border = BorderFactory.createCompoundBorder(out, in); panel.setBorder(border); popup = new JPopupMenu(); popup.setBorder(BorderFactory.createEmptyBorder()); popup.add(panel); popup.addMouseListener(new MouseAdapter() { @Override public void mouseExited(MouseEvent e) { tryDisposeTooltip(); } }); popup.pack(); popup.show(ToolTipButton.this, 0, getHeight()); Point point = popup.getLocationOnScreen(); Dimension dim = popup.getSize(); popupBounds = new Rectangle2D.Double(point.getX(), point.getY(), dim.getWidth(), dim.getHeight()); }
java
private void showTooltip() { Wrap tooltipLabel = new Wrap(toolTipWrapWidth); tooltipLabel.setForeground(getForeground()); tooltipLabel.setFont(ToolTipButton.this.getFont()); tooltipLabel.setText(text); JPanel panel = new JPanel(); panel.setBackground(toolTipBackground); panel.setLayout(new BorderLayout()); panel.add(tooltipLabel, BorderLayout.CENTER); if (extraComponent != null && extraComponentAnchor != null) { if (extraComponentAnchor.equals(ToolTipButtonAnchor.SOUTH)) { panel.add(extraComponent, BorderLayout.SOUTH); } else if (extraComponentAnchor.equals(ToolTipButtonAnchor.NORTH)) { panel.add(extraComponent, BorderLayout.NORTH); } else if (extraComponentAnchor.equals(ToolTipButtonAnchor.EAST)) { panel.add(extraComponent, BorderLayout.EAST); } else if (extraComponentAnchor.equals(ToolTipButtonAnchor.WEST)) { panel.add(extraComponent, BorderLayout.WEST); } } Border out = BorderFactory.createLineBorder(borderColor, borderThickness); Border in = BorderFactory.createEmptyBorder(margin.top, margin.left, margin.bottom, margin.right); Border border = BorderFactory.createCompoundBorder(out, in); panel.setBorder(border); popup = new JPopupMenu(); popup.setBorder(BorderFactory.createEmptyBorder()); popup.add(panel); popup.addMouseListener(new MouseAdapter() { @Override public void mouseExited(MouseEvent e) { tryDisposeTooltip(); } }); popup.pack(); popup.show(ToolTipButton.this, 0, getHeight()); Point point = popup.getLocationOnScreen(); Dimension dim = popup.getSize(); popupBounds = new Rectangle2D.Double(point.getX(), point.getY(), dim.getWidth(), dim.getHeight()); }
[ "private", "void", "showTooltip", "(", ")", "{", "Wrap", "tooltipLabel", "=", "new", "Wrap", "(", "toolTipWrapWidth", ")", ";", "tooltipLabel", ".", "setForeground", "(", "getForeground", "(", ")", ")", ";", "tooltipLabel", ".", "setFont", "(", "ToolTipButton"...
Show the tooltip.
[ "Show", "the", "tooltip", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/ToolTipButton.java#L282-L335
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/delegate/method/MethodFilters.java
MethodFilters.filterByClosestParams
public static Collection<MatchedMethod> filterByClosestParams( final Collection<MatchedMethod> possibilities, final int paramsCount) { Collection<MatchedMethod> res = null; for (int i = 0; i < paramsCount; i++) { final Collection<MatchedMethod> filtered = filterByParam(possibilities, i); if (res != null) { if (filtered.size() < res.size()) { res = filtered; } } else { res = filtered; } } return res; }
java
public static Collection<MatchedMethod> filterByClosestParams( final Collection<MatchedMethod> possibilities, final int paramsCount) { Collection<MatchedMethod> res = null; for (int i = 0; i < paramsCount; i++) { final Collection<MatchedMethod> filtered = filterByParam(possibilities, i); if (res != null) { if (filtered.size() < res.size()) { res = filtered; } } else { res = filtered; } } return res; }
[ "public", "static", "Collection", "<", "MatchedMethod", ">", "filterByClosestParams", "(", "final", "Collection", "<", "MatchedMethod", ">", "possibilities", ",", "final", "int", "paramsCount", ")", "{", "Collection", "<", "MatchedMethod", ">", "res", "=", "null",...
Looks for most specific type for each parameter. @param possibilities methods to reduce @param paramsCount repository method params count @return possibly reduced collection or original one
[ "Looks", "for", "most", "specific", "type", "for", "each", "parameter", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/delegate/method/MethodFilters.java#L45-L59
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/db/pool/DocumentPool.java
DocumentPool.checkAndAcquireConnection
private ODatabaseDocument checkAndAcquireConnection() { final ODatabaseDocument res; if (userManager.isSpecificUser()) { // non pool-managed connection for different user res = orientDB.get().open(database, userManager.getUser(), userManager.getPassword()); } else { res = pool.acquire(); } if (res.isClosed()) { final String message = String.format( "Pool %s return closed connection something is terribly wrong", getType()); logger.error(message); throw new IllegalStateException(message); } return res; }
java
private ODatabaseDocument checkAndAcquireConnection() { final ODatabaseDocument res; if (userManager.isSpecificUser()) { // non pool-managed connection for different user res = orientDB.get().open(database, userManager.getUser(), userManager.getPassword()); } else { res = pool.acquire(); } if (res.isClosed()) { final String message = String.format( "Pool %s return closed connection something is terribly wrong", getType()); logger.error(message); throw new IllegalStateException(message); } return res; }
[ "private", "ODatabaseDocument", "checkAndAcquireConnection", "(", ")", "{", "final", "ODatabaseDocument", "res", ";", "if", "(", "userManager", ".", "isSpecificUser", "(", ")", ")", "{", "// non pool-managed connection for different user", "res", "=", "orientDB", ".", ...
Its definitely not normal that pool returns closed connections, but possible if used improperly. @return connection itself or new valid connection
[ "Its", "definitely", "not", "normal", "that", "pool", "returns", "closed", "connections", "but", "possible", "if", "used", "improperly", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/db/pool/DocumentPool.java#L171-L187
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/db/util/RidUtils.java
RidUtils.trackIdChange
public static void trackIdChange(final ODocument document, final Object pojo) { if (document.getIdentity().isNew()) { ORecordInternal.addIdentityChangeListener(document, new OIdentityChangeListener() { @Override public void onBeforeIdentityChange(final ORecord record) { // not needed } @Override public void onAfterIdentityChange(final ORecord record) { OObjectSerializerHelper.setObjectID(record.getIdentity(), pojo); OObjectSerializerHelper.setObjectVersion(record.getVersion(), pojo); } }); } }
java
public static void trackIdChange(final ODocument document, final Object pojo) { if (document.getIdentity().isNew()) { ORecordInternal.addIdentityChangeListener(document, new OIdentityChangeListener() { @Override public void onBeforeIdentityChange(final ORecord record) { // not needed } @Override public void onAfterIdentityChange(final ORecord record) { OObjectSerializerHelper.setObjectID(record.getIdentity(), pojo); OObjectSerializerHelper.setObjectVersion(record.getVersion(), pojo); } }); } }
[ "public", "static", "void", "trackIdChange", "(", "final", "ODocument", "document", ",", "final", "Object", "pojo", ")", "{", "if", "(", "document", ".", "getIdentity", "(", ")", ".", "isNew", "(", ")", ")", "{", "ORecordInternal", ".", "addIdentityChangeLis...
When just created object is detached to pure pojo it gets temporary id. Real id is assigned only after transaction commit. This method tracks original document, intercepts its id change and sets correct id and version into pojo. So it become safe to use such pojo id outside of transaction. @param document original document @param pojo pojo
[ "When", "just", "created", "object", "is", "detached", "to", "pure", "pojo", "it", "gets", "temporary", "id", ".", "Real", "id", "is", "assigned", "only", "after", "transaction", "commit", ".", "This", "method", "tracks", "original", "document", "intercepts", ...
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/db/util/RidUtils.java#L89-L104
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/db/util/RidUtils.java
RidUtils.findIdField
private static Field findIdField(final Object value) { Field res = null; final Class<?> type = value.getClass(); if (ODatabaseRecordThreadLocal.instance().isDefined()) { res = OObjectEntitySerializer.getIdField(type); } else { final String idField = OObjectSerializerHelper.getObjectIDFieldName(value); if (idField != null) { try { res = type.getDeclaredField(idField); } catch (NoSuchFieldException e) { LOGGER.warn(String .format("Id field '%s' not found in class '%s'.", idField, type.getSimpleName()), e); } } } return res; }
java
private static Field findIdField(final Object value) { Field res = null; final Class<?> type = value.getClass(); if (ODatabaseRecordThreadLocal.instance().isDefined()) { res = OObjectEntitySerializer.getIdField(type); } else { final String idField = OObjectSerializerHelper.getObjectIDFieldName(value); if (idField != null) { try { res = type.getDeclaredField(idField); } catch (NoSuchFieldException e) { LOGGER.warn(String .format("Id field '%s' not found in class '%s'.", idField, type.getSimpleName()), e); } } } return res; }
[ "private", "static", "Field", "findIdField", "(", "final", "Object", "value", ")", "{", "Field", "res", "=", "null", ";", "final", "Class", "<", "?", ">", "type", "=", "value", ".", "getClass", "(", ")", ";", "if", "(", "ODatabaseRecordThreadLocal", ".",...
Core orient field resolve method relies on bound connection, but it may be required to resolve id outside of transaction. So we use orient method under transaction and do manual scan outside of transaction. @param value object instance (non proxy) @return object id field or null if not found
[ "Core", "orient", "field", "resolve", "method", "relies", "on", "bound", "connection", "but", "it", "may", "be", "required", "to", "resolve", "id", "outside", "of", "transaction", ".", "So", "we", "use", "orient", "method", "under", "transaction", "and", "do...
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/db/util/RidUtils.java#L142-L159
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.getCurrentModal_
private static Component getCurrentModal_(RootPaneContainer rootPane) { synchronized (modals) { Modal modal = modals.get(rootPane); if (modal != null) { if (modal.getSize() > 0) { return modal.components.get(modal.components.size() - 1); } } return null; } }
java
private static Component getCurrentModal_(RootPaneContainer rootPane) { synchronized (modals) { Modal modal = modals.get(rootPane); if (modal != null) { if (modal.getSize() > 0) { return modal.components.get(modal.components.size() - 1); } } return null; } }
[ "private", "static", "Component", "getCurrentModal_", "(", "RootPaneContainer", "rootPane", ")", "{", "synchronized", "(", "modals", ")", "{", "Modal", "modal", "=", "modals", ".", "get", "(", "rootPane", ")", ";", "if", "(", "modal", "!=", "null", ")", "{...
Get the current modal component of a specific RootPaneContainer. @param rootPane the RootPaneContainer with a modal @return Component or <code>NULL</code>
[ "Get", "the", "current", "modal", "component", "of", "a", "specific", "RootPaneContainer", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L120-L130
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.closeCurrentModal_
private static void closeCurrentModal_(RootPaneContainer rootPane) { synchronized (modals) { Modal modal = modals.get(rootPane); if (modal != null) { modal.closeCurrent(); if (modal.getSize() == 0) { modals.remove(rootPane); } } } }
java
private static void closeCurrentModal_(RootPaneContainer rootPane) { synchronized (modals) { Modal modal = modals.get(rootPane); if (modal != null) { modal.closeCurrent(); if (modal.getSize() == 0) { modals.remove(rootPane); } } } }
[ "private", "static", "void", "closeCurrentModal_", "(", "RootPaneContainer", "rootPane", ")", "{", "synchronized", "(", "modals", ")", "{", "Modal", "modal", "=", "modals", ".", "get", "(", "rootPane", ")", ";", "if", "(", "modal", "!=", "null", ")", "{", ...
Close the current modal component of a specific RootPaneContainer. @param rootPane the RootPaneContainer with a modal
[ "Close", "the", "current", "modal", "component", "of", "a", "specific", "RootPaneContainer", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L168-L178
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.closeModal
public static void closeModal(Component component) { synchronized (modals) { RootPaneContainer frame = null; Modal modal = null; Iterator<Entry<RootPaneContainer, Modal>> it = modals.entrySet().iterator(); while (it.hasNext()) { Entry<RootPaneContainer, Modal> entry = it.next(); modal = entry.getValue(); frame = entry.getKey(); if (frame != null && modal != null && modal.components.contains(component)) { break; } else { frame = null; modal = null; } } if (frame != null && modal != null) { modal.close(component); if (modal.getSize() == 0) { modals.remove(frame); } } } }
java
public static void closeModal(Component component) { synchronized (modals) { RootPaneContainer frame = null; Modal modal = null; Iterator<Entry<RootPaneContainer, Modal>> it = modals.entrySet().iterator(); while (it.hasNext()) { Entry<RootPaneContainer, Modal> entry = it.next(); modal = entry.getValue(); frame = entry.getKey(); if (frame != null && modal != null && modal.components.contains(component)) { break; } else { frame = null; modal = null; } } if (frame != null && modal != null) { modal.close(component); if (modal.getSize() == 0) { modals.remove(frame); } } } }
[ "public", "static", "void", "closeModal", "(", "Component", "component", ")", "{", "synchronized", "(", "modals", ")", "{", "RootPaneContainer", "frame", "=", "null", ";", "Modal", "modal", "=", "null", ";", "Iterator", "<", "Entry", "<", "RootPaneContainer", ...
Close a specific modal component. @param component the modal's component
[ "Close", "a", "specific", "modal", "component", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L186-L212
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.closeAllModals_
private static void closeAllModals_(RootPaneContainer rootPane) { synchronized (modals) { Modal modal = modals.get(rootPane); if (modal != null) { modal.closeAll(); modals.remove(rootPane); } } }
java
private static void closeAllModals_(RootPaneContainer rootPane) { synchronized (modals) { Modal modal = modals.get(rootPane); if (modal != null) { modal.closeAll(); modals.remove(rootPane); } } }
[ "private", "static", "void", "closeAllModals_", "(", "RootPaneContainer", "rootPane", ")", "{", "synchronized", "(", "modals", ")", "{", "Modal", "modal", "=", "modals", ".", "get", "(", "rootPane", ")", ";", "if", "(", "modal", "!=", "null", ")", "{", "...
Close all modals of a specific RootPaneContainer. @param rootPane the RootPaneContainer with a modal
[ "Close", "all", "modals", "of", "a", "specific", "RootPaneContainer", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L250-L258
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.hasModal_
private static boolean hasModal_(RootPaneContainer rootPane) { synchronized (modals) { Modal modal = modals.get(rootPane); if (modal != null && modal.getSize() > 0) { return true; } return false; } }
java
private static boolean hasModal_(RootPaneContainer rootPane) { synchronized (modals) { Modal modal = modals.get(rootPane); if (modal != null && modal.getSize() > 0) { return true; } return false; } }
[ "private", "static", "boolean", "hasModal_", "(", "RootPaneContainer", "rootPane", ")", "{", "synchronized", "(", "modals", ")", "{", "Modal", "modal", "=", "modals", ".", "get", "(", "rootPane", ")", ";", "if", "(", "modal", "!=", "null", "&&", "modal", ...
Indicates whether the RootPaneContainer has a modal. @param rootPane the RootPaneContainer with a modal @return boolean
[ "Indicates", "whether", "the", "RootPaneContainer", "has", "a", "modal", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L300-L308
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.getModal
private static Modal getModal(RootPaneContainer rootPane) { synchronized (modals) { Modal modal = modals.get(rootPane); if (modal == null) { modal = new Modal(rootPane); modals.put(rootPane, modal); } return modal; } }
java
private static Modal getModal(RootPaneContainer rootPane) { synchronized (modals) { Modal modal = modals.get(rootPane); if (modal == null) { modal = new Modal(rootPane); modals.put(rootPane, modal); } return modal; } }
[ "private", "static", "Modal", "getModal", "(", "RootPaneContainer", "rootPane", ")", "{", "synchronized", "(", "modals", ")", "{", "Modal", "modal", "=", "modals", ".", "get", "(", "rootPane", ")", ";", "if", "(", "modal", "==", "null", ")", "{", "modal"...
Get the modal of a specific frame @param rootPane the RootPaneContainer with a modal @return {@link Modal}
[ "Get", "the", "modal", "of", "a", "specific", "frame" ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L317-L326
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.isModal
public static boolean isModal(Component component) { synchronized (modals) { Iterator<Entry<RootPaneContainer, Modal>> it = modals.entrySet().iterator(); while (it.hasNext()) { Entry<RootPaneContainer, Modal> entry = it.next(); if (entry.getValue().components.contains(component)) { return true; } } return false; } }
java
public static boolean isModal(Component component) { synchronized (modals) { Iterator<Entry<RootPaneContainer, Modal>> it = modals.entrySet().iterator(); while (it.hasNext()) { Entry<RootPaneContainer, Modal> entry = it.next(); if (entry.getValue().components.contains(component)) { return true; } } return false; } }
[ "public", "static", "boolean", "isModal", "(", "Component", "component", ")", "{", "synchronized", "(", "modals", ")", "{", "Iterator", "<", "Entry", "<", "RootPaneContainer", ",", "Modal", ">", ">", "it", "=", "modals", ".", "entrySet", "(", ")", ".", "...
Indicates whether the component is a modal component. @param component the component @return boolean
[ "Indicates", "whether", "the", "component", "is", "a", "modal", "component", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L335-L347
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.addModal
public static void addModal(JInternalFrame frame, Component component, ModalListener listener) { addModal_(frame, component, listener, defaultModalDepth); }
java
public static void addModal(JInternalFrame frame, Component component, ModalListener listener) { addModal_(frame, component, listener, defaultModalDepth); }
[ "public", "static", "void", "addModal", "(", "JInternalFrame", "frame", ",", "Component", "component", ",", "ModalListener", "listener", ")", "{", "addModal_", "(", "frame", ",", "component", ",", "listener", ",", "defaultModalDepth", ")", ";", "}" ]
Add a modal component in the internal frame. @param frame the internal frame @param component the component for modal @param listener the listener for modal
[ "Add", "a", "modal", "component", "in", "the", "internal", "frame", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L371-L374
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.addModal
public static void addModal(JFrame frame, Component component, ModalListener listener, Integer modalDepth) { addModal_(frame, component, listener, modalDepth); }
java
public static void addModal(JFrame frame, Component component, ModalListener listener, Integer modalDepth) { addModal_(frame, component, listener, modalDepth); }
[ "public", "static", "void", "addModal", "(", "JFrame", "frame", ",", "Component", "component", ",", "ModalListener", "listener", ",", "Integer", "modalDepth", ")", "{", "addModal_", "(", "frame", ",", "component", ",", "listener", ",", "modalDepth", ")", ";", ...
Add a modal component in the frame. @param frame the frame @param component the component for modal @param listener the listener for modal @param modalDepth the depth for modal
[ "Add", "a", "modal", "component", "in", "the", "frame", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L499-L502
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.addModal_
private static void addModal_(RootPaneContainer rootPane, Component component, ModalListener listener, Integer modalDepth) { synchronized (modals) { if (isModal(component) == false) { getModal(rootPane).addModal(component, listener, modalDepth); } } }
java
private static void addModal_(RootPaneContainer rootPane, Component component, ModalListener listener, Integer modalDepth) { synchronized (modals) { if (isModal(component) == false) { getModal(rootPane).addModal(component, listener, modalDepth); } } }
[ "private", "static", "void", "addModal_", "(", "RootPaneContainer", "rootPane", ",", "Component", "component", ",", "ModalListener", "listener", ",", "Integer", "modalDepth", ")", "{", "synchronized", "(", "modals", ")", "{", "if", "(", "isModal", "(", "componen...
Add a modal component in the RootPaneContainer. @param rootPane the RootPaneContainer @param component the component for modal @param listener the listener for modal @param modalDepth the depth for modal
[ "Add", "a", "modal", "component", "in", "the", "RootPaneContainer", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L516-L524
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.getModalCount_
private static int getModalCount_(RootPaneContainer rootPane) { synchronized (modals) { Modal modal = modals.get(rootPane); if (modal != null) { return modal.getSize(); } return 0; } }
java
private static int getModalCount_(RootPaneContainer rootPane) { synchronized (modals) { Modal modal = modals.get(rootPane); if (modal != null) { return modal.getSize(); } return 0; } }
[ "private", "static", "int", "getModalCount_", "(", "RootPaneContainer", "rootPane", ")", "{", "synchronized", "(", "modals", ")", "{", "Modal", "modal", "=", "modals", ".", "get", "(", "rootPane", ")", ";", "if", "(", "modal", "!=", "null", ")", "{", "re...
Get the modal count of a specific RootPaneContainer. @param frame the RootPaneContainer with a modal @return int
[ "Get", "the", "modal", "count", "of", "a", "specific", "RootPaneContainer", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L590-L598
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.closeCurrent
private void closeCurrent() { if (components.size() > 0) { Component component = components.remove(components.size() - 1); getModalPanel().removeAll(); fireCloseActionListener(listeners.get(component)); listeners.remove(component); if (components.size() > 0) { showNextComponent(); } else { restoreRootPane(); } } }
java
private void closeCurrent() { if (components.size() > 0) { Component component = components.remove(components.size() - 1); getModalPanel().removeAll(); fireCloseActionListener(listeners.get(component)); listeners.remove(component); if (components.size() > 0) { showNextComponent(); } else { restoreRootPane(); } } }
[ "private", "void", "closeCurrent", "(", ")", "{", "if", "(", "components", ".", "size", "(", ")", ">", "0", ")", "{", "Component", "component", "=", "components", ".", "remove", "(", "components", ".", "size", "(", ")", "-", "1", ")", ";", "getModalP...
Close the current modal.
[ "Close", "the", "current", "modal", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L663-L676
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.close
private void close(Component component) { if (components.size() > 0) { if (components.contains(component) == false) { return; } components.remove(component); depths.remove(component); getModalPanel().removeAll(); fireCloseActionListener(listeners.get(component)); listeners.remove(component); if (components.size() > 0) { showNextComponent(); } else { restoreRootPane(); } } }
java
private void close(Component component) { if (components.size() > 0) { if (components.contains(component) == false) { return; } components.remove(component); depths.remove(component); getModalPanel().removeAll(); fireCloseActionListener(listeners.get(component)); listeners.remove(component); if (components.size() > 0) { showNextComponent(); } else { restoreRootPane(); } } }
[ "private", "void", "close", "(", "Component", "component", ")", "{", "if", "(", "components", ".", "size", "(", ")", ">", "0", ")", "{", "if", "(", "components", ".", "contains", "(", "component", ")", "==", "false", ")", "{", "return", ";", "}", "...
Close a modal @param component - the modal's component
[ "Close", "a", "modal" ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L719-L737
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.closeAll
private void closeAll() { getModalPanel().removeAll(); components.clear(); depths.clear(); listeners.clear(); restoreRootPane(); }
java
private void closeAll() { getModalPanel().removeAll(); components.clear(); depths.clear(); listeners.clear(); restoreRootPane(); }
[ "private", "void", "closeAll", "(", ")", "{", "getModalPanel", "(", ")", ".", "removeAll", "(", ")", ";", "components", ".", "clear", "(", ")", ";", "depths", ".", "clear", "(", ")", ";", "listeners", ".", "clear", "(", ")", ";", "restoreRootPane", "...
Close all modals.
[ "Close", "all", "modals", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L760-L766
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.addModal
private void addModal(Component component, ModalListener listener, Integer modalDepth) { if (modalDepth == null) { modalDepth = defaultModalDepth; } if (components.contains(component) == false) { rootPane.getLayeredPane().remove(getModalPanel()); rootPane.getLayeredPane().add(getModalPanel(), modalDepth); KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); focusManager.clearGlobalFocusOwner(); getModalPanel().removeAll(); getModalPanel().add("", component); resizeModalPanel(); getModalPanel().repaint(); components.add(component); depths.put(component, modalDepth); addListener(component, listener); } }
java
private void addModal(Component component, ModalListener listener, Integer modalDepth) { if (modalDepth == null) { modalDepth = defaultModalDepth; } if (components.contains(component) == false) { rootPane.getLayeredPane().remove(getModalPanel()); rootPane.getLayeredPane().add(getModalPanel(), modalDepth); KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); focusManager.clearGlobalFocusOwner(); getModalPanel().removeAll(); getModalPanel().add("", component); resizeModalPanel(); getModalPanel().repaint(); components.add(component); depths.put(component, modalDepth); addListener(component, listener); } }
[ "private", "void", "addModal", "(", "Component", "component", ",", "ModalListener", "listener", ",", "Integer", "modalDepth", ")", "{", "if", "(", "modalDepth", "==", "null", ")", "{", "modalDepth", "=", "defaultModalDepth", ";", "}", "if", "(", "components", ...
Add a modal component @param component {@link Component} @param listener {@link ModalListener} @param modalDepth
[ "Add", "a", "modal", "component" ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L777-L798
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.getModalPanel
private ModalPanel getModalPanel() { if (modalPanel == null) { modalPanel = new ModalPanel(); modalPanel.setLayout(new ModalLayout()); } return modalPanel; }
java
private ModalPanel getModalPanel() { if (modalPanel == null) { modalPanel = new ModalPanel(); modalPanel.setLayout(new ModalLayout()); } return modalPanel; }
[ "private", "ModalPanel", "getModalPanel", "(", ")", "{", "if", "(", "modalPanel", "==", "null", ")", "{", "modalPanel", "=", "new", "ModalPanel", "(", ")", ";", "modalPanel", ".", "setLayout", "(", "new", "ModalLayout", "(", ")", ")", ";", "}", "return",...
Get the transparent modal panel @return {@link ModalPanel}
[ "Get", "the", "transparent", "modal", "panel" ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L827-L833
train
caduandrade/japura-gui
src/main/java/org/japura/gui/modal/Modal.java
Modal.getRootPaneContainer
public static RootPaneContainer getRootPaneContainer(Component component) { if (component instanceof RootPaneContainer) { return (RootPaneContainer) component; } for (Container p = component.getParent(); p != null; p = p.getParent()) { if (p instanceof RootPaneContainer) { return (RootPaneContainer) p; } } return null; }
java
public static RootPaneContainer getRootPaneContainer(Component component) { if (component instanceof RootPaneContainer) { return (RootPaneContainer) component; } for (Container p = component.getParent(); p != null; p = p.getParent()) { if (p instanceof RootPaneContainer) { return (RootPaneContainer) p; } } return null; }
[ "public", "static", "RootPaneContainer", "getRootPaneContainer", "(", "Component", "component", ")", "{", "if", "(", "component", "instanceof", "RootPaneContainer", ")", "{", "return", "(", "RootPaneContainer", ")", "component", ";", "}", "for", "(", "Container", ...
Get the RootPaneContainer of the specific component. @param component @return the RootPaneContainer or <CODE>NULL</CODE> if its not exist.
[ "Get", "the", "RootPaneContainer", "of", "the", "specific", "component", "." ]
0ea556329843c978d2863d3731a6df244d18d4ca
https://github.com/caduandrade/japura-gui/blob/0ea556329843c978d2863d3731a6df244d18d4ca/src/main/java/org/japura/gui/modal/Modal.java#L885-L896
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/core/result/ResultAnalyzer.java
ResultAnalyzer.analyzeReturnType
public static ResultDescriptor analyzeReturnType(final DescriptorContext context, final Class<? extends Collection> returnCollectionType) { final Method method = context.method; final MethodGenericsContext generics = context.generics.method(method); final Class<?> returnClass = generics.resolveReturnClass(); final ResultDescriptor descriptor = new ResultDescriptor(); descriptor.expectType = resolveExpectedType(returnClass, returnCollectionType); final ResultType type; final Class<?> entityClass; if (isCollection(returnClass)) { type = COLLECTION; entityClass = resolveGenericType(method, generics); } else if (returnClass.isArray()) { type = ARRAY; entityClass = returnClass.getComponentType(); } else if (VOID_TYPES.contains(returnClass)) { type = VOID; entityClass = Void.class; } else { type = PLAIN; // support for guava and jdk8 optionals entityClass = Optionals.isOptional(returnClass) ? resolveGenericType(method, generics) : returnClass; } descriptor.returnType = type; descriptor.entityType = entityClass; return descriptor; }
java
public static ResultDescriptor analyzeReturnType(final DescriptorContext context, final Class<? extends Collection> returnCollectionType) { final Method method = context.method; final MethodGenericsContext generics = context.generics.method(method); final Class<?> returnClass = generics.resolveReturnClass(); final ResultDescriptor descriptor = new ResultDescriptor(); descriptor.expectType = resolveExpectedType(returnClass, returnCollectionType); final ResultType type; final Class<?> entityClass; if (isCollection(returnClass)) { type = COLLECTION; entityClass = resolveGenericType(method, generics); } else if (returnClass.isArray()) { type = ARRAY; entityClass = returnClass.getComponentType(); } else if (VOID_TYPES.contains(returnClass)) { type = VOID; entityClass = Void.class; } else { type = PLAIN; // support for guava and jdk8 optionals entityClass = Optionals.isOptional(returnClass) ? resolveGenericType(method, generics) : returnClass; } descriptor.returnType = type; descriptor.entityType = entityClass; return descriptor; }
[ "public", "static", "ResultDescriptor", "analyzeReturnType", "(", "final", "DescriptorContext", "context", ",", "final", "Class", "<", "?", "extends", "Collection", ">", "returnCollectionType", ")", "{", "final", "Method", "method", "=", "context", ".", "method", ...
Analyze return type. @param context repository method context @param returnCollectionType collection implementation to convert to or null if conversion not required @return result description object
[ "Analyze", "return", "type", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/core/result/ResultAnalyzer.java#L41-L69
train
twotoasters/RecyclerViewLib
library/src/main/java/com/twotoasters/layoutmanager/BaseLayoutManager.java
BaseLayoutManager.recycleByRenderState
protected void recycleByRenderState(RecyclerView.Recycler recycler, RenderState renderState) { if (renderState.mLayoutDirection == RenderState.LAYOUT_START) { recycleViewsFromEnd(recycler, renderState.mScrollingOffset); } else { recycleViewsFromStart(recycler, renderState.mScrollingOffset); } }
java
protected void recycleByRenderState(RecyclerView.Recycler recycler, RenderState renderState) { if (renderState.mLayoutDirection == RenderState.LAYOUT_START) { recycleViewsFromEnd(recycler, renderState.mScrollingOffset); } else { recycleViewsFromStart(recycler, renderState.mScrollingOffset); } }
[ "protected", "void", "recycleByRenderState", "(", "RecyclerView", ".", "Recycler", "recycler", ",", "RenderState", "renderState", ")", "{", "if", "(", "renderState", ".", "mLayoutDirection", "==", "RenderState", ".", "LAYOUT_START", ")", "{", "recycleViewsFromEnd", ...
Helper method to call appropriate recycle method depending on current render layout direction @param recycler Current recycler that is attached to RecyclerView @param renderState Current render state. Right now, this object does not change but we may consider moving it out of this view so passing around as a parameter for now, rather than accessing {@link #mRenderState} @see #recycleViewsFromStart(com.twotoasters.android.support.v7.widget.RecyclerView.Recycler, int) @see #recycleViewsFromEnd(com.twotoasters.android.support.v7.widget.RecyclerView.Recycler, int) @see com.twotoasters.android.support.v7.widget.LinearLayoutManager.RenderState#mLayoutDirection
[ "Helper", "method", "to", "call", "appropriate", "recycle", "method", "depending", "on", "current", "render", "layout", "direction" ]
2379fd5bbf57d4dfc8b28046b7ace950905c75f0
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/layoutmanager/BaseLayoutManager.java#L969-L975
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/util/ResultUtils.java
ResultUtils.check
public static void check(final Object result, final Class<?> targetType) { if (result != null && !targetType.isAssignableFrom(result.getClass())) { // note: conversion logic may go wrong (e.g. because converter expect collection input mostly and may // not work correctly for single element), but anyway overall conversion would be considered failed. throw new ResultConversionException(String.format("Failed to convert %s to %s", toStringType(result), targetType.getSimpleName())); } }
java
public static void check(final Object result, final Class<?> targetType) { if (result != null && !targetType.isAssignableFrom(result.getClass())) { // note: conversion logic may go wrong (e.g. because converter expect collection input mostly and may // not work correctly for single element), but anyway overall conversion would be considered failed. throw new ResultConversionException(String.format("Failed to convert %s to %s", toStringType(result), targetType.getSimpleName())); } }
[ "public", "static", "void", "check", "(", "final", "Object", "result", ",", "final", "Class", "<", "?", ">", "targetType", ")", "{", "if", "(", "result", "!=", "null", "&&", "!", "targetType", ".", "isAssignableFrom", "(", "result", ".", "getClass", "(",...
Check converted result compatibility with required type. @param result result object @param targetType target type @throws ResultConversionException if result doesn't match required type
[ "Check", "converted", "result", "compatibility", "with", "required", "type", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/util/ResultUtils.java#L34-L41
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/util/ResultUtils.java
ResultUtils.convertToCollection
@SuppressWarnings("unchecked") public static Object convertToCollection(final Object result, final Class collectionType, final Class targetEntity, final boolean projection) { final Object converted; if (collectionType.equals(Iterator.class)) { converted = toIterator(result, targetEntity, projection); } else if (collectionType.isAssignableFrom(List.class)) { converted = Lists.newArrayList(toIterator(result, targetEntity, projection)); } else if (collectionType.isAssignableFrom(Set.class)) { converted = Sets.newHashSet(toIterator(result, targetEntity, projection)); } else if (!collectionType.isInterface()) { converted = convertToCollectionImpl(result, collectionType, targetEntity, projection); } else { throw new ResultConversionException(String.format( "Incompatible result type requested %s for conversion from actual result %s", collectionType, result.getClass())); } return converted; }
java
@SuppressWarnings("unchecked") public static Object convertToCollection(final Object result, final Class collectionType, final Class targetEntity, final boolean projection) { final Object converted; if (collectionType.equals(Iterator.class)) { converted = toIterator(result, targetEntity, projection); } else if (collectionType.isAssignableFrom(List.class)) { converted = Lists.newArrayList(toIterator(result, targetEntity, projection)); } else if (collectionType.isAssignableFrom(Set.class)) { converted = Sets.newHashSet(toIterator(result, targetEntity, projection)); } else if (!collectionType.isInterface()) { converted = convertToCollectionImpl(result, collectionType, targetEntity, projection); } else { throw new ResultConversionException(String.format( "Incompatible result type requested %s for conversion from actual result %s", collectionType, result.getClass())); } return converted; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "Object", "convertToCollection", "(", "final", "Object", "result", ",", "final", "Class", "collectionType", ",", "final", "Class", "targetEntity", ",", "final", "boolean", "projection", ")", "...
Convert result object to collection. In some cases, this could be do nothing case, because orient already returns collection. If projection is required or when collection type is different from requested type, result will be re-packaged into the new collection. @param result result instance @param collectionType target collection type @param targetEntity target entity type @param projection true to apply projection, false otherwise @return converted result
[ "Convert", "result", "object", "to", "collection", ".", "In", "some", "cases", "this", "could", "be", "do", "nothing", "case", "because", "orient", "already", "returns", "collection", ".", "If", "projection", "is", "required", "or", "when", "collection", "type...
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/util/ResultUtils.java#L79-L97
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/util/ResultUtils.java
ResultUtils.convertToArray
@SuppressWarnings("PMD.LooseCoupling") public static Object convertToArray(final Object result, final Class entityType, final boolean projection) { final Collection res = result instanceof Collection // no projection because its applied later ? (Collection) result : convertToCollectionImpl(result, ArrayList.class, entityType, false); final Object array = Array.newInstance(entityType, res.size()); int i = 0; for (Object obj : res) { Array.set(array, i++, projection ? applyProjection(obj, entityType) : obj); } return array; }
java
@SuppressWarnings("PMD.LooseCoupling") public static Object convertToArray(final Object result, final Class entityType, final boolean projection) { final Collection res = result instanceof Collection // no projection because its applied later ? (Collection) result : convertToCollectionImpl(result, ArrayList.class, entityType, false); final Object array = Array.newInstance(entityType, res.size()); int i = 0; for (Object obj : res) { Array.set(array, i++, projection ? applyProjection(obj, entityType) : obj); } return array; }
[ "@", "SuppressWarnings", "(", "\"PMD.LooseCoupling\"", ")", "public", "static", "Object", "convertToArray", "(", "final", "Object", "result", ",", "final", "Class", "entityType", ",", "final", "boolean", "projection", ")", "{", "final", "Collection", "res", "=", ...
Convert result object to array. @param result result object @param entityType target entity type @param projection true to apply projection, false otherwise @return converted result
[ "Convert", "result", "object", "to", "array", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/util/ResultUtils.java#L107-L118
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/db/scheme/SchemeInitializationException.java
SchemeInitializationException.check
public static void check(final boolean condition, final String message, final Object... args) { if (!condition) { throw new SchemeInitializationException(String.format(message, args)); } }
java
public static void check(final boolean condition, final String message, final Object... args) { if (!condition) { throw new SchemeInitializationException(String.format(message, args)); } }
[ "public", "static", "void", "check", "(", "final", "boolean", "condition", ",", "final", "String", "message", ",", "final", "Object", "...", "args", ")", "{", "if", "(", "!", "condition", ")", "{", "throw", "new", "SchemeInitializationException", "(", "Strin...
Shortcut to check and throw scheme exception. @param condition condition to validate @param message fail message @param args fail message arguments
[ "Shortcut", "to", "check", "and", "throw", "scheme", "exception", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/db/scheme/SchemeInitializationException.java#L28-L32
train
xvik/guice-persist-orient
src/main/java/ru/vyarus/guice/persist/orient/db/PersistentContext.java
PersistentContext.doInTransaction
public <T> T doInTransaction(final TxConfig config, final TxAction<T> action) { return txTemplate.doInTransaction(config, action); }
java
public <T> T doInTransaction(final TxConfig config, final TxAction<T> action) { return txTemplate.doInTransaction(config, action); }
[ "public", "<", "T", ">", "T", "doInTransaction", "(", "final", "TxConfig", "config", ",", "final", "TxAction", "<", "T", ">", "action", ")", "{", "return", "txTemplate", ".", "doInTransaction", "(", "config", ",", "action", ")", ";", "}" ]
Execute action within transaction. @param config transaction config (ignored in case of ongoing transaction) @param action action to execute within transaction (new or ongoing) @param <T> expected return type @return value produced by action @see ru.vyarus.guice.persist.orient.db.transaction.template.TxTemplate
[ "Execute", "action", "within", "transaction", "." ]
5ef06fb4f734360512e9824a3b875c4906c56b5b
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/db/PersistentContext.java#L93-L95
train
baneizalfe/PullToDismissPager
PullToDismissPager/src/main/java/com/mrbug/pulltodismisspager/PullToDismissPager.java
PullToDismissPager.collapsePanel
public boolean collapsePanel() { if (mFirstLayout) { mSlideState = SlideState.COLLAPSED; return true; } else { if (mSlideState == SlideState.HIDDEN || mSlideState == SlideState.COLLAPSED) return false; return collapsePanel(mSlideableView, 0); } }
java
public boolean collapsePanel() { if (mFirstLayout) { mSlideState = SlideState.COLLAPSED; return true; } else { if (mSlideState == SlideState.HIDDEN || mSlideState == SlideState.COLLAPSED) return false; return collapsePanel(mSlideableView, 0); } }
[ "public", "boolean", "collapsePanel", "(", ")", "{", "if", "(", "mFirstLayout", ")", "{", "mSlideState", "=", "SlideState", ".", "COLLAPSED", ";", "return", "true", ";", "}", "else", "{", "if", "(", "mSlideState", "==", "SlideState", ".", "HIDDEN", "||", ...
Collapse the sliding pane if it is currently slideable. If first layout has already completed this will animate. @return true if the pane was slideable and is now collapsed/in the process of collapsing
[ "Collapse", "the", "sliding", "pane", "if", "it", "is", "currently", "slideable", ".", "If", "first", "layout", "has", "already", "completed", "this", "will", "animate", "." ]
14b12725f8ab9274b2499432d85e1b8b2b1850a5
https://github.com/baneizalfe/PullToDismissPager/blob/14b12725f8ab9274b2499432d85e1b8b2b1850a5/PullToDismissPager/src/main/java/com/mrbug/pulltodismisspager/PullToDismissPager.java#L705-L714
train
baneizalfe/PullToDismissPager
PullToDismissPager/src/main/java/com/mrbug/pulltodismisspager/PullToDismissPager.java
PullToDismissPager.expandPanel
public boolean expandPanel(float mSlideOffset) { if (mSlideableView == null || mSlideState == SlideState.EXPANDED) return false; mSlideableView.setVisibility(View.VISIBLE); return expandPanel(mSlideableView, 0, mSlideOffset); }
java
public boolean expandPanel(float mSlideOffset) { if (mSlideableView == null || mSlideState == SlideState.EXPANDED) return false; mSlideableView.setVisibility(View.VISIBLE); return expandPanel(mSlideableView, 0, mSlideOffset); }
[ "public", "boolean", "expandPanel", "(", "float", "mSlideOffset", ")", "{", "if", "(", "mSlideableView", "==", "null", "||", "mSlideState", "==", "SlideState", ".", "EXPANDED", ")", "return", "false", ";", "mSlideableView", ".", "setVisibility", "(", "View", "...
Partially expand the sliding panel up to a specific offset @param mSlideOffset Value between 0 and 1, where 0 is completely expanded. @return true if the pane was slideable and is now expanded/in the process of expanding
[ "Partially", "expand", "the", "sliding", "panel", "up", "to", "a", "specific", "offset" ]
14b12725f8ab9274b2499432d85e1b8b2b1850a5
https://github.com/baneizalfe/PullToDismissPager/blob/14b12725f8ab9274b2499432d85e1b8b2b1850a5/PullToDismissPager/src/main/java/com/mrbug/pulltodismisspager/PullToDismissPager.java#L736-L740
train
baneizalfe/PullToDismissPager
PullToDismissPager/src/main/java/com/mrbug/pulltodismisspager/PullToDismissPager.java
PullToDismissPager.showPanel
public void showPanel() { if (mFirstLayout) { mSlideState = SlideState.COLLAPSED; } else { if (mSlideableView == null || mSlideState != SlideState.HIDDEN) return; mSlideableView.setVisibility(View.VISIBLE); requestLayout(); smoothSlideTo(0, 0); } }
java
public void showPanel() { if (mFirstLayout) { mSlideState = SlideState.COLLAPSED; } else { if (mSlideableView == null || mSlideState != SlideState.HIDDEN) return; mSlideableView.setVisibility(View.VISIBLE); requestLayout(); smoothSlideTo(0, 0); } }
[ "public", "void", "showPanel", "(", ")", "{", "if", "(", "mFirstLayout", ")", "{", "mSlideState", "=", "SlideState", ".", "COLLAPSED", ";", "}", "else", "{", "if", "(", "mSlideableView", "==", "null", "||", "mSlideState", "!=", "SlideState", ".", "HIDDEN",...
Shows the panel from the hidden state
[ "Shows", "the", "panel", "from", "the", "hidden", "state" ]
14b12725f8ab9274b2499432d85e1b8b2b1850a5
https://github.com/baneizalfe/PullToDismissPager/blob/14b12725f8ab9274b2499432d85e1b8b2b1850a5/PullToDismissPager/src/main/java/com/mrbug/pulltodismisspager/PullToDismissPager.java#L763-L772
train
baneizalfe/PullToDismissPager
PullToDismissPager/src/main/java/com/mrbug/pulltodismisspager/PullToDismissPager.java
PullToDismissPager.hidePanel
public void hidePanel() { if (mFirstLayout) { mSlideState = SlideState.HIDDEN; } else { if (mSlideState == SlideState.DRAGGING || mSlideState == SlideState.HIDDEN) return; int newTop = computePanelTopPosition(0.0f); smoothSlideTo(computeSlideOffset(newTop), 0); } }
java
public void hidePanel() { if (mFirstLayout) { mSlideState = SlideState.HIDDEN; } else { if (mSlideState == SlideState.DRAGGING || mSlideState == SlideState.HIDDEN) return; int newTop = computePanelTopPosition(0.0f); smoothSlideTo(computeSlideOffset(newTop), 0); } }
[ "public", "void", "hidePanel", "(", ")", "{", "if", "(", "mFirstLayout", ")", "{", "mSlideState", "=", "SlideState", ".", "HIDDEN", ";", "}", "else", "{", "if", "(", "mSlideState", "==", "SlideState", ".", "DRAGGING", "||", "mSlideState", "==", "SlideState...
Hides the sliding panel entirely.
[ "Hides", "the", "sliding", "panel", "entirely", "." ]
14b12725f8ab9274b2499432d85e1b8b2b1850a5
https://github.com/baneizalfe/PullToDismissPager/blob/14b12725f8ab9274b2499432d85e1b8b2b1850a5/PullToDismissPager/src/main/java/com/mrbug/pulltodismisspager/PullToDismissPager.java#L777-L785
train
baneizalfe/PullToDismissPager
PullToDismissPager/src/main/java/com/mrbug/pulltodismisspager/PullToDismissPager.java
PullToDismissPager.smoothSlideTo
boolean smoothSlideTo(float slideOffset, int velocity) { if (!isSlidingEnabled()) { // Nothing to do. return false; } int panelTop = computePanelTopPosition(slideOffset); if (mDragHelper.smoothSlideViewTo(mSlideableView, mSlideableView.getLeft(), panelTop)) { setAllChildrenVisible(); ViewCompat.postInvalidateOnAnimation(this); return true; } return false; }
java
boolean smoothSlideTo(float slideOffset, int velocity) { if (!isSlidingEnabled()) { // Nothing to do. return false; } int panelTop = computePanelTopPosition(slideOffset); if (mDragHelper.smoothSlideViewTo(mSlideableView, mSlideableView.getLeft(), panelTop)) { setAllChildrenVisible(); ViewCompat.postInvalidateOnAnimation(this); return true; } return false; }
[ "boolean", "smoothSlideTo", "(", "float", "slideOffset", ",", "int", "velocity", ")", "{", "if", "(", "!", "isSlidingEnabled", "(", ")", ")", "{", "// Nothing to do.", "return", "false", ";", "}", "int", "panelTop", "=", "computePanelTopPosition", "(", "slideO...
Smoothly animate mDraggingPane to the target X position within its range. @param slideOffset position to animate to @param velocity initial velocity in case of fling, or 0.
[ "Smoothly", "animate", "mDraggingPane", "to", "the", "target", "X", "position", "within", "its", "range", "." ]
14b12725f8ab9274b2499432d85e1b8b2b1850a5
https://github.com/baneizalfe/PullToDismissPager/blob/14b12725f8ab9274b2499432d85e1b8b2b1850a5/PullToDismissPager/src/main/java/com/mrbug/pulltodismisspager/PullToDismissPager.java#L836-L849
train
ralscha/wampspring
src/main/java/ch/rasc/wampspring/message/UnsubscribeMessage.java
UnsubscribeMessage.createCleanupMessage
public static UnsubscribeMessage createCleanupMessage(WebSocketSession session) { UnsubscribeMessage msg = new UnsubscribeMessage("**"); msg.setWebSocketSessionId(session.getId()); msg.setPrincipal(session.getPrincipal()); msg.setWampSession(new WampSession(session)); msg.cleanup = true; return msg; }
java
public static UnsubscribeMessage createCleanupMessage(WebSocketSession session) { UnsubscribeMessage msg = new UnsubscribeMessage("**"); msg.setWebSocketSessionId(session.getId()); msg.setPrincipal(session.getPrincipal()); msg.setWampSession(new WampSession(session)); msg.cleanup = true; return msg; }
[ "public", "static", "UnsubscribeMessage", "createCleanupMessage", "(", "WebSocketSession", "session", ")", "{", "UnsubscribeMessage", "msg", "=", "new", "UnsubscribeMessage", "(", "\"**\"", ")", ";", "msg", ".", "setWebSocketSessionId", "(", "session", ".", "getId", ...
Creates an internal unsubscribe message. The system creates this message when the WebSocket session ends and sends it to the subscribed message handlers for cleaning up @param sessionId the WebSocket session id
[ "Creates", "an", "internal", "unsubscribe", "message", ".", "The", "system", "creates", "this", "message", "when", "the", "WebSocket", "session", "ends", "and", "sends", "it", "to", "the", "subscribed", "message", "handlers", "for", "cleaning", "up" ]
7571bb6773b848c580b29890587eb35397bfe5b5
https://github.com/ralscha/wampspring/blob/7571bb6773b848c580b29890587eb35397bfe5b5/src/main/java/ch/rasc/wampspring/message/UnsubscribeMessage.java#L66-L76
train
xhsun/gw2wrapper
src/main/java/me/xhsun/guildwars2wrapper/GuildWars2Utility.java
GuildWars2Utility.parseCoins
public static long[] parseCoins(long value) { long[] result = new long[3]; if (value < 0) return result; long temp = value; result[2] = temp % 100; temp = temp / 100; result[1] = temp % 100; result[0] = temp / 100; return result; }
java
public static long[] parseCoins(long value) { long[] result = new long[3]; if (value < 0) return result; long temp = value; result[2] = temp % 100; temp = temp / 100; result[1] = temp % 100; result[0] = temp / 100; return result; }
[ "public", "static", "long", "[", "]", "parseCoins", "(", "long", "value", ")", "{", "long", "[", "]", "result", "=", "new", "long", "[", "3", "]", ";", "if", "(", "value", "<", "0", ")", "return", "result", ";", "long", "temp", "=", "value", ";",...
parse given coin value into number of gold, sliver, and copper @param value coin value @return results in array: index 0 is number of gold, index 1 is number of sliver, index 2 is number of copper
[ "parse", "given", "coin", "value", "into", "number", "of", "gold", "sliver", "and", "copper" ]
c8a43b51f363b032074fb152ee6efe657e33e525
https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2Utility.java#L50-L60
train
ralscha/wampspring
src/main/java/ch/rasc/wampspring/config/WampSubProtocolHandler.java
WampSubProtocolHandler.handleMessageFromClient
@Override public void handleMessageFromClient(WebSocketSession session, WebSocketMessage<?> webSocketMessage, MessageChannel outputChannel) { Assert.isInstanceOf(TextMessage.class, webSocketMessage); WampMessage wampMessage = null; try { wampMessage = WampMessage.fromJson(session, this.jsonFactory, ((TextMessage) webSocketMessage).getPayload()); } catch (Throwable ex) { if (logger.isErrorEnabled()) { logger.error("Failed to parse " + webSocketMessage + " in session " + session.getId() + ".", ex); } return; } try { WampSessionContextHolder.setAttributesFromMessage(wampMessage); outputChannel.send(wampMessage); } catch (Throwable ex) { logger.error("Failed to send client message to application via MessageChannel" + " in session " + session.getId() + ".", ex); if (wampMessage != null && wampMessage instanceof CallMessage) { CallErrorMessage callErrorMessage = new CallErrorMessage( (CallMessage) wampMessage, "", ex.toString()); try { String json = callErrorMessage.toJson(this.jsonFactory); session.sendMessage(new TextMessage(json)); } catch (Throwable t) { // Could be part of normal workflow (e.g. browser tab closed) logger.debug("Failed to send error to client.", t); } } } finally { WampSessionContextHolder.resetAttributes(); } }
java
@Override public void handleMessageFromClient(WebSocketSession session, WebSocketMessage<?> webSocketMessage, MessageChannel outputChannel) { Assert.isInstanceOf(TextMessage.class, webSocketMessage); WampMessage wampMessage = null; try { wampMessage = WampMessage.fromJson(session, this.jsonFactory, ((TextMessage) webSocketMessage).getPayload()); } catch (Throwable ex) { if (logger.isErrorEnabled()) { logger.error("Failed to parse " + webSocketMessage + " in session " + session.getId() + ".", ex); } return; } try { WampSessionContextHolder.setAttributesFromMessage(wampMessage); outputChannel.send(wampMessage); } catch (Throwable ex) { logger.error("Failed to send client message to application via MessageChannel" + " in session " + session.getId() + ".", ex); if (wampMessage != null && wampMessage instanceof CallMessage) { CallErrorMessage callErrorMessage = new CallErrorMessage( (CallMessage) wampMessage, "", ex.toString()); try { String json = callErrorMessage.toJson(this.jsonFactory); session.sendMessage(new TextMessage(json)); } catch (Throwable t) { // Could be part of normal workflow (e.g. browser tab closed) logger.debug("Failed to send error to client.", t); } } } finally { WampSessionContextHolder.resetAttributes(); } }
[ "@", "Override", "public", "void", "handleMessageFromClient", "(", "WebSocketSession", "session", ",", "WebSocketMessage", "<", "?", ">", "webSocketMessage", ",", "MessageChannel", "outputChannel", ")", "{", "Assert", ".", "isInstanceOf", "(", "TextMessage", ".", "c...
Handle incoming WebSocket messages from clients.
[ "Handle", "incoming", "WebSocket", "messages", "from", "clients", "." ]
7571bb6773b848c580b29890587eb35397bfe5b5
https://github.com/ralscha/wampspring/blob/7571bb6773b848c580b29890587eb35397bfe5b5/src/main/java/ch/rasc/wampspring/config/WampSubProtocolHandler.java#L72-L117
train
ralscha/wampspring
src/main/java/ch/rasc/wampspring/config/WampSubProtocolHandler.java
WampSubProtocolHandler.handleMessageToClient
@Override public void handleMessageToClient(WebSocketSession session, Message<?> message) { if (!(message instanceof WampMessage)) { logger.error("Expected WampMessage. Ignoring " + message + "."); return; } boolean closeWebSocketSession = false; try { String json = ((WampMessage) message).toJson(this.jsonFactory); session.sendMessage(new TextMessage(json)); } catch (SessionLimitExceededException ex) { // Bad session, just get out throw ex; } catch (Throwable ex) { // Could be part of normal workflow (e.g. browser tab closed) logger.debug("Failed to send WebSocket message to client in session " + session.getId() + ".", ex); closeWebSocketSession = true; } finally { if (closeWebSocketSession) { try { session.close(CloseStatus.PROTOCOL_ERROR); } catch (IOException ex) { // Ignore } } } }
java
@Override public void handleMessageToClient(WebSocketSession session, Message<?> message) { if (!(message instanceof WampMessage)) { logger.error("Expected WampMessage. Ignoring " + message + "."); return; } boolean closeWebSocketSession = false; try { String json = ((WampMessage) message).toJson(this.jsonFactory); session.sendMessage(new TextMessage(json)); } catch (SessionLimitExceededException ex) { // Bad session, just get out throw ex; } catch (Throwable ex) { // Could be part of normal workflow (e.g. browser tab closed) logger.debug("Failed to send WebSocket message to client in session " + session.getId() + ".", ex); closeWebSocketSession = true; } finally { if (closeWebSocketSession) { try { session.close(CloseStatus.PROTOCOL_ERROR); } catch (IOException ex) { // Ignore } } } }
[ "@", "Override", "public", "void", "handleMessageToClient", "(", "WebSocketSession", "session", ",", "Message", "<", "?", ">", "message", ")", "{", "if", "(", "!", "(", "message", "instanceof", "WampMessage", ")", ")", "{", "logger", ".", "error", "(", "\"...
Handle WAMP messages going back out to WebSocket clients.
[ "Handle", "WAMP", "messages", "going", "back", "out", "to", "WebSocket", "clients", "." ]
7571bb6773b848c580b29890587eb35397bfe5b5
https://github.com/ralscha/wampspring/blob/7571bb6773b848c580b29890587eb35397bfe5b5/src/main/java/ch/rasc/wampspring/config/WampSubProtocolHandler.java#L122-L154
train
xhsun/gw2wrapper
src/main/java/me/xhsun/guildwars2wrapper/helper/ItemAdapter.java
ItemAdapter.getItemFields
private Set<Field> getItemFields() { Class next = Item.class; Set<Field> fields = new HashSet<>(getFields(next)); while (next.getSuperclass() != Object.class) { next = next.getSuperclass(); fields.addAll(getFields(next)); } return fields; }
java
private Set<Field> getItemFields() { Class next = Item.class; Set<Field> fields = new HashSet<>(getFields(next)); while (next.getSuperclass() != Object.class) { next = next.getSuperclass(); fields.addAll(getFields(next)); } return fields; }
[ "private", "Set", "<", "Field", ">", "getItemFields", "(", ")", "{", "Class", "next", "=", "Item", ".", "class", ";", "Set", "<", "Field", ">", "fields", "=", "new", "HashSet", "<>", "(", "getFields", "(", "next", ")", ")", ";", "while", "(", "next...
get all fields for item class and all of it's super classes
[ "get", "all", "fields", "for", "item", "class", "and", "all", "of", "it", "s", "super", "classes" ]
c8a43b51f363b032074fb152ee6efe657e33e525
https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/helper/ItemAdapter.java#L89-L97
train
xhsun/gw2wrapper
src/main/java/me/xhsun/guildwars2wrapper/helper/ItemAdapter.java
ItemAdapter.getFields
private List<Field> getFields(Class given) { Field[] fs = given.getDeclaredFields(); return new ArrayList<>(Arrays.asList(fs)); }
java
private List<Field> getFields(Class given) { Field[] fs = given.getDeclaredFields(); return new ArrayList<>(Arrays.asList(fs)); }
[ "private", "List", "<", "Field", ">", "getFields", "(", "Class", "given", ")", "{", "Field", "[", "]", "fs", "=", "given", ".", "getDeclaredFields", "(", ")", ";", "return", "new", "ArrayList", "<>", "(", "Arrays", ".", "asList", "(", "fs", ")", ")",...
get field of given class
[ "get", "field", "of", "given", "class" ]
c8a43b51f363b032074fb152ee6efe657e33e525
https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/helper/ItemAdapter.java#L100-L103
train
xhsun/gw2wrapper
src/main/java/me/xhsun/guildwars2wrapper/GuildWars2.java
GuildWars2.setInstance
public static void setInstance(Cache cache) throws GuildWars2Exception { if (instance != null) throw new GuildWars2Exception(ErrorCode.Other, "Instance already initialized"); instance = new GuildWars2(cache); }
java
public static void setInstance(Cache cache) throws GuildWars2Exception { if (instance != null) throw new GuildWars2Exception(ErrorCode.Other, "Instance already initialized"); instance = new GuildWars2(cache); }
[ "public", "static", "void", "setInstance", "(", "Cache", "cache", ")", "throws", "GuildWars2Exception", "{", "if", "(", "instance", "!=", "null", ")", "throw", "new", "GuildWars2Exception", "(", "ErrorCode", ".", "Other", ",", "\"Instance already initialized\"", "...
Use this to initialize instance with custom cache @param cache {@link Cache} @throws GuildWars2Exception instance already exist
[ "Use", "this", "to", "initialize", "instance", "with", "custom", "cache" ]
c8a43b51f363b032074fb152ee6efe657e33e525
https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2.java#L74-L78
train