repository_name stringlengths 7 58 | func_path_in_repository stringlengths 18 188 | func_name stringlengths 7 127 | whole_func_string stringlengths 77 3.91k | language stringclasses 1
value | func_code_string stringlengths 77 3.91k | func_code_tokens listlengths 20 745 | func_documentation_string stringlengths 61 1.98k | func_documentation_tokens listlengths 1 477 | split_name stringclasses 1
value | func_code_url stringlengths 111 288 |
|---|---|---|---|---|---|---|---|---|---|---|
alb-i986/selenium-tinafw | src/main/java/me/alb_i986/selenium/tinafw/ui/PageHelper.java | PageHelper.waitUntil | public static <T> T waitUntil(ExpectedCondition<T> expectedCondition, WebDriver driver) {
return waitUntil(expectedCondition, driver, DEFAULT_EXPLICIT_WAIT_TIMEOUT_SECONDS);
} | java | public static <T> T waitUntil(ExpectedCondition<T> expectedCondition, WebDriver driver) {
return waitUntil(expectedCondition, driver, DEFAULT_EXPLICIT_WAIT_TIMEOUT_SECONDS);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"waitUntil",
"(",
"ExpectedCondition",
"<",
"T",
">",
"expectedCondition",
",",
"WebDriver",
"driver",
")",
"{",
"return",
"waitUntil",
"(",
"expectedCondition",
",",
"driver",
",",
"DEFAULT_EXPLICIT_WAIT_TIMEOUT_SECONDS",
"... | Generic explicit wait, taking an {@link ExpectedCondition} as a parameter.
Times out after {@link #DEFAULT_EXPLICIT_WAIT_TIMEOUT_SECONDS} seconds.
@param expectedCondition
@param driver
@return whatever WebDriverWait#until returns
@see #waitUntil(ExpectedCondition, WebDriver, long) | [
"Generic",
"explicit",
"wait",
"taking",
"an",
"{",
"@link",
"ExpectedCondition",
"}",
"as",
"a",
"parameter",
".",
"Times",
"out",
"after",
"{",
"@link",
"#DEFAULT_EXPLICIT_WAIT_TIMEOUT_SECONDS",
"}",
"seconds",
"."
] | train | https://github.com/alb-i986/selenium-tinafw/blob/91c66720cda9f69751f96c58c0a0624b2222186e/src/main/java/me/alb_i986/selenium/tinafw/ui/PageHelper.java#L41-L43 |
EdwardRaff/JSAT | JSAT/src/jsat/utils/IndexTable.java | IndexTable.apply | public void apply(double[] target)
{
//use DoubleList view b/d we are only using set ops, so we wont run into an issue of re-allocating the array
apply(DoubleList.view(target, target.length), new DoubleList(target.length));
} | java | public void apply(double[] target)
{
//use DoubleList view b/d we are only using set ops, so we wont run into an issue of re-allocating the array
apply(DoubleList.view(target, target.length), new DoubleList(target.length));
} | [
"public",
"void",
"apply",
"(",
"double",
"[",
"]",
"target",
")",
"{",
"//use DoubleList view b/d we are only using set ops, so we wont run into an issue of re-allocating the array",
"apply",
"(",
"DoubleList",
".",
"view",
"(",
"target",
",",
"target",
".",
"length",
")... | Applies this index table to the specified target, putting {@code target}
into the same ordering as this IndexTable.
@param target the array to re-order into the sorted order defined by this index table
@throws RuntimeException if the length of the target array is not the same as the index table | [
"Applies",
"this",
"index",
"table",
"to",
"the",
"specified",
"target",
"putting",
"{",
"@code",
"target",
"}",
"into",
"the",
"same",
"ordering",
"as",
"this",
"IndexTable",
"."
] | train | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/utils/IndexTable.java#L268-L272 |
NoraUi/NoraUi | src/main/java/com/github/noraui/application/steps/Step.java | Step.clickOnByJs | protected void clickOnByJs(Page page, String xpath) throws TechnicalException, FailureException {
displayMessageAtTheBeginningOfMethod("clickOnByJs: %s in %s", xpath, page.getApplication());
try {
Context.waitUntil(ExpectedConditions.elementToBeClickable(By.xpath(xpath.replaceAll("\\\\'", "'"))));
((JavascriptExecutor) getDriver()).executeScript("document.evaluate(\"" + xpath + "\", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.click();");
} catch (final Exception e) {
new Result.Failure<>(e.getMessage(), Messages.format(Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_EVALUATE_XPATH), xpath, page.getApplication()), true, page.getCallBack());
}
} | java | protected void clickOnByJs(Page page, String xpath) throws TechnicalException, FailureException {
displayMessageAtTheBeginningOfMethod("clickOnByJs: %s in %s", xpath, page.getApplication());
try {
Context.waitUntil(ExpectedConditions.elementToBeClickable(By.xpath(xpath.replaceAll("\\\\'", "'"))));
((JavascriptExecutor) getDriver()).executeScript("document.evaluate(\"" + xpath + "\", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.click();");
} catch (final Exception e) {
new Result.Failure<>(e.getMessage(), Messages.format(Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_EVALUATE_XPATH), xpath, page.getApplication()), true, page.getCallBack());
}
} | [
"protected",
"void",
"clickOnByJs",
"(",
"Page",
"page",
",",
"String",
"xpath",
")",
"throws",
"TechnicalException",
",",
"FailureException",
"{",
"displayMessageAtTheBeginningOfMethod",
"(",
"\"clickOnByJs: %s in %s\"",
",",
"xpath",
",",
"page",
".",
"getApplication"... | Click on html element by Javascript.
@param page
page target application
@param xpath
XPath of an element to evaluate
@throws TechnicalException
is thrown if you have a technical error (format, configuration, datas, ...) in NoraUi.
Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_UNABLE_TO_OPEN_ON_CLICK} message (with screenshot, with exception)
@throws FailureException
if the scenario encounters a functional error | [
"Click",
"on",
"html",
"element",
"by",
"Javascript",
"."
] | train | https://github.com/NoraUi/NoraUi/blob/5f491a3339c7d3c20d7207760bdaf2acdb8f260c/src/main/java/com/github/noraui/application/steps/Step.java#L161-L169 |
b3dgs/lionengine | lionengine-game/src/main/java/com/b3dgs/lionengine/game/Cursor.java | Cursor.setGrid | public void setGrid(int width, int height)
{
Check.superiorStrict(width, 0);
Check.superiorStrict(height, 0);
gridWidth = width;
gridHeight = height;
} | java | public void setGrid(int width, int height)
{
Check.superiorStrict(width, 0);
Check.superiorStrict(height, 0);
gridWidth = width;
gridHeight = height;
} | [
"public",
"void",
"setGrid",
"(",
"int",
"width",
",",
"int",
"height",
")",
"{",
"Check",
".",
"superiorStrict",
"(",
"width",
",",
"0",
")",
";",
"Check",
".",
"superiorStrict",
"(",
"height",
",",
"0",
")",
";",
"gridWidth",
"=",
"width",
";",
"gr... | Set the grid size.
@param width The horizontal grid (strictly positive).
@param height The vertical grid (strictly positive).
@throws LionEngineException If grid is not strictly positive. | [
"Set",
"the",
"grid",
"size",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/Cursor.java#L229-L235 |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.peekEntryInternal | final protected Entry<K, V> peekEntryInternal(K key) {
int hc = modifiedHash(key.hashCode());
return peekEntryInternal(key, hc, extractIntKeyValue(key, hc));
} | java | final protected Entry<K, V> peekEntryInternal(K key) {
int hc = modifiedHash(key.hashCode());
return peekEntryInternal(key, hc, extractIntKeyValue(key, hc));
} | [
"final",
"protected",
"Entry",
"<",
"K",
",",
"V",
">",
"peekEntryInternal",
"(",
"K",
"key",
")",
"{",
"int",
"hc",
"=",
"modifiedHash",
"(",
"key",
".",
"hashCode",
"(",
")",
")",
";",
"return",
"peekEntryInternal",
"(",
"key",
",",
"hc",
",",
"ext... | Return the entry, if it is in the cache, without invoking the
cache source.
<p>The cache storage is asked whether the entry is present.
If the entry is not present, this result is cached in the local
cache. | [
"Return",
"the",
"entry",
"if",
"it",
"is",
"in",
"the",
"cache",
"without",
"invoking",
"the",
"cache",
"source",
"."
] | train | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L813-L816 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-properties/src/main/java/org/xwiki/properties/internal/DefaultBeanDescriptor.java | DefaultBeanDescriptor.extractPropertyDescriptor | protected void extractPropertyDescriptor(Field field, Object defaultInstance)
{
DefaultPropertyDescriptor desc = new DefaultPropertyDescriptor();
// is parameter hidden
PropertyHidden parameterHidden = field.getAnnotation(PropertyHidden.class);
if (parameterHidden == null) {
// get parameter id
PropertyId propertyId = field.getAnnotation(PropertyId.class);
desc.setId(propertyId != null ? propertyId.value() : field.getName());
// set parameter type
desc.setPropertyType(field.getGenericType());
// get parameter name
PropertyName parameterName = field.getAnnotation(PropertyName.class);
desc.setName(parameterName != null ? parameterName.value() : desc.getId());
// get parameter description
PropertyDescription parameterDescription = field.getAnnotation(PropertyDescription.class);
desc.setDescription(parameterDescription != null ? parameterDescription.value() : desc.getId());
Map<Class, Annotation> annotations = new HashMap<>();
COMMON_ANNOTATION_CLASSES.forEach(aClass ->
annotations.put(aClass, field.getAnnotation(aClass))
);
setCommonProperties(desc, annotations);
if (defaultInstance != null) {
// get default value
try {
desc.setDefaultValue(field.get(defaultInstance));
} catch (Exception e) {
LOGGER.error(
MessageFormat.format("Failed to get default property value from field {0} in class {1}",
field.getName(), this.beanClass), e);
}
}
desc.setField(field);
this.parameterDescriptorMap.put(desc.getId(), desc);
}
} | java | protected void extractPropertyDescriptor(Field field, Object defaultInstance)
{
DefaultPropertyDescriptor desc = new DefaultPropertyDescriptor();
// is parameter hidden
PropertyHidden parameterHidden = field.getAnnotation(PropertyHidden.class);
if (parameterHidden == null) {
// get parameter id
PropertyId propertyId = field.getAnnotation(PropertyId.class);
desc.setId(propertyId != null ? propertyId.value() : field.getName());
// set parameter type
desc.setPropertyType(field.getGenericType());
// get parameter name
PropertyName parameterName = field.getAnnotation(PropertyName.class);
desc.setName(parameterName != null ? parameterName.value() : desc.getId());
// get parameter description
PropertyDescription parameterDescription = field.getAnnotation(PropertyDescription.class);
desc.setDescription(parameterDescription != null ? parameterDescription.value() : desc.getId());
Map<Class, Annotation> annotations = new HashMap<>();
COMMON_ANNOTATION_CLASSES.forEach(aClass ->
annotations.put(aClass, field.getAnnotation(aClass))
);
setCommonProperties(desc, annotations);
if (defaultInstance != null) {
// get default value
try {
desc.setDefaultValue(field.get(defaultInstance));
} catch (Exception e) {
LOGGER.error(
MessageFormat.format("Failed to get default property value from field {0} in class {1}",
field.getName(), this.beanClass), e);
}
}
desc.setField(field);
this.parameterDescriptorMap.put(desc.getId(), desc);
}
} | [
"protected",
"void",
"extractPropertyDescriptor",
"(",
"Field",
"field",
",",
"Object",
"defaultInstance",
")",
"{",
"DefaultPropertyDescriptor",
"desc",
"=",
"new",
"DefaultPropertyDescriptor",
"(",
")",
";",
"// is parameter hidden",
"PropertyHidden",
"parameterHidden",
... | Extract provided properties informations and insert it in {@link #parameterDescriptorMap}.
@param field the JAVA bean property descriptor.
@param defaultInstance the default instance of bean class. | [
"Extract",
"provided",
"properties",
"informations",
"and",
"insert",
"it",
"in",
"{",
"@link",
"#parameterDescriptorMap",
"}",
"."
] | train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-properties/src/main/java/org/xwiki/properties/internal/DefaultBeanDescriptor.java#L212-L259 |
VoltDB/voltdb | src/frontend/org/voltcore/utils/CoreUtils.java | CoreUtils.getThreadFactory | public static ThreadFactory getThreadFactory(
final String groupName,
final String name,
final int stackSize,
final boolean incrementThreadNames,
final Queue<String> coreList) {
ThreadGroup group = null;
if (groupName != null) {
group = new ThreadGroup(Thread.currentThread().getThreadGroup(), groupName);
}
final ThreadGroup finalGroup = group;
return new ThreadFactory() {
private final AtomicLong m_createdThreadCount = new AtomicLong(0);
private final ThreadGroup m_group = finalGroup;
@Override
public synchronized Thread newThread(final Runnable r) {
final String threadName = name +
(incrementThreadNames ? " - " + m_createdThreadCount.getAndIncrement() : "");
String coreTemp = null;
if (coreList != null && !coreList.isEmpty()) {
coreTemp = coreList.poll();
}
final String core = coreTemp;
Runnable runnable = new Runnable() {
@Override
public void run() {
if (core != null) {
// Remove Affinity for now to make this dependency dissapear from the client.
// Goal is to remove client dependency on this class in the medium term.
//PosixJNAAffinity.INSTANCE.setAffinity(core);
}
try {
r.run();
} catch (Throwable t) {
new VoltLogger("HOST").error("Exception thrown in thread " + threadName, t);
} finally {
m_threadLocalDeallocator.run();
}
}
};
Thread t = new Thread(m_group, runnable, threadName, stackSize);
t.setDaemon(true);
return t;
}
};
} | java | public static ThreadFactory getThreadFactory(
final String groupName,
final String name,
final int stackSize,
final boolean incrementThreadNames,
final Queue<String> coreList) {
ThreadGroup group = null;
if (groupName != null) {
group = new ThreadGroup(Thread.currentThread().getThreadGroup(), groupName);
}
final ThreadGroup finalGroup = group;
return new ThreadFactory() {
private final AtomicLong m_createdThreadCount = new AtomicLong(0);
private final ThreadGroup m_group = finalGroup;
@Override
public synchronized Thread newThread(final Runnable r) {
final String threadName = name +
(incrementThreadNames ? " - " + m_createdThreadCount.getAndIncrement() : "");
String coreTemp = null;
if (coreList != null && !coreList.isEmpty()) {
coreTemp = coreList.poll();
}
final String core = coreTemp;
Runnable runnable = new Runnable() {
@Override
public void run() {
if (core != null) {
// Remove Affinity for now to make this dependency dissapear from the client.
// Goal is to remove client dependency on this class in the medium term.
//PosixJNAAffinity.INSTANCE.setAffinity(core);
}
try {
r.run();
} catch (Throwable t) {
new VoltLogger("HOST").error("Exception thrown in thread " + threadName, t);
} finally {
m_threadLocalDeallocator.run();
}
}
};
Thread t = new Thread(m_group, runnable, threadName, stackSize);
t.setDaemon(true);
return t;
}
};
} | [
"public",
"static",
"ThreadFactory",
"getThreadFactory",
"(",
"final",
"String",
"groupName",
",",
"final",
"String",
"name",
",",
"final",
"int",
"stackSize",
",",
"final",
"boolean",
"incrementThreadNames",
",",
"final",
"Queue",
"<",
"String",
">",
"coreList",
... | Creates a thread factory that creates threads within a thread group if
the group name is given. The threads created will catch any unhandled
exceptions and log them to the HOST logger.
@param groupName
@param name
@param stackSize
@return | [
"Creates",
"a",
"thread",
"factory",
"that",
"creates",
"threads",
"within",
"a",
"thread",
"group",
"if",
"the",
"group",
"name",
"is",
"given",
".",
"The",
"threads",
"created",
"will",
"catch",
"any",
"unhandled",
"exceptions",
"and",
"log",
"them",
"to",... | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/utils/CoreUtils.java#L706-L753 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-velocity/src/main/java/org/xwiki/velocity/internal/util/VelocityParser.java | VelocityParser.followVar | private int followVar(char[] array, int currentIndex, boolean fullSyntax, VelocityParserContext context)
{
int i = currentIndex;
while (i < array.length) {
if (fullSyntax && array[i] == '}') {
++i;
break;
} else if (array[i] == '.') {
try {
i = getMethodOrProperty(array, i, null, context);
} catch (InvalidVelocityException e) {
LOGGER.debug("Not a valid method at char [{}]", i, e);
break;
}
} else if (array[i] == '[') {
i = getTableElement(array, i, null, context);
break;
} else {
break;
}
}
return i;
} | java | private int followVar(char[] array, int currentIndex, boolean fullSyntax, VelocityParserContext context)
{
int i = currentIndex;
while (i < array.length) {
if (fullSyntax && array[i] == '}') {
++i;
break;
} else if (array[i] == '.') {
try {
i = getMethodOrProperty(array, i, null, context);
} catch (InvalidVelocityException e) {
LOGGER.debug("Not a valid method at char [{}]", i, e);
break;
}
} else if (array[i] == '[') {
i = getTableElement(array, i, null, context);
break;
} else {
break;
}
}
return i;
} | [
"private",
"int",
"followVar",
"(",
"char",
"[",
"]",
"array",
",",
"int",
"currentIndex",
",",
"boolean",
"fullSyntax",
",",
"VelocityParserContext",
"context",
")",
"{",
"int",
"i",
"=",
"currentIndex",
";",
"while",
"(",
"i",
"<",
"array",
".",
"length"... | Get the right part of a Velocity variable (the methods and properties starting from the dot).
@param array the source to parse
@param currentIndex the current index in the <code>array</code>
@param fullSyntax indicate if it's between <code>{</code> and <code>}</code>
@param context the parser context to put some informations
@return the index in the <code>array</code> after the matched block | [
"Get",
"the",
"right",
"part",
"of",
"a",
"Velocity",
"variable",
"(",
"the",
"methods",
"and",
"properties",
"starting",
"from",
"the",
"dot",
")",
"."
] | train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-velocity/src/main/java/org/xwiki/velocity/internal/util/VelocityParser.java#L446-L470 |
kmi/iserve | iserve-semantic-discovery/src/main/java/uk/ac/open/kmi/iserve/discovery/disco/impl/SparqlLogicConceptMatcher.java | SparqlLogicConceptMatcher.listMatchesWithinRange | @Override
public Table<URI, URI, MatchResult> listMatchesWithinRange(Set<URI> origins, MatchType minType, MatchType maxType) {
return obtainMatchResults(origins, minType, maxType);
} | java | @Override
public Table<URI, URI, MatchResult> listMatchesWithinRange(Set<URI> origins, MatchType minType, MatchType maxType) {
return obtainMatchResults(origins, minType, maxType);
} | [
"@",
"Override",
"public",
"Table",
"<",
"URI",
",",
"URI",
",",
"MatchResult",
">",
"listMatchesWithinRange",
"(",
"Set",
"<",
"URI",
">",
"origins",
",",
"MatchType",
"minType",
",",
"MatchType",
"maxType",
")",
"{",
"return",
"obtainMatchResults",
"(",
"o... | Obtain all the matching resources with the URIs of {@code origin} within the range of MatchTypes provided, both inclusive.
@param origins URIs to match
@param minType the minimum MatchType we want to obtain
@param maxType the maximum MatchType we want to obtain
@return a {@link com.google.common.collect.Table} with the result of the matching indexed by origin URI and then destination URI. | [
"Obtain",
"all",
"the",
"matching",
"resources",
"with",
"the",
"URIs",
"of",
"{",
"@code",
"origin",
"}",
"within",
"the",
"range",
"of",
"MatchTypes",
"provided",
"both",
"inclusive",
"."
] | train | https://github.com/kmi/iserve/blob/13e7016e64c1d5a539b838c6debf1a5cc4aefcb7/iserve-semantic-discovery/src/main/java/uk/ac/open/kmi/iserve/discovery/disco/impl/SparqlLogicConceptMatcher.java#L346-L349 |
google/closure-compiler | src/com/google/javascript/jscomp/JsMessageVisitor.java | JsMessageVisitor.isMessageName | boolean isMessageName(String identifier, boolean isNewStyleMessage) {
return identifier.startsWith(MSG_PREFIX) &&
(style == JsMessage.Style.CLOSURE || isNewStyleMessage ||
!identifier.endsWith(DESC_SUFFIX));
} | java | boolean isMessageName(String identifier, boolean isNewStyleMessage) {
return identifier.startsWith(MSG_PREFIX) &&
(style == JsMessage.Style.CLOSURE || isNewStyleMessage ||
!identifier.endsWith(DESC_SUFFIX));
} | [
"boolean",
"isMessageName",
"(",
"String",
"identifier",
",",
"boolean",
"isNewStyleMessage",
")",
"{",
"return",
"identifier",
".",
"startsWith",
"(",
"MSG_PREFIX",
")",
"&&",
"(",
"style",
"==",
"JsMessage",
".",
"Style",
".",
"CLOSURE",
"||",
"isNewStyleMessa... | Returns whether the given JS identifier is a valid JS message name. | [
"Returns",
"whether",
"the",
"given",
"JS",
"identifier",
"is",
"a",
"valid",
"JS",
"message",
"name",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/JsMessageVisitor.java#L922-L926 |
nohana/Amalgam | amalgam/src/main/java/com/amalgam/database/CursorUtils.java | CursorUtils.getLong | public static long getLong(Cursor cursor, String columnName) {
if (cursor == null) {
return -1;
}
return cursor.getLong(cursor.getColumnIndex(columnName));
} | java | public static long getLong(Cursor cursor, String columnName) {
if (cursor == null) {
return -1;
}
return cursor.getLong(cursor.getColumnIndex(columnName));
} | [
"public",
"static",
"long",
"getLong",
"(",
"Cursor",
"cursor",
",",
"String",
"columnName",
")",
"{",
"if",
"(",
"cursor",
"==",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"cursor",
".",
"getLong",
"(",
"cursor",
".",
"getColumnIndex",
... | Read the long data for the column.
@see android.database.Cursor#getLong(int).
@see android.database.Cursor#getColumnIndex(String).
@param cursor the cursor.
@param columnName the column name.
@return the long value. | [
"Read",
"the",
"long",
"data",
"for",
"the",
"column",
"."
] | train | https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/database/CursorUtils.java#L112-L118 |
cfg4j/cfg4j | cfg4j-core/src/main/java/org/cfg4j/source/context/propertiesprovider/YamlBasedPropertiesProvider.java | YamlBasedPropertiesProvider.getProperties | @Override
public Properties getProperties(InputStream inputStream) {
requireNonNull(inputStream);
Yaml yaml = new Yaml();
Properties properties = new Properties();
try (Reader reader = new UnicodeReader(inputStream)) {
Object object = yaml.load(reader);
if (object != null) {
Map<String, Object> yamlAsMap = convertToMap(object);
properties.putAll(flatten(yamlAsMap));
}
return properties;
} catch (IOException | ScannerException e) {
throw new IllegalStateException("Unable to load yaml configuration from provided stream", e);
}
} | java | @Override
public Properties getProperties(InputStream inputStream) {
requireNonNull(inputStream);
Yaml yaml = new Yaml();
Properties properties = new Properties();
try (Reader reader = new UnicodeReader(inputStream)) {
Object object = yaml.load(reader);
if (object != null) {
Map<String, Object> yamlAsMap = convertToMap(object);
properties.putAll(flatten(yamlAsMap));
}
return properties;
} catch (IOException | ScannerException e) {
throw new IllegalStateException("Unable to load yaml configuration from provided stream", e);
}
} | [
"@",
"Override",
"public",
"Properties",
"getProperties",
"(",
"InputStream",
"inputStream",
")",
"{",
"requireNonNull",
"(",
"inputStream",
")",
";",
"Yaml",
"yaml",
"=",
"new",
"Yaml",
"(",
")",
";",
"Properties",
"properties",
"=",
"new",
"Properties",
"(",... | Get {@link Properties} for a given {@code inputStream} treating it as a YAML file.
@param inputStream input stream representing YAML file
@return properties representing values from {@code inputStream}
@throws IllegalStateException when unable to read properties | [
"Get",
"{",
"@link",
"Properties",
"}",
"for",
"a",
"given",
"{",
"@code",
"inputStream",
"}",
"treating",
"it",
"as",
"a",
"YAML",
"file",
"."
] | train | https://github.com/cfg4j/cfg4j/blob/47d4f63e5fc820c62631e557adc34a29d8ab396d/cfg4j-core/src/main/java/org/cfg4j/source/context/propertiesprovider/YamlBasedPropertiesProvider.java#L46-L68 |
stratosphere/stratosphere | stratosphere-runtime/src/main/java/eu/stratosphere/pact/runtime/hash/CompactingHashTable.java | CompactingHashTable.open | public void open() {
// sanity checks
if (!this.closed.compareAndSet(true, false)) {
throw new IllegalStateException("Hash Table cannot be opened, because it is currently not closed.");
}
// create the partitions
final int partitionFanOut = getPartitioningFanOutNoEstimates(this.availableMemory.size());
createPartitions(partitionFanOut);
// set up the table structure. the write behind buffers are taken away, as are one buffer per partition
final int numBuckets = getInitialTableSize(this.availableMemory.size(), this.segmentSize,
partitionFanOut, this.avgRecordLen);
initTable(numBuckets, (byte) partitionFanOut);
} | java | public void open() {
// sanity checks
if (!this.closed.compareAndSet(true, false)) {
throw new IllegalStateException("Hash Table cannot be opened, because it is currently not closed.");
}
// create the partitions
final int partitionFanOut = getPartitioningFanOutNoEstimates(this.availableMemory.size());
createPartitions(partitionFanOut);
// set up the table structure. the write behind buffers are taken away, as are one buffer per partition
final int numBuckets = getInitialTableSize(this.availableMemory.size(), this.segmentSize,
partitionFanOut, this.avgRecordLen);
initTable(numBuckets, (byte) partitionFanOut);
} | [
"public",
"void",
"open",
"(",
")",
"{",
"// sanity checks",
"if",
"(",
"!",
"this",
".",
"closed",
".",
"compareAndSet",
"(",
"true",
",",
"false",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Hash Table cannot be opened, because it is currentl... | Build the hash table
@throws IOException Thrown, if an I/O problem occurs while spilling a partition. | [
"Build",
"the",
"hash",
"table"
] | train | https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-runtime/src/main/java/eu/stratosphere/pact/runtime/hash/CompactingHashTable.java#L276-L291 |
google/error-prone-javac | src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java | EnumConstantBuilder.getInstance | public static EnumConstantBuilder getInstance(Context context,
ClassDoc classDoc, EnumConstantWriter writer) {
return new EnumConstantBuilder(context, classDoc, writer);
} | java | public static EnumConstantBuilder getInstance(Context context,
ClassDoc classDoc, EnumConstantWriter writer) {
return new EnumConstantBuilder(context, classDoc, writer);
} | [
"public",
"static",
"EnumConstantBuilder",
"getInstance",
"(",
"Context",
"context",
",",
"ClassDoc",
"classDoc",
",",
"EnumConstantWriter",
"writer",
")",
"{",
"return",
"new",
"EnumConstantBuilder",
"(",
"context",
",",
"classDoc",
",",
"writer",
")",
";",
"}"
] | Construct a new EnumConstantsBuilder.
@param context the build context.
@param classDoc the class whoses members are being documented.
@param writer the doclet specific writer. | [
"Construct",
"a",
"new",
"EnumConstantsBuilder",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java#L105-L108 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/Row.java | Row.compareByKey | public static Comparator<Row> compareByKey() {
return new Comparator<Row>() {
@Override
public int compare(Row r1, Row r2) {
return ByteStringComparator.INSTANCE.compare(r1.getKey(), r2.getKey());
}
};
} | java | public static Comparator<Row> compareByKey() {
return new Comparator<Row>() {
@Override
public int compare(Row r1, Row r2) {
return ByteStringComparator.INSTANCE.compare(r1.getKey(), r2.getKey());
}
};
} | [
"public",
"static",
"Comparator",
"<",
"Row",
">",
"compareByKey",
"(",
")",
"{",
"return",
"new",
"Comparator",
"<",
"Row",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"Row",
"r1",
",",
"Row",
"r2",
")",
"{",
"return",
"Byt... | Returns a comparator that compares two Row objects by comparing the result of {@link
#getKey()}} for each. | [
"Returns",
"a",
"comparator",
"that",
"compares",
"two",
"Row",
"objects",
"by",
"comparing",
"the",
"result",
"of",
"{"
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/Row.java#L44-L51 |
j-a-w-r/jawr-main-repo | jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java | PathNormalizer.concatWebPath | public static String concatWebPath(String basePath, String fullFilenameToAdd) {
if (fullFilenameToAdd == null || basePath == null && (fullFilenameToAdd.length() == 0
|| fullFilenameToAdd.charAt(0) != JawrConstant.URL_SEPARATOR_CHAR)) {
return null;
}
if (basePath == null) {
basePath = "";
}
// If the basePath is pointing to a file, set the base path to the
// parent directory
if (basePath.length() > 1 && basePath.charAt(basePath.length() - 1) != '/') {
basePath = getParentPath(basePath);
}
int len = basePath.length();
String fullPath = null;
if (len == 0) {
return doNormalizeIgnoreOtherSeparator(fullFilenameToAdd, true);
}
char ch = basePath.charAt(len - 1);
if (ch == JawrConstant.URL_SEPARATOR_CHAR) {
fullPath = basePath + fullFilenameToAdd;
} else {
fullPath = basePath + '/' + fullFilenameToAdd;
}
return doNormalizeIgnoreOtherSeparator(fullPath, true);
} | java | public static String concatWebPath(String basePath, String fullFilenameToAdd) {
if (fullFilenameToAdd == null || basePath == null && (fullFilenameToAdd.length() == 0
|| fullFilenameToAdd.charAt(0) != JawrConstant.URL_SEPARATOR_CHAR)) {
return null;
}
if (basePath == null) {
basePath = "";
}
// If the basePath is pointing to a file, set the base path to the
// parent directory
if (basePath.length() > 1 && basePath.charAt(basePath.length() - 1) != '/') {
basePath = getParentPath(basePath);
}
int len = basePath.length();
String fullPath = null;
if (len == 0) {
return doNormalizeIgnoreOtherSeparator(fullFilenameToAdd, true);
}
char ch = basePath.charAt(len - 1);
if (ch == JawrConstant.URL_SEPARATOR_CHAR) {
fullPath = basePath + fullFilenameToAdd;
} else {
fullPath = basePath + '/' + fullFilenameToAdd;
}
return doNormalizeIgnoreOtherSeparator(fullPath, true);
} | [
"public",
"static",
"String",
"concatWebPath",
"(",
"String",
"basePath",
",",
"String",
"fullFilenameToAdd",
")",
"{",
"if",
"(",
"fullFilenameToAdd",
"==",
"null",
"||",
"basePath",
"==",
"null",
"&&",
"(",
"fullFilenameToAdd",
".",
"length",
"(",
")",
"==",... | Concatenates a filename to a base web path. If the base path doesn't end
with "/", it will consider as base path the parent folder of the base
path passed as parameter.
<pre>
PathUtils.concatWebPath("", null)); = null
PathUtils.concatWebPath(null, null)); = null
PathUtils.concatWebPath(null, "")); = null
PathUtils.concatWebPath(null, "a")); = null
PathUtils.concatWebPath(null, "/a")); = "/a"
PathUtils.concatWebPath( "/css/folder/subfolder/", "icons/img.png" ) = "/css/folder/subfolder/icons/img.png"
PathUtils.concatWebPath( "/css/folder/subfolder/style.css", "icons/img.png") = "/css/folder/subfolder/icons/img.png"
PathUtils.concatWebPath( "/css/folder/", "../icons/img.png" ) = "/css/icons/img.png"
PathUtils.concatWebPath( "/css/folder/style.css", "../icons/img.png" ) = "/css/icons/img.png"
</pre>
@param basePath
the base path
@param fullFilenameToAdd
the file name to add
@return the concatenated path, or null if invalid | [
"Concatenates",
"a",
"filename",
"to",
"a",
"base",
"web",
"path",
".",
"If",
"the",
"base",
"path",
"doesn",
"t",
"end",
"with",
"/",
"it",
"will",
"consider",
"as",
"base",
"path",
"the",
"parent",
"folder",
"of",
"the",
"base",
"path",
"passed",
"as... | train | https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java#L615-L646 |
Wikidata/Wikidata-Toolkit | wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/Datamodel.java | Datamodel.makeItemIdValue | public static ItemIdValue makeItemIdValue(String id, String siteIri) {
return factory.getItemIdValue(id, siteIri);
} | java | public static ItemIdValue makeItemIdValue(String id, String siteIri) {
return factory.getItemIdValue(id, siteIri);
} | [
"public",
"static",
"ItemIdValue",
"makeItemIdValue",
"(",
"String",
"id",
",",
"String",
"siteIri",
")",
"{",
"return",
"factory",
".",
"getItemIdValue",
"(",
"id",
",",
"siteIri",
")",
";",
"}"
] | Creates an {@link ItemIdValue}.
@param id
a string of the form Qn... where n... is the string
representation of a positive integer number
@param siteIri
IRI to identify the site, usually the first part of the entity
IRI of the site this belongs to, e.g.,
"http://www.wikidata.org/entity/"
@return an {@link ItemIdValue} corresponding to the input | [
"Creates",
"an",
"{",
"@link",
"ItemIdValue",
"}",
"."
] | train | https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/Datamodel.java#L58-L60 |
neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/periodic/Periodic.java | Periodic.submit | public static <T> JobInfo submit(String name, Runnable task) {
JobInfo info = new JobInfo(name);
Future<T> future = list.remove(info);
if (future != null && !future.isDone()) future.cancel(false);
Future newFuture = Pools.SCHEDULED.submit(task);
list.put(info,newFuture);
return info;
} | java | public static <T> JobInfo submit(String name, Runnable task) {
JobInfo info = new JobInfo(name);
Future<T> future = list.remove(info);
if (future != null && !future.isDone()) future.cancel(false);
Future newFuture = Pools.SCHEDULED.submit(task);
list.put(info,newFuture);
return info;
} | [
"public",
"static",
"<",
"T",
">",
"JobInfo",
"submit",
"(",
"String",
"name",
",",
"Runnable",
"task",
")",
"{",
"JobInfo",
"info",
"=",
"new",
"JobInfo",
"(",
"name",
")",
";",
"Future",
"<",
"T",
">",
"future",
"=",
"list",
".",
"remove",
"(",
"... | Call from a procedure that gets a <code>@Context GraphDatbaseAPI db;</code> injected and provide that db to the runnable. | [
"Call",
"from",
"a",
"procedure",
"that",
"gets",
"a",
"<code",
">"
] | train | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/periodic/Periodic.java#L189-L197 |
apache/flink | flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/parameter/DoubleParameter.java | DoubleParameter.setMaximumValue | public DoubleParameter setMaximumValue(double maximumValue, boolean inclusive) {
if (hasDefaultValue) {
if (inclusive) {
Util.checkParameter(maximumValue >= defaultValue,
"Maximum value (" + maximumValue + ") must be greater than or equal to default (" + defaultValue + ")");
} else {
Util.checkParameter(maximumValue > defaultValue,
"Maximum value (" + maximumValue + ") must be greater than default (" + defaultValue + ")");
}
} else if (hasMinimumValue) {
if (inclusive && minimumValueInclusive) {
Util.checkParameter(maximumValue >= minimumValue,
"Maximum value (" + maximumValue + ") must be greater than or equal to minimum (" + minimumValue + ")");
} else {
Util.checkParameter(maximumValue > minimumValue,
"Maximum value (" + maximumValue + ") must be greater than minimum (" + minimumValue + ")");
}
}
this.hasMaximumValue = true;
this.maximumValue = maximumValue;
this.maximumValueInclusive = inclusive;
return this;
} | java | public DoubleParameter setMaximumValue(double maximumValue, boolean inclusive) {
if (hasDefaultValue) {
if (inclusive) {
Util.checkParameter(maximumValue >= defaultValue,
"Maximum value (" + maximumValue + ") must be greater than or equal to default (" + defaultValue + ")");
} else {
Util.checkParameter(maximumValue > defaultValue,
"Maximum value (" + maximumValue + ") must be greater than default (" + defaultValue + ")");
}
} else if (hasMinimumValue) {
if (inclusive && minimumValueInclusive) {
Util.checkParameter(maximumValue >= minimumValue,
"Maximum value (" + maximumValue + ") must be greater than or equal to minimum (" + minimumValue + ")");
} else {
Util.checkParameter(maximumValue > minimumValue,
"Maximum value (" + maximumValue + ") must be greater than minimum (" + minimumValue + ")");
}
}
this.hasMaximumValue = true;
this.maximumValue = maximumValue;
this.maximumValueInclusive = inclusive;
return this;
} | [
"public",
"DoubleParameter",
"setMaximumValue",
"(",
"double",
"maximumValue",
",",
"boolean",
"inclusive",
")",
"{",
"if",
"(",
"hasDefaultValue",
")",
"{",
"if",
"(",
"inclusive",
")",
"{",
"Util",
".",
"checkParameter",
"(",
"maximumValue",
">=",
"defaultValu... | Set the maximum value. The maximum value is an acceptable value if and
only if inclusive is set to true.
@param maximumValue the maximum value
@param inclusive whether the maximum value is a valid value
@return this | [
"Set",
"the",
"maximum",
"value",
".",
"The",
"maximum",
"value",
"is",
"an",
"acceptable",
"value",
"if",
"and",
"only",
"if",
"inclusive",
"is",
"set",
"to",
"true",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/parameter/DoubleParameter.java#L122-L146 |
ksclarke/freelib-utils | src/main/java/info/freelibrary/util/IOUtils.java | IOUtils.copyStream | public static void copyStream(final InputStream aInStream, final OutputStream aOutStream) throws IOException {
final BufferedOutputStream outStream = new BufferedOutputStream(aOutStream);
final BufferedInputStream inStream = new BufferedInputStream(aInStream);
final ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
final byte[] buffer = new byte[1024];
int bytesRead = 0;
while (true) {
bytesRead = inStream.read(buffer);
if (bytesRead == -1) {
break;
}
byteStream.write(buffer, 0, bytesRead);
}
outStream.write(byteStream.toByteArray());
outStream.flush();
} | java | public static void copyStream(final InputStream aInStream, final OutputStream aOutStream) throws IOException {
final BufferedOutputStream outStream = new BufferedOutputStream(aOutStream);
final BufferedInputStream inStream = new BufferedInputStream(aInStream);
final ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
final byte[] buffer = new byte[1024];
int bytesRead = 0;
while (true) {
bytesRead = inStream.read(buffer);
if (bytesRead == -1) {
break;
}
byteStream.write(buffer, 0, bytesRead);
}
outStream.write(byteStream.toByteArray());
outStream.flush();
} | [
"public",
"static",
"void",
"copyStream",
"(",
"final",
"InputStream",
"aInStream",
",",
"final",
"OutputStream",
"aOutStream",
")",
"throws",
"IOException",
"{",
"final",
"BufferedOutputStream",
"outStream",
"=",
"new",
"BufferedOutputStream",
"(",
"aOutStream",
")",... | Writes from an input stream to an output stream; you're responsible for closing the <code>InputStream</code>
and <code>OutputStream</code>.
@param aInStream The stream from which to read
@param aOutStream The stream from which to write
@throws IOException If there is trouble reading or writing | [
"Writes",
"from",
"an",
"input",
"stream",
"to",
"an",
"output",
"stream",
";",
"you",
"re",
"responsible",
"for",
"closing",
"the",
"<code",
">",
"InputStream<",
"/",
"code",
">",
"and",
"<code",
">",
"OutputStream<",
"/",
"code",
">",
"."
] | train | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/IOUtils.java#L147-L166 |
app55/app55-java | src/support/java/com/googlecode/openbeans/Beans.java | Beans.isInstanceOf | public static boolean isInstanceOf(Object bean, Class<?> targetType)
{
if (bean == null)
{
throw new NullPointerException(Messages.getString("beans.1D")); //$NON-NLS-1$
}
return targetType == null ? false : targetType.isInstance(bean);
} | java | public static boolean isInstanceOf(Object bean, Class<?> targetType)
{
if (bean == null)
{
throw new NullPointerException(Messages.getString("beans.1D")); //$NON-NLS-1$
}
return targetType == null ? false : targetType.isInstance(bean);
} | [
"public",
"static",
"boolean",
"isInstanceOf",
"(",
"Object",
"bean",
",",
"Class",
"<",
"?",
">",
"targetType",
")",
"{",
"if",
"(",
"bean",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"Messages",
".",
"getString",
"(",
"\"beans.1... | Determine if the the specified bean object can be viewed as the specified type.
@param bean
the specified bean object.
@param targetType
the specifed view type.
@return true if the specified bean object can be viewed as the specified type; otherwise, return false; | [
"Determine",
"if",
"the",
"the",
"specified",
"bean",
"object",
"can",
"be",
"viewed",
"as",
"the",
"specified",
"type",
"."
] | train | https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/Beans.java#L241-L249 |
nohana/Amalgam | amalgam/src/main/java/com/amalgam/app/DialogFragmentUtils.java | DialogFragmentUtils.supportDismissOnLoaderCallback | public static void supportDismissOnLoaderCallback(final android.support.v4.app.FragmentManager manager, final String tag) {
supportDismissOnLoaderCallback(HandlerUtils.getMainHandler(), manager, tag);
} | java | public static void supportDismissOnLoaderCallback(final android.support.v4.app.FragmentManager manager, final String tag) {
supportDismissOnLoaderCallback(HandlerUtils.getMainHandler(), manager, tag);
} | [
"public",
"static",
"void",
"supportDismissOnLoaderCallback",
"(",
"final",
"android",
".",
"support",
".",
"v4",
".",
"app",
".",
"FragmentManager",
"manager",
",",
"final",
"String",
"tag",
")",
"{",
"supportDismissOnLoaderCallback",
"(",
"HandlerUtils",
".",
"g... | Dismiss {@link android.support.v4.app.DialogFragment} for the tag on the loader callbacks.
@param manager the manager.
@param tag the tag string that is related to the {@link android.support.v4.app.DialogFragment}. | [
"Dismiss",
"{"
] | train | https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/app/DialogFragmentUtils.java#L93-L95 |
geomajas/geomajas-project-client-gwt2 | common-gwt/command/src/main/java/org/geomajas/gwt/client/util/StyleUtil.java | StyleUtil.createPolygonSymbolizer | public static PolygonSymbolizerInfo createPolygonSymbolizer(FillInfo fillInfo, StrokeInfo strokeInfo) {
PolygonSymbolizerInfo symbolizerInfo = new PolygonSymbolizerInfo();
symbolizerInfo.setFill(fillInfo);
symbolizerInfo.setStroke(strokeInfo);
return symbolizerInfo;
} | java | public static PolygonSymbolizerInfo createPolygonSymbolizer(FillInfo fillInfo, StrokeInfo strokeInfo) {
PolygonSymbolizerInfo symbolizerInfo = new PolygonSymbolizerInfo();
symbolizerInfo.setFill(fillInfo);
symbolizerInfo.setStroke(strokeInfo);
return symbolizerInfo;
} | [
"public",
"static",
"PolygonSymbolizerInfo",
"createPolygonSymbolizer",
"(",
"FillInfo",
"fillInfo",
",",
"StrokeInfo",
"strokeInfo",
")",
"{",
"PolygonSymbolizerInfo",
"symbolizerInfo",
"=",
"new",
"PolygonSymbolizerInfo",
"(",
")",
";",
"symbolizerInfo",
".",
"setFill",... | Creates a polygon symbolizer with the specified fill and stroke.
@param fillInfo the fill
@param strokeInfo the stroke
@return the symbolizer | [
"Creates",
"a",
"polygon",
"symbolizer",
"with",
"the",
"specified",
"fill",
"and",
"stroke",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/common-gwt/command/src/main/java/org/geomajas/gwt/client/util/StyleUtil.java#L173-L178 |
versionone/VersionOne.SDK.Java.ObjectModel | src/main/java/com/versionone/om/V1InstanceCreator.java | V1InstanceCreator.regressionPlan | public RegressionPlan regressionPlan(String name, Project project, Map<String, Object> attributes) {
RegressionPlan regressionPlan = new RegressionPlan(instance);
regressionPlan.setName(name);
regressionPlan.setProject(project);
addAttributes(regressionPlan, attributes);
regressionPlan.save();
return regressionPlan;
} | java | public RegressionPlan regressionPlan(String name, Project project, Map<String, Object> attributes) {
RegressionPlan regressionPlan = new RegressionPlan(instance);
regressionPlan.setName(name);
regressionPlan.setProject(project);
addAttributes(regressionPlan, attributes);
regressionPlan.save();
return regressionPlan;
} | [
"public",
"RegressionPlan",
"regressionPlan",
"(",
"String",
"name",
",",
"Project",
"project",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"attributes",
")",
"{",
"RegressionPlan",
"regressionPlan",
"=",
"new",
"RegressionPlan",
"(",
"instance",
")",
";",
... | Creates a new Regression Plan with title and project.
@param name Title of the plan.
@param project Project to assign.
@param attributes Additional attributes for initialization Regression Plan.
@return A newly minted Regression Plan that exists in the VersionOne system. | [
"Creates",
"a",
"new",
"Regression",
"Plan",
"with",
"title",
"and",
"project",
"."
] | train | https://github.com/versionone/VersionOne.SDK.Java.ObjectModel/blob/59d35b67c849299631bca45ee94143237eb2ae1a/src/main/java/com/versionone/om/V1InstanceCreator.java#L1154-L1163 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/utils/BtcFormat.java | BtcFormat.getInstance | public static BtcFormat getInstance(int scale, Locale locale, int minDecimals, List<Integer> groups) {
return new BtcFixedFormat(locale, scale, minDecimals, groups);
} | java | public static BtcFormat getInstance(int scale, Locale locale, int minDecimals, List<Integer> groups) {
return new BtcFixedFormat(locale, scale, minDecimals, groups);
} | [
"public",
"static",
"BtcFormat",
"getInstance",
"(",
"int",
"scale",
",",
"Locale",
"locale",
",",
"int",
"minDecimals",
",",
"List",
"<",
"Integer",
">",
"groups",
")",
"{",
"return",
"new",
"BtcFixedFormat",
"(",
"locale",
",",
"scale",
",",
"minDecimals",... | Return a new fixed-denomination formatter for the given locale, with the specified
fractional decimal placing. The first argument specifies the denomination as the size
of the shift from coin-denomination in increasingly-precise decimal places. The third
parameter is the minimum number of fractional decimal places to use. The third argument
specifies the minimum number of fractional decimal places in formatted numbers. The
last argument is a {@code List} of {@link Integer} values, each of which
specifies the size of an additional group of fractional decimal places to use as
necessary to avoid rounding, down to a maximum precision of satoshis. | [
"Return",
"a",
"new",
"fixed",
"-",
"denomination",
"formatter",
"for",
"the",
"given",
"locale",
"with",
"the",
"specified",
"fractional",
"decimal",
"placing",
".",
"The",
"first",
"argument",
"specifies",
"the",
"denomination",
"as",
"the",
"size",
"of",
"t... | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/utils/BtcFormat.java#L1112-L1114 |
prestodb/presto | presto-main/src/main/java/com/facebook/presto/connector/system/SystemConnectorSessionUtil.java | SystemConnectorSessionUtil.toSession | public static Session toSession(ConnectorTransactionHandle transactionHandle, ConnectorSession session)
{
TransactionId transactionId = ((GlobalSystemTransactionHandle) transactionHandle).getTransactionId();
ConnectorIdentity connectorIdentity = session.getIdentity();
Identity identity = new Identity(connectorIdentity.getUser(), connectorIdentity.getPrincipal());
return Session.builder(new SessionPropertyManager(SYSTEM_SESSION_PROPERTIES))
.setQueryId(new QueryId(session.getQueryId()))
.setTransactionId(transactionId)
.setCatalog("catalog")
.setSchema("schema")
.setPath(new SqlPath(Optional.of("path")))
.setIdentity(identity)
.setTimeZoneKey(session.getTimeZoneKey())
.setLocale(session.getLocale())
.setStartTime(session.getStartTime())
.build();
} | java | public static Session toSession(ConnectorTransactionHandle transactionHandle, ConnectorSession session)
{
TransactionId transactionId = ((GlobalSystemTransactionHandle) transactionHandle).getTransactionId();
ConnectorIdentity connectorIdentity = session.getIdentity();
Identity identity = new Identity(connectorIdentity.getUser(), connectorIdentity.getPrincipal());
return Session.builder(new SessionPropertyManager(SYSTEM_SESSION_PROPERTIES))
.setQueryId(new QueryId(session.getQueryId()))
.setTransactionId(transactionId)
.setCatalog("catalog")
.setSchema("schema")
.setPath(new SqlPath(Optional.of("path")))
.setIdentity(identity)
.setTimeZoneKey(session.getTimeZoneKey())
.setLocale(session.getLocale())
.setStartTime(session.getStartTime())
.build();
} | [
"public",
"static",
"Session",
"toSession",
"(",
"ConnectorTransactionHandle",
"transactionHandle",
",",
"ConnectorSession",
"session",
")",
"{",
"TransactionId",
"transactionId",
"=",
"(",
"(",
"GlobalSystemTransactionHandle",
")",
"transactionHandle",
")",
".",
"getTran... | this does not preserve any connector properties (for the system connector) | [
"this",
"does",
"not",
"preserve",
"any",
"connector",
"properties",
"(",
"for",
"the",
"system",
"connector",
")"
] | train | https://github.com/prestodb/presto/blob/89de5e379d8f85e139d292b0add8c537a2a01a88/presto-main/src/main/java/com/facebook/presto/connector/system/SystemConnectorSessionUtil.java#L36-L52 |
networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.initMapDefinedHandler | private static void initMapDefinedHandler(Map<String, Object> handler) {
// If the handler is a map, the keys are the class name, values are the
// parameters.
for (Map.Entry<String, Object> entry : handler.entrySet()) {
Tuple<String, Class> namedClass = splitClassAndName(entry.getKey());
// If the values in the config are a map, construct the object using named
// parameters.
if (entry.getValue() instanceof Map) {
HttpHandler httpHandler;
try {
httpHandler = (HttpHandler) ServiceUtil.constructByNamedParams(namedClass.second,
(Map) entry.getValue());
} catch (Exception e) {
throw new RuntimeException(
"Could not construct a handler with values provided as a map: " + namedClass.second);
}
registerMiddlewareHandler(httpHandler);
handlers.put(namedClass.first, httpHandler);
handlerListById.put(namedClass.first, Collections.singletonList(httpHandler));
} else if (entry.getValue() instanceof List) {
// If the values in the config are a list, call the constructor of the handler
// with those fields.
HttpHandler httpHandler;
try {
httpHandler = (HttpHandler) ServiceUtil.constructByParameterizedConstructor(namedClass.second,
(List) entry.getValue());
} catch (Exception e) {
throw new RuntimeException(
"Could not construct a handler with values provided as a list: " + namedClass.second);
}
registerMiddlewareHandler(httpHandler);
handlers.put(namedClass.first, httpHandler);
handlerListById.put(namedClass.first, Collections.singletonList(httpHandler));
}
}
} | java | private static void initMapDefinedHandler(Map<String, Object> handler) {
// If the handler is a map, the keys are the class name, values are the
// parameters.
for (Map.Entry<String, Object> entry : handler.entrySet()) {
Tuple<String, Class> namedClass = splitClassAndName(entry.getKey());
// If the values in the config are a map, construct the object using named
// parameters.
if (entry.getValue() instanceof Map) {
HttpHandler httpHandler;
try {
httpHandler = (HttpHandler) ServiceUtil.constructByNamedParams(namedClass.second,
(Map) entry.getValue());
} catch (Exception e) {
throw new RuntimeException(
"Could not construct a handler with values provided as a map: " + namedClass.second);
}
registerMiddlewareHandler(httpHandler);
handlers.put(namedClass.first, httpHandler);
handlerListById.put(namedClass.first, Collections.singletonList(httpHandler));
} else if (entry.getValue() instanceof List) {
// If the values in the config are a list, call the constructor of the handler
// with those fields.
HttpHandler httpHandler;
try {
httpHandler = (HttpHandler) ServiceUtil.constructByParameterizedConstructor(namedClass.second,
(List) entry.getValue());
} catch (Exception e) {
throw new RuntimeException(
"Could not construct a handler with values provided as a list: " + namedClass.second);
}
registerMiddlewareHandler(httpHandler);
handlers.put(namedClass.first, httpHandler);
handlerListById.put(namedClass.first, Collections.singletonList(httpHandler));
}
}
} | [
"private",
"static",
"void",
"initMapDefinedHandler",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"handler",
")",
"{",
"// If the handler is a map, the keys are the class name, values are the",
"// parameters.",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
... | Helper method for generating the instance of a handler from its map
definition in config. Ie. No mapped values for setters, or list of
constructor fields.
@param handler | [
"Helper",
"method",
"for",
"generating",
"the",
"instance",
"of",
"a",
"handler",
"from",
"its",
"map",
"definition",
"in",
"config",
".",
"Ie",
".",
"No",
"mapped",
"values",
"for",
"setters",
"or",
"list",
"of",
"constructor",
"fields",
"."
] | train | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L444-L481 |
redlink-gmbh/redlink-java-sdk | src/main/java/io/redlink/sdk/impl/analysis/model/Entity.java | Entity.getValue | public String getValue(String property, String language) {
Multimap<Optional<String>, String> values = properties.get(property);
if (values == null) {
return null;
}
Iterator<String> it = values.get(Optional.of(language)).iterator();
return it.hasNext() ? it.next() : null;
} | java | public String getValue(String property, String language) {
Multimap<Optional<String>, String> values = properties.get(property);
if (values == null) {
return null;
}
Iterator<String> it = values.get(Optional.of(language)).iterator();
return it.hasNext() ? it.next() : null;
} | [
"public",
"String",
"getValue",
"(",
"String",
"property",
",",
"String",
"language",
")",
"{",
"Multimap",
"<",
"Optional",
"<",
"String",
">",
",",
"String",
">",
"values",
"=",
"properties",
".",
"get",
"(",
"property",
")",
";",
"if",
"(",
"values",
... | Get a literal value for a property and language passed by parameters
@param property Property URI
@param language Language code
@return | [
"Get",
"a",
"literal",
"value",
"for",
"a",
"property",
"and",
"language",
"passed",
"by",
"parameters"
] | train | https://github.com/redlink-gmbh/redlink-java-sdk/blob/c412ff11bd80da52ade09f2483ab29cdbff5a28a/src/main/java/io/redlink/sdk/impl/analysis/model/Entity.java#L153-L162 |
belaban/JGroups | src/org/jgroups/util/RingBuffer.java | RingBuffer.waitForMessages | public int waitForMessages(int num_spins, final BiConsumer<Integer,Integer> wait_strategy) throws InterruptedException {
// try spinning first (experimental)
for(int i=0; i < num_spins && count == 0; i++) {
if(wait_strategy != null)
wait_strategy.accept(i, num_spins);
else
Thread.yield();
}
if(count == 0)
_waitForMessages();
return count; // whatever is the last count; could have been updated since lock release
} | java | public int waitForMessages(int num_spins, final BiConsumer<Integer,Integer> wait_strategy) throws InterruptedException {
// try spinning first (experimental)
for(int i=0; i < num_spins && count == 0; i++) {
if(wait_strategy != null)
wait_strategy.accept(i, num_spins);
else
Thread.yield();
}
if(count == 0)
_waitForMessages();
return count; // whatever is the last count; could have been updated since lock release
} | [
"public",
"int",
"waitForMessages",
"(",
"int",
"num_spins",
",",
"final",
"BiConsumer",
"<",
"Integer",
",",
"Integer",
">",
"wait_strategy",
")",
"throws",
"InterruptedException",
"{",
"// try spinning first (experimental)",
"for",
"(",
"int",
"i",
"=",
"0",
";"... | Blocks until messages are available
@param num_spins the number of times we should spin before acquiring a lock
@param wait_strategy the strategy used to spin. The first parameter is the iteration count and the second
parameter is the max number of spins | [
"Blocks",
"until",
"messages",
"are",
"available"
] | train | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/RingBuffer.java#L274-L285 |
liyiorg/weixin-popular | src/main/java/weixin/popular/api/SemanticAPI.java | SemanticAPI.semproxySearch | public static SemproxySearchResult semproxySearch(String accessToken, SemproxySearch semproxySearch) {
return semproxySearch(accessToken, JsonUtil.toJSONString(semproxySearch));
} | java | public static SemproxySearchResult semproxySearch(String accessToken, SemproxySearch semproxySearch) {
return semproxySearch(accessToken, JsonUtil.toJSONString(semproxySearch));
} | [
"public",
"static",
"SemproxySearchResult",
"semproxySearch",
"(",
"String",
"accessToken",
",",
"SemproxySearch",
"semproxySearch",
")",
"{",
"return",
"semproxySearch",
"(",
"accessToken",
",",
"JsonUtil",
".",
"toJSONString",
"(",
"semproxySearch",
")",
")",
";",
... | 语义理解
@param accessToken access_token
@param semproxySearch semproxySearch
@return SemproxySearchResult
@since 2.8.22 | [
"语义理解"
] | train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/api/SemanticAPI.java#L50-L52 |
networknt/light-4j | dump/src/main/java/com/networknt/dump/CookiesDumper.java | CookiesDumper.dumpRequest | @Override
public void dumpRequest(Map<String, Object> result) {
Map<String, Cookie> cookiesMap = exchange.getRequestCookies();
dumpCookies(cookiesMap, "requestCookies");
this.putDumpInfoTo(result);
} | java | @Override
public void dumpRequest(Map<String, Object> result) {
Map<String, Cookie> cookiesMap = exchange.getRequestCookies();
dumpCookies(cookiesMap, "requestCookies");
this.putDumpInfoTo(result);
} | [
"@",
"Override",
"public",
"void",
"dumpRequest",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
")",
"{",
"Map",
"<",
"String",
",",
"Cookie",
">",
"cookiesMap",
"=",
"exchange",
".",
"getRequestCookies",
"(",
")",
";",
"dumpCookies",
"(",
"co... | impl of dumping request cookies to result
@param result A map you want to put dump information to | [
"impl",
"of",
"dumping",
"request",
"cookies",
"to",
"result"
] | train | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/dump/src/main/java/com/networknt/dump/CookiesDumper.java#L38-L44 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/util/BaseApplication.java | BaseApplication.getDatabase | public Database getDatabase(String strDBName, int iDatabaseType, Map<String, Object> properties)
{
return m_databaseCollection.getDatabase(strDBName, iDatabaseType, properties);
} | java | public Database getDatabase(String strDBName, int iDatabaseType, Map<String, Object> properties)
{
return m_databaseCollection.getDatabase(strDBName, iDatabaseType, properties);
} | [
"public",
"Database",
"getDatabase",
"(",
"String",
"strDBName",
",",
"int",
"iDatabaseType",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
")",
"{",
"return",
"m_databaseCollection",
".",
"getDatabase",
"(",
"strDBName",
",",
"iDatabaseType",
","... | Given the name, either get the open database, or open a new one.
@param strDBName The name of the database.
@param iDatabaseType The type of database/table.
@return The database (new or current). | [
"Given",
"the",
"name",
"either",
"get",
"the",
"open",
"database",
"or",
"open",
"a",
"new",
"one",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/util/BaseApplication.java#L211-L214 |
igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java | OmemoService.refreshDeviceList | OmemoCachedDeviceList refreshDeviceList(XMPPConnection connection, OmemoDevice userDevice, BareJid contact)
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
// refreshOmemoDeviceList;
OmemoDeviceListElement publishedList;
try {
publishedList = fetchDeviceList(connection, contact);
} catch (PubSubException.NotAPubSubNodeException e) {
LOGGER.log(Level.WARNING, "Error refreshing deviceList: ", e);
publishedList = null;
}
if (publishedList == null) {
publishedList = new OmemoDeviceListElement_VAxolotl(Collections.<Integer>emptySet());
}
return getOmemoStoreBackend().mergeCachedDeviceList(
userDevice, contact, publishedList);
} | java | OmemoCachedDeviceList refreshDeviceList(XMPPConnection connection, OmemoDevice userDevice, BareJid contact)
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
// refreshOmemoDeviceList;
OmemoDeviceListElement publishedList;
try {
publishedList = fetchDeviceList(connection, contact);
} catch (PubSubException.NotAPubSubNodeException e) {
LOGGER.log(Level.WARNING, "Error refreshing deviceList: ", e);
publishedList = null;
}
if (publishedList == null) {
publishedList = new OmemoDeviceListElement_VAxolotl(Collections.<Integer>emptySet());
}
return getOmemoStoreBackend().mergeCachedDeviceList(
userDevice, contact, publishedList);
} | [
"OmemoCachedDeviceList",
"refreshDeviceList",
"(",
"XMPPConnection",
"connection",
",",
"OmemoDevice",
"userDevice",
",",
"BareJid",
"contact",
")",
"throws",
"InterruptedException",
",",
"PubSubException",
".",
"NotALeafNodeException",
",",
"XMPPException",
".",
"XMPPError... | Refresh and merge device list of contact.
@param connection authenticated XMPP connection
@param userDevice our OmemoDevice
@param contact contact we want to fetch the deviceList from
@return cached device list after refresh.
@throws InterruptedException
@throws PubSubException.NotALeafNodeException
@throws XMPPException.XMPPErrorException
@throws SmackException.NotConnectedException
@throws SmackException.NoResponseException | [
"Refresh",
"and",
"merge",
"device",
"list",
"of",
"contact",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L729-L746 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/ui/contextmenu/CmsShowWorkplace.java | CmsShowWorkplace.getContextMenuCommand | public static I_CmsContextMenuCommand getContextMenuCommand() {
return new I_CmsContextMenuCommand() {
public void execute(CmsUUID structureId, I_CmsContextMenuHandler handler, CmsContextMenuEntryBean bean) {
openWorkplace(structureId, false);
}
public A_CmsContextMenuItem getItemWidget(
CmsUUID structureId,
I_CmsContextMenuHandler handler,
CmsContextMenuEntryBean bean) {
return null;
}
public boolean hasItemWidget() {
return false;
}
};
} | java | public static I_CmsContextMenuCommand getContextMenuCommand() {
return new I_CmsContextMenuCommand() {
public void execute(CmsUUID structureId, I_CmsContextMenuHandler handler, CmsContextMenuEntryBean bean) {
openWorkplace(structureId, false);
}
public A_CmsContextMenuItem getItemWidget(
CmsUUID structureId,
I_CmsContextMenuHandler handler,
CmsContextMenuEntryBean bean) {
return null;
}
public boolean hasItemWidget() {
return false;
}
};
} | [
"public",
"static",
"I_CmsContextMenuCommand",
"getContextMenuCommand",
"(",
")",
"{",
"return",
"new",
"I_CmsContextMenuCommand",
"(",
")",
"{",
"public",
"void",
"execute",
"(",
"CmsUUID",
"structureId",
",",
"I_CmsContextMenuHandler",
"handler",
",",
"CmsContextMenuE... | Returns the context menu command according to
{@link org.opencms.gwt.client.ui.contextmenu.I_CmsHasContextMenuCommand}.<p>
@return the context menu command | [
"Returns",
"the",
"context",
"menu",
"command",
"according",
"to",
"{",
"@link",
"org",
".",
"opencms",
".",
"gwt",
".",
"client",
".",
"ui",
".",
"contextmenu",
".",
"I_CmsHasContextMenuCommand",
"}",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/contextmenu/CmsShowWorkplace.java#L58-L80 |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/internal/security/ldap/LdapUtils.java | LdapUtils.concatDn | public static Dn concatDn(String rdnAttribute, String rdnValue, Dn basedn) {
try {
Rdn rdn = new Rdn(rdnAttribute, rdnValue);
return basedn.add(rdn);
} catch (LdapInvalidDnException e) {
throw new LdapRuntimeException(e);
}
} | java | public static Dn concatDn(String rdnAttribute, String rdnValue, Dn basedn) {
try {
Rdn rdn = new Rdn(rdnAttribute, rdnValue);
return basedn.add(rdn);
} catch (LdapInvalidDnException e) {
throw new LdapRuntimeException(e);
}
} | [
"public",
"static",
"Dn",
"concatDn",
"(",
"String",
"rdnAttribute",
",",
"String",
"rdnValue",
",",
"Dn",
"basedn",
")",
"{",
"try",
"{",
"Rdn",
"rdn",
"=",
"new",
"Rdn",
"(",
"rdnAttribute",
",",
"rdnValue",
")",
";",
"return",
"basedn",
".",
"add",
... | Returns a {@link Dn} consisting of baseDn extended by an Rdn of type rdnAttribute and value rdnValue. | [
"Returns",
"a",
"{"
] | train | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/internal/security/ldap/LdapUtils.java#L42-L49 |
brianwhu/xillium | base/src/main/java/org/xillium/base/beans/Beans.java | Beans.valueOf | @Deprecated
public static <T> T valueOf(Class<T> type, String value) {
return valueOf(type, value, null);
} | java | @Deprecated
public static <T> T valueOf(Class<T> type, String value) {
return valueOf(type, value, null);
} | [
"@",
"Deprecated",
"public",
"static",
"<",
"T",
">",
"T",
"valueOf",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"String",
"value",
")",
"{",
"return",
"valueOf",
"(",
"type",
",",
"value",
",",
"null",
")",
";",
"}"
] | Converts a String representation into a value of a given type. This method calls
{@code valueOf(type, value, null)}.
@param <T> the target class
@param type the target class
@param value the string to convert
@return the converted value
@throws IllegalArgumentException if all conversion attempts fail | [
"Converts",
"a",
"String",
"representation",
"into",
"a",
"value",
"of",
"a",
"given",
"type",
".",
"This",
"method",
"calls",
"{",
"@code",
"valueOf",
"(",
"type",
"value",
"null",
")",
"}",
"."
] | train | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/beans/Beans.java#L514-L517 |
alkacon/opencms-core | src/org/opencms/gwt/CmsTemplateFinder.java | CmsTemplateFinder.getTemplateBean | private CmsClientTemplateBean getTemplateBean(CmsObject cms, CmsResource resource) throws CmsException {
CmsProperty titleProp = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_TITLE, false);
CmsProperty descProp = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_DESCRIPTION, false);
CmsProperty imageProp = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_TEMPLATE_IMAGE, false);
CmsProperty selectValueProp = cms.readPropertyObject(
resource,
CmsPropertyDefinition.PROPERTY_TEMPLATE_PROVIDER,
false);
String sitePath = cms.getSitePath(resource);
String templateValue = sitePath;
if (!selectValueProp.isNullProperty() && !CmsStringUtil.isEmptyOrWhitespaceOnly(selectValueProp.getValue())) {
String selectValue = selectValueProp.getValue();
CmsMacroResolver resolver = new CmsMacroResolver();
resolver.addMacro(MACRO_TEMPLATEPATH, sitePath);
templateValue = resolver.resolveMacros(selectValue);
}
return new CmsClientTemplateBean(
titleProp.getValue(),
descProp.getValue(),
templateValue,
imageProp.getValue());
} | java | private CmsClientTemplateBean getTemplateBean(CmsObject cms, CmsResource resource) throws CmsException {
CmsProperty titleProp = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_TITLE, false);
CmsProperty descProp = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_DESCRIPTION, false);
CmsProperty imageProp = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_TEMPLATE_IMAGE, false);
CmsProperty selectValueProp = cms.readPropertyObject(
resource,
CmsPropertyDefinition.PROPERTY_TEMPLATE_PROVIDER,
false);
String sitePath = cms.getSitePath(resource);
String templateValue = sitePath;
if (!selectValueProp.isNullProperty() && !CmsStringUtil.isEmptyOrWhitespaceOnly(selectValueProp.getValue())) {
String selectValue = selectValueProp.getValue();
CmsMacroResolver resolver = new CmsMacroResolver();
resolver.addMacro(MACRO_TEMPLATEPATH, sitePath);
templateValue = resolver.resolveMacros(selectValue);
}
return new CmsClientTemplateBean(
titleProp.getValue(),
descProp.getValue(),
templateValue,
imageProp.getValue());
} | [
"private",
"CmsClientTemplateBean",
"getTemplateBean",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"resource",
")",
"throws",
"CmsException",
"{",
"CmsProperty",
"titleProp",
"=",
"cms",
".",
"readPropertyObject",
"(",
"resource",
",",
"CmsPropertyDefinition",
".",
"... | Returns a bean representing the given template resource.<p>
@param cms the cms context to use for VFS operations
@param resource the template resource
@return bean representing the given template resource
@throws CmsException if something goes wrong | [
"Returns",
"a",
"bean",
"representing",
"the",
"given",
"template",
"resource",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/gwt/CmsTemplateFinder.java#L126-L148 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/MathUtil.java | MathUtil.ipowi | public static int ipowi(int x, int p) {
if(p <= 2) {
return (int) FastMath.powFast(x, p);
}
int tmp = x, ret = (p & 1) == 1 ? x : 1;
while(true) {
tmp *= tmp;
p >>= 1;
if(p == 1) {
return ret * tmp;
}
if((p & 1) != 0) {
ret *= tmp;
}
}
} | java | public static int ipowi(int x, int p) {
if(p <= 2) {
return (int) FastMath.powFast(x, p);
}
int tmp = x, ret = (p & 1) == 1 ? x : 1;
while(true) {
tmp *= tmp;
p >>= 1;
if(p == 1) {
return ret * tmp;
}
if((p & 1) != 0) {
ret *= tmp;
}
}
} | [
"public",
"static",
"int",
"ipowi",
"(",
"int",
"x",
",",
"int",
"p",
")",
"{",
"if",
"(",
"p",
"<=",
"2",
")",
"{",
"return",
"(",
"int",
")",
"FastMath",
".",
"powFast",
"(",
"x",
",",
"p",
")",
";",
"}",
"int",
"tmp",
"=",
"x",
",",
"ret... | Fast loop for computing {@code pow(x, p)}
for {@code p >= 0} integer and x integer.
@param x Base
@param p Exponent
@return {@code pow(x, p)} | [
"Fast",
"loop",
"for",
"computing",
"{",
"@code",
"pow",
"(",
"x",
"p",
")",
"}",
"for",
"{",
"@code",
"p",
">",
"=",
"0",
"}",
"integer",
"and",
"x",
"integer",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/MathUtil.java#L567-L582 |
netty/netty | codec-http2/src/main/java/io/netty/handler/codec/http2/Http2CodecUtil.java | Http2CodecUtil.toByteBuf | public static ByteBuf toByteBuf(ChannelHandlerContext ctx, Throwable cause) {
if (cause == null || cause.getMessage() == null) {
return Unpooled.EMPTY_BUFFER;
}
return ByteBufUtil.writeUtf8(ctx.alloc(), cause.getMessage());
} | java | public static ByteBuf toByteBuf(ChannelHandlerContext ctx, Throwable cause) {
if (cause == null || cause.getMessage() == null) {
return Unpooled.EMPTY_BUFFER;
}
return ByteBufUtil.writeUtf8(ctx.alloc(), cause.getMessage());
} | [
"public",
"static",
"ByteBuf",
"toByteBuf",
"(",
"ChannelHandlerContext",
"ctx",
",",
"Throwable",
"cause",
")",
"{",
"if",
"(",
"cause",
"==",
"null",
"||",
"cause",
".",
"getMessage",
"(",
")",
"==",
"null",
")",
"{",
"return",
"Unpooled",
".",
"EMPTY_BU... | Creates a buffer containing the error message from the given exception. If the cause is
{@code null} returns an empty buffer. | [
"Creates",
"a",
"buffer",
"containing",
"the",
"error",
"message",
"from",
"the",
"given",
"exception",
".",
"If",
"the",
"cause",
"is",
"{"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2CodecUtil.java#L187-L193 |
Alluxio/alluxio | shell/src/main/java/alluxio/cli/fsadmin/FileSystemAdminShellUtils.java | FileSystemAdminShellUtils.checkMasterClientService | public static void checkMasterClientService(AlluxioConfiguration alluxioConf) throws IOException {
try (CloseableResource<FileSystemMasterClient> client =
FileSystemContext.create(ClientContext.create(alluxioConf))
.acquireMasterClientResource()) {
InetSocketAddress address = client.get().getAddress();
List<InetSocketAddress> addresses = Arrays.asList(address);
MasterInquireClient inquireClient = new PollingMasterInquireClient(addresses, () ->
new ExponentialBackoffRetry(50, 100, 2), alluxioConf);
inquireClient.getPrimaryRpcAddress();
} catch (UnavailableException e) {
throw new IOException("Cannot connect to Alluxio leader master.");
}
} | java | public static void checkMasterClientService(AlluxioConfiguration alluxioConf) throws IOException {
try (CloseableResource<FileSystemMasterClient> client =
FileSystemContext.create(ClientContext.create(alluxioConf))
.acquireMasterClientResource()) {
InetSocketAddress address = client.get().getAddress();
List<InetSocketAddress> addresses = Arrays.asList(address);
MasterInquireClient inquireClient = new PollingMasterInquireClient(addresses, () ->
new ExponentialBackoffRetry(50, 100, 2), alluxioConf);
inquireClient.getPrimaryRpcAddress();
} catch (UnavailableException e) {
throw new IOException("Cannot connect to Alluxio leader master.");
}
} | [
"public",
"static",
"void",
"checkMasterClientService",
"(",
"AlluxioConfiguration",
"alluxioConf",
")",
"throws",
"IOException",
"{",
"try",
"(",
"CloseableResource",
"<",
"FileSystemMasterClient",
">",
"client",
"=",
"FileSystemContext",
".",
"create",
"(",
"ClientCon... | Checks if the master client service is available.
Throws an exception if fails to determine that the master client service is running.
@param alluxioConf Alluxio configuration | [
"Checks",
"if",
"the",
"master",
"client",
"service",
"is",
"available",
".",
"Throws",
"an",
"exception",
"if",
"fails",
"to",
"determine",
"that",
"the",
"master",
"client",
"service",
"is",
"running",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/FileSystemAdminShellUtils.java#L58-L71 |
spring-projects/spring-mobile | spring-mobile-device/src/main/java/org/springframework/mobile/device/switcher/StandardSiteSwitcherHandlerFactory.java | StandardSiteSwitcherHandlerFactory.urlPath | public static SiteSwitcherHandler urlPath(String mobilePath, String tabletPath, String rootPath) {
return new StandardSiteSwitcherHandler(
new NormalSitePathUrlFactory(mobilePath, tabletPath, rootPath),
new MobileSitePathUrlFactory(mobilePath, tabletPath, rootPath),
new TabletSitePathUrlFactory(tabletPath, mobilePath, rootPath),
new StandardSitePreferenceHandler(new CookieSitePreferenceRepository()),
null);
} | java | public static SiteSwitcherHandler urlPath(String mobilePath, String tabletPath, String rootPath) {
return new StandardSiteSwitcherHandler(
new NormalSitePathUrlFactory(mobilePath, tabletPath, rootPath),
new MobileSitePathUrlFactory(mobilePath, tabletPath, rootPath),
new TabletSitePathUrlFactory(tabletPath, mobilePath, rootPath),
new StandardSitePreferenceHandler(new CookieSitePreferenceRepository()),
null);
} | [
"public",
"static",
"SiteSwitcherHandler",
"urlPath",
"(",
"String",
"mobilePath",
",",
"String",
"tabletPath",
",",
"String",
"rootPath",
")",
"{",
"return",
"new",
"StandardSiteSwitcherHandler",
"(",
"new",
"NormalSitePathUrlFactory",
"(",
"mobilePath",
",",
"tablet... | Creates a site switcher that redirects to a path on the current domain for normal site requests that either
originate from a mobile device or tablet device, or indicate a mobile or tablet site preference.
Allows you to configure a root path for an application. For example, if your app is running at <code>https://www.domain.com/myapp</code>,
then the root path is <code>/myapp</code>.
Uses a {@link CookieSitePreferenceRepository} that saves a cookie that is stored on the root path. | [
"Creates",
"a",
"site",
"switcher",
"that",
"redirects",
"to",
"a",
"path",
"on",
"the",
"current",
"domain",
"for",
"normal",
"site",
"requests",
"that",
"either",
"originate",
"from",
"a",
"mobile",
"device",
"or",
"tablet",
"device",
"or",
"indicate",
"a"... | train | https://github.com/spring-projects/spring-mobile/blob/a402cbcaf208e24288b957f44c9984bd6e8bf064/spring-mobile-device/src/main/java/org/springframework/mobile/device/switcher/StandardSiteSwitcherHandlerFactory.java#L163-L170 |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.addCustomPersonData | public static void addCustomPersonData(final String key, final String value) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
protected boolean execute(Conversation conversation) {
conversation.getPerson().getCustomData().put(key, trim(value));
return true;
}
}, "add custom person data");
} | java | public static void addCustomPersonData(final String key, final String value) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
protected boolean execute(Conversation conversation) {
conversation.getPerson().getCustomData().put(key, trim(value));
return true;
}
}, "add custom person data");
} | [
"public",
"static",
"void",
"addCustomPersonData",
"(",
"final",
"String",
"key",
",",
"final",
"String",
"value",
")",
"{",
"dispatchConversationTask",
"(",
"new",
"ConversationDispatchTask",
"(",
")",
"{",
"@",
"Override",
"protected",
"boolean",
"execute",
"(",... | Add a custom data String to the Person. Custom data will be sent to the server, is displayed
in the Conversation view, and can be used in Interaction targeting. Calls to this method are
idempotent.
@param key The key to store the data under.
@param value A String value. | [
"Add",
"a",
"custom",
"data",
"String",
"to",
"the",
"Person",
".",
"Custom",
"data",
"will",
"be",
"sent",
"to",
"the",
"server",
"is",
"displayed",
"in",
"the",
"Conversation",
"view",
"and",
"can",
"be",
"used",
"in",
"Interaction",
"targeting",
".",
... | train | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L323-L331 |
apache/flink | flink-core/src/main/java/org/apache/flink/configuration/Configuration.java | Configuration.getDouble | public double getDouble(String key, double defaultValue) {
Object o = getRawValue(key);
if (o == null) {
return defaultValue;
}
return convertToDouble(o, defaultValue);
} | java | public double getDouble(String key, double defaultValue) {
Object o = getRawValue(key);
if (o == null) {
return defaultValue;
}
return convertToDouble(o, defaultValue);
} | [
"public",
"double",
"getDouble",
"(",
"String",
"key",
",",
"double",
"defaultValue",
")",
"{",
"Object",
"o",
"=",
"getRawValue",
"(",
"key",
")",
";",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"return",
"convertToDoubl... | Returns the value associated with the given key as a double.
@param key
the key pointing to the associated value
@param defaultValue
the default value which is returned in case there is no value associated with the given key
@return the (default) value associated with the given key | [
"Returns",
"the",
"value",
"associated",
"with",
"the",
"given",
"key",
"as",
"a",
"double",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/configuration/Configuration.java#L500-L507 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java | ArrayUtil.find | public static int find(byte[] arra, int start, int limit, byte[] arrb) {
int k = start;
limit = limit - arrb.length + 1;
int value = arrb[0];
for (; k < limit; k++) {
if (arra[k] == value) {
if (arrb.length == 1) {
return k;
}
if (containsAt(arra, k, arrb)) {
return k;
}
}
}
return -1;
} | java | public static int find(byte[] arra, int start, int limit, byte[] arrb) {
int k = start;
limit = limit - arrb.length + 1;
int value = arrb[0];
for (; k < limit; k++) {
if (arra[k] == value) {
if (arrb.length == 1) {
return k;
}
if (containsAt(arra, k, arrb)) {
return k;
}
}
}
return -1;
} | [
"public",
"static",
"int",
"find",
"(",
"byte",
"[",
"]",
"arra",
",",
"int",
"start",
",",
"int",
"limit",
",",
"byte",
"[",
"]",
"arrb",
")",
"{",
"int",
"k",
"=",
"start",
";",
"limit",
"=",
"limit",
"-",
"arrb",
".",
"length",
"+",
"1",
";"... | Returns the index of the first occurence of arrb in arra. Or -1 if not found. | [
"Returns",
"the",
"index",
"of",
"the",
"first",
"occurence",
"of",
"arrb",
"in",
"arra",
".",
"Or",
"-",
"1",
"if",
"not",
"found",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L565-L586 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java | AppServiceEnvironmentsInner.listWebWorkerMetricDefinitionsWithServiceResponseAsync | public Observable<ServiceResponse<Page<ResourceMetricDefinitionInner>>> listWebWorkerMetricDefinitionsWithServiceResponseAsync(final String resourceGroupName, final String name, final String workerPoolName) {
return listWebWorkerMetricDefinitionsSinglePageAsync(resourceGroupName, name, workerPoolName)
.concatMap(new Func1<ServiceResponse<Page<ResourceMetricDefinitionInner>>, Observable<ServiceResponse<Page<ResourceMetricDefinitionInner>>>>() {
@Override
public Observable<ServiceResponse<Page<ResourceMetricDefinitionInner>>> call(ServiceResponse<Page<ResourceMetricDefinitionInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listWebWorkerMetricDefinitionsNextWithServiceResponseAsync(nextPageLink));
}
});
} | java | public Observable<ServiceResponse<Page<ResourceMetricDefinitionInner>>> listWebWorkerMetricDefinitionsWithServiceResponseAsync(final String resourceGroupName, final String name, final String workerPoolName) {
return listWebWorkerMetricDefinitionsSinglePageAsync(resourceGroupName, name, workerPoolName)
.concatMap(new Func1<ServiceResponse<Page<ResourceMetricDefinitionInner>>, Observable<ServiceResponse<Page<ResourceMetricDefinitionInner>>>>() {
@Override
public Observable<ServiceResponse<Page<ResourceMetricDefinitionInner>>> call(ServiceResponse<Page<ResourceMetricDefinitionInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listWebWorkerMetricDefinitionsNextWithServiceResponseAsync(nextPageLink));
}
});
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"ResourceMetricDefinitionInner",
">",
">",
">",
"listWebWorkerMetricDefinitionsWithServiceResponseAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"name",
",",
"final",
"String",... | Get metric definitions for a worker pool of an App Service Environment.
Get metric definitions for a worker pool of an App Service Environment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@param workerPoolName Name of the worker pool.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ResourceMetricDefinitionInner> object | [
"Get",
"metric",
"definitions",
"for",
"a",
"worker",
"pool",
"of",
"an",
"App",
"Service",
"Environment",
".",
"Get",
"metric",
"definitions",
"for",
"a",
"worker",
"pool",
"of",
"an",
"App",
"Service",
"Environment",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java#L5995-L6007 |
google/closure-compiler | src/com/google/javascript/jscomp/ValidityCheck.java | ValidityCheck.checkNormalization | private void checkNormalization(Node externs, Node root) {
// Verify nothing has inappropriately denormalize the AST.
CodeChangeHandler handler = new ForbiddenChange();
compiler.addChangeHandler(handler);
// TODO(johnlenz): Change these normalization checks Preconditions and
// Exceptions into Errors so that it is easier to find the root cause
// when there are cascading issues.
new PrepareAst(compiler, true).process(null, root);
if (compiler.getLifeCycleStage().isNormalized()) {
(new Normalize(compiler, true)).process(externs, root);
if (compiler.getLifeCycleStage().isNormalizedUnobfuscated()) {
boolean checkUserDeclarations = true;
CompilerPass pass = new Normalize.VerifyConstants(compiler, checkUserDeclarations);
pass.process(externs, root);
}
}
compiler.removeChangeHandler(handler);
} | java | private void checkNormalization(Node externs, Node root) {
// Verify nothing has inappropriately denormalize the AST.
CodeChangeHandler handler = new ForbiddenChange();
compiler.addChangeHandler(handler);
// TODO(johnlenz): Change these normalization checks Preconditions and
// Exceptions into Errors so that it is easier to find the root cause
// when there are cascading issues.
new PrepareAst(compiler, true).process(null, root);
if (compiler.getLifeCycleStage().isNormalized()) {
(new Normalize(compiler, true)).process(externs, root);
if (compiler.getLifeCycleStage().isNormalizedUnobfuscated()) {
boolean checkUserDeclarations = true;
CompilerPass pass = new Normalize.VerifyConstants(compiler, checkUserDeclarations);
pass.process(externs, root);
}
}
compiler.removeChangeHandler(handler);
} | [
"private",
"void",
"checkNormalization",
"(",
"Node",
"externs",
",",
"Node",
"root",
")",
"{",
"// Verify nothing has inappropriately denormalize the AST.",
"CodeChangeHandler",
"handler",
"=",
"new",
"ForbiddenChange",
"(",
")",
";",
"compiler",
".",
"addChangeHandler",... | Verifies that the normalization pass does nothing on an already-normalized tree. | [
"Verifies",
"that",
"the",
"normalization",
"pass",
"does",
"nothing",
"on",
"an",
"already",
"-",
"normalized",
"tree",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ValidityCheck.java#L80-L100 |
thymeleaf/thymeleaf | src/main/java/org/thymeleaf/util/TextUtils.java | TextUtils.endsWith | public static boolean endsWith(final boolean caseSensitive, final CharSequence text, final CharSequence suffix) {
if (text == null) {
throw new IllegalArgumentException("Text cannot be null");
}
if (suffix == null) {
throw new IllegalArgumentException("Suffix cannot be null");
}
if (text instanceof String && suffix instanceof String) {
return (caseSensitive ? ((String)text).endsWith((String)suffix) : endsWith(caseSensitive, text, 0, text.length(), suffix, 0, suffix.length()));
}
return endsWith(caseSensitive, text, 0, text.length(), suffix, 0, suffix.length());
} | java | public static boolean endsWith(final boolean caseSensitive, final CharSequence text, final CharSequence suffix) {
if (text == null) {
throw new IllegalArgumentException("Text cannot be null");
}
if (suffix == null) {
throw new IllegalArgumentException("Suffix cannot be null");
}
if (text instanceof String && suffix instanceof String) {
return (caseSensitive ? ((String)text).endsWith((String)suffix) : endsWith(caseSensitive, text, 0, text.length(), suffix, 0, suffix.length()));
}
return endsWith(caseSensitive, text, 0, text.length(), suffix, 0, suffix.length());
} | [
"public",
"static",
"boolean",
"endsWith",
"(",
"final",
"boolean",
"caseSensitive",
",",
"final",
"CharSequence",
"text",
",",
"final",
"CharSequence",
"suffix",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
... | <p>
Checks whether a text ends with a specified suffix.
</p>
@param caseSensitive whether the comparison must be done in a case-sensitive or case-insensitive way.
@param text the text to be checked for suffixes.
@param suffix the suffix to be searched.
@return whether the text ends with the suffix or not. | [
"<p",
">",
"Checks",
"whether",
"a",
"text",
"ends",
"with",
"a",
"specified",
"suffix",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/thymeleaf/thymeleaf/blob/2b0e6d6d7571fbe638904b5fd222fc9e77188879/src/main/java/org/thymeleaf/util/TextUtils.java#L680-L695 |
haraldk/TwelveMonkeys | sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/DebugUtil.java | DebugUtil.printDebug | public static void printDebug(final Enumeration pEnumeration, final String pMethodName) {
printDebug(pEnumeration, pMethodName, System.out);
} | java | public static void printDebug(final Enumeration pEnumeration, final String pMethodName) {
printDebug(pEnumeration, pMethodName, System.out);
} | [
"public",
"static",
"void",
"printDebug",
"(",
"final",
"Enumeration",
"pEnumeration",
",",
"final",
"String",
"pMethodName",
")",
"{",
"printDebug",
"(",
"pEnumeration",
",",
"pMethodName",
",",
"System",
".",
"out",
")",
";",
"}"
] | Invokes a given method of every element in a {@code java.util.Enumeration} and prints the results to a {@code java.io.PrintStream}.
The method to be invoked must have no formal parameters.
<p>
If an exception is throwed during the method invocation, the element's {@code toString()} method is called.
For bulk data types, recursive invocations and invocations of other methods in this class, are used.
<p>
@param pEnumeration the {@code java.util.Enumeration} to be printed.
@param pMethodName a {@code java.lang.String} holding the name of the method to be invoked on each collection element.
@see <a href="http://java.sun.com/products/jdk/1.3/docs/api/java/util/Enumeration.html">{@code java.util.Enumeration}</a> | [
"Invokes",
"a",
"given",
"method",
"of",
"every",
"element",
"in",
"a",
"{"
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/DebugUtil.java#L451-L453 |
lukas-krecan/JsonUnit | json-unit/src/main/java/net/javacrumbs/jsonunit/JsonAssert.java | JsonAssert.assertJsonPartNotEquals | public static void assertJsonPartNotEquals(Object expected, Object fullJson, String path, Configuration configuration) {
Diff diff = create(expected, fullJson, FULL_JSON, path, configuration);
if (diff.similar()) {
if (ROOT.equals(path)) {
doFail("Expected different values but the values were equal.");
} else {
doFail(String.format("Expected different values in node \"%s\" but the values were equal.", path));
}
}
} | java | public static void assertJsonPartNotEquals(Object expected, Object fullJson, String path, Configuration configuration) {
Diff diff = create(expected, fullJson, FULL_JSON, path, configuration);
if (diff.similar()) {
if (ROOT.equals(path)) {
doFail("Expected different values but the values were equal.");
} else {
doFail(String.format("Expected different values in node \"%s\" but the values were equal.", path));
}
}
} | [
"public",
"static",
"void",
"assertJsonPartNotEquals",
"(",
"Object",
"expected",
",",
"Object",
"fullJson",
",",
"String",
"path",
",",
"Configuration",
"configuration",
")",
"{",
"Diff",
"diff",
"=",
"create",
"(",
"expected",
",",
"fullJson",
",",
"FULL_JSON"... | Compares part of the JSON and fails if they are equal.
Path has this format "root.array[0].value". | [
"Compares",
"part",
"of",
"the",
"JSON",
"and",
"fails",
"if",
"they",
"are",
"equal",
".",
"Path",
"has",
"this",
"format",
"root",
".",
"array",
"[",
"0",
"]",
".",
"value",
"."
] | train | https://github.com/lukas-krecan/JsonUnit/blob/2b12ed792e8dd787bddd6f3b8eb2325737435791/json-unit/src/main/java/net/javacrumbs/jsonunit/JsonAssert.java#L111-L120 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/FitLinesToContour.java | FitLinesToContour.fitLinesUsingCorners | boolean fitLinesUsingCorners( int numLines , GrowQueue_I32 cornerIndexes) {
for (int i = 1; i <= numLines; i++) {
int index0 = cornerIndexes.get(CircularIndex.addOffset(anchor0, i - 1, cornerIndexes.size));
int index1 = cornerIndexes.get(CircularIndex.addOffset(anchor0, i, cornerIndexes.size));
if( index0 == index1 )
return false;
if (!fitLine(index0, index1, lines.get(i - 1))) {
// TODO do something more intelligent here. Just leave the corners as is?
return false;
}
LineGeneral2D_F64 l = lines.get(i-1);
if( Double.isNaN(l.A) || Double.isNaN(l.B) || Double.isNaN(l.C)) {
throw new RuntimeException("This should be impossible");
}
}
return true;
} | java | boolean fitLinesUsingCorners( int numLines , GrowQueue_I32 cornerIndexes) {
for (int i = 1; i <= numLines; i++) {
int index0 = cornerIndexes.get(CircularIndex.addOffset(anchor0, i - 1, cornerIndexes.size));
int index1 = cornerIndexes.get(CircularIndex.addOffset(anchor0, i, cornerIndexes.size));
if( index0 == index1 )
return false;
if (!fitLine(index0, index1, lines.get(i - 1))) {
// TODO do something more intelligent here. Just leave the corners as is?
return false;
}
LineGeneral2D_F64 l = lines.get(i-1);
if( Double.isNaN(l.A) || Double.isNaN(l.B) || Double.isNaN(l.C)) {
throw new RuntimeException("This should be impossible");
}
}
return true;
} | [
"boolean",
"fitLinesUsingCorners",
"(",
"int",
"numLines",
",",
"GrowQueue_I32",
"cornerIndexes",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"numLines",
";",
"i",
"++",
")",
"{",
"int",
"index0",
"=",
"cornerIndexes",
".",
"get",
"(",
... | Fits lines across the sequence of corners
@param numLines number of lines it will fit | [
"Fits",
"lines",
"across",
"the",
"sequence",
"of",
"corners"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/FitLinesToContour.java#L270-L288 |
powermock/powermock | powermock-modules/powermock-module-javaagent/src/main/java/sun/tools/attach/HotSpotVirtualMachine.java | HotSpotVirtualMachine.loadAgentLibrary | @Override
public void loadAgentLibrary(String agentLibrary, String options)
throws AgentLoadException, AgentInitializationException, IOException
{
loadAgentLibrary(agentLibrary, false, options);
} | java | @Override
public void loadAgentLibrary(String agentLibrary, String options)
throws AgentLoadException, AgentInitializationException, IOException
{
loadAgentLibrary(agentLibrary, false, options);
} | [
"@",
"Override",
"public",
"void",
"loadAgentLibrary",
"(",
"String",
"agentLibrary",
",",
"String",
"options",
")",
"throws",
"AgentLoadException",
",",
"AgentInitializationException",
",",
"IOException",
"{",
"loadAgentLibrary",
"(",
"agentLibrary",
",",
"false",
",... | /*
Load agent library - library name will be expanded in target VM | [
"/",
"*",
"Load",
"agent",
"library",
"-",
"library",
"name",
"will",
"be",
"expanded",
"in",
"target",
"VM"
] | train | https://github.com/powermock/powermock/blob/e8cd68026c284c6a7efe66959809eeebd8d1f9ad/powermock-modules/powermock-module-javaagent/src/main/java/sun/tools/attach/HotSpotVirtualMachine.java#L75-L80 |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java | ByteArrayUtil.readLong | public static long readLong(byte[] array, int offset) {
// First make integers to resolve signed vs. unsigned issues.
long b0 = array[offset + 0];
long b1 = array[offset + 1] & 0xFF;
long b2 = array[offset + 2] & 0xFF;
long b3 = array[offset + 3] & 0xFF;
long b4 = array[offset + 4] & 0xFF;
int b5 = array[offset + 5] & 0xFF;
int b6 = array[offset + 6] & 0xFF;
int b7 = array[offset + 7] & 0xFF;
return ((b0 << 56) + (b1 << 48) + (b2 << 40) + (b3 << 32) + (b4 << 24) + (b5 << 16) + (b6 << 8) + (b7 << 0));
} | java | public static long readLong(byte[] array, int offset) {
// First make integers to resolve signed vs. unsigned issues.
long b0 = array[offset + 0];
long b1 = array[offset + 1] & 0xFF;
long b2 = array[offset + 2] & 0xFF;
long b3 = array[offset + 3] & 0xFF;
long b4 = array[offset + 4] & 0xFF;
int b5 = array[offset + 5] & 0xFF;
int b6 = array[offset + 6] & 0xFF;
int b7 = array[offset + 7] & 0xFF;
return ((b0 << 56) + (b1 << 48) + (b2 << 40) + (b3 << 32) + (b4 << 24) + (b5 << 16) + (b6 << 8) + (b7 << 0));
} | [
"public",
"static",
"long",
"readLong",
"(",
"byte",
"[",
"]",
"array",
",",
"int",
"offset",
")",
"{",
"// First make integers to resolve signed vs. unsigned issues.",
"long",
"b0",
"=",
"array",
"[",
"offset",
"+",
"0",
"]",
";",
"long",
"b1",
"=",
"array",
... | Read a long from the byte array at the given offset.
@param array Array to read from
@param offset Offset to read at
@return data | [
"Read",
"a",
"long",
"from",
"the",
"byte",
"array",
"at",
"the",
"given",
"offset",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L223-L234 |
bluelinelabs/Conductor | conductor/src/main/java/com/bluelinelabs/conductor/Router.java | Router.popToTag | @SuppressWarnings("WeakerAccess")
@UiThread
public boolean popToTag(@NonNull String tag, @Nullable ControllerChangeHandler changeHandler) {
ThreadUtils.ensureMainThread();
for (RouterTransaction transaction : backstack) {
if (tag.equals(transaction.tag())) {
popToTransaction(transaction, changeHandler);
return true;
}
}
return false;
} | java | @SuppressWarnings("WeakerAccess")
@UiThread
public boolean popToTag(@NonNull String tag, @Nullable ControllerChangeHandler changeHandler) {
ThreadUtils.ensureMainThread();
for (RouterTransaction transaction : backstack) {
if (tag.equals(transaction.tag())) {
popToTransaction(transaction, changeHandler);
return true;
}
}
return false;
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"@",
"UiThread",
"public",
"boolean",
"popToTag",
"(",
"@",
"NonNull",
"String",
"tag",
",",
"@",
"Nullable",
"ControllerChangeHandler",
"changeHandler",
")",
"{",
"ThreadUtils",
".",
"ensureMainThread",
"(",
... | Pops all {@link Controller}s until the {@link Controller} with the passed tag is at the top
@param tag The tag being popped to
@param changeHandler The {@link ControllerChangeHandler} to handle this transaction
@return Whether or not the {@link Controller} with the passed tag is now at the top | [
"Pops",
"all",
"{",
"@link",
"Controller",
"}",
"s",
"until",
"the",
"{",
"@link",
"Controller",
"}",
"with",
"the",
"passed",
"tag",
"is",
"at",
"the",
"top"
] | train | https://github.com/bluelinelabs/Conductor/blob/94c9121bb16f93b481954513a8e3905846829fb2/conductor/src/main/java/com/bluelinelabs/conductor/Router.java#L315-L327 |
ist-dresden/composum | sling/core/commons/src/main/java/com/composum/sling/core/AbstractSlingBean.java | AbstractSlingBean.getParent | public ResourceHandle getParent(String resourceType, String path) {
ResourceResolver resolver = getResolver();
Resource resource;
while (((resource = resolver.getResource(path)) == null || !resource.isResourceType(resourceType))
&& StringUtils.isNotBlank(path)) {
int delimiter = path.lastIndexOf('/');
if (delimiter >= 0) {
path = path.substring(0, delimiter);
} else {
break;
}
}
return ResourceHandle.use(resource);
} | java | public ResourceHandle getParent(String resourceType, String path) {
ResourceResolver resolver = getResolver();
Resource resource;
while (((resource = resolver.getResource(path)) == null || !resource.isResourceType(resourceType))
&& StringUtils.isNotBlank(path)) {
int delimiter = path.lastIndexOf('/');
if (delimiter >= 0) {
path = path.substring(0, delimiter);
} else {
break;
}
}
return ResourceHandle.use(resource);
} | [
"public",
"ResourceHandle",
"getParent",
"(",
"String",
"resourceType",
",",
"String",
"path",
")",
"{",
"ResourceResolver",
"resolver",
"=",
"getResolver",
"(",
")",
";",
"Resource",
"resource",
";",
"while",
"(",
"(",
"(",
"resource",
"=",
"resolver",
".",
... | Use path instead of resource (e.g. if resource is synthetic or non existing) to determine a typed parent. | [
"Use",
"path",
"instead",
"of",
"resource",
"(",
"e",
".",
"g",
".",
"if",
"resource",
"is",
"synthetic",
"or",
"non",
"existing",
")",
"to",
"determine",
"a",
"typed",
"parent",
"."
] | train | https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/core/AbstractSlingBean.java#L214-L227 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/CommandGroup.java | CommandGroup.createButtonBar | public JComponent createButtonBar(Size minimumButtonSize) {
return createButtonBar(minimumButtonSize, GuiStandardUtils.createTopAndBottomBorder(UIConstants.TWO_SPACES));
} | java | public JComponent createButtonBar(Size minimumButtonSize) {
return createButtonBar(minimumButtonSize, GuiStandardUtils.createTopAndBottomBorder(UIConstants.TWO_SPACES));
} | [
"public",
"JComponent",
"createButtonBar",
"(",
"Size",
"minimumButtonSize",
")",
"{",
"return",
"createButtonBar",
"(",
"minimumButtonSize",
",",
"GuiStandardUtils",
".",
"createTopAndBottomBorder",
"(",
"UIConstants",
".",
"TWO_SPACES",
")",
")",
";",
"}"
] | Create a button bar with buttons for all the commands in this group. Adds
a border top and bottom of 2 spaces.
@param minimumButtonSize if null, then there is no minimum size
@return never null | [
"Create",
"a",
"button",
"bar",
"with",
"buttons",
"for",
"all",
"the",
"commands",
"in",
"this",
"group",
".",
"Adds",
"a",
"border",
"top",
"and",
"bottom",
"of",
"2",
"spaces",
"."
] | train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/CommandGroup.java#L434-L436 |
lucee/Lucee | core/src/main/java/lucee/runtime/reflection/Reflector.java | Reflector.setProperty | public static void setProperty(Object obj, String prop, Object value) throws PageException {
boolean done = false;
try {
if (setField(obj, prop, value)) done = true;
}
catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
if (!done) callSetter(obj, prop, value);
} | java | public static void setProperty(Object obj, String prop, Object value) throws PageException {
boolean done = false;
try {
if (setField(obj, prop, value)) done = true;
}
catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
if (!done) callSetter(obj, prop, value);
} | [
"public",
"static",
"void",
"setProperty",
"(",
"Object",
"obj",
",",
"String",
"prop",
",",
"Object",
"value",
")",
"throws",
"PageException",
"{",
"boolean",
"done",
"=",
"false",
";",
"try",
"{",
"if",
"(",
"setField",
"(",
"obj",
",",
"prop",
",",
... | assign a value to a visible Property (Field or Setter) of a object
@param obj Object to assign value to his property
@param prop name of property
@param value Value to assign
@throws PageException | [
"assign",
"a",
"value",
"to",
"a",
"visible",
"Property",
"(",
"Field",
"or",
"Setter",
")",
"of",
"a",
"object"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/reflection/Reflector.java#L1247-L1256 |
katharsis-project/katharsis-framework | katharsis-jpa/src/main/java/io/katharsis/jpa/JpaModule.java | JpaModule.newServerModule | public static JpaModule newServerModule(EntityManagerFactory emFactory, EntityManager em, TransactionRunner transactionRunner) {
return new JpaModule(emFactory, em, transactionRunner);
} | java | public static JpaModule newServerModule(EntityManagerFactory emFactory, EntityManager em, TransactionRunner transactionRunner) {
return new JpaModule(emFactory, em, transactionRunner);
} | [
"public",
"static",
"JpaModule",
"newServerModule",
"(",
"EntityManagerFactory",
"emFactory",
",",
"EntityManager",
"em",
",",
"TransactionRunner",
"transactionRunner",
")",
"{",
"return",
"new",
"JpaModule",
"(",
"emFactory",
",",
"em",
",",
"transactionRunner",
")",... | Creates a new JpaModule for a Katharsis server. All entities managed by
the provided EntityManagerFactory are registered to the module and
exposed as JSON API resources if not later configured otherwise.
@param emFactory
to retrieve the managed entities.
@param em
to use
@param transactionRunner
to use
@return created module | [
"Creates",
"a",
"new",
"JpaModule",
"for",
"a",
"Katharsis",
"server",
".",
"All",
"entities",
"managed",
"by",
"the",
"provided",
"EntityManagerFactory",
"are",
"registered",
"to",
"the",
"module",
"and",
"exposed",
"as",
"JSON",
"API",
"resources",
"if",
"no... | train | https://github.com/katharsis-project/katharsis-framework/blob/73d1a8763c49c5cf4643d43e2dbfedb647630c46/katharsis-jpa/src/main/java/io/katharsis/jpa/JpaModule.java#L203-L205 |
SourcePond/fileobserver | fileobserver-impl/src/main/java/ch/sourcepond/io/fileobserver/impl/directory/RootDirectory.java | RootDirectory.relativizeAgainstRoot | @Override
Path relativizeAgainstRoot(final WatchedDirectory pWatchedDirectory, final Path pPath) {
// Because we are on the last root directory possible we can ignore the
// directory key here.
return getPath().relativize(pPath);
} | java | @Override
Path relativizeAgainstRoot(final WatchedDirectory pWatchedDirectory, final Path pPath) {
// Because we are on the last root directory possible we can ignore the
// directory key here.
return getPath().relativize(pPath);
} | [
"@",
"Override",
"Path",
"relativizeAgainstRoot",
"(",
"final",
"WatchedDirectory",
"pWatchedDirectory",
",",
"final",
"Path",
"pPath",
")",
"{",
"// Because we are on the last root directory possible we can ignore the",
"// directory key here.",
"return",
"getPath",
"(",
")",
... | /*
Relativizes the path specified against the path of this directory. | [
"/",
"*",
"Relativizes",
"the",
"path",
"specified",
"against",
"the",
"path",
"of",
"this",
"directory",
"."
] | train | https://github.com/SourcePond/fileobserver/blob/dfb3055ed35759a47f52f6cfdea49879c415fd6b/fileobserver-impl/src/main/java/ch/sourcepond/io/fileobserver/impl/directory/RootDirectory.java#L93-L98 |
jbundle/jbundle | base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/HPopupBox.java | HPopupBox.init | public void init(ScreenComponent model, boolean bEditableControl)
{
super.init(model, bEditableControl);
if (m_vDisplays == null)
if (model.getConverter().getString() == null)
this.scanTableItems();
} | java | public void init(ScreenComponent model, boolean bEditableControl)
{
super.init(model, bEditableControl);
if (m_vDisplays == null)
if (model.getConverter().getString() == null)
this.scanTableItems();
} | [
"public",
"void",
"init",
"(",
"ScreenComponent",
"model",
",",
"boolean",
"bEditableControl",
")",
"{",
"super",
".",
"init",
"(",
"model",
",",
"bEditableControl",
")",
";",
"if",
"(",
"m_vDisplays",
"==",
"null",
")",
"if",
"(",
"model",
".",
"getConver... | Constructor.
@param model The model object for this view object.
@param bEditableControl Is this control editable? | [
"Constructor",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/HPopupBox.java#L61-L67 |
m-m-m/util | exception/src/main/java/net/sf/mmm/util/exception/api/NlsRuntimeException.java | NlsRuntimeException.printStackTraceCause | private static void printStackTraceCause(Throwable cause, Locale locale, Appendable buffer) throws IOException {
if (cause instanceof NlsThrowable) {
((NlsThrowable) cause).printStackTrace(locale, buffer);
} else {
if (buffer instanceof PrintStream) {
cause.printStackTrace((PrintStream) buffer);
} else if (buffer instanceof PrintWriter) {
cause.printStackTrace((PrintWriter) buffer);
} else {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
cause.printStackTrace(printWriter);
printWriter.flush();
buffer.append(writer.toString());
}
}
} | java | private static void printStackTraceCause(Throwable cause, Locale locale, Appendable buffer) throws IOException {
if (cause instanceof NlsThrowable) {
((NlsThrowable) cause).printStackTrace(locale, buffer);
} else {
if (buffer instanceof PrintStream) {
cause.printStackTrace((PrintStream) buffer);
} else if (buffer instanceof PrintWriter) {
cause.printStackTrace((PrintWriter) buffer);
} else {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
cause.printStackTrace(printWriter);
printWriter.flush();
buffer.append(writer.toString());
}
}
} | [
"private",
"static",
"void",
"printStackTraceCause",
"(",
"Throwable",
"cause",
",",
"Locale",
"locale",
",",
"Appendable",
"buffer",
")",
"throws",
"IOException",
"{",
"if",
"(",
"cause",
"instanceof",
"NlsThrowable",
")",
"{",
"(",
"(",
"NlsThrowable",
")",
... | @see NlsThrowable#printStackTrace(Locale, Appendable)
@param cause is the {@link Throwable} to print.
@param locale is the {@link Locale} to translate to.
@param buffer is where to write the stack trace to.
@throws IOException if caused by {@code buffer}. | [
"@see",
"NlsThrowable#printStackTrace",
"(",
"Locale",
"Appendable",
")"
] | train | https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/exception/src/main/java/net/sf/mmm/util/exception/api/NlsRuntimeException.java#L229-L246 |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java | SqlExecutor.query | public static <T> T query(PreparedStatement ps, RsHandler<T> rsh, Object... params) throws SQLException {
StatementUtil.fillParams(ps, params);
return executeQuery(ps, rsh);
} | java | public static <T> T query(PreparedStatement ps, RsHandler<T> rsh, Object... params) throws SQLException {
StatementUtil.fillParams(ps, params);
return executeQuery(ps, rsh);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"query",
"(",
"PreparedStatement",
"ps",
",",
"RsHandler",
"<",
"T",
">",
"rsh",
",",
"Object",
"...",
"params",
")",
"throws",
"SQLException",
"{",
"StatementUtil",
".",
"fillParams",
"(",
"ps",
",",
"params",
")"... | 执行查询语句<br>
此方法不会关闭PreparedStatement
@param <T> 处理结果类型
@param ps PreparedStatement
@param rsh 结果集处理对象
@param params 参数
@return 结果对象
@throws SQLException SQL执行异常 | [
"执行查询语句<br",
">",
"此方法不会关闭PreparedStatement"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java#L312-L315 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/ECKey.java | ECKey.fromEncrypted | public static ECKey fromEncrypted(EncryptedData encryptedPrivateKey, KeyCrypter crypter, byte[] pubKey) {
ECKey key = fromPublicOnly(pubKey);
key.encryptedPrivateKey = checkNotNull(encryptedPrivateKey);
key.keyCrypter = checkNotNull(crypter);
return key;
} | java | public static ECKey fromEncrypted(EncryptedData encryptedPrivateKey, KeyCrypter crypter, byte[] pubKey) {
ECKey key = fromPublicOnly(pubKey);
key.encryptedPrivateKey = checkNotNull(encryptedPrivateKey);
key.keyCrypter = checkNotNull(crypter);
return key;
} | [
"public",
"static",
"ECKey",
"fromEncrypted",
"(",
"EncryptedData",
"encryptedPrivateKey",
",",
"KeyCrypter",
"crypter",
",",
"byte",
"[",
"]",
"pubKey",
")",
"{",
"ECKey",
"key",
"=",
"fromPublicOnly",
"(",
"pubKey",
")",
";",
"key",
".",
"encryptedPrivateKey",... | Constructs a key that has an encrypted private component. The given object wraps encrypted bytes and an
initialization vector. Note that the key will not be decrypted during this call: the returned ECKey is
unusable for signing unless a decryption key is supplied. | [
"Constructs",
"a",
"key",
"that",
"has",
"an",
"encrypted",
"private",
"component",
".",
"The",
"given",
"object",
"wraps",
"encrypted",
"bytes",
"and",
"an",
"initialization",
"vector",
".",
"Note",
"that",
"the",
"key",
"will",
"not",
"be",
"decrypted",
"d... | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/ECKey.java#L355-L360 |
belaban/JGroups | src/org/jgroups/blocks/MessageDispatcher.java | MessageDispatcher.sendMessageWithFuture | public <T> CompletableFuture<T> sendMessageWithFuture(Address dest, byte[] data, int offset, int length,
RequestOptions opts) throws Exception {
return sendMessageWithFuture(dest, new Buffer(data, offset, length), opts);
} | java | public <T> CompletableFuture<T> sendMessageWithFuture(Address dest, byte[] data, int offset, int length,
RequestOptions opts) throws Exception {
return sendMessageWithFuture(dest, new Buffer(data, offset, length), opts);
} | [
"public",
"<",
"T",
">",
"CompletableFuture",
"<",
"T",
">",
"sendMessageWithFuture",
"(",
"Address",
"dest",
",",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
",",
"int",
"length",
",",
"RequestOptions",
"opts",
")",
"throws",
"Exception",
"{",
"return... | Sends a unicast message to the target defined by msg.getDest() and returns a future
@param dest the target to which to send the unicast message. Must not be null.
@param data the payload to send
@param offset the offset at which the data starts
@param length the number of bytes to send
@param opts the options
@return CompletableFuture<T> A future from which the result can be fetched, or null if the call was asynchronous
@throws Exception If there was problem sending the request, processing it at the receiver, or processing
it at the sender. {@link java.util.concurrent.Future#get()} will throw this exception | [
"Sends",
"a",
"unicast",
"message",
"to",
"the",
"target",
"defined",
"by",
"msg",
".",
"getDest",
"()",
"and",
"returns",
"a",
"future"
] | train | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/blocks/MessageDispatcher.java#L398-L401 |
pravega/pravega | segmentstore/server/src/main/java/io/pravega/segmentstore/server/tables/IndexWriter.java | IndexWriter.generateTableAttributeUpdates | private void generateTableAttributeUpdates(long currentOffset, long newOffset, int processedCount, UpdateInstructions update) {
// Add an Update for the INDEX_OFFSET to indicate we have indexed everything up to this offset.
Preconditions.checkArgument(currentOffset <= newOffset, "newOffset must be larger than existingOffset");
update.withAttribute(new AttributeUpdate(TableAttributes.INDEX_OFFSET, AttributeUpdateType.ReplaceIfEquals, newOffset, currentOffset));
// Update Bucket and Entry counts.
if (update.getEntryCountDelta() != 0) {
update.withAttribute(new AttributeUpdate(TableAttributes.ENTRY_COUNT, AttributeUpdateType.Accumulate, update.getEntryCountDelta()));
}
if (update.getBucketCountDelta() != 0) {
update.withAttribute(new AttributeUpdate(TableAttributes.BUCKET_COUNT, AttributeUpdateType.Accumulate, update.getBucketCountDelta()));
}
if (processedCount > 0) {
update.withAttribute(new AttributeUpdate(TableAttributes.TOTAL_ENTRY_COUNT, AttributeUpdateType.Accumulate, processedCount));
}
} | java | private void generateTableAttributeUpdates(long currentOffset, long newOffset, int processedCount, UpdateInstructions update) {
// Add an Update for the INDEX_OFFSET to indicate we have indexed everything up to this offset.
Preconditions.checkArgument(currentOffset <= newOffset, "newOffset must be larger than existingOffset");
update.withAttribute(new AttributeUpdate(TableAttributes.INDEX_OFFSET, AttributeUpdateType.ReplaceIfEquals, newOffset, currentOffset));
// Update Bucket and Entry counts.
if (update.getEntryCountDelta() != 0) {
update.withAttribute(new AttributeUpdate(TableAttributes.ENTRY_COUNT, AttributeUpdateType.Accumulate, update.getEntryCountDelta()));
}
if (update.getBucketCountDelta() != 0) {
update.withAttribute(new AttributeUpdate(TableAttributes.BUCKET_COUNT, AttributeUpdateType.Accumulate, update.getBucketCountDelta()));
}
if (processedCount > 0) {
update.withAttribute(new AttributeUpdate(TableAttributes.TOTAL_ENTRY_COUNT, AttributeUpdateType.Accumulate, processedCount));
}
} | [
"private",
"void",
"generateTableAttributeUpdates",
"(",
"long",
"currentOffset",
",",
"long",
"newOffset",
",",
"int",
"processedCount",
",",
"UpdateInstructions",
"update",
")",
"{",
"// Add an Update for the INDEX_OFFSET to indicate we have indexed everything up to this offset."... | Generates conditional {@link AttributeUpdate}s that update the values for Core Attributes representing the indexing
state of the Table Segment.
@param currentOffset The offset from which this indexing batch began. This will be checked against
{@link TableAttributes#INDEX_OFFSET}.
@param newOffset The new offset to set for {@link TableAttributes#INDEX_OFFSET}.
@param processedCount The total number of Table Entry updates processed (including overwritten ones).
@param update A {@link UpdateInstructions} object to collect updates into. | [
"Generates",
"conditional",
"{",
"@link",
"AttributeUpdate",
"}",
"s",
"that",
"update",
"the",
"values",
"for",
"Core",
"Attributes",
"representing",
"the",
"indexing",
"state",
"of",
"the",
"Table",
"Segment",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/server/src/main/java/io/pravega/segmentstore/server/tables/IndexWriter.java#L227-L244 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_transferSecurityDeposit_POST | public void billingAccount_transferSecurityDeposit_POST(String billingAccount, Long amount, String billingAccountDestination) throws IOException {
String qPath = "/telephony/{billingAccount}/transferSecurityDeposit";
StringBuilder sb = path(qPath, billingAccount);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "amount", amount);
addBody(o, "billingAccountDestination", billingAccountDestination);
exec(qPath, "POST", sb.toString(), o);
} | java | public void billingAccount_transferSecurityDeposit_POST(String billingAccount, Long amount, String billingAccountDestination) throws IOException {
String qPath = "/telephony/{billingAccount}/transferSecurityDeposit";
StringBuilder sb = path(qPath, billingAccount);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "amount", amount);
addBody(o, "billingAccountDestination", billingAccountDestination);
exec(qPath, "POST", sb.toString(), o);
} | [
"public",
"void",
"billingAccount_transferSecurityDeposit_POST",
"(",
"String",
"billingAccount",
",",
"Long",
"amount",
",",
"String",
"billingAccountDestination",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/transferSecurityDeposit... | Transfer security deposit between two billing accounts
REST: POST /telephony/{billingAccount}/transferSecurityDeposit
@param amount [required] The amount, in euros, you want to transfer
@param billingAccountDestination [required] The destination billing account
@param billingAccount [required] The name of your billingAccount | [
"Transfer",
"security",
"deposit",
"between",
"two",
"billing",
"accounts"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L8192-L8199 |
SeleniumHQ/selenium | java/client/src/org/openqa/selenium/interactions/Actions.java | Actions.sendKeys | public Actions sendKeys(WebElement target, CharSequence... keys) {
if (isBuildingActions()) {
action.addAction(new SendKeysAction(jsonKeyboard, jsonMouse, (Locatable) target, keys));
}
return focusInTicks(target).sendKeysInTicks(keys);
} | java | public Actions sendKeys(WebElement target, CharSequence... keys) {
if (isBuildingActions()) {
action.addAction(new SendKeysAction(jsonKeyboard, jsonMouse, (Locatable) target, keys));
}
return focusInTicks(target).sendKeysInTicks(keys);
} | [
"public",
"Actions",
"sendKeys",
"(",
"WebElement",
"target",
",",
"CharSequence",
"...",
"keys",
")",
"{",
"if",
"(",
"isBuildingActions",
"(",
")",
")",
"{",
"action",
".",
"addAction",
"(",
"new",
"SendKeysAction",
"(",
"jsonKeyboard",
",",
"jsonMouse",
"... | Equivalent to calling:
<i>Actions.click(element).sendKeys(keysToSend).</i>
This method is different from {@link WebElement#sendKeys(CharSequence...)} - see
{@link #sendKeys(CharSequence...)} for details how.
@see #sendKeys(java.lang.CharSequence[])
@param target element to focus on.
@param keys The keys.
@return A self reference.
@throws IllegalArgumentException if keys is null | [
"Equivalent",
"to",
"calling",
":",
"<i",
">",
"Actions",
".",
"click",
"(",
"element",
")",
".",
"sendKeys",
"(",
"keysToSend",
")",
".",
"<",
"/",
"i",
">",
"This",
"method",
"is",
"different",
"from",
"{",
"@link",
"WebElement#sendKeys",
"(",
"CharSeq... | train | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/org/openqa/selenium/interactions/Actions.java#L183-L189 |
jbundle/jbundle | thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/transport/BaseTransport.java | BaseTransport.addParam | public void addParam(String strParam, Map<String,Object> properties)
{
this.addParam(strParam, (Object)properties);
} | java | public void addParam(String strParam, Map<String,Object> properties)
{
this.addParam(strParam, (Object)properties);
} | [
"public",
"void",
"addParam",
"(",
"String",
"strParam",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
")",
"{",
"this",
".",
"addParam",
"(",
"strParam",
",",
"(",
"Object",
")",
"properties",
")",
";",
"}"
] | Add this method param to the param list.
@param strParam The param name.
@param strValue The param value. | [
"Add",
"this",
"method",
"param",
"to",
"the",
"param",
"list",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/transport/BaseTransport.java#L120-L123 |
intuit/QuickBooks-V3-Java-SDK | ipp-v3-java-devkit/src/main/java/com/intuit/ipp/util/Config.java | Config.setProperty | public static void setProperty(String key, String value) {
local.get().cc.setProperty(key, value);
} | java | public static void setProperty(String key, String value) {
local.get().cc.setProperty(key, value);
} | [
"public",
"static",
"void",
"setProperty",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"local",
".",
"get",
"(",
")",
".",
"cc",
".",
"setProperty",
"(",
"key",
",",
"value",
")",
";",
"}"
] | Sets the property to the configuration
@param key
@param value | [
"Sets",
"the",
"property",
"to",
"the",
"configuration"
] | train | https://github.com/intuit/QuickBooks-V3-Java-SDK/blob/59f988d0776d46620d0b34711c411b2b5b1da06b/ipp-v3-java-devkit/src/main/java/com/intuit/ipp/util/Config.java#L251-L253 |
Impetus/Kundera | src/jpa-engine/fallback-impl/src/main/java/com/impetus/kundera/index/DocumentIndexer.java | DocumentIndexer.addParentKeyToDocument | protected void addParentKeyToDocument(String parentId, Document currentDoc, Class<?> clazz) {
// if (parentId != null)
if (clazz != null && parentId != null) {
Field luceneField =
new Field(IndexingConstants.PARENT_ID_FIELD, parentId, Field.Store.YES, Field.Index.ANALYZED_NO_NORMS);
currentDoc.add(luceneField);
Field fieldClass =
new Field(IndexingConstants.PARENT_ID_CLASS, clazz.getCanonicalName().toLowerCase(), Field.Store.YES,
Field.Index.ANALYZED);
currentDoc.add(fieldClass);
}
} | java | protected void addParentKeyToDocument(String parentId, Document currentDoc, Class<?> clazz) {
// if (parentId != null)
if (clazz != null && parentId != null) {
Field luceneField =
new Field(IndexingConstants.PARENT_ID_FIELD, parentId, Field.Store.YES, Field.Index.ANALYZED_NO_NORMS);
currentDoc.add(luceneField);
Field fieldClass =
new Field(IndexingConstants.PARENT_ID_CLASS, clazz.getCanonicalName().toLowerCase(), Field.Store.YES,
Field.Index.ANALYZED);
currentDoc.add(fieldClass);
}
} | [
"protected",
"void",
"addParentKeyToDocument",
"(",
"String",
"parentId",
",",
"Document",
"currentDoc",
",",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"// if (parentId != null)",
"if",
"(",
"clazz",
"!=",
"null",
"&&",
"parentId",
"!=",
"null",
")",
"{",
"... | Index parent key.
@param parentId
the parent id
@param currentDoc
the current doc
@param clazz
the clazz | [
"Index",
"parent",
"key",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/fallback-impl/src/main/java/com/impetus/kundera/index/DocumentIndexer.java#L140-L151 |
rwl/CSparseJ | src/main/java/edu/emory/mathcs/csparsej/tdouble/Dcs_transpose.java | Dcs_transpose.cs_transpose | public static Dcs cs_transpose(Dcs A, boolean values) {
int p, q, j, Cp[], Ci[], n, m, Ap[], Ai[], w[];
double Cx[], Ax[];
Dcs C;
if (!Dcs_util.CS_CSC(A))
return (null); /* check inputs */
m = A.m;
n = A.n;
Ap = A.p;
Ai = A.i;
Ax = A.x;
C = Dcs_util.cs_spalloc(n, m, Ap[n], values && (Ax != null), false); /* allocate result */
w = new int[m]; /* get workspace */
Cp = C.p;
Ci = C.i;
Cx = C.x;
for (p = 0; p < Ap[n]; p++)
w[Ai[p]]++; /* row counts */
Dcs_cumsum.cs_cumsum(Cp, w, m); /* row pointers */
for (j = 0; j < n; j++) {
for (p = Ap[j]; p < Ap[j + 1]; p++) {
Ci[q = w[Ai[p]]++] = j; /* place A(i,j) as entry C(j,i) */
if (Cx != null)
Cx[q] = Ax[p];
}
}
return C;
} | java | public static Dcs cs_transpose(Dcs A, boolean values) {
int p, q, j, Cp[], Ci[], n, m, Ap[], Ai[], w[];
double Cx[], Ax[];
Dcs C;
if (!Dcs_util.CS_CSC(A))
return (null); /* check inputs */
m = A.m;
n = A.n;
Ap = A.p;
Ai = A.i;
Ax = A.x;
C = Dcs_util.cs_spalloc(n, m, Ap[n], values && (Ax != null), false); /* allocate result */
w = new int[m]; /* get workspace */
Cp = C.p;
Ci = C.i;
Cx = C.x;
for (p = 0; p < Ap[n]; p++)
w[Ai[p]]++; /* row counts */
Dcs_cumsum.cs_cumsum(Cp, w, m); /* row pointers */
for (j = 0; j < n; j++) {
for (p = Ap[j]; p < Ap[j + 1]; p++) {
Ci[q = w[Ai[p]]++] = j; /* place A(i,j) as entry C(j,i) */
if (Cx != null)
Cx[q] = Ax[p];
}
}
return C;
} | [
"public",
"static",
"Dcs",
"cs_transpose",
"(",
"Dcs",
"A",
",",
"boolean",
"values",
")",
"{",
"int",
"p",
",",
"q",
",",
"j",
",",
"Cp",
"[",
"]",
",",
"Ci",
"[",
"]",
",",
"n",
",",
"m",
",",
"Ap",
"[",
"]",
",",
"Ai",
"[",
"]",
",",
"... | Computes the transpose of a sparse matrix, C =A';
@param A
column-compressed matrix
@param values
pattern only if false, both pattern and values otherwise
@return C=A', null on error | [
"Computes",
"the",
"transpose",
"of",
"a",
"sparse",
"matrix",
"C",
"=",
"A",
";"
] | train | https://github.com/rwl/CSparseJ/blob/6a6f66bccce1558156a961494358952603b0ac84/src/main/java/edu/emory/mathcs/csparsej/tdouble/Dcs_transpose.java#L46-L73 |
rundeck/rundeck | core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java | DataContextUtils.addEnvVars | public static void addEnvVars( final EnvironmentConfigurable sshexecTask, final Map<String, Map<String, String>> dataContext) {
final Map<String, String> environment = generateEnvVarsFromContext(dataContext);
if (null != environment) {
for (final Map.Entry<String, String> entry : environment.entrySet()) {
final String key = entry.getKey();
if (null != key && null != entry.getValue()) {
final Environment.Variable env = new Environment.Variable();
env.setKey(key);
env.setValue(entry.getValue());
sshexecTask.addEnv(env);
}
}
}
} | java | public static void addEnvVars( final EnvironmentConfigurable sshexecTask, final Map<String, Map<String, String>> dataContext) {
final Map<String, String> environment = generateEnvVarsFromContext(dataContext);
if (null != environment) {
for (final Map.Entry<String, String> entry : environment.entrySet()) {
final String key = entry.getKey();
if (null != key && null != entry.getValue()) {
final Environment.Variable env = new Environment.Variable();
env.setKey(key);
env.setValue(entry.getValue());
sshexecTask.addEnv(env);
}
}
}
} | [
"public",
"static",
"void",
"addEnvVars",
"(",
"final",
"EnvironmentConfigurable",
"sshexecTask",
",",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"dataContext",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
... | add Env elements to pass environment variables to the ExtSSHExec
@param sshexecTask task
@param dataContext data | [
"add",
"Env",
"elements",
"to",
"pass",
"environment",
"variables",
"to",
"the",
"ExtSSHExec"
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java#L537-L550 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/internal/FormLogoutExtensionProcessor.java | FormLogoutExtensionProcessor.isRedirectHostTheSameAsLocalHost | private boolean isRedirectHostTheSameAsLocalHost(String exitPage, String logoutURLhost, String hostFullName, String shortName, String ipAddress) {
String localHostIpAddress = "127.0.0.1";
boolean acceptURL = false;
if (logoutURLhost.equalsIgnoreCase("localhost") || logoutURLhost.equals(localHostIpAddress) ||
(hostFullName != null && logoutURLhost.equalsIgnoreCase(hostFullName)) ||
(shortName != null && logoutURLhost.equalsIgnoreCase(shortName)) ||
(ipAddress != null && logoutURLhost.equals(ipAddress))) {
acceptURL = true;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "exitPage points to this host: all ok");
}
return acceptURL;
} | java | private boolean isRedirectHostTheSameAsLocalHost(String exitPage, String logoutURLhost, String hostFullName, String shortName, String ipAddress) {
String localHostIpAddress = "127.0.0.1";
boolean acceptURL = false;
if (logoutURLhost.equalsIgnoreCase("localhost") || logoutURLhost.equals(localHostIpAddress) ||
(hostFullName != null && logoutURLhost.equalsIgnoreCase(hostFullName)) ||
(shortName != null && logoutURLhost.equalsIgnoreCase(shortName)) ||
(ipAddress != null && logoutURLhost.equals(ipAddress))) {
acceptURL = true;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "exitPage points to this host: all ok");
}
return acceptURL;
} | [
"private",
"boolean",
"isRedirectHostTheSameAsLocalHost",
"(",
"String",
"exitPage",
",",
"String",
"logoutURLhost",
",",
"String",
"hostFullName",
",",
"String",
"shortName",
",",
"String",
"ipAddress",
")",
"{",
"String",
"localHostIpAddress",
"=",
"\"127.0.0.1\"",
... | Check the logout URL host name with various combination of shortName, full name and ipAddress.
@param logoutURLhost
@param hostFullName
@param shortName
@param ipAddress | [
"Check",
"the",
"logout",
"URL",
"host",
"name",
"with",
"various",
"combination",
"of",
"shortName",
"full",
"name",
"and",
"ipAddress",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/internal/FormLogoutExtensionProcessor.java#L336-L349 |
overturetool/overture | ide/debug/src/main/java/org/overture/ide/debug/ui/propertypages/VdmBreakpointPropertyPage.java | VdmBreakpointPropertyPage.createRadioButton | protected Button createRadioButton(Composite parent, String text)
{
return SWTFactory.createRadioButton(parent, text);
} | java | protected Button createRadioButton(Composite parent, String text)
{
return SWTFactory.createRadioButton(parent, text);
} | [
"protected",
"Button",
"createRadioButton",
"(",
"Composite",
"parent",
",",
"String",
"text",
")",
"{",
"return",
"SWTFactory",
".",
"createRadioButton",
"(",
"parent",
",",
"text",
")",
";",
"}"
] | Creates a fully configured radio button with the given text.
@param parent
the parent composite
@param text
the label of the returned radio button
@return a fully configured radio button | [
"Creates",
"a",
"fully",
"configured",
"radio",
"button",
"with",
"the",
"given",
"text",
"."
] | train | https://github.com/overturetool/overture/blob/83175dc6c24fa171cde4fcf61ecb648eba3bdbc1/ide/debug/src/main/java/org/overture/ide/debug/ui/propertypages/VdmBreakpointPropertyPage.java#L533-L536 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java | ST_AsGeoJSON.toGeojsonMultiLineString | public static void toGeojsonMultiLineString(MultiLineString multiLineString, StringBuilder sb) {
sb.append("{\"type\":\"MultiLineString\",\"coordinates\":[");
for (int i = 0; i < multiLineString.getNumGeometries(); i++) {
toGeojsonCoordinates(multiLineString.getGeometryN(i).getCoordinates(), sb);
if (i < multiLineString.getNumGeometries() - 1) {
sb.append(",");
}
}
sb.append("]}");
} | java | public static void toGeojsonMultiLineString(MultiLineString multiLineString, StringBuilder sb) {
sb.append("{\"type\":\"MultiLineString\",\"coordinates\":[");
for (int i = 0; i < multiLineString.getNumGeometries(); i++) {
toGeojsonCoordinates(multiLineString.getGeometryN(i).getCoordinates(), sb);
if (i < multiLineString.getNumGeometries() - 1) {
sb.append(",");
}
}
sb.append("]}");
} | [
"public",
"static",
"void",
"toGeojsonMultiLineString",
"(",
"MultiLineString",
"multiLineString",
",",
"StringBuilder",
"sb",
")",
"{",
"sb",
".",
"append",
"(",
"\"{\\\"type\\\":\\\"MultiLineString\\\",\\\"coordinates\\\":[\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
... | Coordinates of a MultiLineString are an array of LineString coordinate
arrays.
Syntax:
{ "type": "MultiLineString", "coordinates": [ [ [100.0, 0.0], [101.0,
1.0] ], [ [102.0, 2.0], [103.0, 3.0] ] ] }
@param multiLineString
@param sb | [
"Coordinates",
"of",
"a",
"MultiLineString",
"are",
"an",
"array",
"of",
"LineString",
"coordinate",
"arrays",
"."
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java#L160-L169 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ReflectionUtil.java | ReflectionUtil.getProperty | public static Object getProperty(final Object object, final String property) {
Class[] paramTypes = new Class[]{};
Object[] params = new Object[]{};
String methodName = "get" + property.substring(0, 1).toUpperCase() + property.substring(1);
return ReflectionUtil.invokeMethod(object, methodName, params, paramTypes);
} | java | public static Object getProperty(final Object object, final String property) {
Class[] paramTypes = new Class[]{};
Object[] params = new Object[]{};
String methodName = "get" + property.substring(0, 1).toUpperCase() + property.substring(1);
return ReflectionUtil.invokeMethod(object, methodName, params, paramTypes);
} | [
"public",
"static",
"Object",
"getProperty",
"(",
"final",
"Object",
"object",
",",
"final",
"String",
"property",
")",
"{",
"Class",
"[",
"]",
"paramTypes",
"=",
"new",
"Class",
"[",
"]",
"{",
"}",
";",
"Object",
"[",
"]",
"params",
"=",
"new",
"Objec... | This method gets a property from an object via reflection.
@param object The object from which the property is to be retrieved.
@param property The name of the property to be retrieved.
@return The value of the specified <em>property</em>. | [
"This",
"method",
"gets",
"a",
"property",
"from",
"an",
"object",
"via",
"reflection",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ReflectionUtil.java#L139-L145 |
OpenTSDB/opentsdb | src/tools/CliUtils.java | CliUtils.fromBytes | static String fromBytes(final byte[] b) {
try {
return (String) fromBytes.invoke(null, b);
} catch (Exception e) {
throw new RuntimeException("fromBytes=" + fromBytes, e);
}
} | java | static String fromBytes(final byte[] b) {
try {
return (String) fromBytes.invoke(null, b);
} catch (Exception e) {
throw new RuntimeException("fromBytes=" + fromBytes, e);
}
} | [
"static",
"String",
"fromBytes",
"(",
"final",
"byte",
"[",
"]",
"b",
")",
"{",
"try",
"{",
"return",
"(",
"String",
")",
"fromBytes",
".",
"invoke",
"(",
"null",
",",
"b",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
... | Invokces the reflected {@code UnqieuiId.fromBytes()} method with the given
byte array using the UniqueId character set.
@param b The byte array to convert to a string
@return The string
@throws RuntimeException if reflection failed | [
"Invokces",
"the",
"reflected",
"{"
] | train | https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tools/CliUtils.java#L260-L266 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/commands/PackageProcessor.java | PackageProcessor.buildManifestForIncludeHasRunnable | protected File buildManifestForIncludeHasRunnable(File installationManifest) throws IOException {
Manifest mf = new Manifest();
mf.read(new FileInputStream(installationManifest));
mf.getMainAttributes().remove(new Attributes.Name("License-Agreement"));
mf.getMainAttributes().remove(new Attributes.Name("License-Information"));
mf.getMainAttributes().putValue("Main-Class", "wlp.lib.extract.SelfExtractRun");
mf.getMainAttributes().putValue("Server-Name", processName);
File newMani = new File(workAreaTmpDir, "MANIFEST.usrinclude.tmp");
mf.write(new FileOutputStream(newMani));
return newMani;
} | java | protected File buildManifestForIncludeHasRunnable(File installationManifest) throws IOException {
Manifest mf = new Manifest();
mf.read(new FileInputStream(installationManifest));
mf.getMainAttributes().remove(new Attributes.Name("License-Agreement"));
mf.getMainAttributes().remove(new Attributes.Name("License-Information"));
mf.getMainAttributes().putValue("Main-Class", "wlp.lib.extract.SelfExtractRun");
mf.getMainAttributes().putValue("Server-Name", processName);
File newMani = new File(workAreaTmpDir, "MANIFEST.usrinclude.tmp");
mf.write(new FileOutputStream(newMani));
return newMani;
} | [
"protected",
"File",
"buildManifestForIncludeHasRunnable",
"(",
"File",
"installationManifest",
")",
"throws",
"IOException",
"{",
"Manifest",
"mf",
"=",
"new",
"Manifest",
"(",
")",
";",
"mf",
".",
"read",
"(",
"new",
"FileInputStream",
"(",
"installationManifest",... | Create a proper manifest file for the --include=execute option. The manifest is a copy
of the given installation manifest, with the following edits:
Change
from:
Main-Class: wlp.lib.extract.SelfExtract
to:
Main-Class: wlp.lib.extract.SelfExtractRun
add:
Server-Name: <processName>
@return the manifest file | [
"Create",
"a",
"proper",
"manifest",
"file",
"for",
"the",
"--",
"include",
"=",
"execute",
"option",
".",
"The",
"manifest",
"is",
"a",
"copy",
"of",
"the",
"given",
"installation",
"manifest",
"with",
"the",
"following",
"edits",
":"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/commands/PackageProcessor.java#L162-L175 |
actorapp/actor-platform | actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/util/images/ops/ImageDrawing.java | ImageDrawing.drawRoundedCorners | public static void drawRoundedCorners(Bitmap src, Bitmap dest, int radius) {
drawRoundedCorners(src, dest, radius, CLEAR_COLOR);
} | java | public static void drawRoundedCorners(Bitmap src, Bitmap dest, int radius) {
drawRoundedCorners(src, dest, radius, CLEAR_COLOR);
} | [
"public",
"static",
"void",
"drawRoundedCorners",
"(",
"Bitmap",
"src",
",",
"Bitmap",
"dest",
",",
"int",
"radius",
")",
"{",
"drawRoundedCorners",
"(",
"src",
",",
"dest",
",",
"radius",
",",
"CLEAR_COLOR",
")",
";",
"}"
] | Drawing src bitmap to dest bitmap with rounded corners
@param src source bitmap
@param dest destination bitmap
@param radius radius in destination bitmap scale | [
"Drawing",
"src",
"bitmap",
"to",
"dest",
"bitmap",
"with",
"rounded",
"corners"
] | train | https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/util/images/ops/ImageDrawing.java#L109-L111 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/mime/MimeTypeDeterminator.java | MimeTypeDeterminator.getMimeTypeFromBytes | @Nullable
public IMimeType getMimeTypeFromBytes (@Nullable final byte [] aBytes, @Nullable final IMimeType aDefault)
{
if (aBytes == null || aBytes.length == 0)
return aDefault;
return m_aRWLock.readLocked ( () -> {
for (final MimeTypeContent aMTC : m_aMimeTypeContents)
if (aMTC.matchesBeginning (aBytes))
return aMTC.getMimeType ();
// default fallback
return aDefault;
});
} | java | @Nullable
public IMimeType getMimeTypeFromBytes (@Nullable final byte [] aBytes, @Nullable final IMimeType aDefault)
{
if (aBytes == null || aBytes.length == 0)
return aDefault;
return m_aRWLock.readLocked ( () -> {
for (final MimeTypeContent aMTC : m_aMimeTypeContents)
if (aMTC.matchesBeginning (aBytes))
return aMTC.getMimeType ();
// default fallback
return aDefault;
});
} | [
"@",
"Nullable",
"public",
"IMimeType",
"getMimeTypeFromBytes",
"(",
"@",
"Nullable",
"final",
"byte",
"[",
"]",
"aBytes",
",",
"@",
"Nullable",
"final",
"IMimeType",
"aDefault",
")",
"{",
"if",
"(",
"aBytes",
"==",
"null",
"||",
"aBytes",
".",
"length",
"... | Try to determine the MIME type from the given byte array.
@param aBytes
The byte array to parse. May be <code>null</code> or empty.
@param aDefault
The default MIME type to be returned, if no matching MIME type was
found. May be <code>null</code>.
@return The supplied default value, if no matching MIME type was found. May
be <code>null</code>. | [
"Try",
"to",
"determine",
"the",
"MIME",
"type",
"from",
"the",
"given",
"byte",
"array",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/mime/MimeTypeDeterminator.java#L233-L247 |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/model/trigram/CharacterBasedGenerativeModel.java | CharacterBasedGenerativeModel.log_prob | double log_prob(char s1, int i1, char s2, int i2, char s3, int i3)
{
if (transMatrix[i1][i2][i3] == 0)
return inf;
char t1 = id2tag[i1];
char t2 = id2tag[i2];
char t3 = id2tag[i3];
double uni = l1 * tf.freq(s3,t3);
double bi = div(l2 * tf.get(s2,t2, s3,t3), tf.get(s2,t2));
double tri = div(l3 * tf.get(s1,t1, s2,t2, s3,t3), tf.get(s1,t1, s2,t2));
if (uni + bi + tri == 0)
return inf;
return Math.log(uni + bi + tri);
} | java | double log_prob(char s1, int i1, char s2, int i2, char s3, int i3)
{
if (transMatrix[i1][i2][i3] == 0)
return inf;
char t1 = id2tag[i1];
char t2 = id2tag[i2];
char t3 = id2tag[i3];
double uni = l1 * tf.freq(s3,t3);
double bi = div(l2 * tf.get(s2,t2, s3,t3), tf.get(s2,t2));
double tri = div(l3 * tf.get(s1,t1, s2,t2, s3,t3), tf.get(s1,t1, s2,t2));
if (uni + bi + tri == 0)
return inf;
return Math.log(uni + bi + tri);
} | [
"double",
"log_prob",
"(",
"char",
"s1",
",",
"int",
"i1",
",",
"char",
"s2",
",",
"int",
"i2",
",",
"char",
"s3",
",",
"int",
"i3",
")",
"{",
"if",
"(",
"transMatrix",
"[",
"i1",
"]",
"[",
"i2",
"]",
"[",
"i3",
"]",
"==",
"0",
")",
"return",... | 求概率
@param s1 前2个字
@param s1 前2个状态的下标
@param s2 前1个字
@param s2 前1个状态的下标
@param s3 当前字
@param s3 当前状态的下标
@return 序列的概率 | [
"求概率"
] | train | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/model/trigram/CharacterBasedGenerativeModel.java#L157-L170 |
PinaeOS/nala | src/main/java/org/pinae/nala/xb/util/ResourceWriter.java | ResourceWriter.writeToFile | public void writeToFile(StringBuffer content, String filename, String encoding) throws NoSuchPathException, IOException{
try {
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(filename), encoding);
writer.write(content.toString(), 0, content.length());
writer.flush();
writer.close();
} catch (FileNotFoundException e) {
throw new NoSuchPathException(e);
}
} | java | public void writeToFile(StringBuffer content, String filename, String encoding) throws NoSuchPathException, IOException{
try {
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(filename), encoding);
writer.write(content.toString(), 0, content.length());
writer.flush();
writer.close();
} catch (FileNotFoundException e) {
throw new NoSuchPathException(e);
}
} | [
"public",
"void",
"writeToFile",
"(",
"StringBuffer",
"content",
",",
"String",
"filename",
",",
"String",
"encoding",
")",
"throws",
"NoSuchPathException",
",",
"IOException",
"{",
"try",
"{",
"OutputStreamWriter",
"writer",
"=",
"new",
"OutputStreamWriter",
"(",
... | 将XML内容写入文件
@param content XML内容
@param filename 需要写入的文件
@param encoding 文件编码
@throws NoSuchPathException 写入文件时, 无法发现路径引发的异常
@throws IOException 文件写入异常 | [
"将XML内容写入文件"
] | train | https://github.com/PinaeOS/nala/blob/2047ade4af197cec938278d300d111ea94af6fbf/src/main/java/org/pinae/nala/xb/util/ResourceWriter.java#L50-L59 |
classgraph/classgraph | src/main/java/nonapi/io/github/classgraph/concurrency/WorkQueue.java | WorkQueue.runWorkLoop | private void runWorkLoop() throws InterruptedException, ExecutionException {
// Get next work unit from queue
for (;;) {
// Check for interruption
interruptionChecker.check();
// Get next work unit
final WorkUnitWrapper<T> workUnitWrapper = workUnits.take();
if (workUnitWrapper.workUnit == null) {
// Received poison pill
break;
}
// Process the work unit
try {
// Process the work unit (may throw InterruptedException)
workUnitProcessor.processWorkUnit(workUnitWrapper.workUnit, this, log);
} catch (InterruptedException | OutOfMemoryError e) {
// On InterruptedException or OutOfMemoryError, drain work queue, send poison pills, and re-throw
workUnits.clear();
sendPoisonPills();
throw e;
} catch (final RuntimeException e) {
// On unchecked exception, drain work queue, send poison pills, and throw ExecutionException
workUnits.clear();
sendPoisonPills();
throw new ExecutionException("Worker thread threw unchecked exception", e);
} finally {
if (numIncompleteWorkUnits.decrementAndGet() == 0) {
// No more work units -- send poison pills
sendPoisonPills();
}
}
}
} | java | private void runWorkLoop() throws InterruptedException, ExecutionException {
// Get next work unit from queue
for (;;) {
// Check for interruption
interruptionChecker.check();
// Get next work unit
final WorkUnitWrapper<T> workUnitWrapper = workUnits.take();
if (workUnitWrapper.workUnit == null) {
// Received poison pill
break;
}
// Process the work unit
try {
// Process the work unit (may throw InterruptedException)
workUnitProcessor.processWorkUnit(workUnitWrapper.workUnit, this, log);
} catch (InterruptedException | OutOfMemoryError e) {
// On InterruptedException or OutOfMemoryError, drain work queue, send poison pills, and re-throw
workUnits.clear();
sendPoisonPills();
throw e;
} catch (final RuntimeException e) {
// On unchecked exception, drain work queue, send poison pills, and throw ExecutionException
workUnits.clear();
sendPoisonPills();
throw new ExecutionException("Worker thread threw unchecked exception", e);
} finally {
if (numIncompleteWorkUnits.decrementAndGet() == 0) {
// No more work units -- send poison pills
sendPoisonPills();
}
}
}
} | [
"private",
"void",
"runWorkLoop",
"(",
")",
"throws",
"InterruptedException",
",",
"ExecutionException",
"{",
"// Get next work unit from queue",
"for",
"(",
";",
";",
")",
"{",
"// Check for interruption",
"interruptionChecker",
".",
"check",
"(",
")",
";",
"// Get n... | Start a worker. Called by startWorkers(), but should also be called by the main thread to do some of the work
on that thread, to prevent deadlock in the case that the ExecutorService doesn't have as many threads
available as numParallelTasks. When this method returns, either all the work has been completed, or this or
some other thread was interrupted. If InterruptedException is thrown, this thread or another was interrupted.
@throws InterruptedException
if a worker thread was interrupted
@throws ExecutionException
if a worker thread throws an uncaught exception | [
"Start",
"a",
"worker",
".",
"Called",
"by",
"startWorkers",
"()",
"but",
"should",
"also",
"be",
"called",
"by",
"the",
"main",
"thread",
"to",
"do",
"some",
"of",
"the",
"work",
"on",
"that",
"thread",
"to",
"prevent",
"deadlock",
"in",
"the",
"case",
... | train | https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/concurrency/WorkQueue.java#L228-L266 |
MTDdk/jawn | jawn-server/src/main/java/net/javapla/jawn/server/SessionFacadeImpl.java | SessionFacadeImpl.put | public Object put(String name, Serializable value){
// Object val = session/*request.getSession(true)*/.getAttribute(name);
// request.getSession(false).setAttribute(name, value);
Object val = session.getAttribute(name);
session.setAttribute(name, value);
return val;
} | java | public Object put(String name, Serializable value){
// Object val = session/*request.getSession(true)*/.getAttribute(name);
// request.getSession(false).setAttribute(name, value);
Object val = session.getAttribute(name);
session.setAttribute(name, value);
return val;
} | [
"public",
"Object",
"put",
"(",
"String",
"name",
",",
"Serializable",
"value",
")",
"{",
"// Object val = session/*request.getSession(true)*/.getAttribute(name);",
"// request.getSession(false).setAttribute(name, value);",
"Object",
"val",
"=",
"session",
".",
"get... | Add object to a session.
@param name name of object
@param value object reference.
@return the previous bound value for the name | [
"Add",
"object",
"to",
"a",
"session",
"."
] | train | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-server/src/main/java/net/javapla/jawn/server/SessionFacadeImpl.java#L75-L81 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/context/configure/AbstractConfiguration.java | AbstractConfiguration.getPropertyValue | public String getPropertyValue(final String propertyName, final String defaultPropertyValue) {
return defaultIfUnset(getPropertyValue(propertyName, NOT_REQUIRED), defaultPropertyValue);
} | java | public String getPropertyValue(final String propertyName, final String defaultPropertyValue) {
return defaultIfUnset(getPropertyValue(propertyName, NOT_REQUIRED), defaultPropertyValue);
} | [
"public",
"String",
"getPropertyValue",
"(",
"final",
"String",
"propertyName",
",",
"final",
"String",
"defaultPropertyValue",
")",
"{",
"return",
"defaultIfUnset",
"(",
"getPropertyValue",
"(",
"propertyName",
",",
"NOT_REQUIRED",
")",
",",
"defaultPropertyValue",
"... | Gets the value of the configuration property identified by name. The defaultPropertyValue parameter effectively
overrides the required attribute indicating that the property is not required to be declared or defined.
@param propertyName a String value indicating the name of the configuration property.
@param defaultPropertyValue the default value for the configuration property when the property is undeclared or
undefined.
@return the value of the configuration property identified by name, or the default property value if the property
was undeclared or undefined. | [
"Gets",
"the",
"value",
"of",
"the",
"configuration",
"property",
"identified",
"by",
"name",
".",
"The",
"defaultPropertyValue",
"parameter",
"effectively",
"overrides",
"the",
"required",
"attribute",
"indicating",
"that",
"the",
"property",
"is",
"not",
"required... | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/context/configure/AbstractConfiguration.java#L218-L220 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java | SingularOps_DDRM.nullspaceSVD | public static DMatrixRMaj nullspaceSVD( DMatrixRMaj A , int totalSingular ) {
SolveNullSpace<DMatrixRMaj> solver = new SolveNullSpaceSvd_DDRM();
DMatrixRMaj nullspace = new DMatrixRMaj(1,1);
if( !solver.process(A,totalSingular,nullspace))
throw new RuntimeException("Solver failed. try SVD based method instead?");
return nullspace;
} | java | public static DMatrixRMaj nullspaceSVD( DMatrixRMaj A , int totalSingular ) {
SolveNullSpace<DMatrixRMaj> solver = new SolveNullSpaceSvd_DDRM();
DMatrixRMaj nullspace = new DMatrixRMaj(1,1);
if( !solver.process(A,totalSingular,nullspace))
throw new RuntimeException("Solver failed. try SVD based method instead?");
return nullspace;
} | [
"public",
"static",
"DMatrixRMaj",
"nullspaceSVD",
"(",
"DMatrixRMaj",
"A",
",",
"int",
"totalSingular",
")",
"{",
"SolveNullSpace",
"<",
"DMatrixRMaj",
">",
"solver",
"=",
"new",
"SolveNullSpaceSvd_DDRM",
"(",
")",
";",
"DMatrixRMaj",
"nullspace",
"=",
"new",
"... | Computes the null space using SVD. Slowest bust most stable way to find the solution
@param A (Input) Matrix
@param totalSingular Number of singular values
@return Null space | [
"Computes",
"the",
"null",
"space",
"using",
"SVD",
".",
"Slowest",
"bust",
"most",
"stable",
"way",
"to",
"find",
"the",
"solution"
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java#L470-L479 |
ggrandes/packer | src/main/java/org/javastack/packer/Packer.java | Packer.loadStringHex | public Packer loadStringHex(final String in) throws InvalidInputDataException {
try {
return loadBytes(fromHex(in));
} catch (ParseException e) {
throw new IllegalArgumentException("Invalid input string", e);
}
} | java | public Packer loadStringHex(final String in) throws InvalidInputDataException {
try {
return loadBytes(fromHex(in));
} catch (ParseException e) {
throw new IllegalArgumentException("Invalid input string", e);
}
} | [
"public",
"Packer",
"loadStringHex",
"(",
"final",
"String",
"in",
")",
"throws",
"InvalidInputDataException",
"{",
"try",
"{",
"return",
"loadBytes",
"(",
"fromHex",
"(",
"in",
")",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"throw",
"n... | Load string in hex format
@return
@throws InvalidInputDataException
@throws ParseException
@see #outputStringHex() | [
"Load",
"string",
"in",
"hex",
"format"
] | train | https://github.com/ggrandes/packer/blob/0b37b286a3d0555050eb2e65419dd74f8d8d3e78/src/main/java/org/javastack/packer/Packer.java#L1266-L1272 |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/io/PDBFileParser.java | PDBFileParser.isKnownChain | private static Chain isKnownChain(String chainID, List<Chain> chains){
for (int i = 0; i< chains.size();i++){
Chain testchain = chains.get(i);
if (chainID.equals(testchain.getName())) {
return testchain;
}
}
return null;
} | java | private static Chain isKnownChain(String chainID, List<Chain> chains){
for (int i = 0; i< chains.size();i++){
Chain testchain = chains.get(i);
if (chainID.equals(testchain.getName())) {
return testchain;
}
}
return null;
} | [
"private",
"static",
"Chain",
"isKnownChain",
"(",
"String",
"chainID",
",",
"List",
"<",
"Chain",
">",
"chains",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"chains",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Chain",
"test... | Finds in the given list of chains the first one that has as name the given chainID.
If no such Chain can be found it returns null. | [
"Finds",
"in",
"the",
"given",
"list",
"of",
"chains",
"the",
"first",
"one",
"that",
"has",
"as",
"name",
"the",
"given",
"chainID",
".",
"If",
"no",
"such",
"Chain",
"can",
"be",
"found",
"it",
"returns",
"null",
"."
] | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/PDBFileParser.java#L2514-L2524 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStatsAsHtml.java | UicStatsAsHtml.writeProfileForTree | private static void writeProfileForTree(final PrintWriter writer,
final Map<WComponent, UicStats.Stat> treeStats) {
// Copy all the stats into a list so we can sort and cull.
List<UicStats.Stat> statList = new ArrayList<>(treeStats.values());
Comparator<UicStats.Stat> comparator = new Comparator<UicStats.Stat>() {
@Override
public int compare(final UicStats.Stat stat1, final UicStats.Stat stat2) {
if (stat1.getModelState() > stat2.getModelState()) {
return -1;
} else if (stat1.getModelState() < stat2.getModelState()) {
return 1;
} else {
int diff = stat1.getClassName().compareTo(stat2.getClassName());
if (diff == 0) {
diff = stat1.getName().compareTo(stat2.getName());
}
return diff;
}
}
};
Collections.sort(statList, comparator);
for (int i = 0; i < statList.size(); i++) {
UicStats.Stat stat = statList.get(i);
writeRow(writer, stat);
}
} | java | private static void writeProfileForTree(final PrintWriter writer,
final Map<WComponent, UicStats.Stat> treeStats) {
// Copy all the stats into a list so we can sort and cull.
List<UicStats.Stat> statList = new ArrayList<>(treeStats.values());
Comparator<UicStats.Stat> comparator = new Comparator<UicStats.Stat>() {
@Override
public int compare(final UicStats.Stat stat1, final UicStats.Stat stat2) {
if (stat1.getModelState() > stat2.getModelState()) {
return -1;
} else if (stat1.getModelState() < stat2.getModelState()) {
return 1;
} else {
int diff = stat1.getClassName().compareTo(stat2.getClassName());
if (diff == 0) {
diff = stat1.getName().compareTo(stat2.getName());
}
return diff;
}
}
};
Collections.sort(statList, comparator);
for (int i = 0; i < statList.size(); i++) {
UicStats.Stat stat = statList.get(i);
writeRow(writer, stat);
}
} | [
"private",
"static",
"void",
"writeProfileForTree",
"(",
"final",
"PrintWriter",
"writer",
",",
"final",
"Map",
"<",
"WComponent",
",",
"UicStats",
".",
"Stat",
">",
"treeStats",
")",
"{",
"// Copy all the stats into a list so we can sort and cull.",
"List",
"<",
"Uic... | Writes the stats for a single component.
@param writer the writer to write the stats to.
@param treeStats the stats for the component. | [
"Writes",
"the",
"stats",
"for",
"a",
"single",
"component",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStatsAsHtml.java#L65-L95 |
haraldk/TwelveMonkeys | imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/Paths.java | Paths.applyClippingPath | public static BufferedImage applyClippingPath(final Shape clip, final BufferedImage image) {
return applyClippingPath(clip, notNull(image, "image"), new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB));
} | java | public static BufferedImage applyClippingPath(final Shape clip, final BufferedImage image) {
return applyClippingPath(clip, notNull(image, "image"), new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB));
} | [
"public",
"static",
"BufferedImage",
"applyClippingPath",
"(",
"final",
"Shape",
"clip",
",",
"final",
"BufferedImage",
"image",
")",
"{",
"return",
"applyClippingPath",
"(",
"clip",
",",
"notNull",
"(",
"image",
",",
"\"image\"",
")",
",",
"new",
"BufferedImage... | Applies the clipping path to the given image.
All pixels outside the path will be transparent.
@param clip the clipping path, not {@code null}
@param image the image to clip, not {@code null}
@return the clipped image.
@throws java.lang.IllegalArgumentException if {@code clip} or {@code image} is {@code null}. | [
"Applies",
"the",
"clipping",
"path",
"to",
"the",
"given",
"image",
".",
"All",
"pixels",
"outside",
"the",
"path",
"will",
"be",
"transparent",
"."
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/Paths.java#L185-L187 |
igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java | LeafNode.getItems | public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
List<Item> itemList = new ArrayList<>(ids.size());
for (String id : ids) {
itemList.add(new Item(id));
}
PubSub request = createPubsubPacket(Type.get, new ItemsExtension(ItemsExtension.ItemsElementType.items, getId(), itemList));
return getItems(request);
} | java | public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
List<Item> itemList = new ArrayList<>(ids.size());
for (String id : ids) {
itemList.add(new Item(id));
}
PubSub request = createPubsubPacket(Type.get, new ItemsExtension(ItemsExtension.ItemsElementType.items, getId(), itemList));
return getItems(request);
} | [
"public",
"<",
"T",
"extends",
"Item",
">",
"List",
"<",
"T",
">",
"getItems",
"(",
"Collection",
"<",
"String",
">",
"ids",
")",
"throws",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"List",
... | Get the items specified from the node. This would typically be
used when the server does not return the payload due to size
constraints. The user would be required to retrieve the payload
after the items have been retrieved via {@link #getItems()} or an
event, that did not include the payload.
@param ids Item ids of the items to retrieve
@param <T> type of the items.
@return The list of {@link Item} with payload
@throws XMPPErrorException
@throws NoResponseException if there was no response from the server.
@throws NotConnectedException
@throws InterruptedException | [
"Get",
"the",
"items",
"specified",
"from",
"the",
"node",
".",
"This",
"would",
"typically",
"be",
"used",
"when",
"the",
"server",
"does",
"not",
"return",
"the",
"payload",
"due",
"to",
"size",
"constraints",
".",
"The",
"user",
"would",
"be",
"required... | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java#L112-L120 |
square/mortar | mortar-sample/src/main/java/com/example/mortar/screen/Layouts.java | Layouts.createView | public static android.view.View createView(Context context, Object screen) {
return createView(context, screen.getClass());
} | java | public static android.view.View createView(Context context, Object screen) {
return createView(context, screen.getClass());
} | [
"public",
"static",
"android",
".",
"view",
".",
"View",
"createView",
"(",
"Context",
"context",
",",
"Object",
"screen",
")",
"{",
"return",
"createView",
"(",
"context",
",",
"screen",
".",
"getClass",
"(",
")",
")",
";",
"}"
] | Create an instance of the view specified in a {@link Layout} annotation. | [
"Create",
"an",
"instance",
"of",
"the",
"view",
"specified",
"in",
"a",
"{"
] | train | https://github.com/square/mortar/blob/c968b99eb96ba56c47e29912c07841be8e2cf97a/mortar-sample/src/main/java/com/example/mortar/screen/Layouts.java#L24-L26 |
mbeiter/util | db/src/main/java/org/beiter/michael/db/DataSourceFactory.java | DataSourceFactory.getPoolingDataSource | private static PoolingDataSource<PoolableConnection> getPoolingDataSource(final String url,
final ConcurrentMap<String, String> properties,
final ConnectionProperties poolSpec) {
// assert in private method
assert url != null : "The url cannot be null";
assert properties != null : "The properties cannot be null";
assert poolSpec != null : "The pol spec cannot be null";
LOG.debug("Creating new pooled data source for '" + url + "'");
// convert the properties hashmap to java properties
final Properties props = new Properties();
props.putAll(properties);
// create a Apache DBCP pool configuration from the pool spec
final GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
poolConfig.setMaxTotal(poolSpec.getMaxTotal());
poolConfig.setMaxIdle(poolSpec.getMaxIdle());
poolConfig.setMinIdle(poolSpec.getMinIdle());
poolConfig.setMaxWaitMillis(poolSpec.getMaxWaitMillis());
poolConfig.setTestOnCreate(poolSpec.isTestOnCreate());
poolConfig.setTestOnBorrow(poolSpec.isTestOnBorrow());
poolConfig.setTestOnReturn(poolSpec.isTestOnReturn());
poolConfig.setTestWhileIdle(poolSpec.isTestWhileIdle());
poolConfig.setTimeBetweenEvictionRunsMillis(poolSpec.getTimeBetweenEvictionRunsMillis());
poolConfig.setNumTestsPerEvictionRun(poolSpec.getNumTestsPerEvictionRun());
poolConfig.setMinEvictableIdleTimeMillis(poolSpec.getMinEvictableIdleTimeMillis());
poolConfig.setSoftMinEvictableIdleTimeMillis(poolSpec.getSoftMinEvictableIdleTimeMillis());
poolConfig.setLifo(poolSpec.isLifo());
// create the pool and assign the factory to the pool
final org.apache.commons.dbcp2.ConnectionFactory connFactory = new DriverManagerConnectionFactory(url, props);
final PoolableConnectionFactory poolConnFactory = new PoolableConnectionFactory(connFactory, null);
poolConnFactory.setDefaultAutoCommit(poolSpec.isDefaultAutoCommit());
poolConnFactory.setDefaultReadOnly(poolSpec.isDefaultReadOnly());
poolConnFactory.setDefaultTransactionIsolation(poolSpec.getDefaultTransactionIsolation());
poolConnFactory.setCacheState(poolSpec.isCacheState());
poolConnFactory.setValidationQuery(poolSpec.getValidationQuery());
poolConnFactory.setMaxConnLifetimeMillis(poolSpec.getMaxConnLifetimeMillis());
final GenericObjectPool<PoolableConnection> connPool = new GenericObjectPool<>(poolConnFactory, poolConfig);
poolConnFactory.setPool(connPool);
// create a new pooled data source
return new PoolingDataSource<>(connPool);
} | java | private static PoolingDataSource<PoolableConnection> getPoolingDataSource(final String url,
final ConcurrentMap<String, String> properties,
final ConnectionProperties poolSpec) {
// assert in private method
assert url != null : "The url cannot be null";
assert properties != null : "The properties cannot be null";
assert poolSpec != null : "The pol spec cannot be null";
LOG.debug("Creating new pooled data source for '" + url + "'");
// convert the properties hashmap to java properties
final Properties props = new Properties();
props.putAll(properties);
// create a Apache DBCP pool configuration from the pool spec
final GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
poolConfig.setMaxTotal(poolSpec.getMaxTotal());
poolConfig.setMaxIdle(poolSpec.getMaxIdle());
poolConfig.setMinIdle(poolSpec.getMinIdle());
poolConfig.setMaxWaitMillis(poolSpec.getMaxWaitMillis());
poolConfig.setTestOnCreate(poolSpec.isTestOnCreate());
poolConfig.setTestOnBorrow(poolSpec.isTestOnBorrow());
poolConfig.setTestOnReturn(poolSpec.isTestOnReturn());
poolConfig.setTestWhileIdle(poolSpec.isTestWhileIdle());
poolConfig.setTimeBetweenEvictionRunsMillis(poolSpec.getTimeBetweenEvictionRunsMillis());
poolConfig.setNumTestsPerEvictionRun(poolSpec.getNumTestsPerEvictionRun());
poolConfig.setMinEvictableIdleTimeMillis(poolSpec.getMinEvictableIdleTimeMillis());
poolConfig.setSoftMinEvictableIdleTimeMillis(poolSpec.getSoftMinEvictableIdleTimeMillis());
poolConfig.setLifo(poolSpec.isLifo());
// create the pool and assign the factory to the pool
final org.apache.commons.dbcp2.ConnectionFactory connFactory = new DriverManagerConnectionFactory(url, props);
final PoolableConnectionFactory poolConnFactory = new PoolableConnectionFactory(connFactory, null);
poolConnFactory.setDefaultAutoCommit(poolSpec.isDefaultAutoCommit());
poolConnFactory.setDefaultReadOnly(poolSpec.isDefaultReadOnly());
poolConnFactory.setDefaultTransactionIsolation(poolSpec.getDefaultTransactionIsolation());
poolConnFactory.setCacheState(poolSpec.isCacheState());
poolConnFactory.setValidationQuery(poolSpec.getValidationQuery());
poolConnFactory.setMaxConnLifetimeMillis(poolSpec.getMaxConnLifetimeMillis());
final GenericObjectPool<PoolableConnection> connPool = new GenericObjectPool<>(poolConnFactory, poolConfig);
poolConnFactory.setPool(connPool);
// create a new pooled data source
return new PoolingDataSource<>(connPool);
} | [
"private",
"static",
"PoolingDataSource",
"<",
"PoolableConnection",
">",
"getPoolingDataSource",
"(",
"final",
"String",
"url",
",",
"final",
"ConcurrentMap",
"<",
"String",
",",
"String",
">",
"properties",
",",
"final",
"ConnectionProperties",
"poolSpec",
")",
"{... | Get a pooled data source for the provided connection parameters.
@param url The JDBC database URL of the form <code>jdbc:subprotocol:subname</code>
@param properties A list of key/value configuration parameters to pass as connection arguments. Normally at
least a "user" and "password" property should be included
@param poolSpec A connection pool spec
@return A pooled database connection | [
"Get",
"a",
"pooled",
"data",
"source",
"for",
"the",
"provided",
"connection",
"parameters",
"."
] | train | https://github.com/mbeiter/util/blob/490fcebecb936e00c2f2ce2096b679b2fd10865e/db/src/main/java/org/beiter/michael/db/DataSourceFactory.java#L237-L283 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/util/PersistentLongFile.java | PersistentLongFile.writeFile | public static void writeFile(File file, long val) throws IOException {
AtomicFileOutputStream fos = new AtomicFileOutputStream(file);
try {
fos.write(String.valueOf(val).getBytes(Charsets.UTF_8));
fos.write('\n');
fos.close();
fos = null;
} finally {
if (fos != null) {
fos.abort();
}
}
} | java | public static void writeFile(File file, long val) throws IOException {
AtomicFileOutputStream fos = new AtomicFileOutputStream(file);
try {
fos.write(String.valueOf(val).getBytes(Charsets.UTF_8));
fos.write('\n');
fos.close();
fos = null;
} finally {
if (fos != null) {
fos.abort();
}
}
} | [
"public",
"static",
"void",
"writeFile",
"(",
"File",
"file",
",",
"long",
"val",
")",
"throws",
"IOException",
"{",
"AtomicFileOutputStream",
"fos",
"=",
"new",
"AtomicFileOutputStream",
"(",
"file",
")",
";",
"try",
"{",
"fos",
".",
"write",
"(",
"String",... | Atomically write the given value to the given file, including fsyncing.
@param file destination file
@param val value to write
@throws IOException if the file cannot be written | [
"Atomically",
"write",
"the",
"given",
"value",
"to",
"the",
"given",
"file",
"including",
"fsyncing",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/util/PersistentLongFile.java#L77-L89 |
yangjm/winlet | utils/src/main/java/com/aggrepoint/utils/StringUtils.java | StringUtils.fixDBString | public static String fixDBString(String str, int dbLen, int n) {
if (str == null) {
return "";
}
char[] chars = str.toCharArray();
int len = 0;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < chars.length; i++) {
if (Character.UnicodeBlock.of(chars[i]) == Character.UnicodeBlock.BASIC_LATIN) {
len++;
} else {
len += n;
}
if (len > dbLen) {
break;
}
sb.append(chars[i]);
}
return sb.toString();
} | java | public static String fixDBString(String str, int dbLen, int n) {
if (str == null) {
return "";
}
char[] chars = str.toCharArray();
int len = 0;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < chars.length; i++) {
if (Character.UnicodeBlock.of(chars[i]) == Character.UnicodeBlock.BASIC_LATIN) {
len++;
} else {
len += n;
}
if (len > dbLen) {
break;
}
sb.append(chars[i]);
}
return sb.toString();
} | [
"public",
"static",
"String",
"fixDBString",
"(",
"String",
"str",
",",
"int",
"dbLen",
",",
"int",
"n",
")",
"{",
"if",
"(",
"str",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"char",
"[",
"]",
"chars",
"=",
"str",
".",
"toCharArray",
"(",... | 将超出长度的字符截去。
@param str
String 要处理的字符串
@param dbLen
int 长度
@param n
int 每个非拉丁字符在数据库中占据的字节数 | [
"将超出长度的字符截去。"
] | train | https://github.com/yangjm/winlet/blob/2126236f56858e283fa6ad69fe9279ee30f47b67/utils/src/main/java/com/aggrepoint/utils/StringUtils.java#L174-L196 |
landawn/AbacusUtil | src/com/landawn/abacus/util/IntList.java | IntList.allMatch | public <E extends Exception> boolean allMatch(Try.IntPredicate<E> filter) throws E {
return allMatch(0, size(), filter);
} | java | public <E extends Exception> boolean allMatch(Try.IntPredicate<E> filter) throws E {
return allMatch(0, size(), filter);
} | [
"public",
"<",
"E",
"extends",
"Exception",
">",
"boolean",
"allMatch",
"(",
"Try",
".",
"IntPredicate",
"<",
"E",
">",
"filter",
")",
"throws",
"E",
"{",
"return",
"allMatch",
"(",
"0",
",",
"size",
"(",
")",
",",
"filter",
")",
";",
"}"
] | Returns whether all elements of this List match the provided predicate.
@param filter
@return | [
"Returns",
"whether",
"all",
"elements",
"of",
"this",
"List",
"match",
"the",
"provided",
"predicate",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/IntList.java#L987-L989 |
apache/groovy | src/main/java/org/codehaus/groovy/vmplugin/v7/TypeTransformers.java | TypeTransformers.createSAMTransform | private static MethodHandle createSAMTransform(Object arg, Class parameter) {
Method method = CachedSAMClass.getSAMMethod(parameter);
if (method == null) return null;
// TODO: have to think about how to optimize this!
if (parameter.isInterface()) {
if (Traits.isTrait(parameter)) {
// the following code will basically do this:
// Map<String,Closure> impl = Collections.singletonMap(method.getName(),arg);
// return ProxyGenerator.INSTANCE.instantiateAggregate(impl,Collections.singletonList(clazz));
// TO_SAMTRAIT_PROXY is a handle (Object,Object,ProxyGenerator,Class)GroovyObject
// where the second object is the input closure, everything else
// needs to be provide and is in remaining order: method name,
// ProxyGenerator.INSTANCE and singletonList(parameter)
MethodHandle ret = TO_SAMTRAIT_PROXY;
ret = MethodHandles.insertArguments(ret, 2, ProxyGenerator.INSTANCE, Collections.singletonList(parameter));
ret = MethodHandles.insertArguments(ret, 0, method.getName());
return ret;
}
// the following code will basically do this:
// return Proxy.newProxyInstance(
// arg.getClass().getClassLoader(),
// new Class[]{parameter},
// new ConvertedClosure((Closure) arg));
// TO_REFLECTIVE_PROXY will do that for us, though
// input is the closure, the method name, the class loader and the
// class[]. All of that but the closure must be provided here
MethodHandle ret = TO_REFLECTIVE_PROXY;
ret = MethodHandles.insertArguments(ret, 1,
method.getName(),
arg.getClass().getClassLoader(),
new Class[]{parameter});
return ret;
} else {
// the following code will basically do this:
//Map<String, Object> m = Collections.singletonMap(method.getName(), arg);
//return ProxyGenerator.INSTANCE.
// instantiateAggregateFromBaseClass(m, parameter);
// TO_GENERATED_PROXY is a handle (Object,Object,ProxyGenerator,Class)GroovyObject
// where the second object is the input closure, everything else
// needs to be provide and is in remaining order: method name,
// ProxyGenerator.INSTANCE and parameter
MethodHandle ret = TO_GENERATED_PROXY;
ret = MethodHandles.insertArguments(ret, 2, ProxyGenerator.INSTANCE, parameter);
ret = MethodHandles.insertArguments(ret, 0, method.getName());
return ret;
}
} | java | private static MethodHandle createSAMTransform(Object arg, Class parameter) {
Method method = CachedSAMClass.getSAMMethod(parameter);
if (method == null) return null;
// TODO: have to think about how to optimize this!
if (parameter.isInterface()) {
if (Traits.isTrait(parameter)) {
// the following code will basically do this:
// Map<String,Closure> impl = Collections.singletonMap(method.getName(),arg);
// return ProxyGenerator.INSTANCE.instantiateAggregate(impl,Collections.singletonList(clazz));
// TO_SAMTRAIT_PROXY is a handle (Object,Object,ProxyGenerator,Class)GroovyObject
// where the second object is the input closure, everything else
// needs to be provide and is in remaining order: method name,
// ProxyGenerator.INSTANCE and singletonList(parameter)
MethodHandle ret = TO_SAMTRAIT_PROXY;
ret = MethodHandles.insertArguments(ret, 2, ProxyGenerator.INSTANCE, Collections.singletonList(parameter));
ret = MethodHandles.insertArguments(ret, 0, method.getName());
return ret;
}
// the following code will basically do this:
// return Proxy.newProxyInstance(
// arg.getClass().getClassLoader(),
// new Class[]{parameter},
// new ConvertedClosure((Closure) arg));
// TO_REFLECTIVE_PROXY will do that for us, though
// input is the closure, the method name, the class loader and the
// class[]. All of that but the closure must be provided here
MethodHandle ret = TO_REFLECTIVE_PROXY;
ret = MethodHandles.insertArguments(ret, 1,
method.getName(),
arg.getClass().getClassLoader(),
new Class[]{parameter});
return ret;
} else {
// the following code will basically do this:
//Map<String, Object> m = Collections.singletonMap(method.getName(), arg);
//return ProxyGenerator.INSTANCE.
// instantiateAggregateFromBaseClass(m, parameter);
// TO_GENERATED_PROXY is a handle (Object,Object,ProxyGenerator,Class)GroovyObject
// where the second object is the input closure, everything else
// needs to be provide and is in remaining order: method name,
// ProxyGenerator.INSTANCE and parameter
MethodHandle ret = TO_GENERATED_PROXY;
ret = MethodHandles.insertArguments(ret, 2, ProxyGenerator.INSTANCE, parameter);
ret = MethodHandles.insertArguments(ret, 0, method.getName());
return ret;
}
} | [
"private",
"static",
"MethodHandle",
"createSAMTransform",
"(",
"Object",
"arg",
",",
"Class",
"parameter",
")",
"{",
"Method",
"method",
"=",
"CachedSAMClass",
".",
"getSAMMethod",
"(",
"parameter",
")",
";",
"if",
"(",
"method",
"==",
"null",
")",
"return",
... | creates a method handle able to transform the given Closure into a SAM type
if the given parameter is a SAM type | [
"creates",
"a",
"method",
"handle",
"able",
"to",
"transform",
"the",
"given",
"Closure",
"into",
"a",
"SAM",
"type",
"if",
"the",
"given",
"parameter",
"is",
"a",
"SAM",
"type"
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/vmplugin/v7/TypeTransformers.java#L145-L191 |
thinkaurelius/titan | titan-core/src/main/java/com/thinkaurelius/titan/diskstorage/keycolumnvalue/KCVSUtil.java | KCVSUtil.get | public static StaticBuffer get(KeyColumnValueStore store, StaticBuffer key, StaticBuffer column, StoreTransaction txh) throws BackendException {
KeySliceQuery query = new KeySliceQuery(key, column, BufferUtil.nextBiggerBuffer(column)).setLimit(2);
List<Entry> result = store.getSlice(query, txh);
if (result.size() > 1)
log.warn("GET query returned more than 1 result: store {} | key {} | column {}", new Object[]{store.getName(),
key, column});
if (result.isEmpty()) return null;
else return result.get(0).getValueAs(StaticBuffer.STATIC_FACTORY);
} | java | public static StaticBuffer get(KeyColumnValueStore store, StaticBuffer key, StaticBuffer column, StoreTransaction txh) throws BackendException {
KeySliceQuery query = new KeySliceQuery(key, column, BufferUtil.nextBiggerBuffer(column)).setLimit(2);
List<Entry> result = store.getSlice(query, txh);
if (result.size() > 1)
log.warn("GET query returned more than 1 result: store {} | key {} | column {}", new Object[]{store.getName(),
key, column});
if (result.isEmpty()) return null;
else return result.get(0).getValueAs(StaticBuffer.STATIC_FACTORY);
} | [
"public",
"static",
"StaticBuffer",
"get",
"(",
"KeyColumnValueStore",
"store",
",",
"StaticBuffer",
"key",
",",
"StaticBuffer",
"column",
",",
"StoreTransaction",
"txh",
")",
"throws",
"BackendException",
"{",
"KeySliceQuery",
"query",
"=",
"new",
"KeySliceQuery",
... | Retrieves the value for the specified column and key under the given transaction
from the store if such exists, otherwise returns NULL
@param store Store
@param key Key
@param column Column
@param txh Transaction
@return Value for key and column or NULL if such does not exist | [
"Retrieves",
"the",
"value",
"for",
"the",
"specified",
"column",
"and",
"key",
"under",
"the",
"given",
"transaction",
"from",
"the",
"store",
"if",
"such",
"exists",
"otherwise",
"returns",
"NULL"
] | train | https://github.com/thinkaurelius/titan/blob/ee226e52415b8bf43b700afac75fa5b9767993a5/titan-core/src/main/java/com/thinkaurelius/titan/diskstorage/keycolumnvalue/KCVSUtil.java#L37-L46 |
UrielCh/ovh-java-sdk | ovh-java-sdk-vps/src/main/java/net/minidev/ovh/api/ApiOvhVps.java | ApiOvhVps.serviceName_models_GET | public ArrayList<OvhModel> serviceName_models_GET(String serviceName) throws IOException {
String qPath = "/vps/{serviceName}/models";
StringBuilder sb = path(qPath, serviceName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t6);
} | java | public ArrayList<OvhModel> serviceName_models_GET(String serviceName) throws IOException {
String qPath = "/vps/{serviceName}/models";
StringBuilder sb = path(qPath, serviceName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t6);
} | [
"public",
"ArrayList",
"<",
"OvhModel",
">",
"serviceName_models_GET",
"(",
"String",
"serviceName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/vps/{serviceName}/models\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName"... | Return all models for the range of the virtual server
REST: GET /vps/{serviceName}/models
@param serviceName [required] The internal name of your VPS offer | [
"Return",
"all",
"models",
"for",
"the",
"range",
"of",
"the",
"virtual",
"server"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-vps/src/main/java/net/minidev/ovh/api/ApiOvhVps.java#L1023-L1028 |
GeoLatte/geolatte-common | src/main/java/org/geolatte/common/transformer/AbstractObservableTransformer.java | AbstractObservableTransformer.onTransformerErrorOccurred | protected void onTransformerErrorOccurred(Source failedObject, Exception exception) {
for (TransformerEventListener listener : transformerEventListeners)
fireErrorEvent(listener, new TransformerErrorEvent(this, failedObject, exception));
}
/**
* (Re)-fires a preconstructed event.
* @param event The event to fire
*/
protected void onTransformerErrorOccurred(TransformerErrorEvent event) {
for (TransformerEventListener listener : transformerEventListeners)
fireErrorEvent(listener, event);
}
/**
* Fires the given event on the given listener.
* @param listener The listener to fire the event to.
* @param event The event to fire.
*/
private void fireErrorEvent(TransformerEventListener listener, TransformerErrorEvent event) {
try {
listener.ErrorOccurred(event);
}
catch (RuntimeException e) {
// Log this somehow
System.err.println("Exception thrown while trying to invoke event listener, removing bed behaved listener.");
e.printStackTrace();
removeTransformerEventListener(listener);
}
} | java | protected void onTransformerErrorOccurred(Source failedObject, Exception exception) {
for (TransformerEventListener listener : transformerEventListeners)
fireErrorEvent(listener, new TransformerErrorEvent(this, failedObject, exception));
}
/**
* (Re)-fires a preconstructed event.
* @param event The event to fire
*/
protected void onTransformerErrorOccurred(TransformerErrorEvent event) {
for (TransformerEventListener listener : transformerEventListeners)
fireErrorEvent(listener, event);
}
/**
* Fires the given event on the given listener.
* @param listener The listener to fire the event to.
* @param event The event to fire.
*/
private void fireErrorEvent(TransformerEventListener listener, TransformerErrorEvent event) {
try {
listener.ErrorOccurred(event);
}
catch (RuntimeException e) {
// Log this somehow
System.err.println("Exception thrown while trying to invoke event listener, removing bed behaved listener.");
e.printStackTrace();
removeTransformerEventListener(listener);
}
} | [
"protected",
"void",
"onTransformerErrorOccurred",
"(",
"Source",
"failedObject",
",",
"Exception",
"exception",
")",
"{",
"for",
"(",
"TransformerEventListener",
"listener",
":",
"transformerEventListeners",
")",
"fireErrorEvent",
"(",
"listener",
",",
"new",
"Transfor... | Called when an exception occurred. Fires the ErrorOccured event.
@param failedObject The input object that caused the error.
@param exception The exception that was thrown by the Transformation. | [
"Called",
"when",
"an",
"exception",
"occurred",
".",
"Fires",
"the",
"ErrorOccured",
"event",
"."
] | train | https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/transformer/AbstractObservableTransformer.java#L67-L99 |
Syncleus/aparapi | src/main/java/com/aparapi/internal/opencl/OpenCLKernel.java | OpenCLKernel.createKernel | public static OpenCLKernel createKernel(OpenCLProgram _program, String _kernelName, List<OpenCLArgDescriptor> _args) {
final OpenCLArgDescriptor[] argArray = _args.toArray(new OpenCLArgDescriptor[0]);
final OpenCLKernel oclk = new OpenCLKernel().createKernelJNI(_program, _kernelName, argArray);
for (final OpenCLArgDescriptor arg : argArray) {
arg.kernel = oclk;
}
return oclk;
} | java | public static OpenCLKernel createKernel(OpenCLProgram _program, String _kernelName, List<OpenCLArgDescriptor> _args) {
final OpenCLArgDescriptor[] argArray = _args.toArray(new OpenCLArgDescriptor[0]);
final OpenCLKernel oclk = new OpenCLKernel().createKernelJNI(_program, _kernelName, argArray);
for (final OpenCLArgDescriptor arg : argArray) {
arg.kernel = oclk;
}
return oclk;
} | [
"public",
"static",
"OpenCLKernel",
"createKernel",
"(",
"OpenCLProgram",
"_program",
",",
"String",
"_kernelName",
",",
"List",
"<",
"OpenCLArgDescriptor",
">",
"_args",
")",
"{",
"final",
"OpenCLArgDescriptor",
"[",
"]",
"argArray",
"=",
"_args",
".",
"toArray",... | This method is used to create a new Kernel from JNI
@param _program
@param _kernelName
@param _args
@return | [
"This",
"method",
"is",
"used",
"to",
"create",
"a",
"new",
"Kernel",
"from",
"JNI"
] | train | https://github.com/Syncleus/aparapi/blob/6d5892c8e69854b3968c541023de37cf4762bd24/src/main/java/com/aparapi/internal/opencl/OpenCLKernel.java#L58-L65 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.