repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
schallee/alib4j
|
jvm/src/main/java/net/darkmist/alib/jvm/JVMLauncher.java
|
JVMLauncher.getProcessBuilder
|
public static ProcessBuilder getProcessBuilder(String mainClass, List<URL> classPath, List<String> args) throws LauncherException {
"""
Get a process loader for a JVM.
@param mainClass Main class to run
@param classPath List of urls to use for the new JVM's
class path.
@param args Additional command line parameters
@return ProcessBuilder that has not been started.
"""
List<String> cmdList = new ArrayList<String>();
String[] cmdArray;
cmdList.add(getJavaPath());
if(classPath != null && classPath.size() > 0)
{
cmdList.add("-cp");
cmdList.add(mkPath(classPath));
}
cmdList.add(mainClass);
if(args!=null && args.size()>0)
cmdList.addAll(args);
cmdArray = cmdList.toArray(new String[cmdList.size()]);
if(logger.isDebugEnabled())
logger.debug("cmdArray=" + Arrays.toString(cmdArray));
return new ProcessBuilder(cmdArray);
}
|
java
|
public static ProcessBuilder getProcessBuilder(String mainClass, List<URL> classPath, List<String> args) throws LauncherException
{
List<String> cmdList = new ArrayList<String>();
String[] cmdArray;
cmdList.add(getJavaPath());
if(classPath != null && classPath.size() > 0)
{
cmdList.add("-cp");
cmdList.add(mkPath(classPath));
}
cmdList.add(mainClass);
if(args!=null && args.size()>0)
cmdList.addAll(args);
cmdArray = cmdList.toArray(new String[cmdList.size()]);
if(logger.isDebugEnabled())
logger.debug("cmdArray=" + Arrays.toString(cmdArray));
return new ProcessBuilder(cmdArray);
}
|
[
"public",
"static",
"ProcessBuilder",
"getProcessBuilder",
"(",
"String",
"mainClass",
",",
"List",
"<",
"URL",
">",
"classPath",
",",
"List",
"<",
"String",
">",
"args",
")",
"throws",
"LauncherException",
"{",
"List",
"<",
"String",
">",
"cmdList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"String",
"[",
"]",
"cmdArray",
";",
"cmdList",
".",
"add",
"(",
"getJavaPath",
"(",
")",
")",
";",
"if",
"(",
"classPath",
"!=",
"null",
"&&",
"classPath",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"cmdList",
".",
"add",
"(",
"\"-cp\"",
")",
";",
"cmdList",
".",
"add",
"(",
"mkPath",
"(",
"classPath",
")",
")",
";",
"}",
"cmdList",
".",
"add",
"(",
"mainClass",
")",
";",
"if",
"(",
"args",
"!=",
"null",
"&&",
"args",
".",
"size",
"(",
")",
">",
"0",
")",
"cmdList",
".",
"addAll",
"(",
"args",
")",
";",
"cmdArray",
"=",
"cmdList",
".",
"toArray",
"(",
"new",
"String",
"[",
"cmdList",
".",
"size",
"(",
")",
"]",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"cmdArray=\"",
"+",
"Arrays",
".",
"toString",
"(",
"cmdArray",
")",
")",
";",
"return",
"new",
"ProcessBuilder",
"(",
"cmdArray",
")",
";",
"}"
] |
Get a process loader for a JVM.
@param mainClass Main class to run
@param classPath List of urls to use for the new JVM's
class path.
@param args Additional command line parameters
@return ProcessBuilder that has not been started.
|
[
"Get",
"a",
"process",
"loader",
"for",
"a",
"JVM",
"."
] |
train
|
https://github.com/schallee/alib4j/blob/0e0718aee574bbb62268e1cf58e99286529ce529/jvm/src/main/java/net/darkmist/alib/jvm/JVMLauncher.java#L220-L238
|
modelmapper/modelmapper
|
core/src/main/java/org/modelmapper/ModelMapper.java
|
ModelMapper.addConverter
|
@SuppressWarnings("unchecked")
public <S, D> void addConverter(Converter<S, D> converter) {
"""
Registers the {@code converter} to use when mapping instances of types {@code S} to {@code D}.
The {@code converter} will be {@link TypeMap#setConverter(Converter) set} against TypeMap
corresponding to the {@code converter}'s type arguments {@code S} and {@code D}.
@param <S> source type
@param <D> destination type
@param converter to register
@throws IllegalArgumentException if {@code converter} is null or if type arguments {@code S}
and {@code D} are not declared for the {@code converter}
@see TypeMap#setConverter(Converter)
"""
Assert.notNull(converter, "converter");
Class<?>[] typeArguments = TypeResolver.resolveRawArguments(Converter.class, converter.getClass());
Assert.notNull(typeArguments, "Must declare source type argument <S> and destination type argument <D> for converter");
config.typeMapStore.<S, D>getOrCreate(null, (Class<S>) typeArguments[0],
(Class<D>) typeArguments[1], null, null, converter, engine);
}
|
java
|
@SuppressWarnings("unchecked")
public <S, D> void addConverter(Converter<S, D> converter) {
Assert.notNull(converter, "converter");
Class<?>[] typeArguments = TypeResolver.resolveRawArguments(Converter.class, converter.getClass());
Assert.notNull(typeArguments, "Must declare source type argument <S> and destination type argument <D> for converter");
config.typeMapStore.<S, D>getOrCreate(null, (Class<S>) typeArguments[0],
(Class<D>) typeArguments[1], null, null, converter, engine);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"S",
",",
"D",
">",
"void",
"addConverter",
"(",
"Converter",
"<",
"S",
",",
"D",
">",
"converter",
")",
"{",
"Assert",
".",
"notNull",
"(",
"converter",
",",
"\"converter\"",
")",
";",
"Class",
"<",
"?",
">",
"[",
"]",
"typeArguments",
"=",
"TypeResolver",
".",
"resolveRawArguments",
"(",
"Converter",
".",
"class",
",",
"converter",
".",
"getClass",
"(",
")",
")",
";",
"Assert",
".",
"notNull",
"(",
"typeArguments",
",",
"\"Must declare source type argument <S> and destination type argument <D> for converter\"",
")",
";",
"config",
".",
"typeMapStore",
".",
"<",
"S",
",",
"D",
">",
"getOrCreate",
"(",
"null",
",",
"(",
"Class",
"<",
"S",
">",
")",
"typeArguments",
"[",
"0",
"]",
",",
"(",
"Class",
"<",
"D",
">",
")",
"typeArguments",
"[",
"1",
"]",
",",
"null",
",",
"null",
",",
"converter",
",",
"engine",
")",
";",
"}"
] |
Registers the {@code converter} to use when mapping instances of types {@code S} to {@code D}.
The {@code converter} will be {@link TypeMap#setConverter(Converter) set} against TypeMap
corresponding to the {@code converter}'s type arguments {@code S} and {@code D}.
@param <S> source type
@param <D> destination type
@param converter to register
@throws IllegalArgumentException if {@code converter} is null or if type arguments {@code S}
and {@code D} are not declared for the {@code converter}
@see TypeMap#setConverter(Converter)
|
[
"Registers",
"the",
"{",
"@code",
"converter",
"}",
"to",
"use",
"when",
"mapping",
"instances",
"of",
"types",
"{",
"@code",
"S",
"}",
"to",
"{",
"@code",
"D",
"}",
".",
"The",
"{",
"@code",
"converter",
"}",
"will",
"be",
"{",
"@link",
"TypeMap#setConverter",
"(",
"Converter",
")",
"set",
"}",
"against",
"TypeMap",
"corresponding",
"to",
"the",
"{",
"@code",
"converter",
"}",
"s",
"type",
"arguments",
"{",
"@code",
"S",
"}",
"and",
"{",
"@code",
"D",
"}",
"."
] |
train
|
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/ModelMapper.java#L70-L77
|
sarl/sarl
|
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/InternalEventBusSkill.java
|
InternalEventBusSkill.runInitializationStage
|
private void runInitializationStage(Event event) {
"""
This function runs the initialization of the agent.
@param event the {@link Initialize} occurrence.
"""
// Immediate synchronous dispatching of Initialize event
try {
setOwnerState(OwnerState.INITIALIZING);
try {
this.eventDispatcher.immediateDispatch(event);
} finally {
setOwnerState(OwnerState.ALIVE);
}
this.agentAsEventListener.fireEnqueuedEvents(this);
if (this.agentAsEventListener.isKilled.get()) {
this.agentAsEventListener.killOwner(InternalEventBusSkill.this);
}
} catch (Exception e) {
// Log the exception
final Logging loggingCapacity = getLoggingSkill();
if (loggingCapacity != null) {
loggingCapacity.error(Messages.InternalEventBusSkill_3, e);
} else {
final LogRecord record = new LogRecord(Level.SEVERE, Messages.InternalEventBusSkill_3);
this.logger.getKernelLogger().log(
this.logger.prepareLogRecord(record, this.logger.getKernelLogger().getName(),
Throwables.getRootCause(e)));
}
// If we have an exception within the agent's initialization, we kill the agent.
setOwnerState(OwnerState.ALIVE);
// Asynchronous kill of the event.
this.agentAsEventListener.killOrMarkAsKilled();
}
}
|
java
|
private void runInitializationStage(Event event) {
// Immediate synchronous dispatching of Initialize event
try {
setOwnerState(OwnerState.INITIALIZING);
try {
this.eventDispatcher.immediateDispatch(event);
} finally {
setOwnerState(OwnerState.ALIVE);
}
this.agentAsEventListener.fireEnqueuedEvents(this);
if (this.agentAsEventListener.isKilled.get()) {
this.agentAsEventListener.killOwner(InternalEventBusSkill.this);
}
} catch (Exception e) {
// Log the exception
final Logging loggingCapacity = getLoggingSkill();
if (loggingCapacity != null) {
loggingCapacity.error(Messages.InternalEventBusSkill_3, e);
} else {
final LogRecord record = new LogRecord(Level.SEVERE, Messages.InternalEventBusSkill_3);
this.logger.getKernelLogger().log(
this.logger.prepareLogRecord(record, this.logger.getKernelLogger().getName(),
Throwables.getRootCause(e)));
}
// If we have an exception within the agent's initialization, we kill the agent.
setOwnerState(OwnerState.ALIVE);
// Asynchronous kill of the event.
this.agentAsEventListener.killOrMarkAsKilled();
}
}
|
[
"private",
"void",
"runInitializationStage",
"(",
"Event",
"event",
")",
"{",
"// Immediate synchronous dispatching of Initialize event",
"try",
"{",
"setOwnerState",
"(",
"OwnerState",
".",
"INITIALIZING",
")",
";",
"try",
"{",
"this",
".",
"eventDispatcher",
".",
"immediateDispatch",
"(",
"event",
")",
";",
"}",
"finally",
"{",
"setOwnerState",
"(",
"OwnerState",
".",
"ALIVE",
")",
";",
"}",
"this",
".",
"agentAsEventListener",
".",
"fireEnqueuedEvents",
"(",
"this",
")",
";",
"if",
"(",
"this",
".",
"agentAsEventListener",
".",
"isKilled",
".",
"get",
"(",
")",
")",
"{",
"this",
".",
"agentAsEventListener",
".",
"killOwner",
"(",
"InternalEventBusSkill",
".",
"this",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Log the exception",
"final",
"Logging",
"loggingCapacity",
"=",
"getLoggingSkill",
"(",
")",
";",
"if",
"(",
"loggingCapacity",
"!=",
"null",
")",
"{",
"loggingCapacity",
".",
"error",
"(",
"Messages",
".",
"InternalEventBusSkill_3",
",",
"e",
")",
";",
"}",
"else",
"{",
"final",
"LogRecord",
"record",
"=",
"new",
"LogRecord",
"(",
"Level",
".",
"SEVERE",
",",
"Messages",
".",
"InternalEventBusSkill_3",
")",
";",
"this",
".",
"logger",
".",
"getKernelLogger",
"(",
")",
".",
"log",
"(",
"this",
".",
"logger",
".",
"prepareLogRecord",
"(",
"record",
",",
"this",
".",
"logger",
".",
"getKernelLogger",
"(",
")",
".",
"getName",
"(",
")",
",",
"Throwables",
".",
"getRootCause",
"(",
"e",
")",
")",
")",
";",
"}",
"// If we have an exception within the agent's initialization, we kill the agent.",
"setOwnerState",
"(",
"OwnerState",
".",
"ALIVE",
")",
";",
"// Asynchronous kill of the event.",
"this",
".",
"agentAsEventListener",
".",
"killOrMarkAsKilled",
"(",
")",
";",
"}",
"}"
] |
This function runs the initialization of the agent.
@param event the {@link Initialize} occurrence.
|
[
"This",
"function",
"runs",
"the",
"initialization",
"of",
"the",
"agent",
"."
] |
train
|
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/InternalEventBusSkill.java#L237-L266
|
intive-FDV/DynamicJasper
|
src/main/java/ar/com/fdvs/dj/domain/chart/builder/DJBarChartBuilder.java
|
DJBarChartBuilder.addSerie
|
public DJBarChartBuilder addSerie(AbstractColumn column, StringExpression labelExpression) {
"""
Adds the specified serie column to the dataset with custom label.
@param column the serie column
"""
getDataset().addSerie(column, labelExpression);
return this;
}
|
java
|
public DJBarChartBuilder addSerie(AbstractColumn column, StringExpression labelExpression) {
getDataset().addSerie(column, labelExpression);
return this;
}
|
[
"public",
"DJBarChartBuilder",
"addSerie",
"(",
"AbstractColumn",
"column",
",",
"StringExpression",
"labelExpression",
")",
"{",
"getDataset",
"(",
")",
".",
"addSerie",
"(",
"column",
",",
"labelExpression",
")",
";",
"return",
"this",
";",
"}"
] |
Adds the specified serie column to the dataset with custom label.
@param column the serie column
|
[
"Adds",
"the",
"specified",
"serie",
"column",
"to",
"the",
"dataset",
"with",
"custom",
"label",
"."
] |
train
|
https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/domain/chart/builder/DJBarChartBuilder.java#L376-L379
|
netty/netty
|
buffer/src/main/java/io/netty/buffer/ByteBufUtil.java
|
ByteBufUtil.indexOf
|
public static int indexOf(ByteBuf needle, ByteBuf haystack) {
"""
Returns the reader index of needle in haystack, or -1 if needle is not in haystack.
"""
// TODO: maybe use Boyer Moore for efficiency.
int attempts = haystack.readableBytes() - needle.readableBytes() + 1;
for (int i = 0; i < attempts; i++) {
if (equals(needle, needle.readerIndex(),
haystack, haystack.readerIndex() + i,
needle.readableBytes())) {
return haystack.readerIndex() + i;
}
}
return -1;
}
|
java
|
public static int indexOf(ByteBuf needle, ByteBuf haystack) {
// TODO: maybe use Boyer Moore for efficiency.
int attempts = haystack.readableBytes() - needle.readableBytes() + 1;
for (int i = 0; i < attempts; i++) {
if (equals(needle, needle.readerIndex(),
haystack, haystack.readerIndex() + i,
needle.readableBytes())) {
return haystack.readerIndex() + i;
}
}
return -1;
}
|
[
"public",
"static",
"int",
"indexOf",
"(",
"ByteBuf",
"needle",
",",
"ByteBuf",
"haystack",
")",
"{",
"// TODO: maybe use Boyer Moore for efficiency.",
"int",
"attempts",
"=",
"haystack",
".",
"readableBytes",
"(",
")",
"-",
"needle",
".",
"readableBytes",
"(",
")",
"+",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"attempts",
";",
"i",
"++",
")",
"{",
"if",
"(",
"equals",
"(",
"needle",
",",
"needle",
".",
"readerIndex",
"(",
")",
",",
"haystack",
",",
"haystack",
".",
"readerIndex",
"(",
")",
"+",
"i",
",",
"needle",
".",
"readableBytes",
"(",
")",
")",
")",
"{",
"return",
"haystack",
".",
"readerIndex",
"(",
")",
"+",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Returns the reader index of needle in haystack, or -1 if needle is not in haystack.
|
[
"Returns",
"the",
"reader",
"index",
"of",
"needle",
"in",
"haystack",
"or",
"-",
"1",
"if",
"needle",
"is",
"not",
"in",
"haystack",
"."
] |
train
|
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java#L210-L221
|
future-architect/uroborosql
|
src/main/java/jp/co/future/uroborosql/config/DefaultSqlConfig.java
|
DefaultSqlConfig.getConfig
|
public static SqlConfig getConfig(final String url, final String user, final String password, final String schema,
final boolean autoCommit, final boolean readOnly) {
"""
DB接続情報を指定してSqlConfigを取得する
@param url JDBC接続URL
@param user JDBC接続ユーザ
@param password JDBC接続パスワード
@param schema JDBCスキーマ名
@param autoCommit 自動コミットするかどうか. 自動コミットの場合<code>true</code>
@param readOnly 参照のみかどうか. 参照のみの場合<code>true</code>
@return SqlConfigオブジェクト
"""
return new DefaultSqlConfig(new JdbcConnectionSupplierImpl(url, user, password, schema, autoCommit, readOnly),
null);
}
|
java
|
public static SqlConfig getConfig(final String url, final String user, final String password, final String schema,
final boolean autoCommit, final boolean readOnly) {
return new DefaultSqlConfig(new JdbcConnectionSupplierImpl(url, user, password, schema, autoCommit, readOnly),
null);
}
|
[
"public",
"static",
"SqlConfig",
"getConfig",
"(",
"final",
"String",
"url",
",",
"final",
"String",
"user",
",",
"final",
"String",
"password",
",",
"final",
"String",
"schema",
",",
"final",
"boolean",
"autoCommit",
",",
"final",
"boolean",
"readOnly",
")",
"{",
"return",
"new",
"DefaultSqlConfig",
"(",
"new",
"JdbcConnectionSupplierImpl",
"(",
"url",
",",
"user",
",",
"password",
",",
"schema",
",",
"autoCommit",
",",
"readOnly",
")",
",",
"null",
")",
";",
"}"
] |
DB接続情報を指定してSqlConfigを取得する
@param url JDBC接続URL
@param user JDBC接続ユーザ
@param password JDBC接続パスワード
@param schema JDBCスキーマ名
@param autoCommit 自動コミットするかどうか. 自動コミットの場合<code>true</code>
@param readOnly 参照のみかどうか. 参照のみの場合<code>true</code>
@return SqlConfigオブジェクト
|
[
"DB接続情報を指定してSqlConfigを取得する"
] |
train
|
https://github.com/future-architect/uroborosql/blob/4c26db51defdac3c6ed16866e33ab45e190e2e0c/src/main/java/jp/co/future/uroborosql/config/DefaultSqlConfig.java#L152-L156
|
RestComm/jss7
|
mtp/mtp-impl/src/main/java/org/restcomm/protocols/ss7/mtp/util/MTPUtility.java
|
MTPUtility.getFromSif_OPC
|
public static final int getFromSif_OPC(byte[] sif, int shift) {
"""
Retrieves OPC from SIF. SIF starts from byte 1 in MSU. For MSU [SIO,DPC,OPC,SLS,Data], call would look as following: int
opc = getFromSif_OPC(MSU,1);
@param sif - byte[] - either SIF or MSU
@param shift - shift in passed byte[]. For MSU its 1. For SIF part of MSU it will be 0;
@return
"""
int opc = ((sif[1 + shift] & 0xC0) >> 6) | ((sif[2 + shift] & 0xff) << 2) | ((sif[3 + shift] & 0x0f) << 10);
return opc;
}
|
java
|
public static final int getFromSif_OPC(byte[] sif, int shift) {
int opc = ((sif[1 + shift] & 0xC0) >> 6) | ((sif[2 + shift] & 0xff) << 2) | ((sif[3 + shift] & 0x0f) << 10);
return opc;
}
|
[
"public",
"static",
"final",
"int",
"getFromSif_OPC",
"(",
"byte",
"[",
"]",
"sif",
",",
"int",
"shift",
")",
"{",
"int",
"opc",
"=",
"(",
"(",
"sif",
"[",
"1",
"+",
"shift",
"]",
"&",
"0xC0",
")",
">>",
"6",
")",
"|",
"(",
"(",
"sif",
"[",
"2",
"+",
"shift",
"]",
"&",
"0xff",
")",
"<<",
"2",
")",
"|",
"(",
"(",
"sif",
"[",
"3",
"+",
"shift",
"]",
"&",
"0x0f",
")",
"<<",
"10",
")",
";",
"return",
"opc",
";",
"}"
] |
Retrieves OPC from SIF. SIF starts from byte 1 in MSU. For MSU [SIO,DPC,OPC,SLS,Data], call would look as following: int
opc = getFromSif_OPC(MSU,1);
@param sif - byte[] - either SIF or MSU
@param shift - shift in passed byte[]. For MSU its 1. For SIF part of MSU it will be 0;
@return
|
[
"Retrieves",
"OPC",
"from",
"SIF",
".",
"SIF",
"starts",
"from",
"byte",
"1",
"in",
"MSU",
".",
"For",
"MSU",
"[",
"SIO",
"DPC",
"OPC",
"SLS",
"Data",
"]",
"call",
"would",
"look",
"as",
"following",
":",
"int",
"opc",
"=",
"getFromSif_OPC",
"(",
"MSU",
"1",
")",
";"
] |
train
|
https://github.com/RestComm/jss7/blob/402b4b3984e581c581e309cb5f6a858fde6dbc33/mtp/mtp-impl/src/main/java/org/restcomm/protocols/ss7/mtp/util/MTPUtility.java#L70-L73
|
Stratio/deep-spark
|
deep-mongodb/src/main/java/com/stratio/deep/mongodb/utils/UtilMongoDB.java
|
UtilMongoDB.getObjectFromBson
|
public static <T> T getObjectFromBson(Class<T> classEntity, BSONObject bsonObject)
throws IllegalAccessException, InstantiationException, InvocationTargetException {
"""
converts from BsonObject to an entity class with deep's anotations
@param classEntity the entity name.
@param bsonObject the instance of the BSONObjet to convert.
@return the provided bsonObject converted to an instance of T.
@throws IllegalAccessException the illegal access exception
@throws IllegalAccessException the instantiation exception
@throws IllegalAccessException the invocation target exception
"""
T t = classEntity.newInstance();
Field[] fields = AnnotationUtils.filterDeepFields(classEntity);
Object insert = null;
for (Field field : fields) {
Object currentBson = null;
Method method = null;
try {
method = Utils.findSetter(field.getName(), classEntity, field.getType());
Class<?> classField = field.getType();
currentBson = bsonObject.get(AnnotationUtils.deepFieldName(field));
if (currentBson != null) {
if (Iterable.class.isAssignableFrom(classField)) {
Type type = field.getGenericType();
insert = subDocumentListCase(type, (List) bsonObject.get(AnnotationUtils.deepFieldName(field)));
} else if (IDeepType.class.isAssignableFrom(classField)) {
insert = getObjectFromBson(classField, (BSONObject) bsonObject.get(AnnotationUtils.deepFieldName
(field)));
} else {
insert = currentBson;
}
method.invoke(t, insert);
}
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | IllegalArgumentException e) {
LOG.error("impossible to create a java object from Bson field:" + field.getName() + " and type:" + field
.getType() + " and value:" + t + "; bsonReceived:" + currentBson + ", bsonClassReceived:"
+ currentBson.getClass());
method.invoke(t, Utils.castNumberType(insert, t.getClass()));
}
}
return t;
}
|
java
|
public static <T> T getObjectFromBson(Class<T> classEntity, BSONObject bsonObject)
throws IllegalAccessException, InstantiationException, InvocationTargetException {
T t = classEntity.newInstance();
Field[] fields = AnnotationUtils.filterDeepFields(classEntity);
Object insert = null;
for (Field field : fields) {
Object currentBson = null;
Method method = null;
try {
method = Utils.findSetter(field.getName(), classEntity, field.getType());
Class<?> classField = field.getType();
currentBson = bsonObject.get(AnnotationUtils.deepFieldName(field));
if (currentBson != null) {
if (Iterable.class.isAssignableFrom(classField)) {
Type type = field.getGenericType();
insert = subDocumentListCase(type, (List) bsonObject.get(AnnotationUtils.deepFieldName(field)));
} else if (IDeepType.class.isAssignableFrom(classField)) {
insert = getObjectFromBson(classField, (BSONObject) bsonObject.get(AnnotationUtils.deepFieldName
(field)));
} else {
insert = currentBson;
}
method.invoke(t, insert);
}
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | IllegalArgumentException e) {
LOG.error("impossible to create a java object from Bson field:" + field.getName() + " and type:" + field
.getType() + " and value:" + t + "; bsonReceived:" + currentBson + ", bsonClassReceived:"
+ currentBson.getClass());
method.invoke(t, Utils.castNumberType(insert, t.getClass()));
}
}
return t;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"getObjectFromBson",
"(",
"Class",
"<",
"T",
">",
"classEntity",
",",
"BSONObject",
"bsonObject",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"InvocationTargetException",
"{",
"T",
"t",
"=",
"classEntity",
".",
"newInstance",
"(",
")",
";",
"Field",
"[",
"]",
"fields",
"=",
"AnnotationUtils",
".",
"filterDeepFields",
"(",
"classEntity",
")",
";",
"Object",
"insert",
"=",
"null",
";",
"for",
"(",
"Field",
"field",
":",
"fields",
")",
"{",
"Object",
"currentBson",
"=",
"null",
";",
"Method",
"method",
"=",
"null",
";",
"try",
"{",
"method",
"=",
"Utils",
".",
"findSetter",
"(",
"field",
".",
"getName",
"(",
")",
",",
"classEntity",
",",
"field",
".",
"getType",
"(",
")",
")",
";",
"Class",
"<",
"?",
">",
"classField",
"=",
"field",
".",
"getType",
"(",
")",
";",
"currentBson",
"=",
"bsonObject",
".",
"get",
"(",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
")",
";",
"if",
"(",
"currentBson",
"!=",
"null",
")",
"{",
"if",
"(",
"Iterable",
".",
"class",
".",
"isAssignableFrom",
"(",
"classField",
")",
")",
"{",
"Type",
"type",
"=",
"field",
".",
"getGenericType",
"(",
")",
";",
"insert",
"=",
"subDocumentListCase",
"(",
"type",
",",
"(",
"List",
")",
"bsonObject",
".",
"get",
"(",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"IDeepType",
".",
"class",
".",
"isAssignableFrom",
"(",
"classField",
")",
")",
"{",
"insert",
"=",
"getObjectFromBson",
"(",
"classField",
",",
"(",
"BSONObject",
")",
"bsonObject",
".",
"get",
"(",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
")",
")",
";",
"}",
"else",
"{",
"insert",
"=",
"currentBson",
";",
"}",
"method",
".",
"invoke",
"(",
"t",
",",
"insert",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"InstantiationException",
"|",
"InvocationTargetException",
"|",
"IllegalArgumentException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"impossible to create a java object from Bson field:\"",
"+",
"field",
".",
"getName",
"(",
")",
"+",
"\" and type:\"",
"+",
"field",
".",
"getType",
"(",
")",
"+",
"\" and value:\"",
"+",
"t",
"+",
"\"; bsonReceived:\"",
"+",
"currentBson",
"+",
"\", bsonClassReceived:\"",
"+",
"currentBson",
".",
"getClass",
"(",
")",
")",
";",
"method",
".",
"invoke",
"(",
"t",
",",
"Utils",
".",
"castNumberType",
"(",
"insert",
",",
"t",
".",
"getClass",
"(",
")",
")",
")",
";",
"}",
"}",
"return",
"t",
";",
"}"
] |
converts from BsonObject to an entity class with deep's anotations
@param classEntity the entity name.
@param bsonObject the instance of the BSONObjet to convert.
@return the provided bsonObject converted to an instance of T.
@throws IllegalAccessException the illegal access exception
@throws IllegalAccessException the instantiation exception
@throws IllegalAccessException the invocation target exception
|
[
"converts",
"from",
"BsonObject",
"to",
"an",
"entity",
"class",
"with",
"deep",
"s",
"anotations"
] |
train
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/utils/UtilMongoDB.java#L77-L120
|
lievendoclo/Valkyrie-RCP
|
valkyrie-rcp-core/src/main/java/org/valkyriercp/layout/GridBagLayoutBuilder.java
|
GridBagLayoutBuilder.appendField
|
public GridBagLayoutBuilder appendField(Component component, int colSpan) {
"""
Appends the given component to the end of the current line. The component
will "grow" horizontally as space allows.
@param component the item to append
@param colSpan the number of columns to span
@return "this" to make it easier to string together append calls
"""
return append(component, colSpan, 1, true, false);
}
|
java
|
public GridBagLayoutBuilder appendField(Component component, int colSpan) {
return append(component, colSpan, 1, true, false);
}
|
[
"public",
"GridBagLayoutBuilder",
"appendField",
"(",
"Component",
"component",
",",
"int",
"colSpan",
")",
"{",
"return",
"append",
"(",
"component",
",",
"colSpan",
",",
"1",
",",
"true",
",",
"false",
")",
";",
"}"
] |
Appends the given component to the end of the current line. The component
will "grow" horizontally as space allows.
@param component the item to append
@param colSpan the number of columns to span
@return "this" to make it easier to string together append calls
|
[
"Appends",
"the",
"given",
"component",
"to",
"the",
"end",
"of",
"the",
"current",
"line",
".",
"The",
"component",
"will",
"grow",
"horizontally",
"as",
"space",
"allows",
"."
] |
train
|
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/layout/GridBagLayoutBuilder.java#L562-L564
|
EdwardRaff/JSAT
|
JSAT/src/jsat/text/topicmodel/OnlineLDAsvi.java
|
OnlineLDAsvi.prepareGammaTheta
|
private void prepareGammaTheta(Vec gamma_i, Vec eLogTheta_i, Vec expLogTheta_i, Random rand) {
"""
Prepares gamma and the associated theta expectations are initialized so
that the iterative updates to them can begin.
@param gamma_i will be completely overwritten
@param eLogTheta_i will be completely overwritten
@param expLogTheta_i will be completely overwritten
@param rand the source of randomness
"""
final double lambdaInv = (W * K) / (D * 100.0);
for (int j = 0; j < gamma_i.length(); j++)
gamma_i.set(j, sampleExpoDist(lambdaInv, rand.nextDouble()) + eta);
expandPsiMinusPsiSum(gamma_i, gamma_i.sum(), eLogTheta_i);
for (int j = 0; j < eLogTheta_i.length(); j++)
expLogTheta_i.set(j, FastMath.exp(eLogTheta_i.get(j)));
}
|
java
|
private void prepareGammaTheta(Vec gamma_i, Vec eLogTheta_i, Vec expLogTheta_i, Random rand)
{
final double lambdaInv = (W * K) / (D * 100.0);
for (int j = 0; j < gamma_i.length(); j++)
gamma_i.set(j, sampleExpoDist(lambdaInv, rand.nextDouble()) + eta);
expandPsiMinusPsiSum(gamma_i, gamma_i.sum(), eLogTheta_i);
for (int j = 0; j < eLogTheta_i.length(); j++)
expLogTheta_i.set(j, FastMath.exp(eLogTheta_i.get(j)));
}
|
[
"private",
"void",
"prepareGammaTheta",
"(",
"Vec",
"gamma_i",
",",
"Vec",
"eLogTheta_i",
",",
"Vec",
"expLogTheta_i",
",",
"Random",
"rand",
")",
"{",
"final",
"double",
"lambdaInv",
"=",
"(",
"W",
"*",
"K",
")",
"/",
"(",
"D",
"*",
"100.0",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"gamma_i",
".",
"length",
"(",
")",
";",
"j",
"++",
")",
"gamma_i",
".",
"set",
"(",
"j",
",",
"sampleExpoDist",
"(",
"lambdaInv",
",",
"rand",
".",
"nextDouble",
"(",
")",
")",
"+",
"eta",
")",
";",
"expandPsiMinusPsiSum",
"(",
"gamma_i",
",",
"gamma_i",
".",
"sum",
"(",
")",
",",
"eLogTheta_i",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"eLogTheta_i",
".",
"length",
"(",
")",
";",
"j",
"++",
")",
"expLogTheta_i",
".",
"set",
"(",
"j",
",",
"FastMath",
".",
"exp",
"(",
"eLogTheta_i",
".",
"get",
"(",
"j",
")",
")",
")",
";",
"}"
] |
Prepares gamma and the associated theta expectations are initialized so
that the iterative updates to them can begin.
@param gamma_i will be completely overwritten
@param eLogTheta_i will be completely overwritten
@param expLogTheta_i will be completely overwritten
@param rand the source of randomness
|
[
"Prepares",
"gamma",
"and",
"the",
"associated",
"theta",
"expectations",
"are",
"initialized",
"so",
"that",
"the",
"iterative",
"updates",
"to",
"them",
"can",
"begin",
"."
] |
train
|
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/text/topicmodel/OnlineLDAsvi.java#L678-L687
|
TheCoder4eu/BootsFaces-OSP
|
src/main/java/net/bootsfaces/component/badge/BadgeRenderer.java
|
BadgeRenderer.encodeBegin
|
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
"""
This methods generates the HTML code of the current b:badge.
@param context
the FacesContext.
@param component
the current b:badge.
@throws IOException
thrown if something goes wrong when writing the HTML code.
"""
if (!component.isRendered()) {
return;
}
Badge badge = (Badge) component;
ResponseWriter rw = context.getResponseWriter();
String clientId = badge.getClientId();
if (!component.isRendered()) {
return;
}
String styleClass = badge.getStyleClass();
String style=badge.getStyle();
String val = getValue2Render(context, badge);
generateBadge(context, badge, rw, clientId, styleClass, style, val, null);
}
|
java
|
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
if (!component.isRendered()) {
return;
}
Badge badge = (Badge) component;
ResponseWriter rw = context.getResponseWriter();
String clientId = badge.getClientId();
if (!component.isRendered()) {
return;
}
String styleClass = badge.getStyleClass();
String style=badge.getStyle();
String val = getValue2Render(context, badge);
generateBadge(context, badge, rw, clientId, styleClass, style, val, null);
}
|
[
"@",
"Override",
"public",
"void",
"encodeBegin",
"(",
"FacesContext",
"context",
",",
"UIComponent",
"component",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"component",
".",
"isRendered",
"(",
")",
")",
"{",
"return",
";",
"}",
"Badge",
"badge",
"=",
"(",
"Badge",
")",
"component",
";",
"ResponseWriter",
"rw",
"=",
"context",
".",
"getResponseWriter",
"(",
")",
";",
"String",
"clientId",
"=",
"badge",
".",
"getClientId",
"(",
")",
";",
"if",
"(",
"!",
"component",
".",
"isRendered",
"(",
")",
")",
"{",
"return",
";",
"}",
"String",
"styleClass",
"=",
"badge",
".",
"getStyleClass",
"(",
")",
";",
"String",
"style",
"=",
"badge",
".",
"getStyle",
"(",
")",
";",
"String",
"val",
"=",
"getValue2Render",
"(",
"context",
",",
"badge",
")",
";",
"generateBadge",
"(",
"context",
",",
"badge",
",",
"rw",
",",
"clientId",
",",
"styleClass",
",",
"style",
",",
"val",
",",
"null",
")",
";",
"}"
] |
This methods generates the HTML code of the current b:badge.
@param context
the FacesContext.
@param component
the current b:badge.
@throws IOException
thrown if something goes wrong when writing the HTML code.
|
[
"This",
"methods",
"generates",
"the",
"HTML",
"code",
"of",
"the",
"current",
"b",
":",
"badge",
"."
] |
train
|
https://github.com/TheCoder4eu/BootsFaces-OSP/blob/d1a70952bc240979b5272fa4fe1c7f100873add0/src/main/java/net/bootsfaces/component/badge/BadgeRenderer.java#L47-L64
|
geomajas/geomajas-project-client-gwt
|
client/src/main/java/org/geomajas/gwt/client/gfx/context/VmlStyleUtil.java
|
VmlStyleUtil.applyShapeStyle
|
private static void applyShapeStyle(Element element, ShapeStyle style) {
"""
When applying ShapeStyles, we create child elements for fill and stroke. According to Microsoft, this is the
proper way to go.
"""
// First check the presence of the fill and stroke elements:
NodeList<Element> fills = element.getElementsByTagName("fill");
if (fills.getLength() == 0) {
Element stroke = Dom.createElementNS(Dom.NS_VML, "stroke");
element.appendChild(stroke);
Element fill = Dom.createElementNS(Dom.NS_VML, "fill");
element.appendChild(fill);
fills = element.getElementsByTagName("fill");
}
// Then if fill-color then filled=true:
if (style.getFillColor() != null) {
element.setAttribute("filled", "true");
fills.getItem(0).setAttribute("color", style.getFillColor());
fills.getItem(0).setAttribute("opacity", Float.toString(style.getFillOpacity()));
} else {
element.setAttribute("filled", "false");
}
// Then if stroke-color then stroke=true:
if (style.getStrokeColor() != null) {
element.setAttribute("stroked", "true");
NodeList<Element> strokes = element.getElementsByTagName("stroke");
strokes.getItem(0).setAttribute("color", style.getStrokeColor());
strokes.getItem(0).setAttribute("opacity", Float.toString(style.getStrokeOpacity()));
element.setAttribute("strokeweight", Float.toString(style.getStrokeWidth()));
} else {
element.setAttribute("stroked", "false");
}
}
|
java
|
private static void applyShapeStyle(Element element, ShapeStyle style) {
// First check the presence of the fill and stroke elements:
NodeList<Element> fills = element.getElementsByTagName("fill");
if (fills.getLength() == 0) {
Element stroke = Dom.createElementNS(Dom.NS_VML, "stroke");
element.appendChild(stroke);
Element fill = Dom.createElementNS(Dom.NS_VML, "fill");
element.appendChild(fill);
fills = element.getElementsByTagName("fill");
}
// Then if fill-color then filled=true:
if (style.getFillColor() != null) {
element.setAttribute("filled", "true");
fills.getItem(0).setAttribute("color", style.getFillColor());
fills.getItem(0).setAttribute("opacity", Float.toString(style.getFillOpacity()));
} else {
element.setAttribute("filled", "false");
}
// Then if stroke-color then stroke=true:
if (style.getStrokeColor() != null) {
element.setAttribute("stroked", "true");
NodeList<Element> strokes = element.getElementsByTagName("stroke");
strokes.getItem(0).setAttribute("color", style.getStrokeColor());
strokes.getItem(0).setAttribute("opacity", Float.toString(style.getStrokeOpacity()));
element.setAttribute("strokeweight", Float.toString(style.getStrokeWidth()));
} else {
element.setAttribute("stroked", "false");
}
}
|
[
"private",
"static",
"void",
"applyShapeStyle",
"(",
"Element",
"element",
",",
"ShapeStyle",
"style",
")",
"{",
"// First check the presence of the fill and stroke elements:",
"NodeList",
"<",
"Element",
">",
"fills",
"=",
"element",
".",
"getElementsByTagName",
"(",
"\"fill\"",
")",
";",
"if",
"(",
"fills",
".",
"getLength",
"(",
")",
"==",
"0",
")",
"{",
"Element",
"stroke",
"=",
"Dom",
".",
"createElementNS",
"(",
"Dom",
".",
"NS_VML",
",",
"\"stroke\"",
")",
";",
"element",
".",
"appendChild",
"(",
"stroke",
")",
";",
"Element",
"fill",
"=",
"Dom",
".",
"createElementNS",
"(",
"Dom",
".",
"NS_VML",
",",
"\"fill\"",
")",
";",
"element",
".",
"appendChild",
"(",
"fill",
")",
";",
"fills",
"=",
"element",
".",
"getElementsByTagName",
"(",
"\"fill\"",
")",
";",
"}",
"// Then if fill-color then filled=true:",
"if",
"(",
"style",
".",
"getFillColor",
"(",
")",
"!=",
"null",
")",
"{",
"element",
".",
"setAttribute",
"(",
"\"filled\"",
",",
"\"true\"",
")",
";",
"fills",
".",
"getItem",
"(",
"0",
")",
".",
"setAttribute",
"(",
"\"color\"",
",",
"style",
".",
"getFillColor",
"(",
")",
")",
";",
"fills",
".",
"getItem",
"(",
"0",
")",
".",
"setAttribute",
"(",
"\"opacity\"",
",",
"Float",
".",
"toString",
"(",
"style",
".",
"getFillOpacity",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"element",
".",
"setAttribute",
"(",
"\"filled\"",
",",
"\"false\"",
")",
";",
"}",
"// Then if stroke-color then stroke=true:",
"if",
"(",
"style",
".",
"getStrokeColor",
"(",
")",
"!=",
"null",
")",
"{",
"element",
".",
"setAttribute",
"(",
"\"stroked\"",
",",
"\"true\"",
")",
";",
"NodeList",
"<",
"Element",
">",
"strokes",
"=",
"element",
".",
"getElementsByTagName",
"(",
"\"stroke\"",
")",
";",
"strokes",
".",
"getItem",
"(",
"0",
")",
".",
"setAttribute",
"(",
"\"color\"",
",",
"style",
".",
"getStrokeColor",
"(",
")",
")",
";",
"strokes",
".",
"getItem",
"(",
"0",
")",
".",
"setAttribute",
"(",
"\"opacity\"",
",",
"Float",
".",
"toString",
"(",
"style",
".",
"getStrokeOpacity",
"(",
")",
")",
")",
";",
"element",
".",
"setAttribute",
"(",
"\"strokeweight\"",
",",
"Float",
".",
"toString",
"(",
"style",
".",
"getStrokeWidth",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"element",
".",
"setAttribute",
"(",
"\"stroked\"",
",",
"\"false\"",
")",
";",
"}",
"}"
] |
When applying ShapeStyles, we create child elements for fill and stroke. According to Microsoft, this is the
proper way to go.
|
[
"When",
"applying",
"ShapeStyles",
"we",
"create",
"child",
"elements",
"for",
"fill",
"and",
"stroke",
".",
"According",
"to",
"Microsoft",
"this",
"is",
"the",
"proper",
"way",
"to",
"go",
"."
] |
train
|
https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/gfx/context/VmlStyleUtil.java#L106-L136
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java
|
MapUtil.getDouble
|
public static Double getDouble(Map<?, ?> map, Object key) {
"""
获取Map指定key的值,并转换为Double
@param map Map
@param key 键
@return 值
@since 4.0.6
"""
return get(map, key, Double.class);
}
|
java
|
public static Double getDouble(Map<?, ?> map, Object key) {
return get(map, key, Double.class);
}
|
[
"public",
"static",
"Double",
"getDouble",
"(",
"Map",
"<",
"?",
",",
"?",
">",
"map",
",",
"Object",
"key",
")",
"{",
"return",
"get",
"(",
"map",
",",
"key",
",",
"Double",
".",
"class",
")",
";",
"}"
] |
获取Map指定key的值,并转换为Double
@param map Map
@param key 键
@return 值
@since 4.0.6
|
[
"获取Map指定key的值,并转换为Double"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java#L780-L782
|
Azure/azure-sdk-for-java
|
sql/resource-manager/v2017_10_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_10_01_preview/implementation/InstanceFailoverGroupsInner.java
|
InstanceFailoverGroupsInner.beginCreateOrUpdateAsync
|
public Observable<InstanceFailoverGroupInner> beginCreateOrUpdateAsync(String resourceGroupName, String locationName, String failoverGroupName, InstanceFailoverGroupInner parameters) {
"""
Creates or updates a failover group.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param locationName The name of the region where the resource is located.
@param failoverGroupName The name of the failover group.
@param parameters The failover group parameters.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the InstanceFailoverGroupInner object
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, locationName, failoverGroupName, parameters).map(new Func1<ServiceResponse<InstanceFailoverGroupInner>, InstanceFailoverGroupInner>() {
@Override
public InstanceFailoverGroupInner call(ServiceResponse<InstanceFailoverGroupInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<InstanceFailoverGroupInner> beginCreateOrUpdateAsync(String resourceGroupName, String locationName, String failoverGroupName, InstanceFailoverGroupInner parameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, locationName, failoverGroupName, parameters).map(new Func1<ServiceResponse<InstanceFailoverGroupInner>, InstanceFailoverGroupInner>() {
@Override
public InstanceFailoverGroupInner call(ServiceResponse<InstanceFailoverGroupInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"InstanceFailoverGroupInner",
">",
"beginCreateOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"locationName",
",",
"String",
"failoverGroupName",
",",
"InstanceFailoverGroupInner",
"parameters",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"locationName",
",",
"failoverGroupName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"InstanceFailoverGroupInner",
">",
",",
"InstanceFailoverGroupInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"InstanceFailoverGroupInner",
"call",
"(",
"ServiceResponse",
"<",
"InstanceFailoverGroupInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Creates or updates a failover group.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param locationName The name of the region where the resource is located.
@param failoverGroupName The name of the failover group.
@param parameters The failover group parameters.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the InstanceFailoverGroupInner object
|
[
"Creates",
"or",
"updates",
"a",
"failover",
"group",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2017_10_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_10_01_preview/implementation/InstanceFailoverGroupsInner.java#L329-L336
|
Azure/azure-sdk-for-java
|
hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ClustersInner.java
|
ClustersInner.updateGatewaySettingsAsync
|
public Observable<Void> updateGatewaySettingsAsync(String resourceGroupName, String clusterName, UpdateGatewaySettingsParameters parameters) {
"""
Configures the gateway settings on the specified cluster.
@param resourceGroupName The name of the resource group.
@param clusterName The name of the cluster.
@param parameters The cluster configurations.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return updateGatewaySettingsWithServiceResponseAsync(resourceGroupName, clusterName, parameters).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
|
java
|
public Observable<Void> updateGatewaySettingsAsync(String resourceGroupName, String clusterName, UpdateGatewaySettingsParameters parameters) {
return updateGatewaySettingsWithServiceResponseAsync(resourceGroupName, clusterName, parameters).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"Void",
">",
"updateGatewaySettingsAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"clusterName",
",",
"UpdateGatewaySettingsParameters",
"parameters",
")",
"{",
"return",
"updateGatewaySettingsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"clusterName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Configures the gateway settings on the specified cluster.
@param resourceGroupName The name of the resource group.
@param clusterName The name of the cluster.
@param parameters The cluster configurations.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
|
[
"Configures",
"the",
"gateway",
"settings",
"on",
"the",
"specified",
"cluster",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ClustersInner.java#L1576-L1583
|
biojava/biojava
|
biojava-structure/src/main/java/org/biojava/nbio/structure/Calc.java
|
Calc.getXYZEuler
|
public static final double[] getXYZEuler(Matrix m) {
"""
Convert a rotation Matrix to Euler angles. This conversion uses
conventions as described on page:
http://www.euclideanspace.com/maths/geometry/rotations/euler/index.htm
Coordinate System: right hand Positive angle: right hand Order of euler
angles: heading first, then attitude, then bank
@param m
the rotation matrix
@return a array of three doubles containing the three euler angles in
radians
"""
double heading, attitude, bank;
// Assuming the angles are in radians.
if (m.get(1,0) > 0.998) { // singularity at north pole
heading = Math.atan2(m.get(0,2),m.get(2,2));
attitude = Math.PI/2;
bank = 0;
} else if (m.get(1,0) < -0.998) { // singularity at south pole
heading = Math.atan2(m.get(0,2),m.get(2,2));
attitude = -Math.PI/2;
bank = 0;
} else {
heading = Math.atan2(-m.get(2,0),m.get(0,0));
bank = Math.atan2(-m.get(1,2),m.get(1,1));
attitude = Math.asin(m.get(1,0));
}
return new double[] { heading, attitude, bank };
}
|
java
|
public static final double[] getXYZEuler(Matrix m){
double heading, attitude, bank;
// Assuming the angles are in radians.
if (m.get(1,0) > 0.998) { // singularity at north pole
heading = Math.atan2(m.get(0,2),m.get(2,2));
attitude = Math.PI/2;
bank = 0;
} else if (m.get(1,0) < -0.998) { // singularity at south pole
heading = Math.atan2(m.get(0,2),m.get(2,2));
attitude = -Math.PI/2;
bank = 0;
} else {
heading = Math.atan2(-m.get(2,0),m.get(0,0));
bank = Math.atan2(-m.get(1,2),m.get(1,1));
attitude = Math.asin(m.get(1,0));
}
return new double[] { heading, attitude, bank };
}
|
[
"public",
"static",
"final",
"double",
"[",
"]",
"getXYZEuler",
"(",
"Matrix",
"m",
")",
"{",
"double",
"heading",
",",
"attitude",
",",
"bank",
";",
"// Assuming the angles are in radians.",
"if",
"(",
"m",
".",
"get",
"(",
"1",
",",
"0",
")",
">",
"0.998",
")",
"{",
"// singularity at north pole",
"heading",
"=",
"Math",
".",
"atan2",
"(",
"m",
".",
"get",
"(",
"0",
",",
"2",
")",
",",
"m",
".",
"get",
"(",
"2",
",",
"2",
")",
")",
";",
"attitude",
"=",
"Math",
".",
"PI",
"/",
"2",
";",
"bank",
"=",
"0",
";",
"}",
"else",
"if",
"(",
"m",
".",
"get",
"(",
"1",
",",
"0",
")",
"<",
"-",
"0.998",
")",
"{",
"// singularity at south pole",
"heading",
"=",
"Math",
".",
"atan2",
"(",
"m",
".",
"get",
"(",
"0",
",",
"2",
")",
",",
"m",
".",
"get",
"(",
"2",
",",
"2",
")",
")",
";",
"attitude",
"=",
"-",
"Math",
".",
"PI",
"/",
"2",
";",
"bank",
"=",
"0",
";",
"}",
"else",
"{",
"heading",
"=",
"Math",
".",
"atan2",
"(",
"-",
"m",
".",
"get",
"(",
"2",
",",
"0",
")",
",",
"m",
".",
"get",
"(",
"0",
",",
"0",
")",
")",
";",
"bank",
"=",
"Math",
".",
"atan2",
"(",
"-",
"m",
".",
"get",
"(",
"1",
",",
"2",
")",
",",
"m",
".",
"get",
"(",
"1",
",",
"1",
")",
")",
";",
"attitude",
"=",
"Math",
".",
"asin",
"(",
"m",
".",
"get",
"(",
"1",
",",
"0",
")",
")",
";",
"}",
"return",
"new",
"double",
"[",
"]",
"{",
"heading",
",",
"attitude",
",",
"bank",
"}",
";",
"}"
] |
Convert a rotation Matrix to Euler angles. This conversion uses
conventions as described on page:
http://www.euclideanspace.com/maths/geometry/rotations/euler/index.htm
Coordinate System: right hand Positive angle: right hand Order of euler
angles: heading first, then attitude, then bank
@param m
the rotation matrix
@return a array of three doubles containing the three euler angles in
radians
|
[
"Convert",
"a",
"rotation",
"Matrix",
"to",
"Euler",
"angles",
".",
"This",
"conversion",
"uses",
"conventions",
"as",
"described",
"on",
"page",
":",
"http",
":",
"//",
"www",
".",
"euclideanspace",
".",
"com",
"/",
"maths",
"/",
"geometry",
"/",
"rotations",
"/",
"euler",
"/",
"index",
".",
"htm",
"Coordinate",
"System",
":",
"right",
"hand",
"Positive",
"angle",
":",
"right",
"hand",
"Order",
"of",
"euler",
"angles",
":",
"heading",
"first",
"then",
"attitude",
"then",
"bank"
] |
train
|
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/Calc.java#L1048-L1068
|
oehf/ipf-oht-atna
|
auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/ihe/GenericIHEAuditEventMessage.java
|
GenericIHEAuditEventMessage.addHumanRequestorActiveParticipant
|
public void addHumanRequestorActiveParticipant(String userId, String altUserId, String userName, List<CodedValueType> roles) {
"""
Adds an Active Participant block representing the human requestor participant
@param userId The Active Participant's User ID
@param altUserId The Active Participant's Alternate UserID
@param userName The Active Participant's UserName
@param roles The participant's roles
"""
addActiveParticipant(
userId,
altUserId,
userName,
true,
roles,
null);
}
|
java
|
public void addHumanRequestorActiveParticipant(String userId, String altUserId, String userName, List<CodedValueType> roles)
{
addActiveParticipant(
userId,
altUserId,
userName,
true,
roles,
null);
}
|
[
"public",
"void",
"addHumanRequestorActiveParticipant",
"(",
"String",
"userId",
",",
"String",
"altUserId",
",",
"String",
"userName",
",",
"List",
"<",
"CodedValueType",
">",
"roles",
")",
"{",
"addActiveParticipant",
"(",
"userId",
",",
"altUserId",
",",
"userName",
",",
"true",
",",
"roles",
",",
"null",
")",
";",
"}"
] |
Adds an Active Participant block representing the human requestor participant
@param userId The Active Participant's User ID
@param altUserId The Active Participant's Alternate UserID
@param userName The Active Participant's UserName
@param roles The participant's roles
|
[
"Adds",
"an",
"Active",
"Participant",
"block",
"representing",
"the",
"human",
"requestor",
"participant"
] |
train
|
https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/ihe/GenericIHEAuditEventMessage.java#L133-L142
|
wildfly/wildfly-core
|
host-controller/src/main/java/org/jboss/as/host/controller/ConfigurationPersisterFactory.java
|
ConfigurationPersisterFactory.createCachedRemoteDomainXmlConfigurationPersister
|
public static ExtensibleConfigurationPersister createCachedRemoteDomainXmlConfigurationPersister(final File configDir, ExecutorService executorService, ExtensionRegistry extensionRegistry) {
"""
--cached-dc, just use the same one as --backup, as we need to write changes as they occur.
"""
return createRemoteBackupDomainXmlConfigurationPersister(configDir, executorService, extensionRegistry);
}
|
java
|
public static ExtensibleConfigurationPersister createCachedRemoteDomainXmlConfigurationPersister(final File configDir, ExecutorService executorService, ExtensionRegistry extensionRegistry) {
return createRemoteBackupDomainXmlConfigurationPersister(configDir, executorService, extensionRegistry);
}
|
[
"public",
"static",
"ExtensibleConfigurationPersister",
"createCachedRemoteDomainXmlConfigurationPersister",
"(",
"final",
"File",
"configDir",
",",
"ExecutorService",
"executorService",
",",
"ExtensionRegistry",
"extensionRegistry",
")",
"{",
"return",
"createRemoteBackupDomainXmlConfigurationPersister",
"(",
"configDir",
",",
"executorService",
",",
"extensionRegistry",
")",
";",
"}"
] |
--cached-dc, just use the same one as --backup, as we need to write changes as they occur.
|
[
"--",
"cached",
"-",
"dc",
"just",
"use",
"the",
"same",
"one",
"as",
"--",
"backup",
"as",
"we",
"need",
"to",
"write",
"changes",
"as",
"they",
"occur",
"."
] |
train
|
https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/ConfigurationPersisterFactory.java#L130-L132
|
OpenNTF/JavascriptAggregator
|
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/module/ModuleImpl.java
|
ModuleImpl.processExtraModules
|
public void processExtraModules(ModuleBuildReader reader, HttpServletRequest request, CacheEntry cacheEntry)
throws IOException {
"""
For any extra modules specified by {@code cacheEntry}, obtain a build
future from the module cache manager and add it to the {@link ModuleBuildReader}
specified by {@code reader}.
@param reader
the {@link ModuleBuildReader} to add the extra modules to
@param request
The http request
@param cacheEntry
The cache entry object for the current module
@throws IOException
"""
List<String> extraModules = cacheEntry.getExtraModules();
if (!extraModules.isEmpty()) {
IAggregator aggr = (IAggregator)request.getAttribute(IAggregator.AGGREGATOR_REQATTRNAME);
IConfig config = aggr.getConfig();
for (String mid : cacheEntry.getExtraModules()) {
ModuleIdentifier ident = new ModuleIdentifier(mid);
String pluginName = ident.getPluginName();
boolean isJavaScript = pluginName == null || config.getJsPluginDelegators().contains(pluginName);
URI uri = config.locateModuleResource(ident.getModuleName(), isJavaScript);
IModule module = aggr.newModule(mid, uri);
Future<ModuleBuildReader> future = aggr.getCacheManager().getCache().getModules().getBuild(request, module);
ModuleBuildFuture mbf = new ModuleBuildFuture(
module,
future,
ModuleSpecifier.BUILD_ADDED);
reader.addExtraBuild(mbf);
}
}
}
|
java
|
public void processExtraModules(ModuleBuildReader reader, HttpServletRequest request, CacheEntry cacheEntry)
throws IOException {
List<String> extraModules = cacheEntry.getExtraModules();
if (!extraModules.isEmpty()) {
IAggregator aggr = (IAggregator)request.getAttribute(IAggregator.AGGREGATOR_REQATTRNAME);
IConfig config = aggr.getConfig();
for (String mid : cacheEntry.getExtraModules()) {
ModuleIdentifier ident = new ModuleIdentifier(mid);
String pluginName = ident.getPluginName();
boolean isJavaScript = pluginName == null || config.getJsPluginDelegators().contains(pluginName);
URI uri = config.locateModuleResource(ident.getModuleName(), isJavaScript);
IModule module = aggr.newModule(mid, uri);
Future<ModuleBuildReader> future = aggr.getCacheManager().getCache().getModules().getBuild(request, module);
ModuleBuildFuture mbf = new ModuleBuildFuture(
module,
future,
ModuleSpecifier.BUILD_ADDED);
reader.addExtraBuild(mbf);
}
}
}
|
[
"public",
"void",
"processExtraModules",
"(",
"ModuleBuildReader",
"reader",
",",
"HttpServletRequest",
"request",
",",
"CacheEntry",
"cacheEntry",
")",
"throws",
"IOException",
"{",
"List",
"<",
"String",
">",
"extraModules",
"=",
"cacheEntry",
".",
"getExtraModules",
"(",
")",
";",
"if",
"(",
"!",
"extraModules",
".",
"isEmpty",
"(",
")",
")",
"{",
"IAggregator",
"aggr",
"=",
"(",
"IAggregator",
")",
"request",
".",
"getAttribute",
"(",
"IAggregator",
".",
"AGGREGATOR_REQATTRNAME",
")",
";",
"IConfig",
"config",
"=",
"aggr",
".",
"getConfig",
"(",
")",
";",
"for",
"(",
"String",
"mid",
":",
"cacheEntry",
".",
"getExtraModules",
"(",
")",
")",
"{",
"ModuleIdentifier",
"ident",
"=",
"new",
"ModuleIdentifier",
"(",
"mid",
")",
";",
"String",
"pluginName",
"=",
"ident",
".",
"getPluginName",
"(",
")",
";",
"boolean",
"isJavaScript",
"=",
"pluginName",
"==",
"null",
"||",
"config",
".",
"getJsPluginDelegators",
"(",
")",
".",
"contains",
"(",
"pluginName",
")",
";",
"URI",
"uri",
"=",
"config",
".",
"locateModuleResource",
"(",
"ident",
".",
"getModuleName",
"(",
")",
",",
"isJavaScript",
")",
";",
"IModule",
"module",
"=",
"aggr",
".",
"newModule",
"(",
"mid",
",",
"uri",
")",
";",
"Future",
"<",
"ModuleBuildReader",
">",
"future",
"=",
"aggr",
".",
"getCacheManager",
"(",
")",
".",
"getCache",
"(",
")",
".",
"getModules",
"(",
")",
".",
"getBuild",
"(",
"request",
",",
"module",
")",
";",
"ModuleBuildFuture",
"mbf",
"=",
"new",
"ModuleBuildFuture",
"(",
"module",
",",
"future",
",",
"ModuleSpecifier",
".",
"BUILD_ADDED",
")",
";",
"reader",
".",
"addExtraBuild",
"(",
"mbf",
")",
";",
"}",
"}",
"}"
] |
For any extra modules specified by {@code cacheEntry}, obtain a build
future from the module cache manager and add it to the {@link ModuleBuildReader}
specified by {@code reader}.
@param reader
the {@link ModuleBuildReader} to add the extra modules to
@param request
The http request
@param cacheEntry
The cache entry object for the current module
@throws IOException
|
[
"For",
"any",
"extra",
"modules",
"specified",
"by",
"{",
"@code",
"cacheEntry",
"}",
"obtain",
"a",
"build",
"future",
"from",
"the",
"module",
"cache",
"manager",
"and",
"add",
"it",
"to",
"the",
"{",
"@link",
"ModuleBuildReader",
"}",
"specified",
"by",
"{",
"@code",
"reader",
"}",
"."
] |
train
|
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/module/ModuleImpl.java#L508-L529
|
Kickflip/kickflip-android-sdk
|
sdk/src/main/java/io/kickflip/sdk/Kickflip.java
|
Kickflip.setup
|
public static KickflipApiClient setup(Context context, String key, String secret) {
"""
Register with Kickflip, creating a new user identity per app installation.
@param context the host application's {@link android.content.Context}
@param key your Kickflip Client Key
@param secret your Kickflip Client Secret
@return a {@link io.kickflip.sdk.api.KickflipApiClient} used to perform actions on behalf of a
{@link io.kickflip.sdk.api.json.User}.
"""
return setup(context, key, secret, null);
}
|
java
|
public static KickflipApiClient setup(Context context, String key, String secret) {
return setup(context, key, secret, null);
}
|
[
"public",
"static",
"KickflipApiClient",
"setup",
"(",
"Context",
"context",
",",
"String",
"key",
",",
"String",
"secret",
")",
"{",
"return",
"setup",
"(",
"context",
",",
"key",
",",
"secret",
",",
"null",
")",
";",
"}"
] |
Register with Kickflip, creating a new user identity per app installation.
@param context the host application's {@link android.content.Context}
@param key your Kickflip Client Key
@param secret your Kickflip Client Secret
@return a {@link io.kickflip.sdk.api.KickflipApiClient} used to perform actions on behalf of a
{@link io.kickflip.sdk.api.json.User}.
|
[
"Register",
"with",
"Kickflip",
"creating",
"a",
"new",
"user",
"identity",
"per",
"app",
"installation",
"."
] |
train
|
https://github.com/Kickflip/kickflip-android-sdk/blob/af3aae5f1128d7376e67aefe11a3a1a3844be734/sdk/src/main/java/io/kickflip/sdk/Kickflip.java#L99-L101
|
deeplearning4j/deeplearning4j
|
deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/time/TimeSourceProvider.java
|
TimeSourceProvider.getInstance
|
public static TimeSource getInstance(String className) {
"""
Get a specific TimeSource by class name
@param className Class name of the TimeSource to return the instance for
@return TimeSource instance
"""
try {
Class<?> c = Class.forName(className);
Method m = c.getMethod("getInstance");
return (TimeSource) m.invoke(null);
} catch (Exception e) {
throw new RuntimeException("Error getting TimeSource instance for class \"" + className + "\"", e);
}
}
|
java
|
public static TimeSource getInstance(String className) {
try {
Class<?> c = Class.forName(className);
Method m = c.getMethod("getInstance");
return (TimeSource) m.invoke(null);
} catch (Exception e) {
throw new RuntimeException("Error getting TimeSource instance for class \"" + className + "\"", e);
}
}
|
[
"public",
"static",
"TimeSource",
"getInstance",
"(",
"String",
"className",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
">",
"c",
"=",
"Class",
".",
"forName",
"(",
"className",
")",
";",
"Method",
"m",
"=",
"c",
".",
"getMethod",
"(",
"\"getInstance\"",
")",
";",
"return",
"(",
"TimeSource",
")",
"m",
".",
"invoke",
"(",
"null",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Error getting TimeSource instance for class \\\"\"",
"+",
"className",
"+",
"\"\\\"\"",
",",
"e",
")",
";",
"}",
"}"
] |
Get a specific TimeSource by class name
@param className Class name of the TimeSource to return the instance for
@return TimeSource instance
|
[
"Get",
"a",
"specific",
"TimeSource",
"by",
"class",
"name"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/time/TimeSourceProvider.java#L63-L71
|
pressgang-ccms/PressGangCCMSBuilder
|
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/ContentSpecBuilder.java
|
ContentSpecBuilder.buildTranslatedBook
|
public byte[] buildTranslatedBook(final ContentSpec contentSpec, final String requester, final DocBookBuildingOptions builderOptions,
final ZanataDetails zanataDetails, final BuildType buildType) throws BuilderCreationException, BuildProcessingException {
"""
Builds a book into a zip file for the passed Content Specification.
@param contentSpec The content specification that is to be built. It should have already been validated, if not errors may occur.
@param requester The user who requested the book to be built.
@param builderOptions The set of options what are to be when building the book.
@param zanataDetails The Zanata details to be used when editor links are turned on.
@param buildType
@return A byte array that is the zip file
@throws BuildProcessingException Any unexpected errors that occur during building.
@throws BuilderCreationException Any error that occurs while trying to setup/create the builder
"""
return buildTranslatedBook(contentSpec, requester, builderOptions, new HashMap<String, byte[]>(), zanataDetails, buildType);
}
|
java
|
public byte[] buildTranslatedBook(final ContentSpec contentSpec, final String requester, final DocBookBuildingOptions builderOptions,
final ZanataDetails zanataDetails, final BuildType buildType) throws BuilderCreationException, BuildProcessingException {
return buildTranslatedBook(contentSpec, requester, builderOptions, new HashMap<String, byte[]>(), zanataDetails, buildType);
}
|
[
"public",
"byte",
"[",
"]",
"buildTranslatedBook",
"(",
"final",
"ContentSpec",
"contentSpec",
",",
"final",
"String",
"requester",
",",
"final",
"DocBookBuildingOptions",
"builderOptions",
",",
"final",
"ZanataDetails",
"zanataDetails",
",",
"final",
"BuildType",
"buildType",
")",
"throws",
"BuilderCreationException",
",",
"BuildProcessingException",
"{",
"return",
"buildTranslatedBook",
"(",
"contentSpec",
",",
"requester",
",",
"builderOptions",
",",
"new",
"HashMap",
"<",
"String",
",",
"byte",
"[",
"]",
">",
"(",
")",
",",
"zanataDetails",
",",
"buildType",
")",
";",
"}"
] |
Builds a book into a zip file for the passed Content Specification.
@param contentSpec The content specification that is to be built. It should have already been validated, if not errors may occur.
@param requester The user who requested the book to be built.
@param builderOptions The set of options what are to be when building the book.
@param zanataDetails The Zanata details to be used when editor links are turned on.
@param buildType
@return A byte array that is the zip file
@throws BuildProcessingException Any unexpected errors that occur during building.
@throws BuilderCreationException Any error that occurs while trying to setup/create the builder
|
[
"Builds",
"a",
"book",
"into",
"a",
"zip",
"file",
"for",
"the",
"passed",
"Content",
"Specification",
"."
] |
train
|
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/ContentSpecBuilder.java#L140-L143
|
networknt/light-4j
|
utility/src/main/java/com/networknt/utility/RegExUtils.java
|
RegExUtils.replaceFirst
|
public static String replaceFirst(final String text, final Pattern regex, final String replacement) {
"""
<p>Replaces the first substring of the text string that matches the given regular expression pattern
with the given replacement.</p>
This method is a {@code null} safe equivalent to:
<ul>
<li>{@code pattern.matcher(text).replaceFirst(replacement)}</li>
</ul>
<p>A {@code null} reference passed to this method is a no-op.</p>
<pre>
StringUtils.replaceFirst(null, *, *) = null
StringUtils.replaceFirst("any", (Pattern) null, *) = "any"
StringUtils.replaceFirst("any", *, null) = "any"
StringUtils.replaceFirst("", Pattern.compile(""), "zzz") = "zzz"
StringUtils.replaceFirst("", Pattern.compile(".*"), "zzz") = "zzz"
StringUtils.replaceFirst("", Pattern.compile(".+"), "zzz") = ""
StringUtils.replaceFirst("abc", Pattern.compile(""), "ZZ") = "ZZabc"
StringUtils.replaceFirst("<__>\n<__>", Pattern.compile("<.*>"), "z") = "z\n<__>"
StringUtils.replaceFirst("<__>\n<__>", Pattern.compile("(?s)<.*>"), "z") = "z"
StringUtils.replaceFirst("ABCabc123", Pattern.compile("[a-z]"), "_") = "ABC_bc123"
StringUtils.replaceFirst("ABCabc123abc", Pattern.compile("[^A-Z0-9]+"), "_") = "ABC_123abc"
StringUtils.replaceFirst("ABCabc123abc", Pattern.compile("[^A-Z0-9]+"), "") = "ABC123abc"
StringUtils.replaceFirst("Lorem ipsum dolor sit", Pattern.compile("( +)([a-z]+)"), "_$2") = "Lorem_ipsum dolor sit"
</pre>
@param text text to search and replace in, may be null
@param regex the regular expression pattern to which this string is to be matched
@param replacement the string to be substituted for the first match
@return the text with the first replacement processed,
{@code null} if null String input
@see java.util.regex.Matcher#replaceFirst(String)
@see java.util.regex.Pattern
"""
if (text == null || regex == null|| replacement == null ) {
return text;
}
return regex.matcher(text).replaceFirst(replacement);
}
|
java
|
public static String replaceFirst(final String text, final Pattern regex, final String replacement) {
if (text == null || regex == null|| replacement == null ) {
return text;
}
return regex.matcher(text).replaceFirst(replacement);
}
|
[
"public",
"static",
"String",
"replaceFirst",
"(",
"final",
"String",
"text",
",",
"final",
"Pattern",
"regex",
",",
"final",
"String",
"replacement",
")",
"{",
"if",
"(",
"text",
"==",
"null",
"||",
"regex",
"==",
"null",
"||",
"replacement",
"==",
"null",
")",
"{",
"return",
"text",
";",
"}",
"return",
"regex",
".",
"matcher",
"(",
"text",
")",
".",
"replaceFirst",
"(",
"replacement",
")",
";",
"}"
] |
<p>Replaces the first substring of the text string that matches the given regular expression pattern
with the given replacement.</p>
This method is a {@code null} safe equivalent to:
<ul>
<li>{@code pattern.matcher(text).replaceFirst(replacement)}</li>
</ul>
<p>A {@code null} reference passed to this method is a no-op.</p>
<pre>
StringUtils.replaceFirst(null, *, *) = null
StringUtils.replaceFirst("any", (Pattern) null, *) = "any"
StringUtils.replaceFirst("any", *, null) = "any"
StringUtils.replaceFirst("", Pattern.compile(""), "zzz") = "zzz"
StringUtils.replaceFirst("", Pattern.compile(".*"), "zzz") = "zzz"
StringUtils.replaceFirst("", Pattern.compile(".+"), "zzz") = ""
StringUtils.replaceFirst("abc", Pattern.compile(""), "ZZ") = "ZZabc"
StringUtils.replaceFirst("<__>\n<__>", Pattern.compile("<.*>"), "z") = "z\n<__>"
StringUtils.replaceFirst("<__>\n<__>", Pattern.compile("(?s)<.*>"), "z") = "z"
StringUtils.replaceFirst("ABCabc123", Pattern.compile("[a-z]"), "_") = "ABC_bc123"
StringUtils.replaceFirst("ABCabc123abc", Pattern.compile("[^A-Z0-9]+"), "_") = "ABC_123abc"
StringUtils.replaceFirst("ABCabc123abc", Pattern.compile("[^A-Z0-9]+"), "") = "ABC123abc"
StringUtils.replaceFirst("Lorem ipsum dolor sit", Pattern.compile("( +)([a-z]+)"), "_$2") = "Lorem_ipsum dolor sit"
</pre>
@param text text to search and replace in, may be null
@param regex the regular expression pattern to which this string is to be matched
@param replacement the string to be substituted for the first match
@return the text with the first replacement processed,
{@code null} if null String input
@see java.util.regex.Matcher#replaceFirst(String)
@see java.util.regex.Pattern
|
[
"<p",
">",
"Replaces",
"the",
"first",
"substring",
"of",
"the",
"text",
"string",
"that",
"matches",
"the",
"given",
"regular",
"expression",
"pattern",
"with",
"the",
"given",
"replacement",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/RegExUtils.java#L355-L360
|
BorderTech/wcomponents
|
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DateUtilities.java
|
DateUtilities.createDate
|
public static Date createDate(final int day, final int month, final int year) {
"""
Creates a date from the given components.
@param day the day of the month, 1-31.
@param month the month, 1-12.
@param year the year.
@return a date with the specified settings.
"""
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(Calendar.DAY_OF_MONTH, day);
cal.set(Calendar.MONTH, month - 1);
cal.set(Calendar.YEAR, year);
return cal.getTime();
}
|
java
|
public static Date createDate(final int day, final int month, final int year) {
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(Calendar.DAY_OF_MONTH, day);
cal.set(Calendar.MONTH, month - 1);
cal.set(Calendar.YEAR, year);
return cal.getTime();
}
|
[
"public",
"static",
"Date",
"createDate",
"(",
"final",
"int",
"day",
",",
"final",
"int",
"month",
",",
"final",
"int",
"year",
")",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"clear",
"(",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
",",
"day",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"MONTH",
",",
"month",
"-",
"1",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"YEAR",
",",
"year",
")",
";",
"return",
"cal",
".",
"getTime",
"(",
")",
";",
"}"
] |
Creates a date from the given components.
@param day the day of the month, 1-31.
@param month the month, 1-12.
@param year the year.
@return a date with the specified settings.
|
[
"Creates",
"a",
"date",
"from",
"the",
"given",
"components",
"."
] |
train
|
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DateUtilities.java#L29-L38
|
HeidelTime/heideltime
|
src/jvnsensegmenter/JVnSenSegmenter.java
|
JVnSenSegmenter.senSegment
|
public void senSegment(String text, List senList) {
"""
Sen segment.
@param text the text
@param senList the sen list
"""
senList.clear();
String resultStr = senSegment(text);
StringTokenizer senTknr = new StringTokenizer(resultStr, "\n");
while(senTknr.hasMoreTokens()){
senList.add(senTknr.nextToken());
}
}
|
java
|
public void senSegment(String text, List senList){
senList.clear();
String resultStr = senSegment(text);
StringTokenizer senTknr = new StringTokenizer(resultStr, "\n");
while(senTknr.hasMoreTokens()){
senList.add(senTknr.nextToken());
}
}
|
[
"public",
"void",
"senSegment",
"(",
"String",
"text",
",",
"List",
"senList",
")",
"{",
"senList",
".",
"clear",
"(",
")",
";",
"String",
"resultStr",
"=",
"senSegment",
"(",
"text",
")",
";",
"StringTokenizer",
"senTknr",
"=",
"new",
"StringTokenizer",
"(",
"resultStr",
",",
"\"\\n\"",
")",
";",
"while",
"(",
"senTknr",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"senList",
".",
"add",
"(",
"senTknr",
".",
"nextToken",
"(",
")",
")",
";",
"}",
"}"
] |
Sen segment.
@param text the text
@param senList the sen list
|
[
"Sen",
"segment",
"."
] |
train
|
https://github.com/HeidelTime/heideltime/blob/4ef5002eb5ecfeb818086ff7e394e792ee360335/src/jvnsensegmenter/JVnSenSegmenter.java#L122-L130
|
overturetool/overture
|
core/interpreter/src/main/java/org/overture/interpreter/assistant/definition/ACpuClassDefinitionAssistantInterpreter.java
|
ACpuClassDefinitionAssistantInterpreter.updateCPUandChildCPUs
|
private void updateCPUandChildCPUs(ObjectValue obj, CPUValue cpu) {
"""
Recursively updates all transitive references with the new CPU, but without removing the parent - child relation,
unlike the deploy method.
@param the
objectvalue to update
@param the
target CPU of the redeploy
"""
if (cpu != obj.getCPU())
{
for (ObjectValue superObj : obj.superobjects)
{
updateCPUandChildCPUs(superObj, cpu);
}
obj.setCPU(cpu);
}
// update all object we have created our self.
for (ObjectValue objVal : obj.children)
{
updateCPUandChildCPUs(objVal, cpu);
}
}
|
java
|
private void updateCPUandChildCPUs(ObjectValue obj, CPUValue cpu)
{
if (cpu != obj.getCPU())
{
for (ObjectValue superObj : obj.superobjects)
{
updateCPUandChildCPUs(superObj, cpu);
}
obj.setCPU(cpu);
}
// update all object we have created our self.
for (ObjectValue objVal : obj.children)
{
updateCPUandChildCPUs(objVal, cpu);
}
}
|
[
"private",
"void",
"updateCPUandChildCPUs",
"(",
"ObjectValue",
"obj",
",",
"CPUValue",
"cpu",
")",
"{",
"if",
"(",
"cpu",
"!=",
"obj",
".",
"getCPU",
"(",
")",
")",
"{",
"for",
"(",
"ObjectValue",
"superObj",
":",
"obj",
".",
"superobjects",
")",
"{",
"updateCPUandChildCPUs",
"(",
"superObj",
",",
"cpu",
")",
";",
"}",
"obj",
".",
"setCPU",
"(",
"cpu",
")",
";",
"}",
"// update all object we have created our self.",
"for",
"(",
"ObjectValue",
"objVal",
":",
"obj",
".",
"children",
")",
"{",
"updateCPUandChildCPUs",
"(",
"objVal",
",",
"cpu",
")",
";",
"}",
"}"
] |
Recursively updates all transitive references with the new CPU, but without removing the parent - child relation,
unlike the deploy method.
@param the
objectvalue to update
@param the
target CPU of the redeploy
|
[
"Recursively",
"updates",
"all",
"transitive",
"references",
"with",
"the",
"new",
"CPU",
"but",
"without",
"removing",
"the",
"parent",
"-",
"child",
"relation",
"unlike",
"the",
"deploy",
"method",
"."
] |
train
|
https://github.com/overturetool/overture/blob/83175dc6c24fa171cde4fcf61ecb648eba3bdbc1/core/interpreter/src/main/java/org/overture/interpreter/assistant/definition/ACpuClassDefinitionAssistantInterpreter.java#L111-L127
|
dlew/joda-time-android
|
library/src/main/java/net/danlew/android/joda/DateUtils.java
|
DateUtils.formatDuration
|
public static CharSequence formatDuration(Context context, ReadableDuration readableDuration) {
"""
Return given duration in a human-friendly format. For example, "4
minutes" or "1 second". Returns only largest meaningful unit of time,
from seconds up to hours.
The longest duration it supports is hours.
This method assumes that there are 60 minutes in an hour,
60 seconds in a minute and 1000 milliseconds in a second.
All currently supplied chronologies use this definition.
"""
Resources res = context.getResources();
Duration duration = readableDuration.toDuration();
final int hours = (int) duration.getStandardHours();
if (hours != 0) {
return res.getQuantityString(R.plurals.joda_time_android_duration_hours, hours, hours);
}
final int minutes = (int) duration.getStandardMinutes();
if (minutes != 0) {
return res.getQuantityString(R.plurals.joda_time_android_duration_minutes, minutes, minutes);
}
final int seconds = (int) duration.getStandardSeconds();
return res.getQuantityString(R.plurals.joda_time_android_duration_seconds, seconds, seconds);
}
|
java
|
public static CharSequence formatDuration(Context context, ReadableDuration readableDuration) {
Resources res = context.getResources();
Duration duration = readableDuration.toDuration();
final int hours = (int) duration.getStandardHours();
if (hours != 0) {
return res.getQuantityString(R.plurals.joda_time_android_duration_hours, hours, hours);
}
final int minutes = (int) duration.getStandardMinutes();
if (minutes != 0) {
return res.getQuantityString(R.plurals.joda_time_android_duration_minutes, minutes, minutes);
}
final int seconds = (int) duration.getStandardSeconds();
return res.getQuantityString(R.plurals.joda_time_android_duration_seconds, seconds, seconds);
}
|
[
"public",
"static",
"CharSequence",
"formatDuration",
"(",
"Context",
"context",
",",
"ReadableDuration",
"readableDuration",
")",
"{",
"Resources",
"res",
"=",
"context",
".",
"getResources",
"(",
")",
";",
"Duration",
"duration",
"=",
"readableDuration",
".",
"toDuration",
"(",
")",
";",
"final",
"int",
"hours",
"=",
"(",
"int",
")",
"duration",
".",
"getStandardHours",
"(",
")",
";",
"if",
"(",
"hours",
"!=",
"0",
")",
"{",
"return",
"res",
".",
"getQuantityString",
"(",
"R",
".",
"plurals",
".",
"joda_time_android_duration_hours",
",",
"hours",
",",
"hours",
")",
";",
"}",
"final",
"int",
"minutes",
"=",
"(",
"int",
")",
"duration",
".",
"getStandardMinutes",
"(",
")",
";",
"if",
"(",
"minutes",
"!=",
"0",
")",
"{",
"return",
"res",
".",
"getQuantityString",
"(",
"R",
".",
"plurals",
".",
"joda_time_android_duration_minutes",
",",
"minutes",
",",
"minutes",
")",
";",
"}",
"final",
"int",
"seconds",
"=",
"(",
"int",
")",
"duration",
".",
"getStandardSeconds",
"(",
")",
";",
"return",
"res",
".",
"getQuantityString",
"(",
"R",
".",
"plurals",
".",
"joda_time_android_duration_seconds",
",",
"seconds",
",",
"seconds",
")",
";",
"}"
] |
Return given duration in a human-friendly format. For example, "4
minutes" or "1 second". Returns only largest meaningful unit of time,
from seconds up to hours.
The longest duration it supports is hours.
This method assumes that there are 60 minutes in an hour,
60 seconds in a minute and 1000 milliseconds in a second.
All currently supplied chronologies use this definition.
|
[
"Return",
"given",
"duration",
"in",
"a",
"human",
"-",
"friendly",
"format",
".",
"For",
"example",
"4",
"minutes",
"or",
"1",
"second",
".",
"Returns",
"only",
"largest",
"meaningful",
"unit",
"of",
"time",
"from",
"seconds",
"up",
"to",
"hours",
"."
] |
train
|
https://github.com/dlew/joda-time-android/blob/5bf96f6ef4ea63ee91e73e1e528896fa00108dec/library/src/main/java/net/danlew/android/joda/DateUtils.java#L489-L505
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.transport.http/src/com/ibm/ws/genericbnf/internal/BNFHeadersImpl.java
|
BNFHeadersImpl.addInstanceOfElement
|
private boolean addInstanceOfElement(HeaderElement root, HeaderElement elem) {
"""
Helper method to add a new instance of a HeaderElement to
root's internal list. This might be the first instance, or an
additional instance in which case it will be added at the end
of the list.
@param root
@param elem
@return boolean
"""
// first add to the overall sequence list
if (null == this.hdrSequence) {
this.hdrSequence = elem;
this.lastHdrInSequence = elem;
} else {
// find the end of the list and append this new element
this.lastHdrInSequence.nextSequence = elem;
elem.prevSequence = this.lastHdrInSequence;
this.lastHdrInSequence = elem;
}
if (null == root) {
return true;
}
HeaderElement prev = root;
while (null != prev.nextInstance) {
prev = prev.nextInstance;
}
prev.nextInstance = elem;
return false;
}
|
java
|
private boolean addInstanceOfElement(HeaderElement root, HeaderElement elem) {
// first add to the overall sequence list
if (null == this.hdrSequence) {
this.hdrSequence = elem;
this.lastHdrInSequence = elem;
} else {
// find the end of the list and append this new element
this.lastHdrInSequence.nextSequence = elem;
elem.prevSequence = this.lastHdrInSequence;
this.lastHdrInSequence = elem;
}
if (null == root) {
return true;
}
HeaderElement prev = root;
while (null != prev.nextInstance) {
prev = prev.nextInstance;
}
prev.nextInstance = elem;
return false;
}
|
[
"private",
"boolean",
"addInstanceOfElement",
"(",
"HeaderElement",
"root",
",",
"HeaderElement",
"elem",
")",
"{",
"// first add to the overall sequence list",
"if",
"(",
"null",
"==",
"this",
".",
"hdrSequence",
")",
"{",
"this",
".",
"hdrSequence",
"=",
"elem",
";",
"this",
".",
"lastHdrInSequence",
"=",
"elem",
";",
"}",
"else",
"{",
"// find the end of the list and append this new element",
"this",
".",
"lastHdrInSequence",
".",
"nextSequence",
"=",
"elem",
";",
"elem",
".",
"prevSequence",
"=",
"this",
".",
"lastHdrInSequence",
";",
"this",
".",
"lastHdrInSequence",
"=",
"elem",
";",
"}",
"if",
"(",
"null",
"==",
"root",
")",
"{",
"return",
"true",
";",
"}",
"HeaderElement",
"prev",
"=",
"root",
";",
"while",
"(",
"null",
"!=",
"prev",
".",
"nextInstance",
")",
"{",
"prev",
"=",
"prev",
".",
"nextInstance",
";",
"}",
"prev",
".",
"nextInstance",
"=",
"elem",
";",
"return",
"false",
";",
"}"
] |
Helper method to add a new instance of a HeaderElement to
root's internal list. This might be the first instance, or an
additional instance in which case it will be added at the end
of the list.
@param root
@param elem
@return boolean
|
[
"Helper",
"method",
"to",
"add",
"a",
"new",
"instance",
"of",
"a",
"HeaderElement",
"to",
"root",
"s",
"internal",
"list",
".",
"This",
"might",
"be",
"the",
"first",
"instance",
"or",
"an",
"additional",
"instance",
"in",
"which",
"case",
"it",
"will",
"be",
"added",
"at",
"the",
"end",
"of",
"the",
"list",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/genericbnf/internal/BNFHeadersImpl.java#L3043-L3063
|
wuman/orientdb-android
|
core/src/main/java/com/orientechnologies/orient/core/storage/fs/OMMapManagerNew.java
|
OMMapManagerNew.linearSearch
|
private int linearSearch(OMMapBufferEntry[] fileEntries, long beginOffset, int beginPosition, int endPosition) {
"""
This method is used in
com.orientechnologies.orient.core.storage.fs.OMMapManagerNew#searchAmongExisting(com.orientechnologies.orient
.core.storage.fs.OFileMMap, com.orientechnologies.orient.core.storage.fs.OMMapBufferEntry[], long, int) to search necessary
entry.
@param fileEntries
already mapped entries.
@param beginOffset
position in file that should be mmaped.
@param beginPosition
first position in fileEntries.
@param endPosition
last position in fileEntries.
@return -1 if entries is not found. Otherwise returns position of necessary file entry.
"""
for (int i = beginPosition; i <= endPosition; i++) {
final OMMapBufferEntry entry = fileEntries[i];
if (entry.beginOffset + entry.size > beginOffset && entry.beginOffset <= beginOffset) {
return i;
}
}
return -1;
}
|
java
|
private int linearSearch(OMMapBufferEntry[] fileEntries, long beginOffset, int beginPosition, int endPosition) {
for (int i = beginPosition; i <= endPosition; i++) {
final OMMapBufferEntry entry = fileEntries[i];
if (entry.beginOffset + entry.size > beginOffset && entry.beginOffset <= beginOffset) {
return i;
}
}
return -1;
}
|
[
"private",
"int",
"linearSearch",
"(",
"OMMapBufferEntry",
"[",
"]",
"fileEntries",
",",
"long",
"beginOffset",
",",
"int",
"beginPosition",
",",
"int",
"endPosition",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"beginPosition",
";",
"i",
"<=",
"endPosition",
";",
"i",
"++",
")",
"{",
"final",
"OMMapBufferEntry",
"entry",
"=",
"fileEntries",
"[",
"i",
"]",
";",
"if",
"(",
"entry",
".",
"beginOffset",
"+",
"entry",
".",
"size",
">",
"beginOffset",
"&&",
"entry",
".",
"beginOffset",
"<=",
"beginOffset",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
This method is used in
com.orientechnologies.orient.core.storage.fs.OMMapManagerNew#searchAmongExisting(com.orientechnologies.orient
.core.storage.fs.OFileMMap, com.orientechnologies.orient.core.storage.fs.OMMapBufferEntry[], long, int) to search necessary
entry.
@param fileEntries
already mapped entries.
@param beginOffset
position in file that should be mmaped.
@param beginPosition
first position in fileEntries.
@param endPosition
last position in fileEntries.
@return -1 if entries is not found. Otherwise returns position of necessary file entry.
|
[
"This",
"method",
"is",
"used",
"in",
"com",
".",
"orientechnologies",
".",
"orient",
".",
"core",
".",
"storage",
".",
"fs",
".",
"OMMapManagerNew#searchAmongExisting",
"(",
"com",
".",
"orientechnologies",
".",
"orient",
".",
"core",
".",
"storage",
".",
"fs",
".",
"OFileMMap",
"com",
".",
"orientechnologies",
".",
"orient",
".",
"core",
".",
"storage",
".",
"fs",
".",
"OMMapBufferEntry",
"[]",
"long",
"int",
")",
"to",
"search",
"necessary",
"entry",
"."
] |
train
|
https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/fs/OMMapManagerNew.java#L307-L315
|
haraldk/TwelveMonkeys
|
imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/QuickDrawContext.java
|
QuickDrawContext.paintArc
|
public void paintArc(final Rectangle2D pRectangle, int pStartAngle, int pArcAngle) {
"""
PaintArc(r,int,int) // fills an arc's interior with the pattern of the
graphics pen, using the pattern mode of the graphics pen.
@param pRectangle the rectangle to paint
@param pStartAngle start angle in degrees (starting from 12'o clock, this differs from Java)
@param pArcAngle rotation angle in degrees (starting from {@code pStartAngle}, this differs from Java arcs)
"""
paintShape(toArc(pRectangle, pStartAngle, pArcAngle, true));
}
|
java
|
public void paintArc(final Rectangle2D pRectangle, int pStartAngle, int pArcAngle) {
paintShape(toArc(pRectangle, pStartAngle, pArcAngle, true));
}
|
[
"public",
"void",
"paintArc",
"(",
"final",
"Rectangle2D",
"pRectangle",
",",
"int",
"pStartAngle",
",",
"int",
"pArcAngle",
")",
"{",
"paintShape",
"(",
"toArc",
"(",
"pRectangle",
",",
"pStartAngle",
",",
"pArcAngle",
",",
"true",
")",
")",
";",
"}"
] |
PaintArc(r,int,int) // fills an arc's interior with the pattern of the
graphics pen, using the pattern mode of the graphics pen.
@param pRectangle the rectangle to paint
@param pStartAngle start angle in degrees (starting from 12'o clock, this differs from Java)
@param pArcAngle rotation angle in degrees (starting from {@code pStartAngle}, this differs from Java arcs)
|
[
"PaintArc",
"(",
"r",
"int",
"int",
")",
"//",
"fills",
"an",
"arc",
"s",
"interior",
"with",
"the",
"pattern",
"of",
"the",
"graphics",
"pen",
"using",
"the",
"pattern",
"mode",
"of",
"the",
"graphics",
"pen",
"."
] |
train
|
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/QuickDrawContext.java#L740-L742
|
doanduyhai/Achilles
|
achilles-embedded/src/main/java/info/archinnov/achilles/embedded/CassandraEmbeddedServerBuilder.java
|
CassandraEmbeddedServerBuilder.withScriptTemplate
|
public CassandraEmbeddedServerBuilder withScriptTemplate(String scriptTemplateLocation, Map<String, Object> values) {
"""
Load an CQL script template in the class path, inject the values into the template
to produce the final script and execute it upon initialization
of the embedded Cassandra server
<br/>
Call this method as many times as there are CQL templates to be executed.
<br/>
Example:
<br/>
<pre class="code"><code class="java">
Map<String, Object> map1 = new HashMap<>();
map1.put("id", 100L);
map1.put("date", new Date());
...
CassandraEmbeddedServerBuilder
.withScriptTemplate("script1.cql", map1)
.withScriptTemplate("script2.cql", map2)
...
.build();
</code></pre>
@param scriptTemplateLocation location of the CQL script in the <strong>class path</strong>
@param values values to inject into the template.
@return CassandraEmbeddedServerBuilder
"""
Validator.validateNotBlank(scriptTemplateLocation, "The script template should not be blank while executing CassandraEmbeddedServerBuilder.withScriptTemplate()");
Validator.validateNotEmpty(values, "The template values should not be empty while executing CassandraEmbeddedServerBuilder.withScriptTemplate()");
scriptTemplates.put(scriptTemplateLocation.trim(), values);
return this;
}
|
java
|
public CassandraEmbeddedServerBuilder withScriptTemplate(String scriptTemplateLocation, Map<String, Object> values) {
Validator.validateNotBlank(scriptTemplateLocation, "The script template should not be blank while executing CassandraEmbeddedServerBuilder.withScriptTemplate()");
Validator.validateNotEmpty(values, "The template values should not be empty while executing CassandraEmbeddedServerBuilder.withScriptTemplate()");
scriptTemplates.put(scriptTemplateLocation.trim(), values);
return this;
}
|
[
"public",
"CassandraEmbeddedServerBuilder",
"withScriptTemplate",
"(",
"String",
"scriptTemplateLocation",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"values",
")",
"{",
"Validator",
".",
"validateNotBlank",
"(",
"scriptTemplateLocation",
",",
"\"The script template should not be blank while executing CassandraEmbeddedServerBuilder.withScriptTemplate()\"",
")",
";",
"Validator",
".",
"validateNotEmpty",
"(",
"values",
",",
"\"The template values should not be empty while executing CassandraEmbeddedServerBuilder.withScriptTemplate()\"",
")",
";",
"scriptTemplates",
".",
"put",
"(",
"scriptTemplateLocation",
".",
"trim",
"(",
")",
",",
"values",
")",
";",
"return",
"this",
";",
"}"
] |
Load an CQL script template in the class path, inject the values into the template
to produce the final script and execute it upon initialization
of the embedded Cassandra server
<br/>
Call this method as many times as there are CQL templates to be executed.
<br/>
Example:
<br/>
<pre class="code"><code class="java">
Map<String, Object> map1 = new HashMap<>();
map1.put("id", 100L);
map1.put("date", new Date());
...
CassandraEmbeddedServerBuilder
.withScriptTemplate("script1.cql", map1)
.withScriptTemplate("script2.cql", map2)
...
.build();
</code></pre>
@param scriptTemplateLocation location of the CQL script in the <strong>class path</strong>
@param values values to inject into the template.
@return CassandraEmbeddedServerBuilder
|
[
"Load",
"an",
"CQL",
"script",
"template",
"in",
"the",
"class",
"path",
"inject",
"the",
"values",
"into",
"the",
"template",
"to",
"produce",
"the",
"final",
"script",
"and",
"execute",
"it",
"upon",
"initialization",
"of",
"the",
"embedded",
"Cassandra",
"server"
] |
train
|
https://github.com/doanduyhai/Achilles/blob/8281c33100e72c993e570592ae1a5306afac6813/achilles-embedded/src/main/java/info/archinnov/achilles/embedded/CassandraEmbeddedServerBuilder.java#L465-L470
|
aol/cyclops
|
cyclops/src/main/java/com/oath/cyclops/internal/stream/FutureStreamUtils.java
|
FutureStreamUtils.forEachXEvents
|
public static <T, X extends Throwable> Tuple3<CompletableFuture<Subscription>, Runnable, CompletableFuture<Boolean>> forEachXEvents(
final Stream<T> stream, final long x, final Consumer<? super T> consumerElement, final Consumer<? super Throwable> consumerError,
final Runnable onComplete) {
"""
Perform a forEach operation over the Stream without closing it, capturing any elements and errors in the supplied consumers, but only consuming
the specified number of elements from the Stream, at this time. More elements can be consumed later, by called request on the returned Subscription,
when the entire Stream has been processed an onComplete event will be recieved.
<pre>
{@code
Subscription next = Streams.forEach(Stream.of(()->1,()->2,()->throw new RuntimeException(),()->4)
.map(Supplier::getValue) ,System.out::println, e->e.printStackTrace(),()->System.out.println("the take!"));
System.out.println("First batch processed!");
next.request(2);
System.out.println("Second batch processed!");
//prints
1
2
First batch processed!
RuntimeException Stack Trace on System.err
4
Second batch processed!
The take!
}
</pre>
@param stream - the Stream to consume data from
@param x To consume from the Stream at this time
@param consumerElement To accept incoming elements from the Stream
@param consumerError To accept incoming processing errors from the Stream
@param onComplete To run after an onComplete event
@return Subscription so that further processing can be continued or cancelled.
"""
final CompletableFuture<Boolean> streamCompleted = new CompletableFuture<>();
final Subscription s = new Subscription() {
Iterator<T> it = stream.iterator();
volatile boolean running = true;
@Override
public void request(final long n) {
for (int i = 0; i < n && running; i++) {
try {
if (it.hasNext()) {
consumerElement.accept(it.next());
} else {
try {
onComplete.run();
} finally {
streamCompleted.complete(true);
break;
}
}
} catch (final Throwable t) {
consumerError.accept(t);
}
}
}
@Override
public void cancel() {
running = false;
}
};
final CompletableFuture<Subscription> subscription = CompletableFuture.completedFuture(s);
return tuple(subscription, () -> {
s.request(x);
} , streamCompleted);
}
|
java
|
public static <T, X extends Throwable> Tuple3<CompletableFuture<Subscription>, Runnable, CompletableFuture<Boolean>> forEachXEvents(
final Stream<T> stream, final long x, final Consumer<? super T> consumerElement, final Consumer<? super Throwable> consumerError,
final Runnable onComplete) {
final CompletableFuture<Boolean> streamCompleted = new CompletableFuture<>();
final Subscription s = new Subscription() {
Iterator<T> it = stream.iterator();
volatile boolean running = true;
@Override
public void request(final long n) {
for (int i = 0; i < n && running; i++) {
try {
if (it.hasNext()) {
consumerElement.accept(it.next());
} else {
try {
onComplete.run();
} finally {
streamCompleted.complete(true);
break;
}
}
} catch (final Throwable t) {
consumerError.accept(t);
}
}
}
@Override
public void cancel() {
running = false;
}
};
final CompletableFuture<Subscription> subscription = CompletableFuture.completedFuture(s);
return tuple(subscription, () -> {
s.request(x);
} , streamCompleted);
}
|
[
"public",
"static",
"<",
"T",
",",
"X",
"extends",
"Throwable",
">",
"Tuple3",
"<",
"CompletableFuture",
"<",
"Subscription",
">",
",",
"Runnable",
",",
"CompletableFuture",
"<",
"Boolean",
">",
">",
"forEachXEvents",
"(",
"final",
"Stream",
"<",
"T",
">",
"stream",
",",
"final",
"long",
"x",
",",
"final",
"Consumer",
"<",
"?",
"super",
"T",
">",
"consumerElement",
",",
"final",
"Consumer",
"<",
"?",
"super",
"Throwable",
">",
"consumerError",
",",
"final",
"Runnable",
"onComplete",
")",
"{",
"final",
"CompletableFuture",
"<",
"Boolean",
">",
"streamCompleted",
"=",
"new",
"CompletableFuture",
"<>",
"(",
")",
";",
"final",
"Subscription",
"s",
"=",
"new",
"Subscription",
"(",
")",
"{",
"Iterator",
"<",
"T",
">",
"it",
"=",
"stream",
".",
"iterator",
"(",
")",
";",
"volatile",
"boolean",
"running",
"=",
"true",
";",
"@",
"Override",
"public",
"void",
"request",
"(",
"final",
"long",
"n",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
"&&",
"running",
";",
"i",
"++",
")",
"{",
"try",
"{",
"if",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"consumerElement",
".",
"accept",
"(",
"it",
".",
"next",
"(",
")",
")",
";",
"}",
"else",
"{",
"try",
"{",
"onComplete",
".",
"run",
"(",
")",
";",
"}",
"finally",
"{",
"streamCompleted",
".",
"complete",
"(",
"true",
")",
";",
"break",
";",
"}",
"}",
"}",
"catch",
"(",
"final",
"Throwable",
"t",
")",
"{",
"consumerError",
".",
"accept",
"(",
"t",
")",
";",
"}",
"}",
"}",
"@",
"Override",
"public",
"void",
"cancel",
"(",
")",
"{",
"running",
"=",
"false",
";",
"}",
"}",
";",
"final",
"CompletableFuture",
"<",
"Subscription",
">",
"subscription",
"=",
"CompletableFuture",
".",
"completedFuture",
"(",
"s",
")",
";",
"return",
"tuple",
"(",
"subscription",
",",
"(",
")",
"->",
"{",
"s",
".",
"request",
"(",
"x",
")",
";",
"}",
",",
"streamCompleted",
")",
";",
"}"
] |
Perform a forEach operation over the Stream without closing it, capturing any elements and errors in the supplied consumers, but only consuming
the specified number of elements from the Stream, at this time. More elements can be consumed later, by called request on the returned Subscription,
when the entire Stream has been processed an onComplete event will be recieved.
<pre>
{@code
Subscription next = Streams.forEach(Stream.of(()->1,()->2,()->throw new RuntimeException(),()->4)
.map(Supplier::getValue) ,System.out::println, e->e.printStackTrace(),()->System.out.println("the take!"));
System.out.println("First batch processed!");
next.request(2);
System.out.println("Second batch processed!");
//prints
1
2
First batch processed!
RuntimeException Stack Trace on System.err
4
Second batch processed!
The take!
}
</pre>
@param stream - the Stream to consume data from
@param x To consume from the Stream at this time
@param consumerElement To accept incoming elements from the Stream
@param consumerError To accept incoming processing errors from the Stream
@param onComplete To run after an onComplete event
@return Subscription so that further processing can be continued or cancelled.
|
[
"Perform",
"a",
"forEach",
"operation",
"over",
"the",
"Stream",
"without",
"closing",
"it",
"capturing",
"any",
"elements",
"and",
"errors",
"in",
"the",
"supplied",
"consumers",
"but",
"only",
"consuming",
"the",
"specified",
"number",
"of",
"elements",
"from",
"the",
"Stream",
"at",
"this",
"time",
".",
"More",
"elements",
"can",
"be",
"consumed",
"later",
"by",
"called",
"request",
"on",
"the",
"returned",
"Subscription",
"when",
"the",
"entire",
"Stream",
"has",
"been",
"processed",
"an",
"onComplete",
"event",
"will",
"be",
"recieved",
"."
] |
train
|
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/internal/stream/FutureStreamUtils.java#L126-L171
|
Azure/azure-sdk-for-java
|
datamigration/resource-manager/v2018_03_31_preview/src/main/java/com/microsoft/azure/management/datamigration/v2018_03_31_preview/implementation/TasksInner.java
|
TasksInner.updateAsync
|
public Observable<ProjectTaskInner> updateAsync(String groupName, String serviceName, String projectName, String taskName, ProjectTaskInner parameters) {
"""
Create or update task.
The tasks resource is a nested, proxy-only resource representing work performed by a DMS instance. The PATCH method updates an existing task, but since tasks have no mutable custom properties, there is little reason to do so.
@param groupName Name of the resource group
@param serviceName Name of the service
@param projectName Name of the project
@param taskName Name of the Task
@param parameters Information about the task
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ProjectTaskInner object
"""
return updateWithServiceResponseAsync(groupName, serviceName, projectName, taskName, parameters).map(new Func1<ServiceResponse<ProjectTaskInner>, ProjectTaskInner>() {
@Override
public ProjectTaskInner call(ServiceResponse<ProjectTaskInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<ProjectTaskInner> updateAsync(String groupName, String serviceName, String projectName, String taskName, ProjectTaskInner parameters) {
return updateWithServiceResponseAsync(groupName, serviceName, projectName, taskName, parameters).map(new Func1<ServiceResponse<ProjectTaskInner>, ProjectTaskInner>() {
@Override
public ProjectTaskInner call(ServiceResponse<ProjectTaskInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"ProjectTaskInner",
">",
"updateAsync",
"(",
"String",
"groupName",
",",
"String",
"serviceName",
",",
"String",
"projectName",
",",
"String",
"taskName",
",",
"ProjectTaskInner",
"parameters",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"groupName",
",",
"serviceName",
",",
"projectName",
",",
"taskName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ProjectTaskInner",
">",
",",
"ProjectTaskInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ProjectTaskInner",
"call",
"(",
"ServiceResponse",
"<",
"ProjectTaskInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Create or update task.
The tasks resource is a nested, proxy-only resource representing work performed by a DMS instance. The PATCH method updates an existing task, but since tasks have no mutable custom properties, there is little reason to do so.
@param groupName Name of the resource group
@param serviceName Name of the service
@param projectName Name of the project
@param taskName Name of the Task
@param parameters Information about the task
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ProjectTaskInner object
|
[
"Create",
"or",
"update",
"task",
".",
"The",
"tasks",
"resource",
"is",
"a",
"nested",
"proxy",
"-",
"only",
"resource",
"representing",
"work",
"performed",
"by",
"a",
"DMS",
"instance",
".",
"The",
"PATCH",
"method",
"updates",
"an",
"existing",
"task",
"but",
"since",
"tasks",
"have",
"no",
"mutable",
"custom",
"properties",
"there",
"is",
"little",
"reason",
"to",
"do",
"so",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datamigration/resource-manager/v2018_03_31_preview/src/main/java/com/microsoft/azure/management/datamigration/v2018_03_31_preview/implementation/TasksInner.java#L938-L945
|
google/j2objc
|
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/RuleBasedCollator.java
|
RuleBasedCollator.getCollationElementIterator
|
public CollationElementIterator getCollationElementIterator(CharacterIterator source) {
"""
Return a CollationElementIterator for the given CharacterIterator. The source iterator's integrity will be
preserved since a new copy will be created for use.
@see CollationElementIterator
"""
initMaxExpansions();
CharacterIterator newsource = (CharacterIterator) source.clone();
return new CollationElementIterator(newsource, this);
}
|
java
|
public CollationElementIterator getCollationElementIterator(CharacterIterator source) {
initMaxExpansions();
CharacterIterator newsource = (CharacterIterator) source.clone();
return new CollationElementIterator(newsource, this);
}
|
[
"public",
"CollationElementIterator",
"getCollationElementIterator",
"(",
"CharacterIterator",
"source",
")",
"{",
"initMaxExpansions",
"(",
")",
";",
"CharacterIterator",
"newsource",
"=",
"(",
"CharacterIterator",
")",
"source",
".",
"clone",
"(",
")",
";",
"return",
"new",
"CollationElementIterator",
"(",
"newsource",
",",
"this",
")",
";",
"}"
] |
Return a CollationElementIterator for the given CharacterIterator. The source iterator's integrity will be
preserved since a new copy will be created for use.
@see CollationElementIterator
|
[
"Return",
"a",
"CollationElementIterator",
"for",
"the",
"given",
"CharacterIterator",
".",
"The",
"source",
"iterator",
"s",
"integrity",
"will",
"be",
"preserved",
"since",
"a",
"new",
"copy",
"will",
"be",
"created",
"for",
"use",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/RuleBasedCollator.java#L277-L281
|
gallandarakhneorg/afc
|
advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/coordinate/GISCoordinates.java
|
GISCoordinates.WSG84_L93
|
@Pure
public static Point2d WSG84_L93(double lambda, double phi) {
"""
This function convert WSG84 GPS coordinate to France Lambert 93 coordinate.
@param lambda in degrees.
@param phi in degrees.
@return the France Lambert 93 coordinates.
"""
final Point2d ntfLambdaPhi = WSG84_NTFLamdaPhi(lambda, phi);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_93_N,
LAMBERT_93_C,
LAMBERT_93_XS,
LAMBERT_93_YS);
}
|
java
|
@Pure
public static Point2d WSG84_L93(double lambda, double phi) {
final Point2d ntfLambdaPhi = WSG84_NTFLamdaPhi(lambda, phi);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_93_N,
LAMBERT_93_C,
LAMBERT_93_XS,
LAMBERT_93_YS);
}
|
[
"@",
"Pure",
"public",
"static",
"Point2d",
"WSG84_L93",
"(",
"double",
"lambda",
",",
"double",
"phi",
")",
"{",
"final",
"Point2d",
"ntfLambdaPhi",
"=",
"WSG84_NTFLamdaPhi",
"(",
"lambda",
",",
"phi",
")",
";",
"return",
"NTFLambdaPhi_NTFLambert",
"(",
"ntfLambdaPhi",
".",
"getX",
"(",
")",
",",
"ntfLambdaPhi",
".",
"getY",
"(",
")",
",",
"LAMBERT_93_N",
",",
"LAMBERT_93_C",
",",
"LAMBERT_93_XS",
",",
"LAMBERT_93_YS",
")",
";",
"}"
] |
This function convert WSG84 GPS coordinate to France Lambert 93 coordinate.
@param lambda in degrees.
@param phi in degrees.
@return the France Lambert 93 coordinates.
|
[
"This",
"function",
"convert",
"WSG84",
"GPS",
"coordinate",
"to",
"France",
"Lambert",
"93",
"coordinate",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/coordinate/GISCoordinates.java#L1132-L1141
|
voldemort/voldemort
|
src/java/voldemort/rest/RestRequestValidator.java
|
RestRequestValidator.debugLog
|
protected void debugLog(String operationType, Long receivedTimeInMs) {
"""
Prints a debug log message that details the time taken for the Http
request to be parsed by the coordinator
@param operationType
@param receivedTimeInMs
"""
long durationInMs = receivedTimeInMs - (this.parsedRequestOriginTimeInMs);
int numVectorClockEntries = (this.parsedVectorClock == null ? 0
: this.parsedVectorClock.getVersionMap()
.size());
logger.debug("Received a new request. Operation type: " + operationType + " , Key(s): "
+ keysHexString(this.parsedKeys) + " , Store: " + this.storeName
+ " , Origin time (in ms): " + (this.parsedRequestOriginTimeInMs)
+ " , Request received at time(in ms): " + receivedTimeInMs
+ " , Num vector clock entries: " + numVectorClockEntries
+ " , Duration from RESTClient to CoordinatorRestRequestValidator(in ms): "
+ durationInMs);
}
|
java
|
protected void debugLog(String operationType, Long receivedTimeInMs) {
long durationInMs = receivedTimeInMs - (this.parsedRequestOriginTimeInMs);
int numVectorClockEntries = (this.parsedVectorClock == null ? 0
: this.parsedVectorClock.getVersionMap()
.size());
logger.debug("Received a new request. Operation type: " + operationType + " , Key(s): "
+ keysHexString(this.parsedKeys) + " , Store: " + this.storeName
+ " , Origin time (in ms): " + (this.parsedRequestOriginTimeInMs)
+ " , Request received at time(in ms): " + receivedTimeInMs
+ " , Num vector clock entries: " + numVectorClockEntries
+ " , Duration from RESTClient to CoordinatorRestRequestValidator(in ms): "
+ durationInMs);
}
|
[
"protected",
"void",
"debugLog",
"(",
"String",
"operationType",
",",
"Long",
"receivedTimeInMs",
")",
"{",
"long",
"durationInMs",
"=",
"receivedTimeInMs",
"-",
"(",
"this",
".",
"parsedRequestOriginTimeInMs",
")",
";",
"int",
"numVectorClockEntries",
"=",
"(",
"this",
".",
"parsedVectorClock",
"==",
"null",
"?",
"0",
":",
"this",
".",
"parsedVectorClock",
".",
"getVersionMap",
"(",
")",
".",
"size",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Received a new request. Operation type: \"",
"+",
"operationType",
"+",
"\" , Key(s): \"",
"+",
"keysHexString",
"(",
"this",
".",
"parsedKeys",
")",
"+",
"\" , Store: \"",
"+",
"this",
".",
"storeName",
"+",
"\" , Origin time (in ms): \"",
"+",
"(",
"this",
".",
"parsedRequestOriginTimeInMs",
")",
"+",
"\" , Request received at time(in ms): \"",
"+",
"receivedTimeInMs",
"+",
"\" , Num vector clock entries: \"",
"+",
"numVectorClockEntries",
"+",
"\" , Duration from RESTClient to CoordinatorRestRequestValidator(in ms): \"",
"+",
"durationInMs",
")",
";",
"}"
] |
Prints a debug log message that details the time taken for the Http
request to be parsed by the coordinator
@param operationType
@param receivedTimeInMs
|
[
"Prints",
"a",
"debug",
"log",
"message",
"that",
"details",
"the",
"time",
"taken",
"for",
"the",
"Http",
"request",
"to",
"be",
"parsed",
"by",
"the",
"coordinator"
] |
train
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/RestRequestValidator.java#L321-L334
|
kuali/ojb-1.0.4
|
src/java/org/apache/ojb/broker/accesslayer/MtoNCollectionPrefetcher.java
|
MtoNCollectionPrefetcher.buildPrefetchCriteria
|
private Criteria buildPrefetchCriteria(Collection ids, String[] fkCols, String[] itemFkCols,
FieldDescriptor[] itemPkFields) {
"""
Build the prefetch criteria
@param ids Collection of identities of M side
@param fkCols indirection table fks to this class
@param itemFkCols indirection table fks to item class
@param itemPkFields
"""
if (fkCols.length == 1 && itemFkCols.length == 1)
{
return buildPrefetchCriteriaSingleKey(ids, fkCols[0], itemFkCols[0], itemPkFields[0]);
}
else
{
return buildPrefetchCriteriaMultipleKeys(ids, fkCols, itemFkCols, itemPkFields);
}
}
|
java
|
private Criteria buildPrefetchCriteria(Collection ids, String[] fkCols, String[] itemFkCols,
FieldDescriptor[] itemPkFields)
{
if (fkCols.length == 1 && itemFkCols.length == 1)
{
return buildPrefetchCriteriaSingleKey(ids, fkCols[0], itemFkCols[0], itemPkFields[0]);
}
else
{
return buildPrefetchCriteriaMultipleKeys(ids, fkCols, itemFkCols, itemPkFields);
}
}
|
[
"private",
"Criteria",
"buildPrefetchCriteria",
"(",
"Collection",
"ids",
",",
"String",
"[",
"]",
"fkCols",
",",
"String",
"[",
"]",
"itemFkCols",
",",
"FieldDescriptor",
"[",
"]",
"itemPkFields",
")",
"{",
"if",
"(",
"fkCols",
".",
"length",
"==",
"1",
"&&",
"itemFkCols",
".",
"length",
"==",
"1",
")",
"{",
"return",
"buildPrefetchCriteriaSingleKey",
"(",
"ids",
",",
"fkCols",
"[",
"0",
"]",
",",
"itemFkCols",
"[",
"0",
"]",
",",
"itemPkFields",
"[",
"0",
"]",
")",
";",
"}",
"else",
"{",
"return",
"buildPrefetchCriteriaMultipleKeys",
"(",
"ids",
",",
"fkCols",
",",
"itemFkCols",
",",
"itemPkFields",
")",
";",
"}",
"}"
] |
Build the prefetch criteria
@param ids Collection of identities of M side
@param fkCols indirection table fks to this class
@param itemFkCols indirection table fks to item class
@param itemPkFields
|
[
"Build",
"the",
"prefetch",
"criteria"
] |
train
|
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/MtoNCollectionPrefetcher.java#L260-L272
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/util/TypeUtil.java
|
TypeUtil.getActualType
|
public static Type getActualType(Type actualType, Class<?> typeDefineClass, Type typeVariable) {
"""
获取指定泛型变量对应的真实类型<br>
由于子类中泛型参数实现和父类(接口)中泛型定义位置是一一对应的,因此可以通过对应关系找到泛型实现类型<br>
使用此方法注意:
<pre>
1. superClass必须是clazz的父类或者clazz实现的接口
2. typeVariable必须在superClass中声明
</pre>
@param actualType 真实类型所在类,此类中记录了泛型参数对应的实际类型
@param typeDefineClass 泛型变量声明所在类或接口,此类中定义了泛型类型
@param typeVariable 泛型变量,需要的实际类型对应的泛型参数
@return 给定泛型参数对应的实际类型
@since 4.5.2
"""
Type[] types = getActualTypes(actualType, typeDefineClass, typeVariable);
if(ArrayUtil.isNotEmpty(types)) {
return types[0];
}
return null;
}
|
java
|
public static Type getActualType(Type actualType, Class<?> typeDefineClass, Type typeVariable) {
Type[] types = getActualTypes(actualType, typeDefineClass, typeVariable);
if(ArrayUtil.isNotEmpty(types)) {
return types[0];
}
return null;
}
|
[
"public",
"static",
"Type",
"getActualType",
"(",
"Type",
"actualType",
",",
"Class",
"<",
"?",
">",
"typeDefineClass",
",",
"Type",
"typeVariable",
")",
"{",
"Type",
"[",
"]",
"types",
"=",
"getActualTypes",
"(",
"actualType",
",",
"typeDefineClass",
",",
"typeVariable",
")",
";",
"if",
"(",
"ArrayUtil",
".",
"isNotEmpty",
"(",
"types",
")",
")",
"{",
"return",
"types",
"[",
"0",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
获取指定泛型变量对应的真实类型<br>
由于子类中泛型参数实现和父类(接口)中泛型定义位置是一一对应的,因此可以通过对应关系找到泛型实现类型<br>
使用此方法注意:
<pre>
1. superClass必须是clazz的父类或者clazz实现的接口
2. typeVariable必须在superClass中声明
</pre>
@param actualType 真实类型所在类,此类中记录了泛型参数对应的实际类型
@param typeDefineClass 泛型变量声明所在类或接口,此类中定义了泛型类型
@param typeVariable 泛型变量,需要的实际类型对应的泛型参数
@return 给定泛型参数对应的实际类型
@since 4.5.2
|
[
"获取指定泛型变量对应的真实类型<br",
">",
"由于子类中泛型参数实现和父类(接口)中泛型定义位置是一一对应的,因此可以通过对应关系找到泛型实现类型<br",
">",
"使用此方法注意:"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/TypeUtil.java#L325-L331
|
Azure/azure-sdk-for-java
|
labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/GlobalUsersInner.java
|
GlobalUsersInner.beginStopEnvironmentAsync
|
public Observable<Void> beginStopEnvironmentAsync(String userName, String environmentId) {
"""
Stops an environment by stopping all resources inside the environment This operation can take a while to complete.
@param userName The name of the user.
@param environmentId The resourceId of the environment
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return beginStopEnvironmentWithServiceResponseAsync(userName, environmentId).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
|
java
|
public Observable<Void> beginStopEnvironmentAsync(String userName, String environmentId) {
return beginStopEnvironmentWithServiceResponseAsync(userName, environmentId).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"Void",
">",
"beginStopEnvironmentAsync",
"(",
"String",
"userName",
",",
"String",
"environmentId",
")",
"{",
"return",
"beginStopEnvironmentWithServiceResponseAsync",
"(",
"userName",
",",
"environmentId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Stops an environment by stopping all resources inside the environment This operation can take a while to complete.
@param userName The name of the user.
@param environmentId The resourceId of the environment
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
|
[
"Stops",
"an",
"environment",
"by",
"stopping",
"all",
"resources",
"inside",
"the",
"environment",
"This",
"operation",
"can",
"take",
"a",
"while",
"to",
"complete",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/GlobalUsersInner.java#L1326-L1333
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/VirtualWANsInner.java
|
VirtualWANsInner.beginCreateOrUpdateAsync
|
public Observable<VirtualWANInner> beginCreateOrUpdateAsync(String resourceGroupName, String virtualWANName, VirtualWANInner wANParameters) {
"""
Creates a VirtualWAN resource if it doesn't exist else updates the existing VirtualWAN.
@param resourceGroupName The resource group name of the VirtualWan.
@param virtualWANName The name of the VirtualWAN being created or updated.
@param wANParameters Parameters supplied to create or update VirtualWAN.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualWANInner object
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualWANName, wANParameters).map(new Func1<ServiceResponse<VirtualWANInner>, VirtualWANInner>() {
@Override
public VirtualWANInner call(ServiceResponse<VirtualWANInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<VirtualWANInner> beginCreateOrUpdateAsync(String resourceGroupName, String virtualWANName, VirtualWANInner wANParameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualWANName, wANParameters).map(new Func1<ServiceResponse<VirtualWANInner>, VirtualWANInner>() {
@Override
public VirtualWANInner call(ServiceResponse<VirtualWANInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"VirtualWANInner",
">",
"beginCreateOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualWANName",
",",
"VirtualWANInner",
"wANParameters",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualWANName",
",",
"wANParameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"VirtualWANInner",
">",
",",
"VirtualWANInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"VirtualWANInner",
"call",
"(",
"ServiceResponse",
"<",
"VirtualWANInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Creates a VirtualWAN resource if it doesn't exist else updates the existing VirtualWAN.
@param resourceGroupName The resource group name of the VirtualWan.
@param virtualWANName The name of the VirtualWAN being created or updated.
@param wANParameters Parameters supplied to create or update VirtualWAN.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualWANInner object
|
[
"Creates",
"a",
"VirtualWAN",
"resource",
"if",
"it",
"doesn",
"t",
"exist",
"else",
"updates",
"the",
"existing",
"VirtualWAN",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/VirtualWANsInner.java#L313-L320
|
Azure/azure-sdk-for-java
|
keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java
|
KeyVaultClientImpl.deleteSecretAsync
|
public Observable<SecretBundle> deleteSecretAsync(String vaultBaseUrl, String secretName) {
"""
Deletes a secret from a specified key vault.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param secretName The name of the secret.
@return the observable to the SecretBundle object
"""
return deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName).map(new Func1<ServiceResponse<SecretBundle>, SecretBundle>() {
@Override
public SecretBundle call(ServiceResponse<SecretBundle> response) {
return response.body();
}
});
}
|
java
|
public Observable<SecretBundle> deleteSecretAsync(String vaultBaseUrl, String secretName) {
return deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName).map(new Func1<ServiceResponse<SecretBundle>, SecretBundle>() {
@Override
public SecretBundle call(ServiceResponse<SecretBundle> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"SecretBundle",
">",
"deleteSecretAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"secretName",
")",
"{",
"return",
"deleteSecretWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"secretName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"SecretBundle",
">",
",",
"SecretBundle",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"SecretBundle",
"call",
"(",
"ServiceResponse",
"<",
"SecretBundle",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Deletes a secret from a specified key vault.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param secretName The name of the secret.
@return the observable to the SecretBundle object
|
[
"Deletes",
"a",
"secret",
"from",
"a",
"specified",
"key",
"vault",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java#L2617-L2624
|
google/error-prone-javac
|
src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java
|
TreeScanner.visitVariable
|
@Override
public R visitVariable(VariableTree node, P p) {
"""
{@inheritDoc} This implementation scans the children in left to right order.
@param node {@inheritDoc}
@param p {@inheritDoc}
@return the result of scanning
"""
R r = scan(node.getModifiers(), p);
r = scanAndReduce(node.getType(), p, r);
r = scanAndReduce(node.getNameExpression(), p, r);
r = scanAndReduce(node.getInitializer(), p, r);
return r;
}
|
java
|
@Override
public R visitVariable(VariableTree node, P p) {
R r = scan(node.getModifiers(), p);
r = scanAndReduce(node.getType(), p, r);
r = scanAndReduce(node.getNameExpression(), p, r);
r = scanAndReduce(node.getInitializer(), p, r);
return r;
}
|
[
"@",
"Override",
"public",
"R",
"visitVariable",
"(",
"VariableTree",
"node",
",",
"P",
"p",
")",
"{",
"R",
"r",
"=",
"scan",
"(",
"node",
".",
"getModifiers",
"(",
")",
",",
"p",
")",
";",
"r",
"=",
"scanAndReduce",
"(",
"node",
".",
"getType",
"(",
")",
",",
"p",
",",
"r",
")",
";",
"r",
"=",
"scanAndReduce",
"(",
"node",
".",
"getNameExpression",
"(",
")",
",",
"p",
",",
"r",
")",
";",
"r",
"=",
"scanAndReduce",
"(",
"node",
".",
"getInitializer",
"(",
")",
",",
"p",
",",
"r",
")",
";",
"return",
"r",
";",
"}"
] |
{@inheritDoc} This implementation scans the children in left to right order.
@param node {@inheritDoc}
@param p {@inheritDoc}
@return the result of scanning
|
[
"{",
"@inheritDoc",
"}",
"This",
"implementation",
"scans",
"the",
"children",
"in",
"left",
"to",
"right",
"order",
"."
] |
train
|
https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java#L218-L225
|
alkacon/opencms-core
|
src/org/opencms/gwt/CmsVfsService.java
|
CmsVfsService.getPageInfo
|
private CmsListInfoBean getPageInfo(CmsResource res) throws CmsException, CmsLoaderException {
"""
Returns a bean to display the {@link org.opencms.gwt.client.ui.CmsListItemWidget}.<p>
@param res the resource to get the page info for
@return a bean to display the {@link org.opencms.gwt.client.ui.CmsListItemWidget}.<p>
@throws CmsLoaderException if the resource type could not be found
@throws CmsException if something else goes wrong
"""
CmsObject cms = getCmsObject();
return getPageInfo(cms, res);
}
|
java
|
private CmsListInfoBean getPageInfo(CmsResource res) throws CmsException, CmsLoaderException {
CmsObject cms = getCmsObject();
return getPageInfo(cms, res);
}
|
[
"private",
"CmsListInfoBean",
"getPageInfo",
"(",
"CmsResource",
"res",
")",
"throws",
"CmsException",
",",
"CmsLoaderException",
"{",
"CmsObject",
"cms",
"=",
"getCmsObject",
"(",
")",
";",
"return",
"getPageInfo",
"(",
"cms",
",",
"res",
")",
";",
"}"
] |
Returns a bean to display the {@link org.opencms.gwt.client.ui.CmsListItemWidget}.<p>
@param res the resource to get the page info for
@return a bean to display the {@link org.opencms.gwt.client.ui.CmsListItemWidget}.<p>
@throws CmsLoaderException if the resource type could not be found
@throws CmsException if something else goes wrong
|
[
"Returns",
"a",
"bean",
"to",
"display",
"the",
"{",
"@link",
"org",
".",
"opencms",
".",
"gwt",
".",
"client",
".",
"ui",
".",
"CmsListItemWidget",
"}",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/gwt/CmsVfsService.java#L1592-L1596
|
spring-projects/spring-mobile
|
spring-mobile-device/src/main/java/org/springframework/mobile/device/switcher/SiteSwitcherHandlerInterceptor.java
|
SiteSwitcherHandlerInterceptor.mDot
|
public static SiteSwitcherHandlerInterceptor mDot(String serverName, Boolean tabletIsMobile) {
"""
Creates a site switcher that redirects to a <code>m.</code> domain for normal site requests that either
originate from a mobile device or indicate a mobile site preference.
Uses a {@link CookieSitePreferenceRepository} that saves a cookie that is shared between the two domains.
"""
return new SiteSwitcherHandlerInterceptor(StandardSiteSwitcherHandlerFactory.mDot(serverName, tabletIsMobile));
}
|
java
|
public static SiteSwitcherHandlerInterceptor mDot(String serverName, Boolean tabletIsMobile) {
return new SiteSwitcherHandlerInterceptor(StandardSiteSwitcherHandlerFactory.mDot(serverName, tabletIsMobile));
}
|
[
"public",
"static",
"SiteSwitcherHandlerInterceptor",
"mDot",
"(",
"String",
"serverName",
",",
"Boolean",
"tabletIsMobile",
")",
"{",
"return",
"new",
"SiteSwitcherHandlerInterceptor",
"(",
"StandardSiteSwitcherHandlerFactory",
".",
"mDot",
"(",
"serverName",
",",
"tabletIsMobile",
")",
")",
";",
"}"
] |
Creates a site switcher that redirects to a <code>m.</code> domain for normal site requests that either
originate from a mobile device or indicate a mobile site preference.
Uses a {@link CookieSitePreferenceRepository} that saves a cookie that is shared between the two domains.
|
[
"Creates",
"a",
"site",
"switcher",
"that",
"redirects",
"to",
"a",
"<code",
">",
"m",
".",
"<",
"/",
"code",
">",
"domain",
"for",
"normal",
"site",
"requests",
"that",
"either",
"originate",
"from",
"a",
"mobile",
"device",
"or",
"indicate",
"a",
"mobile",
"site",
"preference",
".",
"Uses",
"a",
"{"
] |
train
|
https://github.com/spring-projects/spring-mobile/blob/a402cbcaf208e24288b957f44c9984bd6e8bf064/spring-mobile-device/src/main/java/org/springframework/mobile/device/switcher/SiteSwitcherHandlerInterceptor.java#L130-L132
|
lettuce-io/lettuce-core
|
src/main/java/io/lettuce/core/dynamic/support/ResolvableType.java
|
ResolvableType.forClassWithGenerics
|
public static ResolvableType forClassWithGenerics(Class<?> sourceClass, ResolvableType... generics) {
"""
Return a {@link ResolvableType} for the specified {@link Class} with pre-declared generics.
@param sourceClass the source class
@param generics the generics of the class
@return a {@link ResolvableType} for the specific class and generics
@see #forClassWithGenerics(Class, Class...)
"""
LettuceAssert.notNull(sourceClass, "Source class must not be null");
LettuceAssert.notNull(generics, "Generics must not be null");
TypeVariable<?>[] variables = sourceClass.getTypeParameters();
LettuceAssert.isTrue(variables.length == generics.length, "Mismatched number of generics specified");
Type[] arguments = new Type[generics.length];
for (int i = 0; i < generics.length; i++) {
ResolvableType generic = generics[i];
Type argument = (generic != null ? generic.getType() : null);
arguments[i] = (argument != null ? argument : variables[i]);
}
ParameterizedType syntheticType = new SyntheticParameterizedType(sourceClass, arguments);
return forType(syntheticType, new TypeVariablesVariableResolver(variables, generics));
}
|
java
|
public static ResolvableType forClassWithGenerics(Class<?> sourceClass, ResolvableType... generics) {
LettuceAssert.notNull(sourceClass, "Source class must not be null");
LettuceAssert.notNull(generics, "Generics must not be null");
TypeVariable<?>[] variables = sourceClass.getTypeParameters();
LettuceAssert.isTrue(variables.length == generics.length, "Mismatched number of generics specified");
Type[] arguments = new Type[generics.length];
for (int i = 0; i < generics.length; i++) {
ResolvableType generic = generics[i];
Type argument = (generic != null ? generic.getType() : null);
arguments[i] = (argument != null ? argument : variables[i]);
}
ParameterizedType syntheticType = new SyntheticParameterizedType(sourceClass, arguments);
return forType(syntheticType, new TypeVariablesVariableResolver(variables, generics));
}
|
[
"public",
"static",
"ResolvableType",
"forClassWithGenerics",
"(",
"Class",
"<",
"?",
">",
"sourceClass",
",",
"ResolvableType",
"...",
"generics",
")",
"{",
"LettuceAssert",
".",
"notNull",
"(",
"sourceClass",
",",
"\"Source class must not be null\"",
")",
";",
"LettuceAssert",
".",
"notNull",
"(",
"generics",
",",
"\"Generics must not be null\"",
")",
";",
"TypeVariable",
"<",
"?",
">",
"[",
"]",
"variables",
"=",
"sourceClass",
".",
"getTypeParameters",
"(",
")",
";",
"LettuceAssert",
".",
"isTrue",
"(",
"variables",
".",
"length",
"==",
"generics",
".",
"length",
",",
"\"Mismatched number of generics specified\"",
")",
";",
"Type",
"[",
"]",
"arguments",
"=",
"new",
"Type",
"[",
"generics",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"generics",
".",
"length",
";",
"i",
"++",
")",
"{",
"ResolvableType",
"generic",
"=",
"generics",
"[",
"i",
"]",
";",
"Type",
"argument",
"=",
"(",
"generic",
"!=",
"null",
"?",
"generic",
".",
"getType",
"(",
")",
":",
"null",
")",
";",
"arguments",
"[",
"i",
"]",
"=",
"(",
"argument",
"!=",
"null",
"?",
"argument",
":",
"variables",
"[",
"i",
"]",
")",
";",
"}",
"ParameterizedType",
"syntheticType",
"=",
"new",
"SyntheticParameterizedType",
"(",
"sourceClass",
",",
"arguments",
")",
";",
"return",
"forType",
"(",
"syntheticType",
",",
"new",
"TypeVariablesVariableResolver",
"(",
"variables",
",",
"generics",
")",
")",
";",
"}"
] |
Return a {@link ResolvableType} for the specified {@link Class} with pre-declared generics.
@param sourceClass the source class
@param generics the generics of the class
@return a {@link ResolvableType} for the specific class and generics
@see #forClassWithGenerics(Class, Class...)
|
[
"Return",
"a",
"{",
"@link",
"ResolvableType",
"}",
"for",
"the",
"specified",
"{",
"@link",
"Class",
"}",
"with",
"pre",
"-",
"declared",
"generics",
"."
] |
train
|
https://github.com/lettuce-io/lettuce-core/blob/b6de74e384dea112e3656684ca3f50cdfd6c8e0d/src/main/java/io/lettuce/core/dynamic/support/ResolvableType.java#L895-L910
|
devnied/Bit-lib4j
|
src/main/java/fr/devnied/bitlib/BitUtils.java
|
BitUtils.getNextDate
|
public Date getNextDate(final int pSize, final String pPattern, final boolean pUseBcd) {
"""
Method to get the next date
@param pSize
the size of the string date in bit
@param pPattern
the Date pattern
@param pUseBcd
get the Date with BCD format (Binary coded decimal)
@return a date object or null
"""
Date date = null;
// create date formatter
SimpleDateFormat sdf = new SimpleDateFormat(pPattern);
// get String
String dateTxt = null;
if (pUseBcd) {
dateTxt = getNextHexaString(pSize);
} else {
dateTxt = getNextString(pSize);
}
try {
date = sdf.parse(dateTxt);
} catch (ParseException e) {
LOGGER.error("Parsing date error. date:" + dateTxt + " pattern:" + pPattern, e);
}
return date;
}
|
java
|
public Date getNextDate(final int pSize, final String pPattern, final boolean pUseBcd) {
Date date = null;
// create date formatter
SimpleDateFormat sdf = new SimpleDateFormat(pPattern);
// get String
String dateTxt = null;
if (pUseBcd) {
dateTxt = getNextHexaString(pSize);
} else {
dateTxt = getNextString(pSize);
}
try {
date = sdf.parse(dateTxt);
} catch (ParseException e) {
LOGGER.error("Parsing date error. date:" + dateTxt + " pattern:" + pPattern, e);
}
return date;
}
|
[
"public",
"Date",
"getNextDate",
"(",
"final",
"int",
"pSize",
",",
"final",
"String",
"pPattern",
",",
"final",
"boolean",
"pUseBcd",
")",
"{",
"Date",
"date",
"=",
"null",
";",
"// create date formatter\r",
"SimpleDateFormat",
"sdf",
"=",
"new",
"SimpleDateFormat",
"(",
"pPattern",
")",
";",
"// get String\r",
"String",
"dateTxt",
"=",
"null",
";",
"if",
"(",
"pUseBcd",
")",
"{",
"dateTxt",
"=",
"getNextHexaString",
"(",
"pSize",
")",
";",
"}",
"else",
"{",
"dateTxt",
"=",
"getNextString",
"(",
"pSize",
")",
";",
"}",
"try",
"{",
"date",
"=",
"sdf",
".",
"parse",
"(",
"dateTxt",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Parsing date error. date:\"",
"+",
"dateTxt",
"+",
"\" pattern:\"",
"+",
"pPattern",
",",
"e",
")",
";",
"}",
"return",
"date",
";",
"}"
] |
Method to get the next date
@param pSize
the size of the string date in bit
@param pPattern
the Date pattern
@param pUseBcd
get the Date with BCD format (Binary coded decimal)
@return a date object or null
|
[
"Method",
"to",
"get",
"the",
"next",
"date"
] |
train
|
https://github.com/devnied/Bit-lib4j/blob/bdfa79fd12e7e3d5cf1196291825ef1bb12a1ee0/src/main/java/fr/devnied/bitlib/BitUtils.java#L245-L263
|
hawkular/hawkular-apm
|
client/instrumenter/src/main/java/org/hawkular/apm/instrumenter/RuleHelper.java
|
RuleHelper.removeSuffix
|
public String removeSuffix(String original, String suffix) {
"""
This method removes the supplied suffix (if it exists) in the
supplied 'original' string.
@param original The original string
@param suffix The suffix to remove
@return The modified string
"""
if (original.endsWith(suffix)) {
return original.substring(0, original.length() - suffix.length());
}
return original;
}
|
java
|
public String removeSuffix(String original, String suffix) {
if (original.endsWith(suffix)) {
return original.substring(0, original.length() - suffix.length());
}
return original;
}
|
[
"public",
"String",
"removeSuffix",
"(",
"String",
"original",
",",
"String",
"suffix",
")",
"{",
"if",
"(",
"original",
".",
"endsWith",
"(",
"suffix",
")",
")",
"{",
"return",
"original",
".",
"substring",
"(",
"0",
",",
"original",
".",
"length",
"(",
")",
"-",
"suffix",
".",
"length",
"(",
")",
")",
";",
"}",
"return",
"original",
";",
"}"
] |
This method removes the supplied suffix (if it exists) in the
supplied 'original' string.
@param original The original string
@param suffix The suffix to remove
@return The modified string
|
[
"This",
"method",
"removes",
"the",
"supplied",
"suffix",
"(",
"if",
"it",
"exists",
")",
"in",
"the",
"supplied",
"original",
"string",
"."
] |
train
|
https://github.com/hawkular/hawkular-apm/blob/57a4df0611b359597626563ea5f9ac64d4bb2533/client/instrumenter/src/main/java/org/hawkular/apm/instrumenter/RuleHelper.java#L270-L275
|
line/armeria
|
core/src/main/java/com/linecorp/armeria/server/annotation/JacksonRequestConverterFunction.java
|
JacksonRequestConverterFunction.convertRequest
|
@Override
@Nullable
public Object convertRequest(ServiceRequestContext ctx, AggregatedHttpMessage request,
Class<?> expectedResultType) throws Exception {
"""
Converts the specified {@link AggregatedHttpMessage} to an object of {@code expectedResultType}.
"""
final MediaType contentType = request.contentType();
if (contentType != null && (contentType.is(MediaType.JSON) ||
contentType.subtype().endsWith("+json"))) {
final ObjectReader reader = readers.computeIfAbsent(expectedResultType, mapper::readerFor);
if (reader != null) {
final String content = request.content(contentType.charset().orElse(StandardCharsets.UTF_8));
try {
return reader.readValue(content);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException("failed to parse a JSON document: " + e, e);
}
}
}
return RequestConverterFunction.fallthrough();
}
|
java
|
@Override
@Nullable
public Object convertRequest(ServiceRequestContext ctx, AggregatedHttpMessage request,
Class<?> expectedResultType) throws Exception {
final MediaType contentType = request.contentType();
if (contentType != null && (contentType.is(MediaType.JSON) ||
contentType.subtype().endsWith("+json"))) {
final ObjectReader reader = readers.computeIfAbsent(expectedResultType, mapper::readerFor);
if (reader != null) {
final String content = request.content(contentType.charset().orElse(StandardCharsets.UTF_8));
try {
return reader.readValue(content);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException("failed to parse a JSON document: " + e, e);
}
}
}
return RequestConverterFunction.fallthrough();
}
|
[
"@",
"Override",
"@",
"Nullable",
"public",
"Object",
"convertRequest",
"(",
"ServiceRequestContext",
"ctx",
",",
"AggregatedHttpMessage",
"request",
",",
"Class",
"<",
"?",
">",
"expectedResultType",
")",
"throws",
"Exception",
"{",
"final",
"MediaType",
"contentType",
"=",
"request",
".",
"contentType",
"(",
")",
";",
"if",
"(",
"contentType",
"!=",
"null",
"&&",
"(",
"contentType",
".",
"is",
"(",
"MediaType",
".",
"JSON",
")",
"||",
"contentType",
".",
"subtype",
"(",
")",
".",
"endsWith",
"(",
"\"+json\"",
")",
")",
")",
"{",
"final",
"ObjectReader",
"reader",
"=",
"readers",
".",
"computeIfAbsent",
"(",
"expectedResultType",
",",
"mapper",
"::",
"readerFor",
")",
";",
"if",
"(",
"reader",
"!=",
"null",
")",
"{",
"final",
"String",
"content",
"=",
"request",
".",
"content",
"(",
"contentType",
".",
"charset",
"(",
")",
".",
"orElse",
"(",
"StandardCharsets",
".",
"UTF_8",
")",
")",
";",
"try",
"{",
"return",
"reader",
".",
"readValue",
"(",
"content",
")",
";",
"}",
"catch",
"(",
"JsonProcessingException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"failed to parse a JSON document: \"",
"+",
"e",
",",
"e",
")",
";",
"}",
"}",
"}",
"return",
"RequestConverterFunction",
".",
"fallthrough",
"(",
")",
";",
"}"
] |
Converts the specified {@link AggregatedHttpMessage} to an object of {@code expectedResultType}.
|
[
"Converts",
"the",
"specified",
"{"
] |
train
|
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/server/annotation/JacksonRequestConverterFunction.java#L63-L82
|
b3dgs/lionengine
|
lionengine-core/src/main/java/com/b3dgs/lionengine/Xml.java
|
Xml.createChild
|
public Xml createChild(String child) {
"""
Create a child node.
@param child The child name@throws LionEngineException If invalid argument.
@return The child node.
"""
Check.notNull(child);
final Element element = document.createElement(child);
root.appendChild(element);
return new Xml(document, element);
}
|
java
|
public Xml createChild(String child)
{
Check.notNull(child);
final Element element = document.createElement(child);
root.appendChild(element);
return new Xml(document, element);
}
|
[
"public",
"Xml",
"createChild",
"(",
"String",
"child",
")",
"{",
"Check",
".",
"notNull",
"(",
"child",
")",
";",
"final",
"Element",
"element",
"=",
"document",
".",
"createElement",
"(",
"child",
")",
";",
"root",
".",
"appendChild",
"(",
"element",
")",
";",
"return",
"new",
"Xml",
"(",
"document",
",",
"element",
")",
";",
"}"
] |
Create a child node.
@param child The child name@throws LionEngineException If invalid argument.
@return The child node.
|
[
"Create",
"a",
"child",
"node",
"."
] |
train
|
https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/Xml.java#L174-L181
|
marvinlabs/android-slideshow-widget
|
library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java
|
SlideShowView.playSlide
|
protected void playSlide(int currentPosition, int previousPosition) {
"""
Play the current slide in the playlist if it is ready. If that slide is not available, we
move to the next one. If that slide is loading, we wait until it is ready and then we play
it.
"""
final SlideStatus slideStatus = adapter.getSlideStatus(currentPosition);
final PlayList pl = getPlaylist();
// Don't play anything if we have reached the end
if (currentPosition < 0) {
stop();
return;
}
// Stop anything planned
slideHandler.removeCallbacksAndMessages(null);
// If the slide is ready, then we can display it straight away
switch (slideStatus) {
case READY:
notAvailableSlidesSkipped = 0;
// We are playing the slide show!
status = Status.PLAYING;
// Schedule next slide
if (pl.isAutoAdvanceEnabled()) {
slideHandler.postDelayed(moveToNextSlide, pl.getSlideDuration(currentPosition));
}
// Display the slide
displaySlide(currentPosition, previousPosition);
break;
case NOT_AVAILABLE:
Log.w("SlideShowView", "Slide is not available: " + currentPosition);
// Stop if we have already skipped all slides
++notAvailableSlidesSkipped;
if (notAvailableSlidesSkipped < adapter.getCount()) {
prepareSlide(pl.getNextSlide());
next();
} else {
Log.w("SlideShowView", "Skipped too many slides in a row. Stopping playback.");
stop();
}
break;
case LOADING:
Log.d("SlideShowView", "Slide is not yet ready, waiting for it: " + currentPosition);
// Show an indicator to the user
showProgressIndicator();
// Start waiting for the slide to be available
waitForCurrentSlide.startWaiting(currentPosition, previousPosition);
break;
}
}
|
java
|
protected void playSlide(int currentPosition, int previousPosition) {
final SlideStatus slideStatus = adapter.getSlideStatus(currentPosition);
final PlayList pl = getPlaylist();
// Don't play anything if we have reached the end
if (currentPosition < 0) {
stop();
return;
}
// Stop anything planned
slideHandler.removeCallbacksAndMessages(null);
// If the slide is ready, then we can display it straight away
switch (slideStatus) {
case READY:
notAvailableSlidesSkipped = 0;
// We are playing the slide show!
status = Status.PLAYING;
// Schedule next slide
if (pl.isAutoAdvanceEnabled()) {
slideHandler.postDelayed(moveToNextSlide, pl.getSlideDuration(currentPosition));
}
// Display the slide
displaySlide(currentPosition, previousPosition);
break;
case NOT_AVAILABLE:
Log.w("SlideShowView", "Slide is not available: " + currentPosition);
// Stop if we have already skipped all slides
++notAvailableSlidesSkipped;
if (notAvailableSlidesSkipped < adapter.getCount()) {
prepareSlide(pl.getNextSlide());
next();
} else {
Log.w("SlideShowView", "Skipped too many slides in a row. Stopping playback.");
stop();
}
break;
case LOADING:
Log.d("SlideShowView", "Slide is not yet ready, waiting for it: " + currentPosition);
// Show an indicator to the user
showProgressIndicator();
// Start waiting for the slide to be available
waitForCurrentSlide.startWaiting(currentPosition, previousPosition);
break;
}
}
|
[
"protected",
"void",
"playSlide",
"(",
"int",
"currentPosition",
",",
"int",
"previousPosition",
")",
"{",
"final",
"SlideStatus",
"slideStatus",
"=",
"adapter",
".",
"getSlideStatus",
"(",
"currentPosition",
")",
";",
"final",
"PlayList",
"pl",
"=",
"getPlaylist",
"(",
")",
";",
"// Don't play anything if we have reached the end",
"if",
"(",
"currentPosition",
"<",
"0",
")",
"{",
"stop",
"(",
")",
";",
"return",
";",
"}",
"// Stop anything planned",
"slideHandler",
".",
"removeCallbacksAndMessages",
"(",
"null",
")",
";",
"// If the slide is ready, then we can display it straight away",
"switch",
"(",
"slideStatus",
")",
"{",
"case",
"READY",
":",
"notAvailableSlidesSkipped",
"=",
"0",
";",
"// We are playing the slide show!",
"status",
"=",
"Status",
".",
"PLAYING",
";",
"// Schedule next slide",
"if",
"(",
"pl",
".",
"isAutoAdvanceEnabled",
"(",
")",
")",
"{",
"slideHandler",
".",
"postDelayed",
"(",
"moveToNextSlide",
",",
"pl",
".",
"getSlideDuration",
"(",
"currentPosition",
")",
")",
";",
"}",
"// Display the slide",
"displaySlide",
"(",
"currentPosition",
",",
"previousPosition",
")",
";",
"break",
";",
"case",
"NOT_AVAILABLE",
":",
"Log",
".",
"w",
"(",
"\"SlideShowView\"",
",",
"\"Slide is not available: \"",
"+",
"currentPosition",
")",
";",
"// Stop if we have already skipped all slides",
"++",
"notAvailableSlidesSkipped",
";",
"if",
"(",
"notAvailableSlidesSkipped",
"<",
"adapter",
".",
"getCount",
"(",
")",
")",
"{",
"prepareSlide",
"(",
"pl",
".",
"getNextSlide",
"(",
")",
")",
";",
"next",
"(",
")",
";",
"}",
"else",
"{",
"Log",
".",
"w",
"(",
"\"SlideShowView\"",
",",
"\"Skipped too many slides in a row. Stopping playback.\"",
")",
";",
"stop",
"(",
")",
";",
"}",
"break",
";",
"case",
"LOADING",
":",
"Log",
".",
"d",
"(",
"\"SlideShowView\"",
",",
"\"Slide is not yet ready, waiting for it: \"",
"+",
"currentPosition",
")",
";",
"// Show an indicator to the user",
"showProgressIndicator",
"(",
")",
";",
"// Start waiting for the slide to be available",
"waitForCurrentSlide",
".",
"startWaiting",
"(",
"currentPosition",
",",
"previousPosition",
")",
";",
"break",
";",
"}",
"}"
] |
Play the current slide in the playlist if it is ready. If that slide is not available, we
move to the next one. If that slide is loading, we wait until it is ready and then we play
it.
|
[
"Play",
"the",
"current",
"slide",
"in",
"the",
"playlist",
"if",
"it",
"is",
"ready",
".",
"If",
"that",
"slide",
"is",
"not",
"available",
"we",
"move",
"to",
"the",
"next",
"one",
".",
"If",
"that",
"slide",
"is",
"loading",
"we",
"wait",
"until",
"it",
"is",
"ready",
"and",
"then",
"we",
"play",
"it",
"."
] |
train
|
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L513-L569
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-freefax/src/main/java/net/minidev/ovh/api/ApiOvhFreefax.java
|
ApiOvhFreefax.serviceName_voicemail_PUT
|
public void serviceName_voicemail_PUT(String serviceName, OvhVoicemailProperties body) throws IOException {
"""
Alter this object properties
REST: PUT /freefax/{serviceName}/voicemail
@param body [required] New object properties
@param serviceName [required] Freefax number
"""
String qPath = "/freefax/{serviceName}/voicemail";
StringBuilder sb = path(qPath, serviceName);
exec(qPath, "PUT", sb.toString(), body);
}
|
java
|
public void serviceName_voicemail_PUT(String serviceName, OvhVoicemailProperties body) throws IOException {
String qPath = "/freefax/{serviceName}/voicemail";
StringBuilder sb = path(qPath, serviceName);
exec(qPath, "PUT", sb.toString(), body);
}
|
[
"public",
"void",
"serviceName_voicemail_PUT",
"(",
"String",
"serviceName",
",",
"OvhVoicemailProperties",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/freefax/{serviceName}/voicemail\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] |
Alter this object properties
REST: PUT /freefax/{serviceName}/voicemail
@param body [required] New object properties
@param serviceName [required] Freefax number
|
[
"Alter",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-freefax/src/main/java/net/minidev/ovh/api/ApiOvhFreefax.java#L98-L102
|
openbase/jul
|
schedule/src/main/java/org/openbase/jul/schedule/Stopwatch.java
|
Stopwatch.getTime
|
public long getTime() throws NotAvailableException {
"""
This method returns the time interval between the start- and end timestamps.
In case the the Stopwatch is still running, the elapsed time since Stopwatch start will be returned.
@return the time interval in milliseconds.
@throws NotAvailableException This exception will thrown in case the timer was never started.
"""
synchronized (timeSync) {
try {
if (!isRunning()) {
throw new InvalidStateException("Stopwatch was never started!");
}
if (endTime == -1) {
return System.currentTimeMillis() - startTime;
}
return endTime - startTime;
} catch (CouldNotPerformException ex) {
throw new NotAvailableException(ContextType.INSTANCE, "time", ex);
}
}
}
|
java
|
public long getTime() throws NotAvailableException {
synchronized (timeSync) {
try {
if (!isRunning()) {
throw new InvalidStateException("Stopwatch was never started!");
}
if (endTime == -1) {
return System.currentTimeMillis() - startTime;
}
return endTime - startTime;
} catch (CouldNotPerformException ex) {
throw new NotAvailableException(ContextType.INSTANCE, "time", ex);
}
}
}
|
[
"public",
"long",
"getTime",
"(",
")",
"throws",
"NotAvailableException",
"{",
"synchronized",
"(",
"timeSync",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"isRunning",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidStateException",
"(",
"\"Stopwatch was never started!\"",
")",
";",
"}",
"if",
"(",
"endTime",
"==",
"-",
"1",
")",
"{",
"return",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"startTime",
";",
"}",
"return",
"endTime",
"-",
"startTime",
";",
"}",
"catch",
"(",
"CouldNotPerformException",
"ex",
")",
"{",
"throw",
"new",
"NotAvailableException",
"(",
"ContextType",
".",
"INSTANCE",
",",
"\"time\"",
",",
"ex",
")",
";",
"}",
"}",
"}"
] |
This method returns the time interval between the start- and end timestamps.
In case the the Stopwatch is still running, the elapsed time since Stopwatch start will be returned.
@return the time interval in milliseconds.
@throws NotAvailableException This exception will thrown in case the timer was never started.
|
[
"This",
"method",
"returns",
"the",
"time",
"interval",
"between",
"the",
"start",
"-",
"and",
"end",
"timestamps",
".",
"In",
"case",
"the",
"the",
"Stopwatch",
"is",
"still",
"running",
"the",
"elapsed",
"time",
"since",
"Stopwatch",
"start",
"will",
"be",
"returned",
"."
] |
train
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/schedule/src/main/java/org/openbase/jul/schedule/Stopwatch.java#L92-L108
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/ExternalContextUtils.java
|
ExternalContextUtils.getSessionId
|
public static String getSessionId(ExternalContext ec, boolean create) {
"""
Returns the current active session id or <code>null</code> if there is
none.
@param ec the current external context
@param create create a new session if one is not created
@return a string containing the requestedSessionId
"""
Object session = ec.getSession(create);
return (null != session) ? (String) _runMethod(session, "getId") : null;
}
|
java
|
public static String getSessionId(ExternalContext ec, boolean create)
{
Object session = ec.getSession(create);
return (null != session) ? (String) _runMethod(session, "getId") : null;
}
|
[
"public",
"static",
"String",
"getSessionId",
"(",
"ExternalContext",
"ec",
",",
"boolean",
"create",
")",
"{",
"Object",
"session",
"=",
"ec",
".",
"getSession",
"(",
"create",
")",
";",
"return",
"(",
"null",
"!=",
"session",
")",
"?",
"(",
"String",
")",
"_runMethod",
"(",
"session",
",",
"\"getId\"",
")",
":",
"null",
";",
"}"
] |
Returns the current active session id or <code>null</code> if there is
none.
@param ec the current external context
@param create create a new session if one is not created
@return a string containing the requestedSessionId
|
[
"Returns",
"the",
"current",
"active",
"session",
"id",
"or",
"<code",
">",
"null<",
"/",
"code",
">",
"if",
"there",
"is",
"none",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/ExternalContextUtils.java#L235-L239
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/VirtualNetworkGatewaysInner.java
|
VirtualNetworkGatewaysInner.beginGenerateVpnProfileAsync
|
public Observable<String> beginGenerateVpnProfileAsync(String resourceGroupName, String virtualNetworkGatewayName, VpnClientParameters parameters) {
"""
Generates VPN profile for P2S client of the virtual network gateway in the specified resource group. Used for IKEV2 and radius based authentication.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@param parameters Parameters supplied to the generate virtual network gateway VPN client package operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the String object
"""
return beginGenerateVpnProfileWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName, parameters).map(new Func1<ServiceResponse<String>, String>() {
@Override
public String call(ServiceResponse<String> response) {
return response.body();
}
});
}
|
java
|
public Observable<String> beginGenerateVpnProfileAsync(String resourceGroupName, String virtualNetworkGatewayName, VpnClientParameters parameters) {
return beginGenerateVpnProfileWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName, parameters).map(new Func1<ServiceResponse<String>, String>() {
@Override
public String call(ServiceResponse<String> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"String",
">",
"beginGenerateVpnProfileAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualNetworkGatewayName",
",",
"VpnClientParameters",
"parameters",
")",
"{",
"return",
"beginGenerateVpnProfileWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualNetworkGatewayName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"String",
">",
",",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"call",
"(",
"ServiceResponse",
"<",
"String",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Generates VPN profile for P2S client of the virtual network gateway in the specified resource group. Used for IKEV2 and radius based authentication.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@param parameters Parameters supplied to the generate virtual network gateway VPN client package operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the String object
|
[
"Generates",
"VPN",
"profile",
"for",
"P2S",
"client",
"of",
"the",
"virtual",
"network",
"gateway",
"in",
"the",
"specified",
"resource",
"group",
".",
"Used",
"for",
"IKEV2",
"and",
"radius",
"based",
"authentication",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/VirtualNetworkGatewaysInner.java#L1734-L1741
|
datacleaner/AnalyzerBeans
|
components/value-distribution/src/main/java/org/eobjects/analyzer/result/AbstractValueCountingAnalyzerResult.java
|
AbstractValueCountingAnalyzerResult.appendToString
|
protected void appendToString(StringBuilder sb, ValueCountingAnalyzerResult groupResult, int maxEntries) {
"""
Appends a string representation with a maximum amount of entries
@param sb
the StringBuilder to append to
@param maxEntries
@return
"""
if (maxEntries != 0) {
Collection<ValueFrequency> valueCounts = groupResult.getValueCounts();
for (ValueFrequency valueCount : valueCounts) {
sb.append("\n - ");
sb.append(valueCount.getName());
sb.append(": ");
sb.append(valueCount.getCount());
maxEntries--;
if (maxEntries == 0) {
sb.append("\n ...");
break;
}
}
}
}
|
java
|
protected void appendToString(StringBuilder sb, ValueCountingAnalyzerResult groupResult, int maxEntries) {
if (maxEntries != 0) {
Collection<ValueFrequency> valueCounts = groupResult.getValueCounts();
for (ValueFrequency valueCount : valueCounts) {
sb.append("\n - ");
sb.append(valueCount.getName());
sb.append(": ");
sb.append(valueCount.getCount());
maxEntries--;
if (maxEntries == 0) {
sb.append("\n ...");
break;
}
}
}
}
|
[
"protected",
"void",
"appendToString",
"(",
"StringBuilder",
"sb",
",",
"ValueCountingAnalyzerResult",
"groupResult",
",",
"int",
"maxEntries",
")",
"{",
"if",
"(",
"maxEntries",
"!=",
"0",
")",
"{",
"Collection",
"<",
"ValueFrequency",
">",
"valueCounts",
"=",
"groupResult",
".",
"getValueCounts",
"(",
")",
";",
"for",
"(",
"ValueFrequency",
"valueCount",
":",
"valueCounts",
")",
"{",
"sb",
".",
"append",
"(",
"\"\\n - \"",
")",
";",
"sb",
".",
"append",
"(",
"valueCount",
".",
"getName",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\": \"",
")",
";",
"sb",
".",
"append",
"(",
"valueCount",
".",
"getCount",
"(",
")",
")",
";",
"maxEntries",
"--",
";",
"if",
"(",
"maxEntries",
"==",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"\"\\n ...\"",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] |
Appends a string representation with a maximum amount of entries
@param sb
the StringBuilder to append to
@param maxEntries
@return
|
[
"Appends",
"a",
"string",
"representation",
"with",
"a",
"maximum",
"amount",
"of",
"entries"
] |
train
|
https://github.com/datacleaner/AnalyzerBeans/blob/f82dae080d80d2a647b706a5fb22b3ea250613b3/components/value-distribution/src/main/java/org/eobjects/analyzer/result/AbstractValueCountingAnalyzerResult.java#L179-L195
|
btaz/data-util
|
src/main/java/com/btaz/util/files/FileDeleter.java
|
FileDeleter.deleteFilesByRegex
|
public static void deleteFilesByRegex(File dir, String regex) {
"""
Delete files in a directory matching a regular expression
@param dir directory
@param regex regular expression
"""
if(regex == null) {
throw new DataUtilException("Filename regex can not be null");
}
FilenameFilter filter = new RegexFilenameFilter(regex);
FileDeleter.deleteFiles(dir, filter);
}
|
java
|
public static void deleteFilesByRegex(File dir, String regex) {
if(regex == null) {
throw new DataUtilException("Filename regex can not be null");
}
FilenameFilter filter = new RegexFilenameFilter(regex);
FileDeleter.deleteFiles(dir, filter);
}
|
[
"public",
"static",
"void",
"deleteFilesByRegex",
"(",
"File",
"dir",
",",
"String",
"regex",
")",
"{",
"if",
"(",
"regex",
"==",
"null",
")",
"{",
"throw",
"new",
"DataUtilException",
"(",
"\"Filename regex can not be null\"",
")",
";",
"}",
"FilenameFilter",
"filter",
"=",
"new",
"RegexFilenameFilter",
"(",
"regex",
")",
";",
"FileDeleter",
".",
"deleteFiles",
"(",
"dir",
",",
"filter",
")",
";",
"}"
] |
Delete files in a directory matching a regular expression
@param dir directory
@param regex regular expression
|
[
"Delete",
"files",
"in",
"a",
"directory",
"matching",
"a",
"regular",
"expression"
] |
train
|
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/files/FileDeleter.java#L30-L36
|
bmwcarit/joynr
|
java/javaapi/src/main/java/io/joynr/provider/AbstractSubscriptionPublisher.java
|
AbstractSubscriptionPublisher.fireMulticast
|
protected void fireMulticast(String multicastName, String[] partitions, Object... values) {
"""
Called by generated {@code <Interface>AbstractProvider} classes to notify
all registered multicast listeners about the fired multicast.
<p>
NOTE: Provider implementations should _not_ call this method but use
multicast specific {@code <Interface>AbstractProvider.fire<Multicast>}
methods.
@param multicastName the multicast name as defined in the Franca model (as a non-selective broadcast).
@param partitions the partitions which will be used in transmitting the multicast
@param values the broadcast arguments.
"""
List<MulticastListener> listeners;
synchronized (multicastListeners) {
listeners = new ArrayList<>(multicastListeners);
}
for (MulticastListener listener : listeners) {
listener.multicastOccurred(multicastName, partitions, values);
}
}
|
java
|
protected void fireMulticast(String multicastName, String[] partitions, Object... values) {
List<MulticastListener> listeners;
synchronized (multicastListeners) {
listeners = new ArrayList<>(multicastListeners);
}
for (MulticastListener listener : listeners) {
listener.multicastOccurred(multicastName, partitions, values);
}
}
|
[
"protected",
"void",
"fireMulticast",
"(",
"String",
"multicastName",
",",
"String",
"[",
"]",
"partitions",
",",
"Object",
"...",
"values",
")",
"{",
"List",
"<",
"MulticastListener",
">",
"listeners",
";",
"synchronized",
"(",
"multicastListeners",
")",
"{",
"listeners",
"=",
"new",
"ArrayList",
"<>",
"(",
"multicastListeners",
")",
";",
"}",
"for",
"(",
"MulticastListener",
"listener",
":",
"listeners",
")",
"{",
"listener",
".",
"multicastOccurred",
"(",
"multicastName",
",",
"partitions",
",",
"values",
")",
";",
"}",
"}"
] |
Called by generated {@code <Interface>AbstractProvider} classes to notify
all registered multicast listeners about the fired multicast.
<p>
NOTE: Provider implementations should _not_ call this method but use
multicast specific {@code <Interface>AbstractProvider.fire<Multicast>}
methods.
@param multicastName the multicast name as defined in the Franca model (as a non-selective broadcast).
@param partitions the partitions which will be used in transmitting the multicast
@param values the broadcast arguments.
|
[
"Called",
"by",
"generated",
"{",
"@code",
"<Interface",
">",
"AbstractProvider",
"}",
"classes",
"to",
"notify",
"all",
"registered",
"multicast",
"listeners",
"about",
"the",
"fired",
"multicast",
".",
"<p",
">",
"NOTE",
":",
"Provider",
"implementations",
"should",
"_not_",
"call",
"this",
"method",
"but",
"use",
"multicast",
"specific",
"{",
"@code",
"<Interface",
">",
"AbstractProvider",
".",
"fire<Multicast",
">",
"}",
"methods",
"."
] |
train
|
https://github.com/bmwcarit/joynr/blob/b7a92bad1cf2f093de080facd2c803560f4c6c26/java/javaapi/src/main/java/io/joynr/provider/AbstractSubscriptionPublisher.java#L109-L117
|
keenon/loglinear
|
src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java
|
GraphicalModel.addBinaryFactor
|
public Factor addBinaryFactor(int a, int cardA, int b, int cardB, BiFunction<Integer, Integer, ConcatVector> featurizer) {
"""
Add a binary factor, with known dimensions for the variables
@param a The index of the first variable.
@param cardA The cardinality (i.e, dimension) of the first factor
@param b The index of the second variable
@param cardB The cardinality (i.e, dimension) of the second factor
@param featurizer The featurizer. This takes as input two assignments for the two variables, and returns the features on
those variables.
@return a reference to the created factor. This can be safely ignored, as the factor is already saved in the model
"""
return addFactor(new int[]{a, b}, new int[]{cardA, cardB}, assignment -> featurizer.apply(assignment[0], assignment[1]) );
}
|
java
|
public Factor addBinaryFactor(int a, int cardA, int b, int cardB, BiFunction<Integer, Integer, ConcatVector> featurizer) {
return addFactor(new int[]{a, b}, new int[]{cardA, cardB}, assignment -> featurizer.apply(assignment[0], assignment[1]) );
}
|
[
"public",
"Factor",
"addBinaryFactor",
"(",
"int",
"a",
",",
"int",
"cardA",
",",
"int",
"b",
",",
"int",
"cardB",
",",
"BiFunction",
"<",
"Integer",
",",
"Integer",
",",
"ConcatVector",
">",
"featurizer",
")",
"{",
"return",
"addFactor",
"(",
"new",
"int",
"[",
"]",
"{",
"a",
",",
"b",
"}",
",",
"new",
"int",
"[",
"]",
"{",
"cardA",
",",
"cardB",
"}",
",",
"assignment",
"->",
"featurizer",
".",
"apply",
"(",
"assignment",
"[",
"0",
"]",
",",
"assignment",
"[",
"1",
"]",
")",
")",
";",
"}"
] |
Add a binary factor, with known dimensions for the variables
@param a The index of the first variable.
@param cardA The cardinality (i.e, dimension) of the first factor
@param b The index of the second variable
@param cardB The cardinality (i.e, dimension) of the second factor
@param featurizer The featurizer. This takes as input two assignments for the two variables, and returns the features on
those variables.
@return a reference to the created factor. This can be safely ignored, as the factor is already saved in the model
|
[
"Add",
"a",
"binary",
"factor",
"with",
"known",
"dimensions",
"for",
"the",
"variables"
] |
train
|
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java#L455-L457
|
infinispan/infinispan
|
core/src/main/java/org/infinispan/util/concurrent/CommandAckCollector.java
|
CommandAckCollector.multiKeyBackupAck
|
public void multiKeyBackupAck(long id, Address from, int segment, int topologyId) {
"""
Acknowledges a {@link org.infinispan.commands.write.PutMapCommand} completion in the backup owner.
@param id the id from {@link CommandInvocationId#getId()}.
@param from the backup owner.
@param segment the segments affected and acknowledged.
@param topologyId the topology id.
"""
SegmentBasedCollector collector = (SegmentBasedCollector) collectorMap.get(id);
if (collector != null) {
collector.backupAck(from, segment, topologyId);
}
}
|
java
|
public void multiKeyBackupAck(long id, Address from, int segment, int topologyId) {
SegmentBasedCollector collector = (SegmentBasedCollector) collectorMap.get(id);
if (collector != null) {
collector.backupAck(from, segment, topologyId);
}
}
|
[
"public",
"void",
"multiKeyBackupAck",
"(",
"long",
"id",
",",
"Address",
"from",
",",
"int",
"segment",
",",
"int",
"topologyId",
")",
"{",
"SegmentBasedCollector",
"collector",
"=",
"(",
"SegmentBasedCollector",
")",
"collectorMap",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"collector",
"!=",
"null",
")",
"{",
"collector",
".",
"backupAck",
"(",
"from",
",",
"segment",
",",
"topologyId",
")",
";",
"}",
"}"
] |
Acknowledges a {@link org.infinispan.commands.write.PutMapCommand} completion in the backup owner.
@param id the id from {@link CommandInvocationId#getId()}.
@param from the backup owner.
@param segment the segments affected and acknowledged.
@param topologyId the topology id.
|
[
"Acknowledges",
"a",
"{",
"@link",
"org",
".",
"infinispan",
".",
"commands",
".",
"write",
".",
"PutMapCommand",
"}",
"completion",
"in",
"the",
"backup",
"owner",
"."
] |
train
|
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/util/concurrent/CommandAckCollector.java#L151-L156
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/BooleanField.java
|
BooleanField.getSQLFilter
|
public String getSQLFilter(String strSeekSign, String strCompare, boolean bComparison) {
"""
Retrieve (in string format) from this field.
This method is used for SQL calls (ie., WHERE Id=5 AND Name="Don")
@return String the ' = "Don"' portion.
@param strSeekSign The sign in the comparison.
@param strCompare Use the current field values or plug in a '?'
@param bComparison true if this is a comparison, otherwise this is an assignment statement.
"""
if (strCompare == null)
{ // Use the current field value
Boolean bField = (Boolean)this.getData(); // Get the physical data
if (bField != null)
{
boolean bValue = bField.booleanValue();
if (bValue == false)
strCompare = SQLFALSE;
else
strCompare = SQLTRUE;
}
}
return super.getSQLFilter(strSeekSign, strCompare, bComparison);
}
|
java
|
public String getSQLFilter(String strSeekSign, String strCompare, boolean bComparison)
{
if (strCompare == null)
{ // Use the current field value
Boolean bField = (Boolean)this.getData(); // Get the physical data
if (bField != null)
{
boolean bValue = bField.booleanValue();
if (bValue == false)
strCompare = SQLFALSE;
else
strCompare = SQLTRUE;
}
}
return super.getSQLFilter(strSeekSign, strCompare, bComparison);
}
|
[
"public",
"String",
"getSQLFilter",
"(",
"String",
"strSeekSign",
",",
"String",
"strCompare",
",",
"boolean",
"bComparison",
")",
"{",
"if",
"(",
"strCompare",
"==",
"null",
")",
"{",
"// Use the current field value",
"Boolean",
"bField",
"=",
"(",
"Boolean",
")",
"this",
".",
"getData",
"(",
")",
";",
"// Get the physical data",
"if",
"(",
"bField",
"!=",
"null",
")",
"{",
"boolean",
"bValue",
"=",
"bField",
".",
"booleanValue",
"(",
")",
";",
"if",
"(",
"bValue",
"==",
"false",
")",
"strCompare",
"=",
"SQLFALSE",
";",
"else",
"strCompare",
"=",
"SQLTRUE",
";",
"}",
"}",
"return",
"super",
".",
"getSQLFilter",
"(",
"strSeekSign",
",",
"strCompare",
",",
"bComparison",
")",
";",
"}"
] |
Retrieve (in string format) from this field.
This method is used for SQL calls (ie., WHERE Id=5 AND Name="Don")
@return String the ' = "Don"' portion.
@param strSeekSign The sign in the comparison.
@param strCompare Use the current field values or plug in a '?'
@param bComparison true if this is a comparison, otherwise this is an assignment statement.
|
[
"Retrieve",
"(",
"in",
"string",
"format",
")",
"from",
"this",
"field",
".",
"This",
"method",
"is",
"used",
"for",
"SQL",
"calls",
"(",
"ie",
".",
"WHERE",
"Id",
"=",
"5",
"AND",
"Name",
"=",
"Don",
")"
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/BooleanField.java#L145-L160
|
aNNiMON/Lightweight-Stream-API
|
stream/src/main/java/com/annimon/stream/RandomCompat.java
|
RandomCompat.longs
|
@NotNull
public LongStream longs(final long randomNumberOrigin, final long randomNumberBound) {
"""
Returns an effectively unlimited stream of pseudorandom {@code long}
values, each conforming to the given origin (inclusive) and bound (exclusive)
@param randomNumberOrigin the origin (inclusive) of each random value
@param randomNumberBound the bound (exclusive) of each random value
@return a stream of pseudorandom {@code long} values,
each with the given origin (inclusive) and bound (exclusive)
@throws IllegalArgumentException if {@code randomNumberOrigin}
is greater than or equal to {@code randomNumberBound}
"""
if (randomNumberOrigin >= randomNumberBound) {
throw new IllegalArgumentException();
}
return LongStream.generate(new LongSupplier() {
private final long bound = randomNumberBound - randomNumberOrigin;
private final long boundMinus1 = bound - 1;
@Override
public long getAsLong() {
long result = random.nextLong();
if ((bound & boundMinus1) == 0L) {
// power of two
result = (result & boundMinus1) + randomNumberOrigin;
} else if (bound > 0L) {
// reject over-represented candidates
long u = result >>> 1; // ensure nonnegative
while (u + boundMinus1 - (result = u % bound) < 0L) {
u = random.nextLong() >>> 1;
}
result += randomNumberOrigin;
} else {
// range not representable as long
while (randomNumberOrigin >= result || result >= randomNumberBound) {
result = random.nextLong();
}
}
return result;
}
});
}
|
java
|
@NotNull
public LongStream longs(final long randomNumberOrigin, final long randomNumberBound) {
if (randomNumberOrigin >= randomNumberBound) {
throw new IllegalArgumentException();
}
return LongStream.generate(new LongSupplier() {
private final long bound = randomNumberBound - randomNumberOrigin;
private final long boundMinus1 = bound - 1;
@Override
public long getAsLong() {
long result = random.nextLong();
if ((bound & boundMinus1) == 0L) {
// power of two
result = (result & boundMinus1) + randomNumberOrigin;
} else if (bound > 0L) {
// reject over-represented candidates
long u = result >>> 1; // ensure nonnegative
while (u + boundMinus1 - (result = u % bound) < 0L) {
u = random.nextLong() >>> 1;
}
result += randomNumberOrigin;
} else {
// range not representable as long
while (randomNumberOrigin >= result || result >= randomNumberBound) {
result = random.nextLong();
}
}
return result;
}
});
}
|
[
"@",
"NotNull",
"public",
"LongStream",
"longs",
"(",
"final",
"long",
"randomNumberOrigin",
",",
"final",
"long",
"randomNumberBound",
")",
"{",
"if",
"(",
"randomNumberOrigin",
">=",
"randomNumberBound",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"return",
"LongStream",
".",
"generate",
"(",
"new",
"LongSupplier",
"(",
")",
"{",
"private",
"final",
"long",
"bound",
"=",
"randomNumberBound",
"-",
"randomNumberOrigin",
";",
"private",
"final",
"long",
"boundMinus1",
"=",
"bound",
"-",
"1",
";",
"@",
"Override",
"public",
"long",
"getAsLong",
"(",
")",
"{",
"long",
"result",
"=",
"random",
".",
"nextLong",
"(",
")",
";",
"if",
"(",
"(",
"bound",
"&",
"boundMinus1",
")",
"==",
"0L",
")",
"{",
"// power of two",
"result",
"=",
"(",
"result",
"&",
"boundMinus1",
")",
"+",
"randomNumberOrigin",
";",
"}",
"else",
"if",
"(",
"bound",
">",
"0L",
")",
"{",
"// reject over-represented candidates",
"long",
"u",
"=",
"result",
">>>",
"1",
";",
"// ensure nonnegative",
"while",
"(",
"u",
"+",
"boundMinus1",
"-",
"(",
"result",
"=",
"u",
"%",
"bound",
")",
"<",
"0L",
")",
"{",
"u",
"=",
"random",
".",
"nextLong",
"(",
")",
">>>",
"1",
";",
"}",
"result",
"+=",
"randomNumberOrigin",
";",
"}",
"else",
"{",
"// range not representable as long",
"while",
"(",
"randomNumberOrigin",
">=",
"result",
"||",
"result",
">=",
"randomNumberBound",
")",
"{",
"result",
"=",
"random",
".",
"nextLong",
"(",
")",
";",
"}",
"}",
"return",
"result",
";",
"}",
"}",
")",
";",
"}"
] |
Returns an effectively unlimited stream of pseudorandom {@code long}
values, each conforming to the given origin (inclusive) and bound (exclusive)
@param randomNumberOrigin the origin (inclusive) of each random value
@param randomNumberBound the bound (exclusive) of each random value
@return a stream of pseudorandom {@code long} values,
each with the given origin (inclusive) and bound (exclusive)
@throws IllegalArgumentException if {@code randomNumberOrigin}
is greater than or equal to {@code randomNumberBound}
|
[
"Returns",
"an",
"effectively",
"unlimited",
"stream",
"of",
"pseudorandom",
"{",
"@code",
"long",
"}",
"values",
"each",
"conforming",
"to",
"the",
"given",
"origin",
"(",
"inclusive",
")",
"and",
"bound",
"(",
"exclusive",
")"
] |
train
|
https://github.com/aNNiMON/Lightweight-Stream-API/blob/f29fd57208c20252a4549b084d55ed082c3e58f0/stream/src/main/java/com/annimon/stream/RandomCompat.java#L293-L325
|
matthewhorridge/owlapi-gwt
|
owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLLiteralImplInteger_CustomFieldSerializer.java
|
OWLLiteralImplInteger_CustomFieldSerializer.serializeInstance
|
@Override
public void serializeInstance(SerializationStreamWriter streamWriter, OWLLiteralImplInteger instance) throws SerializationException {
"""
Serializes the content of the object into the
{@link com.google.gwt.user.client.rpc.SerializationStreamWriter}.
@param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the
object's content to
@param instance the object instance to serialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the serialization operation is not
successful
"""
serialize(streamWriter, instance);
}
|
java
|
@Override
public void serializeInstance(SerializationStreamWriter streamWriter, OWLLiteralImplInteger instance) throws SerializationException {
serialize(streamWriter, instance);
}
|
[
"@",
"Override",
"public",
"void",
"serializeInstance",
"(",
"SerializationStreamWriter",
"streamWriter",
",",
"OWLLiteralImplInteger",
"instance",
")",
"throws",
"SerializationException",
"{",
"serialize",
"(",
"streamWriter",
",",
"instance",
")",
";",
"}"
] |
Serializes the content of the object into the
{@link com.google.gwt.user.client.rpc.SerializationStreamWriter}.
@param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the
object's content to
@param instance the object instance to serialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the serialization operation is not
successful
|
[
"Serializes",
"the",
"content",
"of",
"the",
"object",
"into",
"the",
"{"
] |
train
|
https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLLiteralImplInteger_CustomFieldSerializer.java#L63-L66
|
census-instrumentation/opencensus-java
|
contrib/http_util/src/main/java/io/opencensus/contrib/http/AbstractHttpHandler.java
|
AbstractHttpHandler.handleMessageSent
|
public final void handleMessageSent(HttpRequestContext context, long bytes) {
"""
Instrument an HTTP span after a message is sent. Typically called for every chunk of request or
response is sent.
@param context request specific {@link HttpRequestContext}
@param bytes bytes sent.
@since 0.19
"""
checkNotNull(context, "context");
context.sentMessageSize.addAndGet(bytes);
if (context.span.getOptions().contains(Options.RECORD_EVENTS)) {
// record compressed size
recordMessageEvent(context.span, context.sentSeqId.addAndGet(1L), Type.SENT, bytes, 0L);
}
}
|
java
|
public final void handleMessageSent(HttpRequestContext context, long bytes) {
checkNotNull(context, "context");
context.sentMessageSize.addAndGet(bytes);
if (context.span.getOptions().contains(Options.RECORD_EVENTS)) {
// record compressed size
recordMessageEvent(context.span, context.sentSeqId.addAndGet(1L), Type.SENT, bytes, 0L);
}
}
|
[
"public",
"final",
"void",
"handleMessageSent",
"(",
"HttpRequestContext",
"context",
",",
"long",
"bytes",
")",
"{",
"checkNotNull",
"(",
"context",
",",
"\"context\"",
")",
";",
"context",
".",
"sentMessageSize",
".",
"addAndGet",
"(",
"bytes",
")",
";",
"if",
"(",
"context",
".",
"span",
".",
"getOptions",
"(",
")",
".",
"contains",
"(",
"Options",
".",
"RECORD_EVENTS",
")",
")",
"{",
"// record compressed size",
"recordMessageEvent",
"(",
"context",
".",
"span",
",",
"context",
".",
"sentSeqId",
".",
"addAndGet",
"(",
"1L",
")",
",",
"Type",
".",
"SENT",
",",
"bytes",
",",
"0L",
")",
";",
"}",
"}"
] |
Instrument an HTTP span after a message is sent. Typically called for every chunk of request or
response is sent.
@param context request specific {@link HttpRequestContext}
@param bytes bytes sent.
@since 0.19
|
[
"Instrument",
"an",
"HTTP",
"span",
"after",
"a",
"message",
"is",
"sent",
".",
"Typically",
"called",
"for",
"every",
"chunk",
"of",
"request",
"or",
"response",
"is",
"sent",
"."
] |
train
|
https://github.com/census-instrumentation/opencensus-java/blob/deefac9bed77e40a2297bff1ca5ec5aa48a5f755/contrib/http_util/src/main/java/io/opencensus/contrib/http/AbstractHttpHandler.java#L77-L84
|
openbase/jul
|
communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java
|
AbstractRemoteClient.waitForData
|
@Override
public void waitForData() throws CouldNotPerformException, InterruptedException {
"""
{@inheritDoc}
@throws CouldNotPerformException {@inheritDoc}
@throws InterruptedException {@inheritDoc}
"""
try {
if (isDataAvailable()) {
return;
}
logger.debug("Wait for " + this.toString() + " data...");
getDataFuture().get();
dataObservable.waitForValue();
} catch (ExecutionException | CancellationException ex) {
if (shutdownInitiated) {
throw new InterruptedException("Interrupt request because system shutdown was initiated!");
}
throw new CouldNotPerformException("Could not wait for data!", ex);
}
}
|
java
|
@Override
public void waitForData() throws CouldNotPerformException, InterruptedException {
try {
if (isDataAvailable()) {
return;
}
logger.debug("Wait for " + this.toString() + " data...");
getDataFuture().get();
dataObservable.waitForValue();
} catch (ExecutionException | CancellationException ex) {
if (shutdownInitiated) {
throw new InterruptedException("Interrupt request because system shutdown was initiated!");
}
throw new CouldNotPerformException("Could not wait for data!", ex);
}
}
|
[
"@",
"Override",
"public",
"void",
"waitForData",
"(",
")",
"throws",
"CouldNotPerformException",
",",
"InterruptedException",
"{",
"try",
"{",
"if",
"(",
"isDataAvailable",
"(",
")",
")",
"{",
"return",
";",
"}",
"logger",
".",
"debug",
"(",
"\"Wait for \"",
"+",
"this",
".",
"toString",
"(",
")",
"+",
"\" data...\"",
")",
";",
"getDataFuture",
"(",
")",
".",
"get",
"(",
")",
";",
"dataObservable",
".",
"waitForValue",
"(",
")",
";",
"}",
"catch",
"(",
"ExecutionException",
"|",
"CancellationException",
"ex",
")",
"{",
"if",
"(",
"shutdownInitiated",
")",
"{",
"throw",
"new",
"InterruptedException",
"(",
"\"Interrupt request because system shutdown was initiated!\"",
")",
";",
"}",
"throw",
"new",
"CouldNotPerformException",
"(",
"\"Could not wait for data!\"",
",",
"ex",
")",
";",
"}",
"}"
] |
{@inheritDoc}
@throws CouldNotPerformException {@inheritDoc}
@throws InterruptedException {@inheritDoc}
|
[
"{",
"@inheritDoc",
"}"
] |
train
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java#L1175-L1190
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java
|
ApiOvhMe.contact_contactId_PUT
|
public OvhContact contact_contactId_PUT(Long contactId, OvhAddress address, String birthCity, OvhCountryEnum birthCountry, Date birthDay, String birthZip, String cellPhone, String companyNationalIdentificationNumber, String email, String fax, String firstName, OvhGenderEnum gender, OvhLanguageEnum language, String lastName, OvhLegalFormEnum legalForm, String nationalIdentificationNumber, OvhCountryEnum nationality, String organisationName, String organisationType, String phone, String vat) throws IOException {
"""
Update an existing contact
REST: PUT /me/contact/{contactId}
@param contactId [required] Contact Identifier
@param address [required] Address of the contact
@param cellPhone [required] Cellphone number
@param phone [required] Landline phone number
@param fax [required] Fax phone number
@param birthDay [required] Birthday date
@param birthCity [required] City of birth
@param birthZip [required] Birth Zipcode
@param birthCountry [required] Birth Country
@param vat [required] VAT number
@param companyNationalIdentificationNumber [required] Company national identification number
@param nationalIdentificationNumber [required] National identification number
@param organisationType [required] Type of your organisation
@param organisationName [required] Name of your organisation
@param email [required] Email address
@param firstName [required] First name
@param gender [required] Gender
@param language [required] Language
@param nationality [required] Nationality
@param lastName [required] Last name
@param legalForm [required] Legal form of the contact
"""
String qPath = "/me/contact/{contactId}";
StringBuilder sb = path(qPath, contactId);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "address", address);
addBody(o, "birthCity", birthCity);
addBody(o, "birthCountry", birthCountry);
addBody(o, "birthDay", birthDay);
addBody(o, "birthZip", birthZip);
addBody(o, "cellPhone", cellPhone);
addBody(o, "companyNationalIdentificationNumber", companyNationalIdentificationNumber);
addBody(o, "email", email);
addBody(o, "fax", fax);
addBody(o, "firstName", firstName);
addBody(o, "gender", gender);
addBody(o, "language", language);
addBody(o, "lastName", lastName);
addBody(o, "legalForm", legalForm);
addBody(o, "nationalIdentificationNumber", nationalIdentificationNumber);
addBody(o, "nationality", nationality);
addBody(o, "organisationName", organisationName);
addBody(o, "organisationType", organisationType);
addBody(o, "phone", phone);
addBody(o, "vat", vat);
String resp = exec(qPath, "PUT", sb.toString(), o);
return convertTo(resp, OvhContact.class);
}
|
java
|
public OvhContact contact_contactId_PUT(Long contactId, OvhAddress address, String birthCity, OvhCountryEnum birthCountry, Date birthDay, String birthZip, String cellPhone, String companyNationalIdentificationNumber, String email, String fax, String firstName, OvhGenderEnum gender, OvhLanguageEnum language, String lastName, OvhLegalFormEnum legalForm, String nationalIdentificationNumber, OvhCountryEnum nationality, String organisationName, String organisationType, String phone, String vat) throws IOException {
String qPath = "/me/contact/{contactId}";
StringBuilder sb = path(qPath, contactId);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "address", address);
addBody(o, "birthCity", birthCity);
addBody(o, "birthCountry", birthCountry);
addBody(o, "birthDay", birthDay);
addBody(o, "birthZip", birthZip);
addBody(o, "cellPhone", cellPhone);
addBody(o, "companyNationalIdentificationNumber", companyNationalIdentificationNumber);
addBody(o, "email", email);
addBody(o, "fax", fax);
addBody(o, "firstName", firstName);
addBody(o, "gender", gender);
addBody(o, "language", language);
addBody(o, "lastName", lastName);
addBody(o, "legalForm", legalForm);
addBody(o, "nationalIdentificationNumber", nationalIdentificationNumber);
addBody(o, "nationality", nationality);
addBody(o, "organisationName", organisationName);
addBody(o, "organisationType", organisationType);
addBody(o, "phone", phone);
addBody(o, "vat", vat);
String resp = exec(qPath, "PUT", sb.toString(), o);
return convertTo(resp, OvhContact.class);
}
|
[
"public",
"OvhContact",
"contact_contactId_PUT",
"(",
"Long",
"contactId",
",",
"OvhAddress",
"address",
",",
"String",
"birthCity",
",",
"OvhCountryEnum",
"birthCountry",
",",
"Date",
"birthDay",
",",
"String",
"birthZip",
",",
"String",
"cellPhone",
",",
"String",
"companyNationalIdentificationNumber",
",",
"String",
"email",
",",
"String",
"fax",
",",
"String",
"firstName",
",",
"OvhGenderEnum",
"gender",
",",
"OvhLanguageEnum",
"language",
",",
"String",
"lastName",
",",
"OvhLegalFormEnum",
"legalForm",
",",
"String",
"nationalIdentificationNumber",
",",
"OvhCountryEnum",
"nationality",
",",
"String",
"organisationName",
",",
"String",
"organisationType",
",",
"String",
"phone",
",",
"String",
"vat",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/contact/{contactId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"contactId",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"address\"",
",",
"address",
")",
";",
"addBody",
"(",
"o",
",",
"\"birthCity\"",
",",
"birthCity",
")",
";",
"addBody",
"(",
"o",
",",
"\"birthCountry\"",
",",
"birthCountry",
")",
";",
"addBody",
"(",
"o",
",",
"\"birthDay\"",
",",
"birthDay",
")",
";",
"addBody",
"(",
"o",
",",
"\"birthZip\"",
",",
"birthZip",
")",
";",
"addBody",
"(",
"o",
",",
"\"cellPhone\"",
",",
"cellPhone",
")",
";",
"addBody",
"(",
"o",
",",
"\"companyNationalIdentificationNumber\"",
",",
"companyNationalIdentificationNumber",
")",
";",
"addBody",
"(",
"o",
",",
"\"email\"",
",",
"email",
")",
";",
"addBody",
"(",
"o",
",",
"\"fax\"",
",",
"fax",
")",
";",
"addBody",
"(",
"o",
",",
"\"firstName\"",
",",
"firstName",
")",
";",
"addBody",
"(",
"o",
",",
"\"gender\"",
",",
"gender",
")",
";",
"addBody",
"(",
"o",
",",
"\"language\"",
",",
"language",
")",
";",
"addBody",
"(",
"o",
",",
"\"lastName\"",
",",
"lastName",
")",
";",
"addBody",
"(",
"o",
",",
"\"legalForm\"",
",",
"legalForm",
")",
";",
"addBody",
"(",
"o",
",",
"\"nationalIdentificationNumber\"",
",",
"nationalIdentificationNumber",
")",
";",
"addBody",
"(",
"o",
",",
"\"nationality\"",
",",
"nationality",
")",
";",
"addBody",
"(",
"o",
",",
"\"organisationName\"",
",",
"organisationName",
")",
";",
"addBody",
"(",
"o",
",",
"\"organisationType\"",
",",
"organisationType",
")",
";",
"addBody",
"(",
"o",
",",
"\"phone\"",
",",
"phone",
")",
";",
"addBody",
"(",
"o",
",",
"\"vat\"",
",",
"vat",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhContact",
".",
"class",
")",
";",
"}"
] |
Update an existing contact
REST: PUT /me/contact/{contactId}
@param contactId [required] Contact Identifier
@param address [required] Address of the contact
@param cellPhone [required] Cellphone number
@param phone [required] Landline phone number
@param fax [required] Fax phone number
@param birthDay [required] Birthday date
@param birthCity [required] City of birth
@param birthZip [required] Birth Zipcode
@param birthCountry [required] Birth Country
@param vat [required] VAT number
@param companyNationalIdentificationNumber [required] Company national identification number
@param nationalIdentificationNumber [required] National identification number
@param organisationType [required] Type of your organisation
@param organisationName [required] Name of your organisation
@param email [required] Email address
@param firstName [required] First name
@param gender [required] Gender
@param language [required] Language
@param nationality [required] Nationality
@param lastName [required] Last name
@param legalForm [required] Legal form of the contact
|
[
"Update",
"an",
"existing",
"contact"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L3058-L3084
|
LGoodDatePicker/LGoodDatePicker
|
Project/src/main/java/com/github/lgooddatepicker/zinternaltools/InternalUtilities.java
|
InternalUtilities.getConstraints
|
static public GridBagConstraints getConstraints(int gridx, int gridy) {
"""
getConstraints, This returns a grid bag constraints object that can be used for placing a
component appropriately into a grid bag layout.
"""
GridBagConstraints gc = new GridBagConstraints();
gc.fill = GridBagConstraints.BOTH;
gc.gridx = gridx;
gc.gridy = gridy;
return gc;
}
|
java
|
static public GridBagConstraints getConstraints(int gridx, int gridy) {
GridBagConstraints gc = new GridBagConstraints();
gc.fill = GridBagConstraints.BOTH;
gc.gridx = gridx;
gc.gridy = gridy;
return gc;
}
|
[
"static",
"public",
"GridBagConstraints",
"getConstraints",
"(",
"int",
"gridx",
",",
"int",
"gridy",
")",
"{",
"GridBagConstraints",
"gc",
"=",
"new",
"GridBagConstraints",
"(",
")",
";",
"gc",
".",
"fill",
"=",
"GridBagConstraints",
".",
"BOTH",
";",
"gc",
".",
"gridx",
"=",
"gridx",
";",
"gc",
".",
"gridy",
"=",
"gridy",
";",
"return",
"gc",
";",
"}"
] |
getConstraints, This returns a grid bag constraints object that can be used for placing a
component appropriately into a grid bag layout.
|
[
"getConstraints",
"This",
"returns",
"a",
"grid",
"bag",
"constraints",
"object",
"that",
"can",
"be",
"used",
"for",
"placing",
"a",
"component",
"appropriately",
"into",
"a",
"grid",
"bag",
"layout",
"."
] |
train
|
https://github.com/LGoodDatePicker/LGoodDatePicker/blob/c7df05a5fe382e1e08a6237e9391d8dc5fd48692/Project/src/main/java/com/github/lgooddatepicker/zinternaltools/InternalUtilities.java#L340-L346
|
looly/hutool
|
hutool-cron/src/main/java/cn/hutool/cron/pattern/CronPatternUtil.java
|
CronPatternUtil.matchedDates
|
public static List<Date> matchedDates(String patternStr, Date start, int count, boolean isMatchSecond) {
"""
列举指定日期之后(到开始日期对应年年底)内所有匹配表达式的日期
@param patternStr 表达式字符串
@param start 起始时间
@param count 列举数量
@param isMatchSecond 是否匹配秒
@return 日期列表
"""
return matchedDates(patternStr, start, DateUtil.endOfYear(start), count, isMatchSecond);
}
|
java
|
public static List<Date> matchedDates(String patternStr, Date start, int count, boolean isMatchSecond) {
return matchedDates(patternStr, start, DateUtil.endOfYear(start), count, isMatchSecond);
}
|
[
"public",
"static",
"List",
"<",
"Date",
">",
"matchedDates",
"(",
"String",
"patternStr",
",",
"Date",
"start",
",",
"int",
"count",
",",
"boolean",
"isMatchSecond",
")",
"{",
"return",
"matchedDates",
"(",
"patternStr",
",",
"start",
",",
"DateUtil",
".",
"endOfYear",
"(",
"start",
")",
",",
"count",
",",
"isMatchSecond",
")",
";",
"}"
] |
列举指定日期之后(到开始日期对应年年底)内所有匹配表达式的日期
@param patternStr 表达式字符串
@param start 起始时间
@param count 列举数量
@param isMatchSecond 是否匹配秒
@return 日期列表
|
[
"列举指定日期之后(到开始日期对应年年底)内所有匹配表达式的日期"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-cron/src/main/java/cn/hutool/cron/pattern/CronPatternUtil.java#L28-L30
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-horizonView/src/main/java/net/minidev/ovh/api/ApiOvhHorizonView.java
|
ApiOvhHorizonView.serviceName_dedicatedHorizon_customerUser_POST
|
public ArrayList<OvhTask> serviceName_dedicatedHorizon_customerUser_POST(String serviceName, String email, String password, String username) throws IOException {
"""
Create a new customer user
REST: POST /horizonView/{serviceName}/dedicatedHorizon/customerUser
@param email [required] Email for your new user in Active diRectory.
@param username [required] Username for your new user in Active Directory.
@param password [required] New password for this Horizon View user. It must fits your HaaS password policy. If this field is empty, a random password will be generated and sent to your email.
@param serviceName [required] Domain of the service
"""
String qPath = "/horizonView/{serviceName}/dedicatedHorizon/customerUser";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "email", email);
addBody(o, "password", password);
addBody(o, "username", username);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, t2);
}
|
java
|
public ArrayList<OvhTask> serviceName_dedicatedHorizon_customerUser_POST(String serviceName, String email, String password, String username) throws IOException {
String qPath = "/horizonView/{serviceName}/dedicatedHorizon/customerUser";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "email", email);
addBody(o, "password", password);
addBody(o, "username", username);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, t2);
}
|
[
"public",
"ArrayList",
"<",
"OvhTask",
">",
"serviceName_dedicatedHorizon_customerUser_POST",
"(",
"String",
"serviceName",
",",
"String",
"email",
",",
"String",
"password",
",",
"String",
"username",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/horizonView/{serviceName}/dedicatedHorizon/customerUser\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"email\"",
",",
"email",
")",
";",
"addBody",
"(",
"o",
",",
"\"password\"",
",",
"password",
")",
";",
"addBody",
"(",
"o",
",",
"\"username\"",
",",
"username",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t2",
")",
";",
"}"
] |
Create a new customer user
REST: POST /horizonView/{serviceName}/dedicatedHorizon/customerUser
@param email [required] Email for your new user in Active diRectory.
@param username [required] Username for your new user in Active Directory.
@param password [required] New password for this Horizon View user. It must fits your HaaS password policy. If this field is empty, a random password will be generated and sent to your email.
@param serviceName [required] Domain of the service
|
[
"Create",
"a",
"new",
"customer",
"user"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-horizonView/src/main/java/net/minidev/ovh/api/ApiOvhHorizonView.java#L520-L529
|
Netflix/servo
|
servo-core/src/main/java/com/netflix/servo/publish/PollScheduler.java
|
PollScheduler.addPoller
|
public void addPoller(PollRunnable task, long delay, TimeUnit timeUnit) {
"""
Add a tasks to execute at a fixed rate based on the provided delay.
"""
ScheduledExecutorService service = executor.get();
if (service != null) {
service.scheduleWithFixedDelay(task, 0, delay, timeUnit);
} else {
throw new IllegalStateException(
"you must start the scheduler before tasks can be submitted");
}
}
|
java
|
public void addPoller(PollRunnable task, long delay, TimeUnit timeUnit) {
ScheduledExecutorService service = executor.get();
if (service != null) {
service.scheduleWithFixedDelay(task, 0, delay, timeUnit);
} else {
throw new IllegalStateException(
"you must start the scheduler before tasks can be submitted");
}
}
|
[
"public",
"void",
"addPoller",
"(",
"PollRunnable",
"task",
",",
"long",
"delay",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"ScheduledExecutorService",
"service",
"=",
"executor",
".",
"get",
"(",
")",
";",
"if",
"(",
"service",
"!=",
"null",
")",
"{",
"service",
".",
"scheduleWithFixedDelay",
"(",
"task",
",",
"0",
",",
"delay",
",",
"timeUnit",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"you must start the scheduler before tasks can be submitted\"",
")",
";",
"}",
"}"
] |
Add a tasks to execute at a fixed rate based on the provided delay.
|
[
"Add",
"a",
"tasks",
"to",
"execute",
"at",
"a",
"fixed",
"rate",
"based",
"on",
"the",
"provided",
"delay",
"."
] |
train
|
https://github.com/Netflix/servo/blob/d67b5afce8c50bd9e9e31c288dbf4b78fb2ac815/servo-core/src/main/java/com/netflix/servo/publish/PollScheduler.java#L51-L59
|
google/closure-compiler
|
src/com/google/javascript/jscomp/FunctionToBlockMutator.java
|
FunctionToBlockMutator.makeLocalNamesUnique
|
private void makeLocalNamesUnique(Node fnNode, boolean isCallInLoop) {
"""
Fix-up all local names to be unique for this subtree.
@param fnNode A mutable instance of the function to be inlined.
"""
Supplier<String> idSupplier = compiler.getUniqueNameIdSupplier();
// Make variable names unique to this instance.
NodeTraversal.traverseScopeRoots(
compiler,
null,
ImmutableList.of(fnNode),
new MakeDeclaredNamesUnique(
new InlineRenamer(
compiler.getCodingConvention(), idSupplier, "inline_", isCallInLoop, true, null),
false),
true);
// Make label names unique to this instance.
new RenameLabels(compiler, new LabelNameSupplier(idSupplier), false, false)
.process(null, fnNode);
}
|
java
|
private void makeLocalNamesUnique(Node fnNode, boolean isCallInLoop) {
Supplier<String> idSupplier = compiler.getUniqueNameIdSupplier();
// Make variable names unique to this instance.
NodeTraversal.traverseScopeRoots(
compiler,
null,
ImmutableList.of(fnNode),
new MakeDeclaredNamesUnique(
new InlineRenamer(
compiler.getCodingConvention(), idSupplier, "inline_", isCallInLoop, true, null),
false),
true);
// Make label names unique to this instance.
new RenameLabels(compiler, new LabelNameSupplier(idSupplier), false, false)
.process(null, fnNode);
}
|
[
"private",
"void",
"makeLocalNamesUnique",
"(",
"Node",
"fnNode",
",",
"boolean",
"isCallInLoop",
")",
"{",
"Supplier",
"<",
"String",
">",
"idSupplier",
"=",
"compiler",
".",
"getUniqueNameIdSupplier",
"(",
")",
";",
"// Make variable names unique to this instance.",
"NodeTraversal",
".",
"traverseScopeRoots",
"(",
"compiler",
",",
"null",
",",
"ImmutableList",
".",
"of",
"(",
"fnNode",
")",
",",
"new",
"MakeDeclaredNamesUnique",
"(",
"new",
"InlineRenamer",
"(",
"compiler",
".",
"getCodingConvention",
"(",
")",
",",
"idSupplier",
",",
"\"inline_\"",
",",
"isCallInLoop",
",",
"true",
",",
"null",
")",
",",
"false",
")",
",",
"true",
")",
";",
"// Make label names unique to this instance.",
"new",
"RenameLabels",
"(",
"compiler",
",",
"new",
"LabelNameSupplier",
"(",
"idSupplier",
")",
",",
"false",
",",
"false",
")",
".",
"process",
"(",
"null",
",",
"fnNode",
")",
";",
"}"
] |
Fix-up all local names to be unique for this subtree.
@param fnNode A mutable instance of the function to be inlined.
|
[
"Fix",
"-",
"up",
"all",
"local",
"names",
"to",
"be",
"unique",
"for",
"this",
"subtree",
"."
] |
train
|
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionToBlockMutator.java#L255-L270
|
googleapis/google-cloud-java
|
google-cloud-examples/src/main/java/com/google/cloud/examples/translate/snippets/TranslateSnippetsBeta.java
|
TranslateSnippetsBeta.translateText
|
static TranslateTextResponse translateText(
String projectId,
String location,
String text,
String sourceLanguageCode,
String targetLanguageCode) {
"""
Translates a given text to a target language.
@param projectId - Id of the project.
@param location - location name.
@param text - Text for translation.
@param sourceLanguageCode - Language code of text. e.g. "en"
@param targetLanguageCode - Language code for translation. e.g. "sr"
"""
try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
LocationName locationName =
LocationName.newBuilder().setProject(projectId).setLocation(location).build();
TranslateTextRequest translateTextRequest =
TranslateTextRequest.newBuilder()
.setParent(locationName.toString())
.setMimeType("text/plain")
.setSourceLanguageCode(sourceLanguageCode)
.setTargetLanguageCode(targetLanguageCode)
.addContents(text)
.build();
// Call the API
TranslateTextResponse response = translationServiceClient.translateText(translateTextRequest);
System.out.format(
"Translated Text: %s", response.getTranslationsList().get(0).getTranslatedText());
return response;
} catch (Exception e) {
throw new RuntimeException("Couldn't create client.", e);
}
}
|
java
|
static TranslateTextResponse translateText(
String projectId,
String location,
String text,
String sourceLanguageCode,
String targetLanguageCode) {
try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
LocationName locationName =
LocationName.newBuilder().setProject(projectId).setLocation(location).build();
TranslateTextRequest translateTextRequest =
TranslateTextRequest.newBuilder()
.setParent(locationName.toString())
.setMimeType("text/plain")
.setSourceLanguageCode(sourceLanguageCode)
.setTargetLanguageCode(targetLanguageCode)
.addContents(text)
.build();
// Call the API
TranslateTextResponse response = translationServiceClient.translateText(translateTextRequest);
System.out.format(
"Translated Text: %s", response.getTranslationsList().get(0).getTranslatedText());
return response;
} catch (Exception e) {
throw new RuntimeException("Couldn't create client.", e);
}
}
|
[
"static",
"TranslateTextResponse",
"translateText",
"(",
"String",
"projectId",
",",
"String",
"location",
",",
"String",
"text",
",",
"String",
"sourceLanguageCode",
",",
"String",
"targetLanguageCode",
")",
"{",
"try",
"(",
"TranslationServiceClient",
"translationServiceClient",
"=",
"TranslationServiceClient",
".",
"create",
"(",
")",
")",
"{",
"LocationName",
"locationName",
"=",
"LocationName",
".",
"newBuilder",
"(",
")",
".",
"setProject",
"(",
"projectId",
")",
".",
"setLocation",
"(",
"location",
")",
".",
"build",
"(",
")",
";",
"TranslateTextRequest",
"translateTextRequest",
"=",
"TranslateTextRequest",
".",
"newBuilder",
"(",
")",
".",
"setParent",
"(",
"locationName",
".",
"toString",
"(",
")",
")",
".",
"setMimeType",
"(",
"\"text/plain\"",
")",
".",
"setSourceLanguageCode",
"(",
"sourceLanguageCode",
")",
".",
"setTargetLanguageCode",
"(",
"targetLanguageCode",
")",
".",
"addContents",
"(",
"text",
")",
".",
"build",
"(",
")",
";",
"// Call the API",
"TranslateTextResponse",
"response",
"=",
"translationServiceClient",
".",
"translateText",
"(",
"translateTextRequest",
")",
";",
"System",
".",
"out",
".",
"format",
"(",
"\"Translated Text: %s\"",
",",
"response",
".",
"getTranslationsList",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getTranslatedText",
"(",
")",
")",
";",
"return",
"response",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Couldn't create client.\"",
",",
"e",
")",
";",
"}",
"}"
] |
Translates a given text to a target language.
@param projectId - Id of the project.
@param location - location name.
@param text - Text for translation.
@param sourceLanguageCode - Language code of text. e.g. "en"
@param targetLanguageCode - Language code for translation. e.g. "sr"
|
[
"Translates",
"a",
"given",
"text",
"to",
"a",
"target",
"language",
"."
] |
train
|
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-examples/src/main/java/com/google/cloud/examples/translate/snippets/TranslateSnippetsBeta.java#L169-L198
|
mockito/mockito
|
src/main/java/org/mockito/internal/matchers/apachecommons/EqualsBuilder.java
|
EqualsBuilder.reflectionEquals
|
public static boolean reflectionEquals(Object lhs, Object rhs, String[] excludeFields) {
"""
<p>This method uses reflection to determine if the two <code>Object</code>s
are equal.</p>
<p>It uses <code>AccessibleObject.setAccessible</code> to gain access to private
fields. This means that it will throw a security exception if run under
a security manager, if the permissions are not set up correctly. It is also
not as efficient as testing explicitly.</p>
<p>Transient members will be not be tested, as they are likely derived
fields, and not part of the value of the Object.</p>
<p>Static fields will not be tested. Superclass fields will be included.</p>
@param lhs <code>this</code> object
@param rhs the other object
@param excludeFields array of field names to exclude from testing
@return <code>true</code> if the two Objects have tested equals.
"""
return reflectionEquals(lhs, rhs, false, null, excludeFields);
}
|
java
|
public static boolean reflectionEquals(Object lhs, Object rhs, String[] excludeFields) {
return reflectionEquals(lhs, rhs, false, null, excludeFields);
}
|
[
"public",
"static",
"boolean",
"reflectionEquals",
"(",
"Object",
"lhs",
",",
"Object",
"rhs",
",",
"String",
"[",
"]",
"excludeFields",
")",
"{",
"return",
"reflectionEquals",
"(",
"lhs",
",",
"rhs",
",",
"false",
",",
"null",
",",
"excludeFields",
")",
";",
"}"
] |
<p>This method uses reflection to determine if the two <code>Object</code>s
are equal.</p>
<p>It uses <code>AccessibleObject.setAccessible</code> to gain access to private
fields. This means that it will throw a security exception if run under
a security manager, if the permissions are not set up correctly. It is also
not as efficient as testing explicitly.</p>
<p>Transient members will be not be tested, as they are likely derived
fields, and not part of the value of the Object.</p>
<p>Static fields will not be tested. Superclass fields will be included.</p>
@param lhs <code>this</code> object
@param rhs the other object
@param excludeFields array of field names to exclude from testing
@return <code>true</code> if the two Objects have tested equals.
|
[
"<p",
">",
"This",
"method",
"uses",
"reflection",
"to",
"determine",
"if",
"the",
"two",
"<code",
">",
"Object<",
"/",
"code",
">",
"s",
"are",
"equal",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/mockito/mockito/blob/c5e2b80af76e3192cae7c9550b70c4d1ab312034/src/main/java/org/mockito/internal/matchers/apachecommons/EqualsBuilder.java#L138-L140
|
Microsoft/malmo
|
Minecraft/src/main/java/com/microsoft/Malmo/Utils/SchemaHelper.java
|
SchemaHelper.getNodeValue
|
static public String getNodeValue(List<Element> elements, String nodeName, String defaultValue) {
"""
Return the text value of the first child of the named node, or the specified default if the node can't be found.<br>
For example, calling getNodeValue(el, "Mode", "whatever") on a list of elements which contains the following XML:
<Mode>survival</Mode>
should return "survival".
@param elements the list of XML elements to search
@param nodeName the name of the parent node to extract the text value from
@param defaultValue the default to return if the node is empty / doesn't exist
@return the text content of the desired element
"""
if (elements != null)
{
for (Element el : elements)
{
if (el.getNodeName().equals(nodeName))
{
if (el.getFirstChild() != null)
{
return el.getFirstChild().getTextContent();
}
}
}
}
return defaultValue;
}
|
java
|
static public String getNodeValue(List<Element> elements, String nodeName, String defaultValue)
{
if (elements != null)
{
for (Element el : elements)
{
if (el.getNodeName().equals(nodeName))
{
if (el.getFirstChild() != null)
{
return el.getFirstChild().getTextContent();
}
}
}
}
return defaultValue;
}
|
[
"static",
"public",
"String",
"getNodeValue",
"(",
"List",
"<",
"Element",
">",
"elements",
",",
"String",
"nodeName",
",",
"String",
"defaultValue",
")",
"{",
"if",
"(",
"elements",
"!=",
"null",
")",
"{",
"for",
"(",
"Element",
"el",
":",
"elements",
")",
"{",
"if",
"(",
"el",
".",
"getNodeName",
"(",
")",
".",
"equals",
"(",
"nodeName",
")",
")",
"{",
"if",
"(",
"el",
".",
"getFirstChild",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"el",
".",
"getFirstChild",
"(",
")",
".",
"getTextContent",
"(",
")",
";",
"}",
"}",
"}",
"}",
"return",
"defaultValue",
";",
"}"
] |
Return the text value of the first child of the named node, or the specified default if the node can't be found.<br>
For example, calling getNodeValue(el, "Mode", "whatever") on a list of elements which contains the following XML:
<Mode>survival</Mode>
should return "survival".
@param elements the list of XML elements to search
@param nodeName the name of the parent node to extract the text value from
@param defaultValue the default to return if the node is empty / doesn't exist
@return the text content of the desired element
|
[
"Return",
"the",
"text",
"value",
"of",
"the",
"first",
"child",
"of",
"the",
"named",
"node",
"or",
"the",
"specified",
"default",
"if",
"the",
"node",
"can",
"t",
"be",
"found",
".",
"<br",
">",
"For",
"example",
"calling",
"getNodeValue",
"(",
"el",
"Mode",
"whatever",
")",
"on",
"a",
"list",
"of",
"elements",
"which",
"contains",
"the",
"following",
"XML",
":",
"<Mode",
">",
"survival<",
"/",
"Mode",
">",
"should",
"return",
"survival",
"."
] |
train
|
https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/SchemaHelper.java#L223-L239
|
kikinteractive/ice
|
ice-jmx/src/main/java/com/kik/config/ice/source/JmxDynamicConfigSource.java
|
JmxDynamicConfigSource.fireEvent
|
@Override
public void fireEvent(String configName, Optional<String> valueOpt) {
"""
Used by instances of {@link ConfigDynamicMBean} to emit values back to the config system.
@param configName full configuration name from the descriptor
@param valueOpt the value to be emitted (if different from last emission)
"""
this.emitEvent(configName, valueOpt);
}
|
java
|
@Override
public void fireEvent(String configName, Optional<String> valueOpt)
{
this.emitEvent(configName, valueOpt);
}
|
[
"@",
"Override",
"public",
"void",
"fireEvent",
"(",
"String",
"configName",
",",
"Optional",
"<",
"String",
">",
"valueOpt",
")",
"{",
"this",
".",
"emitEvent",
"(",
"configName",
",",
"valueOpt",
")",
";",
"}"
] |
Used by instances of {@link ConfigDynamicMBean} to emit values back to the config system.
@param configName full configuration name from the descriptor
@param valueOpt the value to be emitted (if different from last emission)
|
[
"Used",
"by",
"instances",
"of",
"{",
"@link",
"ConfigDynamicMBean",
"}",
"to",
"emit",
"values",
"back",
"to",
"the",
"config",
"system",
"."
] |
train
|
https://github.com/kikinteractive/ice/blob/0c58d7bf2d9f6504892d0768d6022fcfa6df7514/ice-jmx/src/main/java/com/kik/config/ice/source/JmxDynamicConfigSource.java#L110-L114
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/MPPUtility.java
|
MPPUtility.getTimestampFromTenths
|
public static final Date getTimestampFromTenths(byte[] data, int offset) {
"""
Reads a combined date and time value expressed in tenths of a minute.
@param data byte array of data
@param offset location of data as offset into the array
@return time value
"""
long ms = ((long) getInt(data, offset)) * 6000;
return (DateHelper.getTimestampFromLong(EPOCH + ms));
}
|
java
|
public static final Date getTimestampFromTenths(byte[] data, int offset)
{
long ms = ((long) getInt(data, offset)) * 6000;
return (DateHelper.getTimestampFromLong(EPOCH + ms));
}
|
[
"public",
"static",
"final",
"Date",
"getTimestampFromTenths",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
")",
"{",
"long",
"ms",
"=",
"(",
"(",
"long",
")",
"getInt",
"(",
"data",
",",
"offset",
")",
")",
"*",
"6000",
";",
"return",
"(",
"DateHelper",
".",
"getTimestampFromLong",
"(",
"EPOCH",
"+",
"ms",
")",
")",
";",
"}"
] |
Reads a combined date and time value expressed in tenths of a minute.
@param data byte array of data
@param offset location of data as offset into the array
@return time value
|
[
"Reads",
"a",
"combined",
"date",
"and",
"time",
"value",
"expressed",
"in",
"tenths",
"of",
"a",
"minute",
"."
] |
train
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPPUtility.java#L406-L410
|
datasalt/pangool
|
core/src/main/java/com/datasalt/pangool/io/Mutator.java
|
Mutator.jointSchema
|
public static Schema jointSchema(Schema leftSchema, Schema rightSchema) {
"""
Creates a joint schema between two Schemas. All Fields from both schema are deduplicated
and combined into a single Schema. The left Schema has priority so if both Schemas have
the same Field with the same name but different Types, the Type from the left Schema will be
taken.
<p>
The name of the schema is auto-generated with a static counter.
"""
return jointSchema("jointSchema" + (COUNTER++), leftSchema, rightSchema);
}
|
java
|
public static Schema jointSchema(Schema leftSchema, Schema rightSchema) {
return jointSchema("jointSchema" + (COUNTER++), leftSchema, rightSchema);
}
|
[
"public",
"static",
"Schema",
"jointSchema",
"(",
"Schema",
"leftSchema",
",",
"Schema",
"rightSchema",
")",
"{",
"return",
"jointSchema",
"(",
"\"jointSchema\"",
"+",
"(",
"COUNTER",
"++",
")",
",",
"leftSchema",
",",
"rightSchema",
")",
";",
"}"
] |
Creates a joint schema between two Schemas. All Fields from both schema are deduplicated
and combined into a single Schema. The left Schema has priority so if both Schemas have
the same Field with the same name but different Types, the Type from the left Schema will be
taken.
<p>
The name of the schema is auto-generated with a static counter.
|
[
"Creates",
"a",
"joint",
"schema",
"between",
"two",
"Schemas",
".",
"All",
"Fields",
"from",
"both",
"schema",
"are",
"deduplicated",
"and",
"combined",
"into",
"a",
"single",
"Schema",
".",
"The",
"left",
"Schema",
"has",
"priority",
"so",
"if",
"both",
"Schemas",
"have",
"the",
"same",
"Field",
"with",
"the",
"same",
"name",
"but",
"different",
"Types",
"the",
"Type",
"from",
"the",
"left",
"Schema",
"will",
"be",
"taken",
".",
"<p",
">",
"The",
"name",
"of",
"the",
"schema",
"is",
"auto",
"-",
"generated",
"with",
"a",
"static",
"counter",
"."
] |
train
|
https://github.com/datasalt/pangool/blob/bfd312dd78cba03febaf7988ae96a3d4bc585408/core/src/main/java/com/datasalt/pangool/io/Mutator.java#L99-L101
|
actorapp/actor-platform
|
actor-sdk/sdk-core/runtime/runtime-android/src/main/java/im/actor/runtime/android/crypto/PRNGFixes.java
|
PRNGFixes.applyOpenSSLFix
|
private static void applyOpenSSLFix() throws SecurityException {
"""
Applies the fix for OpenSSL PRNG having low entropy. Does nothing if the
fix is not needed.
@throws SecurityException if the fix is needed but could not be applied.
"""
if ((Build.VERSION.SDK_INT < VERSION_CODE_JELLY_BEAN)
|| (Build.VERSION.SDK_INT > VERSION_CODE_JELLY_BEAN_MR2)) {
// No need to apply the fix
return;
}
try {
// Mix in the device- and invocation-specific seed.
Class.forName("org.apache.harmony.xnet.provider.jsse.NativeCrypto")
.getMethod("RAND_seed", byte[].class)
.invoke(null, (Object) generateSeed());
// Mix output of Linux PRNG into OpenSSL's PRNG
int bytesRead = (Integer) Class.forName(
"org.apache.harmony.xnet.provider.jsse.NativeCrypto")
.getMethod("RAND_load_file", String.class, long.class)
.invoke(null, "/dev/urandom", 1024);
if (bytesRead != 1024) {
throw new IOException(
"Unexpected number of bytes read from Linux PRNG: "
+ bytesRead);
}
} catch (Exception e) {
throw new SecurityException("Failed to seed OpenSSL PRNG", e);
}
}
|
java
|
private static void applyOpenSSLFix() throws SecurityException {
if ((Build.VERSION.SDK_INT < VERSION_CODE_JELLY_BEAN)
|| (Build.VERSION.SDK_INT > VERSION_CODE_JELLY_BEAN_MR2)) {
// No need to apply the fix
return;
}
try {
// Mix in the device- and invocation-specific seed.
Class.forName("org.apache.harmony.xnet.provider.jsse.NativeCrypto")
.getMethod("RAND_seed", byte[].class)
.invoke(null, (Object) generateSeed());
// Mix output of Linux PRNG into OpenSSL's PRNG
int bytesRead = (Integer) Class.forName(
"org.apache.harmony.xnet.provider.jsse.NativeCrypto")
.getMethod("RAND_load_file", String.class, long.class)
.invoke(null, "/dev/urandom", 1024);
if (bytesRead != 1024) {
throw new IOException(
"Unexpected number of bytes read from Linux PRNG: "
+ bytesRead);
}
} catch (Exception e) {
throw new SecurityException("Failed to seed OpenSSL PRNG", e);
}
}
|
[
"private",
"static",
"void",
"applyOpenSSLFix",
"(",
")",
"throws",
"SecurityException",
"{",
"if",
"(",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
"<",
"VERSION_CODE_JELLY_BEAN",
")",
"||",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">",
"VERSION_CODE_JELLY_BEAN_MR2",
")",
")",
"{",
"// No need to apply the fix",
"return",
";",
"}",
"try",
"{",
"// Mix in the device- and invocation-specific seed.",
"Class",
".",
"forName",
"(",
"\"org.apache.harmony.xnet.provider.jsse.NativeCrypto\"",
")",
".",
"getMethod",
"(",
"\"RAND_seed\"",
",",
"byte",
"[",
"]",
".",
"class",
")",
".",
"invoke",
"(",
"null",
",",
"(",
"Object",
")",
"generateSeed",
"(",
")",
")",
";",
"// Mix output of Linux PRNG into OpenSSL's PRNG",
"int",
"bytesRead",
"=",
"(",
"Integer",
")",
"Class",
".",
"forName",
"(",
"\"org.apache.harmony.xnet.provider.jsse.NativeCrypto\"",
")",
".",
"getMethod",
"(",
"\"RAND_load_file\"",
",",
"String",
".",
"class",
",",
"long",
".",
"class",
")",
".",
"invoke",
"(",
"null",
",",
"\"/dev/urandom\"",
",",
"1024",
")",
";",
"if",
"(",
"bytesRead",
"!=",
"1024",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Unexpected number of bytes read from Linux PRNG: \"",
"+",
"bytesRead",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"SecurityException",
"(",
"\"Failed to seed OpenSSL PRNG\"",
",",
"e",
")",
";",
"}",
"}"
] |
Applies the fix for OpenSSL PRNG having low entropy. Does nothing if the
fix is not needed.
@throws SecurityException if the fix is needed but could not be applied.
|
[
"Applies",
"the",
"fix",
"for",
"OpenSSL",
"PRNG",
"having",
"low",
"entropy",
".",
"Does",
"nothing",
"if",
"the",
"fix",
"is",
"not",
"needed",
"."
] |
train
|
https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core/runtime/runtime-android/src/main/java/im/actor/runtime/android/crypto/PRNGFixes.java#L81-L107
|
MaxxtonGroup/microdocs
|
example/order-service/src/main/java/com/example/service/order/controller/OrderController.java
|
OrderController.getOrder
|
@RequestMapping(path = "/ {
"""
Get order by id
@param orderId order id
@response 200
@response 404
@return Order or not found
"""orderId}", method = {RequestMethod.GET, RequestMethod.POST})
public ResponseEntity<Order> getOrder(@PathVariable("orderId") Long orderId) {
Order order = orderService.getOrder(orderId);
if(order != null){
return new ResponseEntity(order, HttpStatus.OK);
}
return new ResponseEntity<Order>(HttpStatus.NOT_FOUND);
}
|
java
|
@RequestMapping(path = "/{orderId}", method = {RequestMethod.GET, RequestMethod.POST})
public ResponseEntity<Order> getOrder(@PathVariable("orderId") Long orderId) {
Order order = orderService.getOrder(orderId);
if(order != null){
return new ResponseEntity(order, HttpStatus.OK);
}
return new ResponseEntity<Order>(HttpStatus.NOT_FOUND);
}
|
[
"@",
"RequestMapping",
"(",
"path",
"=",
"\"/{orderId}\"",
",",
"method",
"=",
"{",
"RequestMethod",
".",
"GET",
",",
"RequestMethod",
".",
"POST",
"}",
")",
"public",
"ResponseEntity",
"<",
"Order",
">",
"getOrder",
"(",
"@",
"PathVariable",
"(",
"\"orderId\"",
")",
"Long",
"orderId",
")",
"{",
"Order",
"order",
"=",
"orderService",
".",
"getOrder",
"(",
"orderId",
")",
";",
"if",
"(",
"order",
"!=",
"null",
")",
"{",
"return",
"new",
"ResponseEntity",
"(",
"order",
",",
"HttpStatus",
".",
"OK",
")",
";",
"}",
"return",
"new",
"ResponseEntity",
"<",
"Order",
">",
"(",
"HttpStatus",
".",
"NOT_FOUND",
")",
";",
"}"
] |
Get order by id
@param orderId order id
@response 200
@response 404
@return Order or not found
|
[
"Get",
"order",
"by",
"id"
] |
train
|
https://github.com/MaxxtonGroup/microdocs/blob/fdc80f203d68145af3e8d28d13de63ddfa3e6953/example/order-service/src/main/java/com/example/service/order/controller/OrderController.java#L42-L49
|
kuali/ojb-1.0.4
|
src/java/org/apache/ojb/broker/util/ClassHelper.java
|
ClassHelper.getMethod
|
public static Method getMethod(String className, String methodName, Class[] params) {
"""
Determines the method with the specified signature via reflection look-up.
@param className The qualified name of the searched class
@param methodName The method's name
@param params The parameter types
@return A method object or <code>null</code> if no matching method was found
"""
try
{
return getMethod(getClass(className, false), methodName, params);
}
catch (Exception ignored)
{}
return null;
}
|
java
|
public static Method getMethod(String className, String methodName, Class[] params)
{
try
{
return getMethod(getClass(className, false), methodName, params);
}
catch (Exception ignored)
{}
return null;
}
|
[
"public",
"static",
"Method",
"getMethod",
"(",
"String",
"className",
",",
"String",
"methodName",
",",
"Class",
"[",
"]",
"params",
")",
"{",
"try",
"{",
"return",
"getMethod",
"(",
"getClass",
"(",
"className",
",",
"false",
")",
",",
"methodName",
",",
"params",
")",
";",
"}",
"catch",
"(",
"Exception",
"ignored",
")",
"{",
"}",
"return",
"null",
";",
"}"
] |
Determines the method with the specified signature via reflection look-up.
@param className The qualified name of the searched class
@param methodName The method's name
@param params The parameter types
@return A method object or <code>null</code> if no matching method was found
|
[
"Determines",
"the",
"method",
"with",
"the",
"specified",
"signature",
"via",
"reflection",
"look",
"-",
"up",
"."
] |
train
|
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/ClassHelper.java#L371-L380
|
mebigfatguy/fb-contrib
|
src/main/java/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java
|
ExceptionSoftening.removeFinishedCatchBlocks
|
private static void removeFinishedCatchBlocks(Iterable<CatchInfo> infos, int pc) {
"""
remove catchinfo blocks from the map where the handler end is before the
current pc
@param infos the exception handlers installed
@param pc the current pc
"""
Iterator<CatchInfo> it = infos.iterator();
while (it.hasNext()) {
if (it.next().getFinish() < pc) {
it.remove();
}
}
}
|
java
|
private static void removeFinishedCatchBlocks(Iterable<CatchInfo> infos, int pc) {
Iterator<CatchInfo> it = infos.iterator();
while (it.hasNext()) {
if (it.next().getFinish() < pc) {
it.remove();
}
}
}
|
[
"private",
"static",
"void",
"removeFinishedCatchBlocks",
"(",
"Iterable",
"<",
"CatchInfo",
">",
"infos",
",",
"int",
"pc",
")",
"{",
"Iterator",
"<",
"CatchInfo",
">",
"it",
"=",
"infos",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"it",
".",
"next",
"(",
")",
".",
"getFinish",
"(",
")",
"<",
"pc",
")",
"{",
"it",
".",
"remove",
"(",
")",
";",
"}",
"}",
"}"
] |
remove catchinfo blocks from the map where the handler end is before the
current pc
@param infos the exception handlers installed
@param pc the current pc
|
[
"remove",
"catchinfo",
"blocks",
"from",
"the",
"map",
"where",
"the",
"handler",
"end",
"is",
"before",
"the",
"current",
"pc"
] |
train
|
https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java#L315-L322
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/NetworkWatchersInner.java
|
NetworkWatchersInner.setFlowLogConfigurationAsync
|
public Observable<FlowLogInformationInner> setFlowLogConfigurationAsync(String resourceGroupName, String networkWatcherName, FlowLogInformationInner parameters) {
"""
Configures flow log on a specified resource.
@param resourceGroupName The name of the network watcher resource group.
@param networkWatcherName The name of the network watcher resource.
@param parameters Parameters that define the configuration of flow log.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return setFlowLogConfigurationWithServiceResponseAsync(resourceGroupName, networkWatcherName, parameters).map(new Func1<ServiceResponse<FlowLogInformationInner>, FlowLogInformationInner>() {
@Override
public FlowLogInformationInner call(ServiceResponse<FlowLogInformationInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<FlowLogInformationInner> setFlowLogConfigurationAsync(String resourceGroupName, String networkWatcherName, FlowLogInformationInner parameters) {
return setFlowLogConfigurationWithServiceResponseAsync(resourceGroupName, networkWatcherName, parameters).map(new Func1<ServiceResponse<FlowLogInformationInner>, FlowLogInformationInner>() {
@Override
public FlowLogInformationInner call(ServiceResponse<FlowLogInformationInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"FlowLogInformationInner",
">",
"setFlowLogConfigurationAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"networkWatcherName",
",",
"FlowLogInformationInner",
"parameters",
")",
"{",
"return",
"setFlowLogConfigurationWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"networkWatcherName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"FlowLogInformationInner",
">",
",",
"FlowLogInformationInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"FlowLogInformationInner",
"call",
"(",
"ServiceResponse",
"<",
"FlowLogInformationInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Configures flow log on a specified resource.
@param resourceGroupName The name of the network watcher resource group.
@param networkWatcherName The name of the network watcher resource.
@param parameters Parameters that define the configuration of flow log.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
|
[
"Configures",
"flow",
"log",
"on",
"a",
"specified",
"resource",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/NetworkWatchersInner.java#L1829-L1836
|
att/AAF
|
authz/authz-gw/src/main/java/com/att/authz/gw/GwAPI.java
|
GwAPI.route
|
public void route(HttpMethods meth, String path, API api, GwCode code) throws Exception {
"""
Setup XML and JSON implementations for each supported Version type
We do this by taking the Code passed in and creating clones of these with the appropriate Facades and properties
to do Versions and Content switches
"""
String version = "1.0";
// Get Correct API Class from Mapper
Class<?> respCls = facade.mapper().getClass(api);
if(respCls==null) throw new Exception("Unknown class associated with " + api.getClass().getName() + ' ' + api.name());
// setup Application API HTML ContentTypes for JSON and Route
String application = applicationJSON(respCls, version);
//route(env,meth,path,code,application,"application/json;version="+version,"*/*");
// setup Application API HTML ContentTypes for XML and Route
application = applicationXML(respCls, version);
//route(env,meth,path,code.clone(facade_1_0_XML,false),application,"text/xml;version="+version);
// Add other Supported APIs here as created
}
|
java
|
public void route(HttpMethods meth, String path, API api, GwCode code) throws Exception {
String version = "1.0";
// Get Correct API Class from Mapper
Class<?> respCls = facade.mapper().getClass(api);
if(respCls==null) throw new Exception("Unknown class associated with " + api.getClass().getName() + ' ' + api.name());
// setup Application API HTML ContentTypes for JSON and Route
String application = applicationJSON(respCls, version);
//route(env,meth,path,code,application,"application/json;version="+version,"*/*");
// setup Application API HTML ContentTypes for XML and Route
application = applicationXML(respCls, version);
//route(env,meth,path,code.clone(facade_1_0_XML,false),application,"text/xml;version="+version);
// Add other Supported APIs here as created
}
|
[
"public",
"void",
"route",
"(",
"HttpMethods",
"meth",
",",
"String",
"path",
",",
"API",
"api",
",",
"GwCode",
"code",
")",
"throws",
"Exception",
"{",
"String",
"version",
"=",
"\"1.0\"",
";",
"// Get Correct API Class from Mapper",
"Class",
"<",
"?",
">",
"respCls",
"=",
"facade",
".",
"mapper",
"(",
")",
".",
"getClass",
"(",
"api",
")",
";",
"if",
"(",
"respCls",
"==",
"null",
")",
"throw",
"new",
"Exception",
"(",
"\"Unknown class associated with \"",
"+",
"api",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"'",
"'",
"+",
"api",
".",
"name",
"(",
")",
")",
";",
"// setup Application API HTML ContentTypes for JSON and Route",
"String",
"application",
"=",
"applicationJSON",
"(",
"respCls",
",",
"version",
")",
";",
"//route(env,meth,path,code,application,\"application/json;version=\"+version,\"*/*\");",
"// setup Application API HTML ContentTypes for XML and Route",
"application",
"=",
"applicationXML",
"(",
"respCls",
",",
"version",
")",
";",
"//route(env,meth,path,code.clone(facade_1_0_XML,false),application,\"text/xml;version=\"+version);",
"// Add other Supported APIs here as created",
"}"
] |
Setup XML and JSON implementations for each supported Version type
We do this by taking the Code passed in and creating clones of these with the appropriate Facades and properties
to do Versions and Content switches
|
[
"Setup",
"XML",
"and",
"JSON",
"implementations",
"for",
"each",
"supported",
"Version",
"type"
] |
train
|
https://github.com/att/AAF/blob/090562e956c0035db972aafba844dc6d3fc948ee/authz/authz-gw/src/main/java/com/att/authz/gw/GwAPI.java#L119-L133
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/AlpnSupportUtils.java
|
AlpnSupportUtils.getAlpnResult
|
protected static void getAlpnResult(SSLEngine engine, SSLConnectionLink link) {
"""
This must be called after the SSL handshake has completed. If an ALPN protocol was selected by the available provider,
that protocol will be set on the SSLConnectionLink. Also, additional cleanup will be done for some ALPN providers.
@param SSLEngine
@param SSLConnectionLink
"""
alpnNegotiator.tryToRemoveAlpnNegotiator(link.getAlpnNegotiator(), engine, link);
}
|
java
|
protected static void getAlpnResult(SSLEngine engine, SSLConnectionLink link) {
alpnNegotiator.tryToRemoveAlpnNegotiator(link.getAlpnNegotiator(), engine, link);
}
|
[
"protected",
"static",
"void",
"getAlpnResult",
"(",
"SSLEngine",
"engine",
",",
"SSLConnectionLink",
"link",
")",
"{",
"alpnNegotiator",
".",
"tryToRemoveAlpnNegotiator",
"(",
"link",
".",
"getAlpnNegotiator",
"(",
")",
",",
"engine",
",",
"link",
")",
";",
"}"
] |
This must be called after the SSL handshake has completed. If an ALPN protocol was selected by the available provider,
that protocol will be set on the SSLConnectionLink. Also, additional cleanup will be done for some ALPN providers.
@param SSLEngine
@param SSLConnectionLink
|
[
"This",
"must",
"be",
"called",
"after",
"the",
"SSL",
"handshake",
"has",
"completed",
".",
"If",
"an",
"ALPN",
"protocol",
"was",
"selected",
"by",
"the",
"available",
"provider",
"that",
"protocol",
"will",
"be",
"set",
"on",
"the",
"SSLConnectionLink",
".",
"Also",
"additional",
"cleanup",
"will",
"be",
"done",
"for",
"some",
"ALPN",
"providers",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/AlpnSupportUtils.java#L58-L60
|
kuali/ojb-1.0.4
|
src/java/org/apache/ojb/broker/accesslayer/RelationshipPrefetcherFactory.java
|
RelationshipPrefetcherFactory.createRelationshipPrefetcher
|
public RelationshipPrefetcher createRelationshipPrefetcher(ClassDescriptor anOwnerCld, String aRelationshipName) {
"""
create either a CollectionPrefetcher or a ReferencePrefetcher
"""
ObjectReferenceDescriptor ord;
ord = anOwnerCld.getCollectionDescriptorByName(aRelationshipName);
if (ord == null)
{
ord = anOwnerCld.getObjectReferenceDescriptorByName(aRelationshipName);
if (ord == null)
{
throw new PersistenceBrokerException("Relationship named '" + aRelationshipName
+ "' not found in owner class " + (anOwnerCld != null ? anOwnerCld.getClassNameOfObject() : null));
}
}
return createRelationshipPrefetcher(ord);
}
|
java
|
public RelationshipPrefetcher createRelationshipPrefetcher(ClassDescriptor anOwnerCld, String aRelationshipName)
{
ObjectReferenceDescriptor ord;
ord = anOwnerCld.getCollectionDescriptorByName(aRelationshipName);
if (ord == null)
{
ord = anOwnerCld.getObjectReferenceDescriptorByName(aRelationshipName);
if (ord == null)
{
throw new PersistenceBrokerException("Relationship named '" + aRelationshipName
+ "' not found in owner class " + (anOwnerCld != null ? anOwnerCld.getClassNameOfObject() : null));
}
}
return createRelationshipPrefetcher(ord);
}
|
[
"public",
"RelationshipPrefetcher",
"createRelationshipPrefetcher",
"(",
"ClassDescriptor",
"anOwnerCld",
",",
"String",
"aRelationshipName",
")",
"{",
"ObjectReferenceDescriptor",
"ord",
";",
"ord",
"=",
"anOwnerCld",
".",
"getCollectionDescriptorByName",
"(",
"aRelationshipName",
")",
";",
"if",
"(",
"ord",
"==",
"null",
")",
"{",
"ord",
"=",
"anOwnerCld",
".",
"getObjectReferenceDescriptorByName",
"(",
"aRelationshipName",
")",
";",
"if",
"(",
"ord",
"==",
"null",
")",
"{",
"throw",
"new",
"PersistenceBrokerException",
"(",
"\"Relationship named '\"",
"+",
"aRelationshipName",
"+",
"\"' not found in owner class \"",
"+",
"(",
"anOwnerCld",
"!=",
"null",
"?",
"anOwnerCld",
".",
"getClassNameOfObject",
"(",
")",
":",
"null",
")",
")",
";",
"}",
"}",
"return",
"createRelationshipPrefetcher",
"(",
"ord",
")",
";",
"}"
] |
create either a CollectionPrefetcher or a ReferencePrefetcher
|
[
"create",
"either",
"a",
"CollectionPrefetcher",
"or",
"a",
"ReferencePrefetcher"
] |
train
|
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/RelationshipPrefetcherFactory.java#L65-L80
|
httpcache4j/httpcache4j
|
httpcache4j-api/src/main/java/org/codehaus/httpcache4j/MIMEType.java
|
MIMEType.addParameter
|
public MIMEType addParameter(String name, String value) {
"""
Adds a parameter to the MIMEType.
@param name name of parameter
@param value value of parameter
@return returns a new instance with the parameter set
"""
Map<String, String> copy = new LinkedHashMap<>(this.parameters);
copy.put(name, value);
return new MIMEType(type, subType, copy);
}
|
java
|
public MIMEType addParameter(String name, String value) {
Map<String, String> copy = new LinkedHashMap<>(this.parameters);
copy.put(name, value);
return new MIMEType(type, subType, copy);
}
|
[
"public",
"MIMEType",
"addParameter",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"copy",
"=",
"new",
"LinkedHashMap",
"<>",
"(",
"this",
".",
"parameters",
")",
";",
"copy",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"return",
"new",
"MIMEType",
"(",
"type",
",",
"subType",
",",
"copy",
")",
";",
"}"
] |
Adds a parameter to the MIMEType.
@param name name of parameter
@param value value of parameter
@return returns a new instance with the parameter set
|
[
"Adds",
"a",
"parameter",
"to",
"the",
"MIMEType",
"."
] |
train
|
https://github.com/httpcache4j/httpcache4j/blob/9c07ebd63cd104a99eb9e771f760f14efa4fe0f6/httpcache4j-api/src/main/java/org/codehaus/httpcache4j/MIMEType.java#L54-L58
|
looly/hutool
|
hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelPicUtil.java
|
ExcelPicUtil.getPicMap
|
public static Map<String, PictureData> getPicMap(Workbook workbook, int sheetIndex) {
"""
获取工作簿指定sheet中图片列表
@param workbook 工作簿{@link Workbook}
@param sheetIndex sheet的索引
@return 图片映射,键格式:行_列,值:{@link PictureData}
"""
Assert.notNull(workbook, "Workbook must be not null !");
if (sheetIndex < 0) {
sheetIndex = 0;
}
if (workbook instanceof HSSFWorkbook) {
return getPicMapXls((HSSFWorkbook) workbook, sheetIndex);
} else if (workbook instanceof XSSFWorkbook) {
return getPicMapXlsx((XSSFWorkbook) workbook, sheetIndex);
} else {
throw new IllegalArgumentException(StrUtil.format("Workbook type [{}] is not supported!", workbook.getClass()));
}
}
|
java
|
public static Map<String, PictureData> getPicMap(Workbook workbook, int sheetIndex) {
Assert.notNull(workbook, "Workbook must be not null !");
if (sheetIndex < 0) {
sheetIndex = 0;
}
if (workbook instanceof HSSFWorkbook) {
return getPicMapXls((HSSFWorkbook) workbook, sheetIndex);
} else if (workbook instanceof XSSFWorkbook) {
return getPicMapXlsx((XSSFWorkbook) workbook, sheetIndex);
} else {
throw new IllegalArgumentException(StrUtil.format("Workbook type [{}] is not supported!", workbook.getClass()));
}
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"PictureData",
">",
"getPicMap",
"(",
"Workbook",
"workbook",
",",
"int",
"sheetIndex",
")",
"{",
"Assert",
".",
"notNull",
"(",
"workbook",
",",
"\"Workbook must be not null !\"",
")",
";",
"if",
"(",
"sheetIndex",
"<",
"0",
")",
"{",
"sheetIndex",
"=",
"0",
";",
"}",
"if",
"(",
"workbook",
"instanceof",
"HSSFWorkbook",
")",
"{",
"return",
"getPicMapXls",
"(",
"(",
"HSSFWorkbook",
")",
"workbook",
",",
"sheetIndex",
")",
";",
"}",
"else",
"if",
"(",
"workbook",
"instanceof",
"XSSFWorkbook",
")",
"{",
"return",
"getPicMapXlsx",
"(",
"(",
"XSSFWorkbook",
")",
"workbook",
",",
"sheetIndex",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"StrUtil",
".",
"format",
"(",
"\"Workbook type [{}] is not supported!\"",
",",
"workbook",
".",
"getClass",
"(",
")",
")",
")",
";",
"}",
"}"
] |
获取工作簿指定sheet中图片列表
@param workbook 工作簿{@link Workbook}
@param sheetIndex sheet的索引
@return 图片映射,键格式:行_列,值:{@link PictureData}
|
[
"获取工作簿指定sheet中图片列表"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelPicUtil.java#L41-L54
|
exoplatform/jcr
|
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryResultImpl.java
|
QueryResultImpl.collectScoreNodes
|
private void collectScoreNodes(MultiColumnQueryHits hits, List<ScoreNode[]> collector, long maxResults, boolean isOffset) throws IOException,
RepositoryException {
"""
Collect score nodes from <code>hits</code> into the <code>collector</code>
list until the size of <code>collector</code> reaches <code>maxResults</code>
or there are not more results.
@param hits the raw hits.
@param collector where the access checked score nodes are collected.
@param maxResults the maximum number of results in the collector.
@param isOffset if true the access is checked for the offset result.
@throws IOException if an error occurs while reading from hits.
@throws RepositoryException if an error occurs while checking access rights.
"""
while (collector.size() < maxResults)
{
ScoreNode[] sn = hits.nextScoreNodes();
if (sn == null)
{
// no more results
break;
}
// check access
if ((!docOrder && !isOffset ) || isAccessGranted(sn))
{
collector.add(sn);
}
else
{
invalid++;
}
}
}
|
java
|
private void collectScoreNodes(MultiColumnQueryHits hits, List<ScoreNode[]> collector, long maxResults, boolean isOffset) throws IOException,
RepositoryException
{
while (collector.size() < maxResults)
{
ScoreNode[] sn = hits.nextScoreNodes();
if (sn == null)
{
// no more results
break;
}
// check access
if ((!docOrder && !isOffset ) || isAccessGranted(sn))
{
collector.add(sn);
}
else
{
invalid++;
}
}
}
|
[
"private",
"void",
"collectScoreNodes",
"(",
"MultiColumnQueryHits",
"hits",
",",
"List",
"<",
"ScoreNode",
"[",
"]",
">",
"collector",
",",
"long",
"maxResults",
",",
"boolean",
"isOffset",
")",
"throws",
"IOException",
",",
"RepositoryException",
"{",
"while",
"(",
"collector",
".",
"size",
"(",
")",
"<",
"maxResults",
")",
"{",
"ScoreNode",
"[",
"]",
"sn",
"=",
"hits",
".",
"nextScoreNodes",
"(",
")",
";",
"if",
"(",
"sn",
"==",
"null",
")",
"{",
"// no more results",
"break",
";",
"}",
"// check access",
"if",
"(",
"(",
"!",
"docOrder",
"&&",
"!",
"isOffset",
")",
"||",
"isAccessGranted",
"(",
"sn",
")",
")",
"{",
"collector",
".",
"add",
"(",
"sn",
")",
";",
"}",
"else",
"{",
"invalid",
"++",
";",
"}",
"}",
"}"
] |
Collect score nodes from <code>hits</code> into the <code>collector</code>
list until the size of <code>collector</code> reaches <code>maxResults</code>
or there are not more results.
@param hits the raw hits.
@param collector where the access checked score nodes are collected.
@param maxResults the maximum number of results in the collector.
@param isOffset if true the access is checked for the offset result.
@throws IOException if an error occurs while reading from hits.
@throws RepositoryException if an error occurs while checking access rights.
|
[
"Collect",
"score",
"nodes",
"from",
"<code",
">",
"hits<",
"/",
"code",
">",
"into",
"the",
"<code",
">",
"collector<",
"/",
"code",
">",
"list",
"until",
"the",
"size",
"of",
"<code",
">",
"collector<",
"/",
"code",
">",
"reaches",
"<code",
">",
"maxResults<",
"/",
"code",
">",
"or",
"there",
"are",
"not",
"more",
"results",
"."
] |
train
|
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryResultImpl.java#L391-L412
|
Faylixe/googlecodejam-client
|
src/main/java/fr/faylixe/googlecodejam/client/CodeJamSession.java
|
CodeJamSession.createSession
|
public static CodeJamSession createSession(final HttpRequestExecutor executor, final Round round) throws IOException {
"""
<p>Static factory method that should be used for creating a session.
Loads associated contest info and initial values from the given
<tt>round</tt>, using the given <tt>executor</tt>.</p>
@param executor {@link HttpRequestExecutor} instance to use.
@param round Contextual {@link Round} instance this session is bound to.
@return Created session.
@throws IOException If any error occurs while retrieving contest info or initial values.
"""
final ContestInfo info = ContestInfo.get(executor, round);
final InitialValues values = InitialValues.get(executor, round);
return new CodeJamSession(executor, round, info, values);
}
|
java
|
public static CodeJamSession createSession(final HttpRequestExecutor executor, final Round round) throws IOException {
final ContestInfo info = ContestInfo.get(executor, round);
final InitialValues values = InitialValues.get(executor, round);
return new CodeJamSession(executor, round, info, values);
}
|
[
"public",
"static",
"CodeJamSession",
"createSession",
"(",
"final",
"HttpRequestExecutor",
"executor",
",",
"final",
"Round",
"round",
")",
"throws",
"IOException",
"{",
"final",
"ContestInfo",
"info",
"=",
"ContestInfo",
".",
"get",
"(",
"executor",
",",
"round",
")",
";",
"final",
"InitialValues",
"values",
"=",
"InitialValues",
".",
"get",
"(",
"executor",
",",
"round",
")",
";",
"return",
"new",
"CodeJamSession",
"(",
"executor",
",",
"round",
",",
"info",
",",
"values",
")",
";",
"}"
] |
<p>Static factory method that should be used for creating a session.
Loads associated contest info and initial values from the given
<tt>round</tt>, using the given <tt>executor</tt>.</p>
@param executor {@link HttpRequestExecutor} instance to use.
@param round Contextual {@link Round} instance this session is bound to.
@return Created session.
@throws IOException If any error occurs while retrieving contest info or initial values.
|
[
"<p",
">",
"Static",
"factory",
"method",
"that",
"should",
"be",
"used",
"for",
"creating",
"a",
"session",
".",
"Loads",
"associated",
"contest",
"info",
"and",
"initial",
"values",
"from",
"the",
"given",
"<tt",
">",
"round<",
"/",
"tt",
">",
"using",
"the",
"given",
"<tt",
">",
"executor<",
"/",
"tt",
">",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/Faylixe/googlecodejam-client/blob/84a5fed4e049dca48994dc3f70213976aaff4bd3/src/main/java/fr/faylixe/googlecodejam/client/CodeJamSession.java#L368-L372
|
susom/database
|
src/main/java/com/github/susom/database/DatabaseProvider.java
|
DatabaseProvider.fromDriverManager
|
@CheckReturnValue
public static Builder fromDriverManager(String url, Properties info) {
"""
Builder method to create and initialize an instance of this class using
the JDBC standard DriverManager method. The url parameter will be inspected
to determine the Flavor for this database.
"""
return fromDriverManager(url, Flavor.fromJdbcUrl(url), info, null, null);
}
|
java
|
@CheckReturnValue
public static Builder fromDriverManager(String url, Properties info) {
return fromDriverManager(url, Flavor.fromJdbcUrl(url), info, null, null);
}
|
[
"@",
"CheckReturnValue",
"public",
"static",
"Builder",
"fromDriverManager",
"(",
"String",
"url",
",",
"Properties",
"info",
")",
"{",
"return",
"fromDriverManager",
"(",
"url",
",",
"Flavor",
".",
"fromJdbcUrl",
"(",
"url",
")",
",",
"info",
",",
"null",
",",
"null",
")",
";",
"}"
] |
Builder method to create and initialize an instance of this class using
the JDBC standard DriverManager method. The url parameter will be inspected
to determine the Flavor for this database.
|
[
"Builder",
"method",
"to",
"create",
"and",
"initialize",
"an",
"instance",
"of",
"this",
"class",
"using",
"the",
"JDBC",
"standard",
"DriverManager",
"method",
".",
"The",
"url",
"parameter",
"will",
"be",
"inspected",
"to",
"determine",
"the",
"Flavor",
"for",
"this",
"database",
"."
] |
train
|
https://github.com/susom/database/blob/25add9e08ad863712f9b5e319b6cb826f6f97640/src/main/java/com/github/susom/database/DatabaseProvider.java#L150-L153
|
EXIficient/exificient-grammars
|
src/main/java/com/siemens/ct/exi/grammars/XSDGrammarsBuilder.java
|
XSDGrammarsBuilder.addLocalNameStringEntry
|
protected void addLocalNameStringEntry(String namespaceURI, String localName) {
"""
/*
When a schema is provided, the string table (Local-name) is also
pre-populated with the local name of each attribute, element and type
declared in the schema, partitioned by namespace URI and sorted
lexicographically.
"""
// fetch localName list
List<String> localNameList = addNamespaceStringEntry(namespaceURI);
// check localName value presence
if (!localNameList.contains(localName)) {
localNameList.add(localName);
}
}
|
java
|
protected void addLocalNameStringEntry(String namespaceURI, String localName) {
// fetch localName list
List<String> localNameList = addNamespaceStringEntry(namespaceURI);
// check localName value presence
if (!localNameList.contains(localName)) {
localNameList.add(localName);
}
}
|
[
"protected",
"void",
"addLocalNameStringEntry",
"(",
"String",
"namespaceURI",
",",
"String",
"localName",
")",
"{",
"// fetch localName list\r",
"List",
"<",
"String",
">",
"localNameList",
"=",
"addNamespaceStringEntry",
"(",
"namespaceURI",
")",
";",
"// check localName value presence\r",
"if",
"(",
"!",
"localNameList",
".",
"contains",
"(",
"localName",
")",
")",
"{",
"localNameList",
".",
"add",
"(",
"localName",
")",
";",
"}",
"}"
] |
/*
When a schema is provided, the string table (Local-name) is also
pre-populated with the local name of each attribute, element and type
declared in the schema, partitioned by namespace URI and sorted
lexicographically.
|
[
"/",
"*",
"When",
"a",
"schema",
"is",
"provided",
"the",
"string",
"table",
"(",
"Local",
"-",
"name",
")",
"is",
"also",
"pre",
"-",
"populated",
"with",
"the",
"local",
"name",
"of",
"each",
"attribute",
"element",
"and",
"type",
"declared",
"in",
"the",
"schema",
"partitioned",
"by",
"namespace",
"URI",
"and",
"sorted",
"lexicographically",
"."
] |
train
|
https://github.com/EXIficient/exificient-grammars/blob/d96477062ebdd4245920e44cc1995259699fc7fb/src/main/java/com/siemens/ct/exi/grammars/XSDGrammarsBuilder.java#L1219-L1227
|
inaiat/jqplot4java
|
src/main/java/br/com/digilabs/jqplot/chart/BubbleChart.java
|
BubbleChart.addValue
|
public void addValue(Float x, Float y, Float radius, String label) {
"""
Add a value
@param x x
@param y y
@param radius radius
@param label label
"""
bubbleData.addValue(new BubbleItem(x, y, radius, label));
}
|
java
|
public void addValue(Float x, Float y, Float radius, String label) {
bubbleData.addValue(new BubbleItem(x, y, radius, label));
}
|
[
"public",
"void",
"addValue",
"(",
"Float",
"x",
",",
"Float",
"y",
",",
"Float",
"radius",
",",
"String",
"label",
")",
"{",
"bubbleData",
".",
"addValue",
"(",
"new",
"BubbleItem",
"(",
"x",
",",
"y",
",",
"radius",
",",
"label",
")",
")",
";",
"}"
] |
Add a value
@param x x
@param y y
@param radius radius
@param label label
|
[
"Add",
"a",
"value"
] |
train
|
https://github.com/inaiat/jqplot4java/blob/35bcd17749442e88695df0438c8330a65a3977cc/src/main/java/br/com/digilabs/jqplot/chart/BubbleChart.java#L84-L86
|
intive-FDV/DynamicJasper
|
src/main/java/ar/com/fdvs/dj/domain/chart/builder/DJBar3DChartBuilder.java
|
DJBar3DChartBuilder.addSerie
|
public DJBar3DChartBuilder addSerie(AbstractColumn column, StringExpression labelExpression) {
"""
Adds the specified serie column to the dataset with custom label.
@param column the serie column
"""
getDataset().addSerie(column, labelExpression);
return this;
}
|
java
|
public DJBar3DChartBuilder addSerie(AbstractColumn column, StringExpression labelExpression) {
getDataset().addSerie(column, labelExpression);
return this;
}
|
[
"public",
"DJBar3DChartBuilder",
"addSerie",
"(",
"AbstractColumn",
"column",
",",
"StringExpression",
"labelExpression",
")",
"{",
"getDataset",
"(",
")",
".",
"addSerie",
"(",
"column",
",",
"labelExpression",
")",
";",
"return",
"this",
";",
"}"
] |
Adds the specified serie column to the dataset with custom label.
@param column the serie column
|
[
"Adds",
"the",
"specified",
"serie",
"column",
"to",
"the",
"dataset",
"with",
"custom",
"label",
"."
] |
train
|
https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/domain/chart/builder/DJBar3DChartBuilder.java#L376-L379
|
apache/groovy
|
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
|
DefaultGroovyMethods.setMetaClass
|
public static void setMetaClass(Class self, MetaClass metaClass) {
"""
Sets the metaclass for a given class.
@param self the class whose metaclass we wish to set
@param metaClass the new MetaClass
@since 1.6.0
"""
final MetaClassRegistry metaClassRegistry = GroovySystem.getMetaClassRegistry();
if (metaClass == null)
metaClassRegistry.removeMetaClass(self);
else {
if (metaClass instanceof HandleMetaClass) {
metaClassRegistry.setMetaClass(self, ((HandleMetaClass)metaClass).getAdaptee());
} else {
metaClassRegistry.setMetaClass(self, metaClass);
}
if (self==NullObject.class) {
NullObject.getNullObject().setMetaClass(metaClass);
}
}
}
|
java
|
public static void setMetaClass(Class self, MetaClass metaClass) {
final MetaClassRegistry metaClassRegistry = GroovySystem.getMetaClassRegistry();
if (metaClass == null)
metaClassRegistry.removeMetaClass(self);
else {
if (metaClass instanceof HandleMetaClass) {
metaClassRegistry.setMetaClass(self, ((HandleMetaClass)metaClass).getAdaptee());
} else {
metaClassRegistry.setMetaClass(self, metaClass);
}
if (self==NullObject.class) {
NullObject.getNullObject().setMetaClass(metaClass);
}
}
}
|
[
"public",
"static",
"void",
"setMetaClass",
"(",
"Class",
"self",
",",
"MetaClass",
"metaClass",
")",
"{",
"final",
"MetaClassRegistry",
"metaClassRegistry",
"=",
"GroovySystem",
".",
"getMetaClassRegistry",
"(",
")",
";",
"if",
"(",
"metaClass",
"==",
"null",
")",
"metaClassRegistry",
".",
"removeMetaClass",
"(",
"self",
")",
";",
"else",
"{",
"if",
"(",
"metaClass",
"instanceof",
"HandleMetaClass",
")",
"{",
"metaClassRegistry",
".",
"setMetaClass",
"(",
"self",
",",
"(",
"(",
"HandleMetaClass",
")",
"metaClass",
")",
".",
"getAdaptee",
"(",
")",
")",
";",
"}",
"else",
"{",
"metaClassRegistry",
".",
"setMetaClass",
"(",
"self",
",",
"metaClass",
")",
";",
"}",
"if",
"(",
"self",
"==",
"NullObject",
".",
"class",
")",
"{",
"NullObject",
".",
"getNullObject",
"(",
")",
".",
"setMetaClass",
"(",
"metaClass",
")",
";",
"}",
"}",
"}"
] |
Sets the metaclass for a given class.
@param self the class whose metaclass we wish to set
@param metaClass the new MetaClass
@since 1.6.0
|
[
"Sets",
"the",
"metaclass",
"for",
"a",
"given",
"class",
"."
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L17270-L17284
|
exoplatform/jcr
|
exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java
|
AddMetadataAction.extractMetaInfoProperties
|
private Properties extractMetaInfoProperties(Context ctx, Content content) throws IllegalArgumentException,
RepositoryException, IOException, DocumentReadException, HandlerNotFoundException {
"""
Extracts some metainfo properties from content using {@link DocumentReaderService}.
@throws IllegalArgumentException if {@link DocumentReaderService} not configured
@throws RepositoryException
@throws HandlerNotFoundException
@throws DocumentReadException
@throws IOException
"""
DocumentReaderService readerService =
(DocumentReaderService)((ExoContainer)ctx.get(InvocationContext.EXO_CONTAINER))
.getComponentInstanceOfType(DocumentReaderService.class);
if (readerService == null)
{
throw new IllegalArgumentException("No DocumentReaderService configured for current container");
}
Properties props = new Properties();
props = readerService.getDocumentReader(content.mimeType).getProperties(content.stream);
return props;
}
|
java
|
private Properties extractMetaInfoProperties(Context ctx, Content content) throws IllegalArgumentException,
RepositoryException, IOException, DocumentReadException, HandlerNotFoundException
{
DocumentReaderService readerService =
(DocumentReaderService)((ExoContainer)ctx.get(InvocationContext.EXO_CONTAINER))
.getComponentInstanceOfType(DocumentReaderService.class);
if (readerService == null)
{
throw new IllegalArgumentException("No DocumentReaderService configured for current container");
}
Properties props = new Properties();
props = readerService.getDocumentReader(content.mimeType).getProperties(content.stream);
return props;
}
|
[
"private",
"Properties",
"extractMetaInfoProperties",
"(",
"Context",
"ctx",
",",
"Content",
"content",
")",
"throws",
"IllegalArgumentException",
",",
"RepositoryException",
",",
"IOException",
",",
"DocumentReadException",
",",
"HandlerNotFoundException",
"{",
"DocumentReaderService",
"readerService",
"=",
"(",
"DocumentReaderService",
")",
"(",
"(",
"ExoContainer",
")",
"ctx",
".",
"get",
"(",
"InvocationContext",
".",
"EXO_CONTAINER",
")",
")",
".",
"getComponentInstanceOfType",
"(",
"DocumentReaderService",
".",
"class",
")",
";",
"if",
"(",
"readerService",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No DocumentReaderService configured for current container\"",
")",
";",
"}",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"props",
"=",
"readerService",
".",
"getDocumentReader",
"(",
"content",
".",
"mimeType",
")",
".",
"getProperties",
"(",
"content",
".",
"stream",
")",
";",
"return",
"props",
";",
"}"
] |
Extracts some metainfo properties from content using {@link DocumentReaderService}.
@throws IllegalArgumentException if {@link DocumentReaderService} not configured
@throws RepositoryException
@throws HandlerNotFoundException
@throws DocumentReadException
@throws IOException
|
[
"Extracts",
"some",
"metainfo",
"properties",
"from",
"content",
"using",
"{",
"@link",
"DocumentReaderService",
"}",
"."
] |
train
|
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java#L115-L131
|
zeroturnaround/zt-zip
|
src/main/java/org/zeroturnaround/zip/ZipEntryUtil.java
|
ZipEntryUtil.fromFile
|
static ZipEntry fromFile(String name, File file) {
"""
Create new Zip entry and fill it with associated with file meta-info
@param name Zip entry name
@param file source File
@return newly created Zip entry
"""
ZipEntry zipEntry = new ZipEntry(name);
if (!file.isDirectory()) {
zipEntry.setSize(file.length());
}
zipEntry.setTime(file.lastModified());
ZTFilePermissions permissions = ZTFilePermissionsUtil.getDefaultStategy().getPermissions(file);
if (permissions != null) {
ZipEntryUtil.setZTFilePermissions(zipEntry, permissions);
}
return zipEntry;
}
|
java
|
static ZipEntry fromFile(String name, File file) {
ZipEntry zipEntry = new ZipEntry(name);
if (!file.isDirectory()) {
zipEntry.setSize(file.length());
}
zipEntry.setTime(file.lastModified());
ZTFilePermissions permissions = ZTFilePermissionsUtil.getDefaultStategy().getPermissions(file);
if (permissions != null) {
ZipEntryUtil.setZTFilePermissions(zipEntry, permissions);
}
return zipEntry;
}
|
[
"static",
"ZipEntry",
"fromFile",
"(",
"String",
"name",
",",
"File",
"file",
")",
"{",
"ZipEntry",
"zipEntry",
"=",
"new",
"ZipEntry",
"(",
"name",
")",
";",
"if",
"(",
"!",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"zipEntry",
".",
"setSize",
"(",
"file",
".",
"length",
"(",
")",
")",
";",
"}",
"zipEntry",
".",
"setTime",
"(",
"file",
".",
"lastModified",
"(",
")",
")",
";",
"ZTFilePermissions",
"permissions",
"=",
"ZTFilePermissionsUtil",
".",
"getDefaultStategy",
"(",
")",
".",
"getPermissions",
"(",
"file",
")",
";",
"if",
"(",
"permissions",
"!=",
"null",
")",
"{",
"ZipEntryUtil",
".",
"setZTFilePermissions",
"(",
"zipEntry",
",",
"permissions",
")",
";",
"}",
"return",
"zipEntry",
";",
"}"
] |
Create new Zip entry and fill it with associated with file meta-info
@param name Zip entry name
@param file source File
@return newly created Zip entry
|
[
"Create",
"new",
"Zip",
"entry",
"and",
"fill",
"it",
"with",
"associated",
"with",
"file",
"meta",
"-",
"info"
] |
train
|
https://github.com/zeroturnaround/zt-zip/blob/abb4dc43583e4d19339c0c021035019798970a13/src/main/java/org/zeroturnaround/zip/ZipEntryUtil.java#L143-L155
|
hap-java/HAP-Java
|
src/main/java/io/github/hapjava/HomekitServer.java
|
HomekitServer.createBridge
|
public HomekitRoot createBridge(
HomekitAuthInfo authInfo,
String label,
String manufacturer,
String model,
String serialNumber)
throws IOException {
"""
Creates a bridge accessory, capable of holding multiple child accessories. This has the
advantage over multiple standalone accessories of only requiring a single pairing from iOS for
the bridge.
@param authInfo authentication information for this accessory. These values should be persisted
and re-supplied on re-start of your application.
@param label label for the bridge. This will show in iOS during pairing.
@param manufacturer manufacturer of the bridge. This information is exposed to iOS for unknown
purposes.
@param model model of the bridge. This is also exposed to iOS for unknown purposes.
@param serialNumber serial number of the bridge. Also exposed. Purposes also unknown.
@return the bridge, from which you can {@link HomekitRoot#addAccessory add accessories} and
then {@link HomekitRoot#start start} handling requests.
@throws IOException when mDNS cannot connect to the network
"""
HomekitRoot root = new HomekitRoot(label, http, localAddress, authInfo);
root.addAccessory(new HomekitBridge(label, serialNumber, model, manufacturer));
return root;
}
|
java
|
public HomekitRoot createBridge(
HomekitAuthInfo authInfo,
String label,
String manufacturer,
String model,
String serialNumber)
throws IOException {
HomekitRoot root = new HomekitRoot(label, http, localAddress, authInfo);
root.addAccessory(new HomekitBridge(label, serialNumber, model, manufacturer));
return root;
}
|
[
"public",
"HomekitRoot",
"createBridge",
"(",
"HomekitAuthInfo",
"authInfo",
",",
"String",
"label",
",",
"String",
"manufacturer",
",",
"String",
"model",
",",
"String",
"serialNumber",
")",
"throws",
"IOException",
"{",
"HomekitRoot",
"root",
"=",
"new",
"HomekitRoot",
"(",
"label",
",",
"http",
",",
"localAddress",
",",
"authInfo",
")",
";",
"root",
".",
"addAccessory",
"(",
"new",
"HomekitBridge",
"(",
"label",
",",
"serialNumber",
",",
"model",
",",
"manufacturer",
")",
")",
";",
"return",
"root",
";",
"}"
] |
Creates a bridge accessory, capable of holding multiple child accessories. This has the
advantage over multiple standalone accessories of only requiring a single pairing from iOS for
the bridge.
@param authInfo authentication information for this accessory. These values should be persisted
and re-supplied on re-start of your application.
@param label label for the bridge. This will show in iOS during pairing.
@param manufacturer manufacturer of the bridge. This information is exposed to iOS for unknown
purposes.
@param model model of the bridge. This is also exposed to iOS for unknown purposes.
@param serialNumber serial number of the bridge. Also exposed. Purposes also unknown.
@return the bridge, from which you can {@link HomekitRoot#addAccessory add accessories} and
then {@link HomekitRoot#start start} handling requests.
@throws IOException when mDNS cannot connect to the network
|
[
"Creates",
"a",
"bridge",
"accessory",
"capable",
"of",
"holding",
"multiple",
"child",
"accessories",
".",
"This",
"has",
"the",
"advantage",
"over",
"multiple",
"standalone",
"accessories",
"of",
"only",
"requiring",
"a",
"single",
"pairing",
"from",
"iOS",
"for",
"the",
"bridge",
"."
] |
train
|
https://github.com/hap-java/HAP-Java/blob/d2b2f4f1579580a2b5958af3a192128345843db9/src/main/java/io/github/hapjava/HomekitServer.java#L104-L114
|
RestComm/Restcomm-Connect
|
restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/security/PermissionEvaluator.java
|
PermissionEvaluator.hasAccountRole
|
public boolean hasAccountRole(final String role,UserIdentityContext userIdentityContext) {
"""
Checks is the effective account has the specified role. Only role values contained in the Restcomm Account
are take into account.
@param role
@return true if the role exists in the Account. Otherwise it returns false.
"""
if (userIdentityContext.getEffectiveAccount() != null) {
return userIdentityContext.getEffectiveAccountRoles().contains(role);
}
return false;
}
|
java
|
public boolean hasAccountRole(final String role,UserIdentityContext userIdentityContext) {
if (userIdentityContext.getEffectiveAccount() != null) {
return userIdentityContext.getEffectiveAccountRoles().contains(role);
}
return false;
}
|
[
"public",
"boolean",
"hasAccountRole",
"(",
"final",
"String",
"role",
",",
"UserIdentityContext",
"userIdentityContext",
")",
"{",
"if",
"(",
"userIdentityContext",
".",
"getEffectiveAccount",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"userIdentityContext",
".",
"getEffectiveAccountRoles",
"(",
")",
".",
"contains",
"(",
"role",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks is the effective account has the specified role. Only role values contained in the Restcomm Account
are take into account.
@param role
@return true if the role exists in the Account. Otherwise it returns false.
|
[
"Checks",
"is",
"the",
"effective",
"account",
"has",
"the",
"specified",
"role",
".",
"Only",
"role",
"values",
"contained",
"in",
"the",
"Restcomm",
"Account",
"are",
"take",
"into",
"account",
"."
] |
train
|
https://github.com/RestComm/Restcomm-Connect/blob/2194dee4fc524cdfd0af77a218ba5f212f97f7c5/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/security/PermissionEvaluator.java#L255-L260
|
structr/structr
|
structr-core/src/main/java/org/structr/schema/action/Function.java
|
Function.logException
|
protected void logException (final Object caller, final Throwable t, final Object[] parameters) {
"""
Logging of an Exception in a function with a simple message outputting the name and call parameters of the function
@param caller The element that caused the error
@param t The thrown Exception
@param parameters The method parameters
"""
logException(t, "{}: Exception in '{}' for parameters: {}", new Object[] { getReplacement(), caller, getParametersAsString(parameters) });
}
|
java
|
protected void logException (final Object caller, final Throwable t, final Object[] parameters) {
logException(t, "{}: Exception in '{}' for parameters: {}", new Object[] { getReplacement(), caller, getParametersAsString(parameters) });
}
|
[
"protected",
"void",
"logException",
"(",
"final",
"Object",
"caller",
",",
"final",
"Throwable",
"t",
",",
"final",
"Object",
"[",
"]",
"parameters",
")",
"{",
"logException",
"(",
"t",
",",
"\"{}: Exception in '{}' for parameters: {}\"",
",",
"new",
"Object",
"[",
"]",
"{",
"getReplacement",
"(",
")",
",",
"caller",
",",
"getParametersAsString",
"(",
"parameters",
")",
"}",
")",
";",
"}"
] |
Logging of an Exception in a function with a simple message outputting the name and call parameters of the function
@param caller The element that caused the error
@param t The thrown Exception
@param parameters The method parameters
|
[
"Logging",
"of",
"an",
"Exception",
"in",
"a",
"function",
"with",
"a",
"simple",
"message",
"outputting",
"the",
"name",
"and",
"call",
"parameters",
"of",
"the",
"function"
] |
train
|
https://github.com/structr/structr/blob/c111a1d0c0201c7fea5574ed69aa5a5053185a97/structr-core/src/main/java/org/structr/schema/action/Function.java#L98-L100
|
GenesysPureEngage/workspace-client-java
|
src/main/java/com/genesys/internal/workspace/api/TargetsApi.java
|
TargetsApi.deletePersonalFavorite
|
public ApiSuccessResponse deletePersonalFavorite(String id, String type) throws ApiException {
"""
Delete a target
Delete the target from the agent's personal favorites.
@param id The ID of the target. (required)
@param type The type of target. (required)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
ApiResponse<ApiSuccessResponse> resp = deletePersonalFavoriteWithHttpInfo(id, type);
return resp.getData();
}
|
java
|
public ApiSuccessResponse deletePersonalFavorite(String id, String type) throws ApiException {
ApiResponse<ApiSuccessResponse> resp = deletePersonalFavoriteWithHttpInfo(id, type);
return resp.getData();
}
|
[
"public",
"ApiSuccessResponse",
"deletePersonalFavorite",
"(",
"String",
"id",
",",
"String",
"type",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"ApiSuccessResponse",
">",
"resp",
"=",
"deletePersonalFavoriteWithHttpInfo",
"(",
"id",
",",
"type",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] |
Delete a target
Delete the target from the agent's personal favorites.
@param id The ID of the target. (required)
@param type The type of target. (required)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
[
"Delete",
"a",
"target",
"Delete",
"the",
"target",
"from",
"the",
"agent'",
";",
"s",
"personal",
"favorites",
"."
] |
train
|
https://github.com/GenesysPureEngage/workspace-client-java/blob/509fdd9e89b9359d012f9a72be95037a3cef53e6/src/main/java/com/genesys/internal/workspace/api/TargetsApi.java#L376-L379
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.threading/src/com/ibm/ws/threading/internal/ThreadPoolController.java
|
ThreadPoolController.pruneData
|
private boolean pruneData(ThroughputDistribution priorStats, double forecast) {
"""
Evaluates a ThroughputDistribution for possible removal from the historical dataset.
@param priorStats - ThroughputDistribution under evaluation
@param forecast - expected throughput at the current poolSize
@return - true if priorStats should be removed
"""
boolean prune = false;
// if forecast tput is much greater or much smaller than priorStats, we suspect
// priorStats is no longer relevant, so prune it
double tputRatio = forecast / priorStats.getMovingAverage();
if (tputRatio > tputRatioPruneLevel || tputRatio < (1 / tputRatioPruneLevel)) {
prune = true;
} else {
// age & reliability (represented by standard deviation) check
int age = controllerCycle - priorStats.getLastUpdate();
double variability = (priorStats.getStddev() / priorStats.getMovingAverage());
if (age * variability > dataAgePruneLevel)
prune = true;
}
return prune;
}
|
java
|
private boolean pruneData(ThroughputDistribution priorStats, double forecast) {
boolean prune = false;
// if forecast tput is much greater or much smaller than priorStats, we suspect
// priorStats is no longer relevant, so prune it
double tputRatio = forecast / priorStats.getMovingAverage();
if (tputRatio > tputRatioPruneLevel || tputRatio < (1 / tputRatioPruneLevel)) {
prune = true;
} else {
// age & reliability (represented by standard deviation) check
int age = controllerCycle - priorStats.getLastUpdate();
double variability = (priorStats.getStddev() / priorStats.getMovingAverage());
if (age * variability > dataAgePruneLevel)
prune = true;
}
return prune;
}
|
[
"private",
"boolean",
"pruneData",
"(",
"ThroughputDistribution",
"priorStats",
",",
"double",
"forecast",
")",
"{",
"boolean",
"prune",
"=",
"false",
";",
"// if forecast tput is much greater or much smaller than priorStats, we suspect",
"// priorStats is no longer relevant, so prune it",
"double",
"tputRatio",
"=",
"forecast",
"/",
"priorStats",
".",
"getMovingAverage",
"(",
")",
";",
"if",
"(",
"tputRatio",
">",
"tputRatioPruneLevel",
"||",
"tputRatio",
"<",
"(",
"1",
"/",
"tputRatioPruneLevel",
")",
")",
"{",
"prune",
"=",
"true",
";",
"}",
"else",
"{",
"// age & reliability (represented by standard deviation) check",
"int",
"age",
"=",
"controllerCycle",
"-",
"priorStats",
".",
"getLastUpdate",
"(",
")",
";",
"double",
"variability",
"=",
"(",
"priorStats",
".",
"getStddev",
"(",
")",
"/",
"priorStats",
".",
"getMovingAverage",
"(",
")",
")",
";",
"if",
"(",
"age",
"*",
"variability",
">",
"dataAgePruneLevel",
")",
"prune",
"=",
"true",
";",
"}",
"return",
"prune",
";",
"}"
] |
Evaluates a ThroughputDistribution for possible removal from the historical dataset.
@param priorStats - ThroughputDistribution under evaluation
@param forecast - expected throughput at the current poolSize
@return - true if priorStats should be removed
|
[
"Evaluates",
"a",
"ThroughputDistribution",
"for",
"possible",
"removal",
"from",
"the",
"historical",
"dataset",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.threading/src/com/ibm/ws/threading/internal/ThreadPoolController.java#L1583-L1600
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.