repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
opentelecoms-org/jsmpp | jsmpp/src/main/java/org/jsmpp/util/StringValidator.java | StringValidator.isCOctetStringValid | static boolean isCOctetStringValid(String value, int maxLength) {
if (value == null)
return true;
if (value.length() >= maxLength)
return false;
return true;
} | java | static boolean isCOctetStringValid(String value, int maxLength) {
if (value == null)
return true;
if (value.length() >= maxLength)
return false;
return true;
} | [
"static",
"boolean",
"isCOctetStringValid",
"(",
"String",
"value",
",",
"int",
"maxLength",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"true",
";",
"if",
"(",
"value",
".",
"length",
"(",
")",
">=",
"maxLength",
")",
"return",
"false",
... | Validate the C-Octet String.
@param value
@param maxLength
@return | [
"Validate",
"the",
"C",
"-",
"Octet",
"String",
"."
] | acc15e73e7431deabc803731971b15323315baaf | https://github.com/opentelecoms-org/jsmpp/blob/acc15e73e7431deabc803731971b15323315baaf/jsmpp/src/main/java/org/jsmpp/util/StringValidator.java#L91-L98 | train |
opentelecoms-org/jsmpp | jsmpp/src/main/java/org/jsmpp/util/StringValidator.java | StringValidator.isCOctetStringNullOrNValValid | static boolean isCOctetStringNullOrNValValid(String value,
int length) {
if (value == null) {
return true;
}
if (value.length() == 0) {
return true;
}
if (value.length() == length - 1) {
return true;
}
... | java | static boolean isCOctetStringNullOrNValValid(String value,
int length) {
if (value == null) {
return true;
}
if (value.length() == 0) {
return true;
}
if (value.length() == length - 1) {
return true;
}
... | [
"static",
"boolean",
"isCOctetStringNullOrNValValid",
"(",
"String",
"value",
",",
"int",
"length",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"value",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"r... | Validate the C-Octet String
@param value
@param length
@return | [
"Validate",
"the",
"C",
"-",
"Octet",
"String"
] | acc15e73e7431deabc803731971b15323315baaf | https://github.com/opentelecoms-org/jsmpp/blob/acc15e73e7431deabc803731971b15323315baaf/jsmpp/src/main/java/org/jsmpp/util/StringValidator.java#L116-L130 | train |
opentelecoms-org/jsmpp | jsmpp/src/main/java/org/jsmpp/util/StringValidator.java | StringValidator.isOctetStringValid | static boolean isOctetStringValid(String value, int maxLength) {
if (value == null)
return true;
if (value.length() > maxLength)
return false;
return true;
} | java | static boolean isOctetStringValid(String value, int maxLength) {
if (value == null)
return true;
if (value.length() > maxLength)
return false;
return true;
} | [
"static",
"boolean",
"isOctetStringValid",
"(",
"String",
"value",
",",
"int",
"maxLength",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"true",
";",
"if",
"(",
"value",
".",
"length",
"(",
")",
">",
"maxLength",
")",
"return",
"false",
"... | Validate the Octet String
@param value
@param maxLength
@return | [
"Validate",
"the",
"Octet",
"String"
] | acc15e73e7431deabc803731971b15323315baaf | https://github.com/opentelecoms-org/jsmpp/blob/acc15e73e7431deabc803731971b15323315baaf/jsmpp/src/main/java/org/jsmpp/util/StringValidator.java#L151-L157 | train |
opentelecoms-org/jsmpp | jsmpp/src/main/java/org/jsmpp/util/RelativeTimeFormatter.java | RelativeTimeFormatter.format | public String format(Calendar calendar, Calendar smscCalendar) {
if (calendar == null || smscCalendar == null) {
return null;
}
long diffTimeInMillis = calendar.getTimeInMillis() - smscCalendar.getTimeInMillis();
if (diffTimeInMillis < 0) {
throw new IllegalArgumentException("The requested ... | java | public String format(Calendar calendar, Calendar smscCalendar) {
if (calendar == null || smscCalendar == null) {
return null;
}
long diffTimeInMillis = calendar.getTimeInMillis() - smscCalendar.getTimeInMillis();
if (diffTimeInMillis < 0) {
throw new IllegalArgumentException("The requested ... | [
"public",
"String",
"format",
"(",
"Calendar",
"calendar",
",",
"Calendar",
"smscCalendar",
")",
"{",
"if",
"(",
"calendar",
"==",
"null",
"||",
"smscCalendar",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"long",
"diffTimeInMillis",
"=",
"calendar",
... | Return the relative time from the calendar datetime against the SMSC datetime.
@param calendar the date.
@param smscCalendar the SMSC date.
@return The relative time between the calendar date and the SMSC calendar date. | [
"Return",
"the",
"relative",
"time",
"from",
"the",
"calendar",
"datetime",
"against",
"the",
"SMSC",
"datetime",
"."
] | acc15e73e7431deabc803731971b15323315baaf | https://github.com/opentelecoms-org/jsmpp/blob/acc15e73e7431deabc803731971b15323315baaf/jsmpp/src/main/java/org/jsmpp/util/RelativeTimeFormatter.java#L64-L89 | train |
opentelecoms-org/jsmpp | jsmpp/src/main/java/org/jsmpp/util/PDUByteBuffer.java | PDUByteBuffer.append | public int append(byte[] b, int offset, int length) {
int oldLength = bytesLength;
bytesLength += length;
int newCapacity = capacityPolicy.ensureCapacity(bytesLength, bytes.length);
if (newCapacity > bytes.length) {
byte[] newB = new byte[newCapacity];
System.arra... | java | public int append(byte[] b, int offset, int length) {
int oldLength = bytesLength;
bytesLength += length;
int newCapacity = capacityPolicy.ensureCapacity(bytesLength, bytes.length);
if (newCapacity > bytes.length) {
byte[] newB = new byte[newCapacity];
System.arra... | [
"public",
"int",
"append",
"(",
"byte",
"[",
"]",
"b",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"int",
"oldLength",
"=",
"bytesLength",
";",
"bytesLength",
"+=",
"length",
";",
"int",
"newCapacity",
"=",
"capacityPolicy",
".",
"ensureCapacity"... | Append bytes to specified offset and length.
@param b is the bytes to append.
@param offset is the offset where the bytes will be placed.
@param length the length that will specified which part of the bytes will
be append.
@return the latest length of the byte buffer. | [
"Append",
"bytes",
"to",
"specified",
"offset",
"and",
"length",
"."
] | acc15e73e7431deabc803731971b15323315baaf | https://github.com/opentelecoms-org/jsmpp/blob/acc15e73e7431deabc803731971b15323315baaf/jsmpp/src/main/java/org/jsmpp/util/PDUByteBuffer.java#L94-L106 | train |
opentelecoms-org/jsmpp | jsmpp/src/main/java/org/jsmpp/util/PDUByteBuffer.java | PDUByteBuffer.appendAll | public int appendAll(OptionalParameter[] optionalParameters) {
int length = 0;
for (OptionalParameter optionalParamameter : optionalParameters) {
length += append(optionalParamameter);
}
return length;
} | java | public int appendAll(OptionalParameter[] optionalParameters) {
int length = 0;
for (OptionalParameter optionalParamameter : optionalParameters) {
length += append(optionalParamameter);
}
return length;
} | [
"public",
"int",
"appendAll",
"(",
"OptionalParameter",
"[",
"]",
"optionalParameters",
")",
"{",
"int",
"length",
"=",
"0",
";",
"for",
"(",
"OptionalParameter",
"optionalParamameter",
":",
"optionalParameters",
")",
"{",
"length",
"+=",
"append",
"(",
"optiona... | Append all optional parameters.
@param optionalParameters is the optional parameters.
@return the latest length of the buffer. | [
"Append",
"all",
"optional",
"parameters",
"."
] | acc15e73e7431deabc803731971b15323315baaf | https://github.com/opentelecoms-org/jsmpp/blob/acc15e73e7431deabc803731971b15323315baaf/jsmpp/src/main/java/org/jsmpp/util/PDUByteBuffer.java#L180-L186 | train |
copper-engine/copper-engine | projects/copper-coreengine/src/main/java/org/copperengine/core/wfrepo/FileBasedWorkflowRepository.java | FileBasedWorkflowRepository.setSourceArchiveUrls | public void setSourceArchiveUrls(List<String> sourceArchiveUrls) {
if (sourceArchiveUrls == null)
throw new IllegalArgumentException();
this.sourceArchiveUrls = new ArrayList<String>(sourceArchiveUrls);
} | java | public void setSourceArchiveUrls(List<String> sourceArchiveUrls) {
if (sourceArchiveUrls == null)
throw new IllegalArgumentException();
this.sourceArchiveUrls = new ArrayList<String>(sourceArchiveUrls);
} | [
"public",
"void",
"setSourceArchiveUrls",
"(",
"List",
"<",
"String",
">",
"sourceArchiveUrls",
")",
"{",
"if",
"(",
"sourceArchiveUrls",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"this",
".",
"sourceArchiveUrls",
"=",
"new",
... | Sets the list of source archive URLs. The source archives must be ZIP compressed archives, containing COPPER
workflows as .java files.
@param sourceArchiveUrls
urls where workflow class sources reside in | [
"Sets",
"the",
"list",
"of",
"source",
"archive",
"URLs",
".",
"The",
"source",
"archives",
"must",
"be",
"ZIP",
"compressed",
"archives",
"containing",
"COPPER",
"workflows",
"as",
".",
"java",
"files",
"."
] | 92acf748a1be3d2d49e86b04e180bd19b1745c15 | https://github.com/copper-engine/copper-engine/blob/92acf748a1be3d2d49e86b04e180bd19b1745c15/projects/copper-coreengine/src/main/java/org/copperengine/core/wfrepo/FileBasedWorkflowRepository.java#L94-L98 | train |
copper-engine/copper-engine | projects/copper-coreengine/src/main/java/org/copperengine/core/wfrepo/FileBasedWorkflowRepository.java | FileBasedWorkflowRepository.setCompilerOptionsProviders | public void setCompilerOptionsProviders(List<CompilerOptionsProvider> compilerOptionsProviders) {
if (compilerOptionsProviders == null)
throw new NullPointerException();
this.compilerOptionsProviders = new ArrayList<CompilerOptionsProvider>(compilerOptionsProviders);
} | java | public void setCompilerOptionsProviders(List<CompilerOptionsProvider> compilerOptionsProviders) {
if (compilerOptionsProviders == null)
throw new NullPointerException();
this.compilerOptionsProviders = new ArrayList<CompilerOptionsProvider>(compilerOptionsProviders);
} | [
"public",
"void",
"setCompilerOptionsProviders",
"(",
"List",
"<",
"CompilerOptionsProvider",
">",
"compilerOptionsProviders",
")",
"{",
"if",
"(",
"compilerOptionsProviders",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"this",
".",
"co... | Sets the list of CompilerOptionsProviders. They are called before compiling the workflow files to append compiler
options.
@param compilerOptionsProviders
Options from those providers are used for compilation. | [
"Sets",
"the",
"list",
"of",
"CompilerOptionsProviders",
".",
"They",
"are",
"called",
"before",
"compiling",
"the",
"workflow",
"files",
"to",
"append",
"compiler",
"options",
"."
] | 92acf748a1be3d2d49e86b04e180bd19b1745c15 | https://github.com/copper-engine/copper-engine/blob/92acf748a1be3d2d49e86b04e180bd19b1745c15/projects/copper-coreengine/src/main/java/org/copperengine/core/wfrepo/FileBasedWorkflowRepository.java#L124-L128 | train |
copper-engine/copper-engine | projects/copper-coreengine/src/main/java/org/copperengine/core/tranzient/DefaultEarlyResponseContainer.java | DefaultEarlyResponseContainer.doHousekeeping | private void doHousekeeping() {
logger.info("started");
while (!shutdown) {
try {
List<EarlyResponse> removedEarlyResponses = new ArrayList<>();
synchronized (responseMap) {
Iterator<List<EarlyResponse>> responseMapIterator = response... | java | private void doHousekeeping() {
logger.info("started");
while (!shutdown) {
try {
List<EarlyResponse> removedEarlyResponses = new ArrayList<>();
synchronized (responseMap) {
Iterator<List<EarlyResponse>> responseMapIterator = response... | [
"private",
"void",
"doHousekeeping",
"(",
")",
"{",
"logger",
".",
"info",
"(",
"\"started\"",
")",
";",
"while",
"(",
"!",
"shutdown",
")",
"{",
"try",
"{",
"List",
"<",
"EarlyResponse",
">",
"removedEarlyResponses",
"=",
"new",
"ArrayList",
"<>",
"(",
... | Jetzt gibt es eine Map von Listen und man muss immer alles komplett Ueberpruefen - ggf. optimieren | [
"Jetzt",
"gibt",
"es",
"eine",
"Map",
"von",
"Listen",
"und",
"man",
"muss",
"immer",
"alles",
"komplett",
"Ueberpruefen",
"-",
"ggf",
".",
"optimieren"
] | 92acf748a1be3d2d49e86b04e180bd19b1745c15 | https://github.com/copper-engine/copper-engine/blob/92acf748a1be3d2d49e86b04e180bd19b1745c15/projects/copper-coreengine/src/main/java/org/copperengine/core/tranzient/DefaultEarlyResponseContainer.java#L175-L207 | train |
copper-engine/copper-engine | projects/copper-coreengine/src/main/java/org/copperengine/core/audit/BatchingAuditTrail.java | BatchingAuditTrail.asynchLog | public void asynchLog(final AuditTrailEvent e, final AuditTrailCallback cb) {
CommandCallback<BatchInsertIntoAutoTrail.Command> callback = new CommandCallback<BatchInsertIntoAutoTrail.Command>() {
@Override
public void commandCompleted() {
cb.done();
}
... | java | public void asynchLog(final AuditTrailEvent e, final AuditTrailCallback cb) {
CommandCallback<BatchInsertIntoAutoTrail.Command> callback = new CommandCallback<BatchInsertIntoAutoTrail.Command>() {
@Override
public void commandCompleted() {
cb.done();
}
... | [
"public",
"void",
"asynchLog",
"(",
"final",
"AuditTrailEvent",
"e",
",",
"final",
"AuditTrailCallback",
"cb",
")",
"{",
"CommandCallback",
"<",
"BatchInsertIntoAutoTrail",
".",
"Command",
">",
"callback",
"=",
"new",
"CommandCallback",
"<",
"BatchInsertIntoAutoTrail"... | returns immediately after queueing the log message
@param e
the AuditTrailEvent to be logged
@param cb
callback called when logging succeeded or failed. | [
"returns",
"immediately",
"after",
"queueing",
"the",
"log",
"message"
] | 92acf748a1be3d2d49e86b04e180bd19b1745c15 | https://github.com/copper-engine/copper-engine/blob/92acf748a1be3d2d49e86b04e180bd19b1745c15/projects/copper-coreengine/src/main/java/org/copperengine/core/audit/BatchingAuditTrail.java#L119-L132 | train |
copper-engine/copper-engine | projects/copper-coreengine/src/main/java/org/copperengine/core/db/utility/JdbcUtils.java | JdbcUtils.closeConnection | public static void closeConnection(Connection con) {
if (con != null) {
try {
con.close();
} catch (SQLException ex) {
logger.debug("Could not close JDBC Connection", ex);
} catch (Throwable ex) {
logger.debug("Unexpected... | java | public static void closeConnection(Connection con) {
if (con != null) {
try {
con.close();
} catch (SQLException ex) {
logger.debug("Could not close JDBC Connection", ex);
} catch (Throwable ex) {
logger.debug("Unexpected... | [
"public",
"static",
"void",
"closeConnection",
"(",
"Connection",
"con",
")",
"{",
"if",
"(",
"con",
"!=",
"null",
")",
"{",
"try",
"{",
"con",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"ex",
")",
"{",
"logger",
".",
"debug",
... | Close the given JDBC Connection and ignore any thrown exception.
This is useful for typical finally blocks in manual JDBC code.
@param con
Connection which shall be closed | [
"Close",
"the",
"given",
"JDBC",
"Connection",
"and",
"ignore",
"any",
"thrown",
"exception",
".",
"This",
"is",
"useful",
"for",
"typical",
"finally",
"blocks",
"in",
"manual",
"JDBC",
"code",
"."
] | 92acf748a1be3d2d49e86b04e180bd19b1745c15 | https://github.com/copper-engine/copper-engine/blob/92acf748a1be3d2d49e86b04e180bd19b1745c15/projects/copper-coreengine/src/main/java/org/copperengine/core/db/utility/JdbcUtils.java#L35-L45 | train |
copper-engine/copper-engine | projects/copper-coreengine/src/main/java/org/copperengine/core/common/TicketPool.java | TicketPool.release | public synchronized void release(int count) {
used -= count;
if (used < 0)
used = 0; // no negative number of ticket!
if (logger.isDebugEnabled())
logger.debug("Released " + count + " tickets! (Now " + this.toString() + ")");
notifyAll();
} | java | public synchronized void release(int count) {
used -= count;
if (used < 0)
used = 0; // no negative number of ticket!
if (logger.isDebugEnabled())
logger.debug("Released " + count + " tickets! (Now " + this.toString() + ")");
notifyAll();
} | [
"public",
"synchronized",
"void",
"release",
"(",
"int",
"count",
")",
"{",
"used",
"-=",
"count",
";",
"if",
"(",
"used",
"<",
"0",
")",
"used",
"=",
"0",
";",
"// no negative number of ticket!\r",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
"... | Releases the given number of tickets and notifies potentially waiting
threads, that new tickets are in the pool.
@param count
number of tickets to be released | [
"Releases",
"the",
"given",
"number",
"of",
"tickets",
"and",
"notifies",
"potentially",
"waiting",
"threads",
"that",
"new",
"tickets",
"are",
"in",
"the",
"pool",
"."
] | 92acf748a1be3d2d49e86b04e180bd19b1745c15 | https://github.com/copper-engine/copper-engine/blob/92acf748a1be3d2d49e86b04e180bd19b1745c15/projects/copper-coreengine/src/main/java/org/copperengine/core/common/TicketPool.java#L173-L180 | train |
copper-engine/copper-engine | projects/copper-coreengine/src/main/java/org/copperengine/core/common/DefaultTicketPoolManager.java | DefaultTicketPoolManager.obtainAndReturnTicketPoolId | public String obtainAndReturnTicketPoolId(Workflow<?> wf) {
TicketPool tp = findPool(wf.getClass().getName());
tp.obtain();
return tp.getId();
} | java | public String obtainAndReturnTicketPoolId(Workflow<?> wf) {
TicketPool tp = findPool(wf.getClass().getName());
tp.obtain();
return tp.getId();
} | [
"public",
"String",
"obtainAndReturnTicketPoolId",
"(",
"Workflow",
"<",
"?",
">",
"wf",
")",
"{",
"TicketPool",
"tp",
"=",
"findPool",
"(",
"wf",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"tp",
".",
"obtain",
"(",
")",
";",
"ret... | For testing..
@param wf
For this workflow, the corresponding ticketPool is searched and then a ticket is obtained from this pool.
@return
id of the ticket pool. | [
"For",
"testing",
".."
] | 92acf748a1be3d2d49e86b04e180bd19b1745c15 | https://github.com/copper-engine/copper-engine/blob/92acf748a1be3d2d49e86b04e180bd19b1745c15/projects/copper-coreengine/src/main/java/org/copperengine/core/common/DefaultTicketPoolManager.java#L115-L119 | train |
copper-engine/copper-engine | projects/copper-coreengine/src/main/java/org/copperengine/core/persistent/StandardJavaSerializer.java | StandardJavaSerializer.classnameReplacement | protected String classnameReplacement(String classname) {
if (classname.startsWith(COPPER_2X_PACKAGE_PREFIX)) {
String className3x = classname.replace(COPPER_2X_PACKAGE_PREFIX, COPPER_3_PACKAGE_PREFIX);
if ((COPPER_3_PACKAGE_PREFIX + COPPER_2X_INTERRUPT_NAME).equals(className3x)) {
... | java | protected String classnameReplacement(String classname) {
if (classname.startsWith(COPPER_2X_PACKAGE_PREFIX)) {
String className3x = classname.replace(COPPER_2X_PACKAGE_PREFIX, COPPER_3_PACKAGE_PREFIX);
if ((COPPER_3_PACKAGE_PREFIX + COPPER_2X_INTERRUPT_NAME).equals(className3x)) {
... | [
"protected",
"String",
"classnameReplacement",
"(",
"String",
"classname",
")",
"{",
"if",
"(",
"classname",
".",
"startsWith",
"(",
"COPPER_2X_PACKAGE_PREFIX",
")",
")",
"{",
"String",
"className3x",
"=",
"classname",
".",
"replace",
"(",
"COPPER_2X_PACKAGE_PREFIX"... | For downward compatibility, there is a package name replacement during
deserialization of workflow instances and responses.
The default implementation ensures downward compatibility to copper <= 2.x.
@param classname the workflow class name
@return the adjusted workflow class name | [
"For",
"downward",
"compatibility",
"there",
"is",
"a",
"package",
"name",
"replacement",
"during",
"deserialization",
"of",
"workflow",
"instances",
"and",
"responses",
".",
"The",
"default",
"implementation",
"ensures",
"downward",
"compatibility",
"to",
"copper",
... | 92acf748a1be3d2d49e86b04e180bd19b1745c15 | https://github.com/copper-engine/copper-engine/blob/92acf748a1be3d2d49e86b04e180bd19b1745c15/projects/copper-coreengine/src/main/java/org/copperengine/core/persistent/StandardJavaSerializer.java#L129-L138 | train |
copper-engine/copper-engine | projects/copper-coreengine/src/main/java/org/copperengine/core/persistent/MementoUtil.java | MementoUtil.addCurrentEntity | public void addCurrentEntity(Object entity) {
Object identifier = identifier(entity);
Object o = memento.get(identifier);
if (o == null) {
inserted.add(entity);
} else {
potentiallyChanged.put(identifier, entity);
}
} | java | public void addCurrentEntity(Object entity) {
Object identifier = identifier(entity);
Object o = memento.get(identifier);
if (o == null) {
inserted.add(entity);
} else {
potentiallyChanged.put(identifier, entity);
}
} | [
"public",
"void",
"addCurrentEntity",
"(",
"Object",
"entity",
")",
"{",
"Object",
"identifier",
"=",
"identifier",
"(",
"entity",
")",
";",
"Object",
"o",
"=",
"memento",
".",
"get",
"(",
"identifier",
")",
";",
"if",
"(",
"o",
"==",
"null",
")",
"{",... | Use this entity as the new
@param entity
the entity to be used as the new | [
"Use",
"this",
"entity",
"as",
"the",
"new"
] | 92acf748a1be3d2d49e86b04e180bd19b1745c15 | https://github.com/copper-engine/copper-engine/blob/92acf748a1be3d2d49e86b04e180bd19b1745c15/projects/copper-coreengine/src/main/java/org/copperengine/core/persistent/MementoUtil.java#L67-L75 | train |
copper-engine/copper-engine | projects/copper-coreengine/src/main/java/org/copperengine/core/Workflow.java | Workflow.putResponse | public void putResponse(Response<?> r) {
synchronized (responseMap) {
List<Response<?>> l = responseMap.get(r.getCorrelationId());
if (l == null) {
l = new SortedResponseList();
responseMap.put(r.getCorrelationId(), l);
}
l.a... | java | public void putResponse(Response<?> r) {
synchronized (responseMap) {
List<Response<?>> l = responseMap.get(r.getCorrelationId());
if (l == null) {
l = new SortedResponseList();
responseMap.put(r.getCorrelationId(), l);
}
l.a... | [
"public",
"void",
"putResponse",
"(",
"Response",
"<",
"?",
">",
"r",
")",
"{",
"synchronized",
"(",
"responseMap",
")",
"{",
"List",
"<",
"Response",
"<",
"?",
">",
">",
"l",
"=",
"responseMap",
".",
"get",
"(",
"r",
".",
"getCorrelationId",
"(",
")... | Internal use only - called by the processing engine
@param r
response to be put into the response map. | [
"Internal",
"use",
"only",
"-",
"called",
"by",
"the",
"processing",
"engine"
] | 92acf748a1be3d2d49e86b04e180bd19b1745c15 | https://github.com/copper-engine/copper-engine/blob/92acf748a1be3d2d49e86b04e180bd19b1745c15/projects/copper-coreengine/src/main/java/org/copperengine/core/Workflow.java#L287-L296 | train |
copper-engine/copper-engine | projects/copper-coreengine/src/main/java/org/copperengine/core/Workflow.java | Workflow.resubmit | protected final void resubmit() throws Interrupt {
final String cid = engine.createUUID();
engine.registerCallbacks(this, WaitMode.ALL, 0, cid);
Acknowledge ack = createCheckpointAcknowledge();
engine.notify(new Response<Object>(cid, null, null), ack);
registerCheckpointAckn... | java | protected final void resubmit() throws Interrupt {
final String cid = engine.createUUID();
engine.registerCallbacks(this, WaitMode.ALL, 0, cid);
Acknowledge ack = createCheckpointAcknowledge();
engine.notify(new Response<Object>(cid, null, null), ack);
registerCheckpointAckn... | [
"protected",
"final",
"void",
"resubmit",
"(",
")",
"throws",
"Interrupt",
"{",
"final",
"String",
"cid",
"=",
"engine",
".",
"createUUID",
"(",
")",
";",
"engine",
".",
"registerCallbacks",
"(",
"this",
",",
"WaitMode",
".",
"ALL",
",",
"0",
",",
"cid",... | Causes the engine to stop processing of this workflow instance and to enqueue it again.
May be used in case of processor pool change or to create a 'savepoint'.
@throws Interrupt
for internal use of COPPER. After resubmit is called, an Interrupt is thrown, caught by COPPER itself for
taking back control over the execu... | [
"Causes",
"the",
"engine",
"to",
"stop",
"processing",
"of",
"this",
"workflow",
"instance",
"and",
"to",
"enqueue",
"it",
"again",
".",
"May",
"be",
"used",
"in",
"case",
"of",
"processor",
"pool",
"change",
"or",
"to",
"create",
"a",
"savepoint",
"."
] | 92acf748a1be3d2d49e86b04e180bd19b1745c15 | https://github.com/copper-engine/copper-engine/blob/92acf748a1be3d2d49e86b04e180bd19b1745c15/projects/copper-coreengine/src/main/java/org/copperengine/core/Workflow.java#L419-L427 | train |
copper-engine/copper-engine | projects/copper-cassandra/cassandra-storage/src/main/java/org/copperengine/core/persistent/cassandra/CassandraStorage.java | CassandraStorage.countWorkflowInstances | @Override
public int countWorkflowInstances(WorkflowInstanceFilter filter) throws Exception {
final StringBuilder query = new StringBuilder();
final List<Object> values = new ArrayList<>();
query.append("SELECT COUNT(*) AS COUNT_NUMBER FROM COP_WORKFLOW_INSTANCE");
appendQueryBase(qu... | java | @Override
public int countWorkflowInstances(WorkflowInstanceFilter filter) throws Exception {
final StringBuilder query = new StringBuilder();
final List<Object> values = new ArrayList<>();
query.append("SELECT COUNT(*) AS COUNT_NUMBER FROM COP_WORKFLOW_INSTANCE");
appendQueryBase(qu... | [
"@",
"Override",
"public",
"int",
"countWorkflowInstances",
"(",
"WorkflowInstanceFilter",
"filter",
")",
"throws",
"Exception",
"{",
"final",
"StringBuilder",
"query",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"List",
"<",
"Object",
">",
"values",
"=... | Probably it's gonna be slow. We can consider creating counting table for that sake. | [
"Probably",
"it",
"s",
"gonna",
"be",
"slow",
".",
"We",
"can",
"consider",
"creating",
"counting",
"table",
"for",
"that",
"sake",
"."
] | 92acf748a1be3d2d49e86b04e180bd19b1745c15 | https://github.com/copper-engine/copper-engine/blob/92acf748a1be3d2d49e86b04e180bd19b1745c15/projects/copper-cassandra/cassandra-storage/src/main/java/org/copperengine/core/persistent/cassandra/CassandraStorage.java#L511-L526 | train |
scireum/s3ninja | src/main/java/ninja/S3Dispatcher.java | S3Dispatcher.getAuthHash | private String getAuthHash(WebContext ctx) {
Value authorizationHeaderValue = ctx.getHeaderValue(HttpHeaderNames.AUTHORIZATION);
if (!authorizationHeaderValue.isFilled()) {
return ctx.get("Signature").asString(ctx.get("X-Amz-Signature").asString());
}
String authentication =
... | java | private String getAuthHash(WebContext ctx) {
Value authorizationHeaderValue = ctx.getHeaderValue(HttpHeaderNames.AUTHORIZATION);
if (!authorizationHeaderValue.isFilled()) {
return ctx.get("Signature").asString(ctx.get("X-Amz-Signature").asString());
}
String authentication =
... | [
"private",
"String",
"getAuthHash",
"(",
"WebContext",
"ctx",
")",
"{",
"Value",
"authorizationHeaderValue",
"=",
"ctx",
".",
"getHeaderValue",
"(",
"HttpHeaderNames",
".",
"AUTHORIZATION",
")",
";",
"if",
"(",
"!",
"authorizationHeaderValue",
".",
"isFilled",
"("... | Extracts the given hash from the given request. Returns null if no hash was given. | [
"Extracts",
"the",
"given",
"hash",
"from",
"the",
"given",
"request",
".",
"Returns",
"null",
"if",
"no",
"hash",
"was",
"given",
"."
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/S3Dispatcher.java#L199-L217 | train |
scireum/s3ninja | src/main/java/ninja/S3Dispatcher.java | S3Dispatcher.signalObjectError | private void signalObjectError(WebContext ctx, HttpResponseStatus status, String message) {
if (ctx.getRequest().method() == HEAD) {
ctx.respondWith().status(status);
} else {
ctx.respondWith().error(status, message);
}
log.log(ctx.getRequest().method().name(),
... | java | private void signalObjectError(WebContext ctx, HttpResponseStatus status, String message) {
if (ctx.getRequest().method() == HEAD) {
ctx.respondWith().status(status);
} else {
ctx.respondWith().error(status, message);
}
log.log(ctx.getRequest().method().name(),
... | [
"private",
"void",
"signalObjectError",
"(",
"WebContext",
"ctx",
",",
"HttpResponseStatus",
"status",
",",
"String",
"message",
")",
"{",
"if",
"(",
"ctx",
".",
"getRequest",
"(",
")",
".",
"method",
"(",
")",
"==",
"HEAD",
")",
"{",
"ctx",
".",
"respon... | Writes an API error to the log | [
"Writes",
"an",
"API",
"error",
"to",
"the",
"log"
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/S3Dispatcher.java#L222-L232 | train |
scireum/s3ninja | src/main/java/ninja/S3Dispatcher.java | S3Dispatcher.signalObjectSuccess | private void signalObjectSuccess(WebContext ctx) {
log.log(ctx.getRequest().method().name(),
ctx.getRequestedURI(),
APILog.Result.OK,
CallContext.getCurrent().getWatch());
} | java | private void signalObjectSuccess(WebContext ctx) {
log.log(ctx.getRequest().method().name(),
ctx.getRequestedURI(),
APILog.Result.OK,
CallContext.getCurrent().getWatch());
} | [
"private",
"void",
"signalObjectSuccess",
"(",
"WebContext",
"ctx",
")",
"{",
"log",
".",
"log",
"(",
"ctx",
".",
"getRequest",
"(",
")",
".",
"method",
"(",
")",
".",
"name",
"(",
")",
",",
"ctx",
".",
"getRequestedURI",
"(",
")",
",",
"APILog",
"."... | Writes an API success entry to the log | [
"Writes",
"an",
"API",
"success",
"entry",
"to",
"the",
"log"
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/S3Dispatcher.java#L237-L242 | train |
scireum/s3ninja | src/main/java/ninja/S3Dispatcher.java | S3Dispatcher.listBuckets | private void listBuckets(WebContext ctx) {
HttpMethod method = ctx.getRequest().method();
if (GET == method) {
List<Bucket> buckets = storage.getBuckets();
Response response = ctx.respondWith();
response.setHeader(HTTP_HEADER_NAME_CONTENT_TYPE, CONTENT_TYPE_XML);
... | java | private void listBuckets(WebContext ctx) {
HttpMethod method = ctx.getRequest().method();
if (GET == method) {
List<Bucket> buckets = storage.getBuckets();
Response response = ctx.respondWith();
response.setHeader(HTTP_HEADER_NAME_CONTENT_TYPE, CONTENT_TYPE_XML);
... | [
"private",
"void",
"listBuckets",
"(",
"WebContext",
"ctx",
")",
"{",
"HttpMethod",
"method",
"=",
"ctx",
".",
"getRequest",
"(",
")",
".",
"method",
"(",
")",
";",
"if",
"(",
"GET",
"==",
"method",
")",
"{",
"List",
"<",
"Bucket",
">",
"buckets",
"=... | GET a list of all buckets
@param ctx the context describing the current request | [
"GET",
"a",
"list",
"of",
"all",
"buckets"
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/S3Dispatcher.java#L249-L277 | train |
scireum/s3ninja | src/main/java/ninja/S3Dispatcher.java | S3Dispatcher.readObject | private void readObject(WebContext ctx, String bucketName, String objectId) throws IOException {
Bucket bucket = storage.getBucket(bucketName);
String id = objectId.replace('/', '_');
String uploadId = ctx.get("uploadId").asString();
if (!checkObjectRequest(ctx, bucket, id)) {
... | java | private void readObject(WebContext ctx, String bucketName, String objectId) throws IOException {
Bucket bucket = storage.getBucket(bucketName);
String id = objectId.replace('/', '_');
String uploadId = ctx.get("uploadId").asString();
if (!checkObjectRequest(ctx, bucket, id)) {
... | [
"private",
"void",
"readObject",
"(",
"WebContext",
"ctx",
",",
"String",
"bucketName",
",",
"String",
"objectId",
")",
"throws",
"IOException",
"{",
"Bucket",
"bucket",
"=",
"storage",
".",
"getBucket",
"(",
"bucketName",
")",
";",
"String",
"id",
"=",
"obj... | Dispatching method handling all object specific calls which either read or delete the object but do not provide
any data.
@param ctx the context describing the current request
@param bucketName name of the bucket which contains the object (must exist)
@param objectId name of the object of interest
@throws IOE... | [
"Dispatching",
"method",
"handling",
"all",
"object",
"specific",
"calls",
"which",
"either",
"read",
"or",
"delete",
"the",
"object",
"but",
"do",
"not",
"provide",
"any",
"data",
"."
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/S3Dispatcher.java#L336-L363 | train |
scireum/s3ninja | src/main/java/ninja/Aws4HashCalculator.java | Aws4HashCalculator.supports | public boolean supports(final WebContext ctx) {
return AWS_AUTH4_PATTERN.matcher(ctx.getHeaderValue("Authorization").asString("")).matches()
|| X_AMZ_CREDENTIAL_PATTERN.matcher(ctx.get("X-Amz-Credential").asString("")).matches();
} | java | public boolean supports(final WebContext ctx) {
return AWS_AUTH4_PATTERN.matcher(ctx.getHeaderValue("Authorization").asString("")).matches()
|| X_AMZ_CREDENTIAL_PATTERN.matcher(ctx.get("X-Amz-Credential").asString("")).matches();
} | [
"public",
"boolean",
"supports",
"(",
"final",
"WebContext",
"ctx",
")",
"{",
"return",
"AWS_AUTH4_PATTERN",
".",
"matcher",
"(",
"ctx",
".",
"getHeaderValue",
"(",
"\"Authorization\"",
")",
".",
"asString",
"(",
"\"\"",
")",
")",
".",
"matches",
"(",
")",
... | Determines if the given request contains an AWS4 auth token.
@param ctx the request to check
@return <tt>true</tt> if the request contains an AWS4 auth token, <tt>false</tt> otherwise. | [
"Determines",
"if",
"the",
"given",
"request",
"contains",
"an",
"AWS4",
"auth",
"token",
"."
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/Aws4HashCalculator.java#L54-L57 | train |
scireum/s3ninja | src/main/java/ninja/Storage.java | Storage.getBasePath | public String getBasePath() {
StringBuilder sb = new StringBuilder(getBaseDirUnchecked().getAbsolutePath());
if (!getBaseDirUnchecked().exists()) {
sb.append(" (non-existent!)");
} else if (!getBaseDirUnchecked().isDirectory()) {
sb.append(" (no directory!)");
} e... | java | public String getBasePath() {
StringBuilder sb = new StringBuilder(getBaseDirUnchecked().getAbsolutePath());
if (!getBaseDirUnchecked().exists()) {
sb.append(" (non-existent!)");
} else if (!getBaseDirUnchecked().isDirectory()) {
sb.append(" (no directory!)");
} e... | [
"public",
"String",
"getBasePath",
"(",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"getBaseDirUnchecked",
"(",
")",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"if",
"(",
"!",
"getBaseDirUnchecked",
"(",
")",
".",
"exists",
"(",
")"... | Returns the base directory as string.
@return a string containing the path of the base directory. Will contain additional infos, if the path is
not usable | [
"Returns",
"the",
"base",
"directory",
"as",
"string",
"."
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/Storage.java#L78-L89 | train |
scireum/s3ninja | src/main/java/ninja/Storage.java | Storage.getBuckets | public List<Bucket> getBuckets() {
List<Bucket> result = Lists.newArrayList();
for (File file : getBaseDir().listFiles()) {
if (file.isDirectory()) {
result.add(new Bucket(file));
}
}
return result;
} | java | public List<Bucket> getBuckets() {
List<Bucket> result = Lists.newArrayList();
for (File file : getBaseDir().listFiles()) {
if (file.isDirectory()) {
result.add(new Bucket(file));
}
}
return result;
} | [
"public",
"List",
"<",
"Bucket",
">",
"getBuckets",
"(",
")",
"{",
"List",
"<",
"Bucket",
">",
"result",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"for",
"(",
"File",
"file",
":",
"getBaseDir",
"(",
")",
".",
"listFiles",
"(",
")",
")",
"{"... | Enumerates all known buckets.
@return a list of all known buckets | [
"Enumerates",
"all",
"known",
"buckets",
"."
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/Storage.java#L96-L105 | train |
scireum/s3ninja | src/main/java/ninja/Storage.java | Storage.getBucket | public Bucket getBucket(String bucket) {
if (bucket.contains("..") || bucket.contains("/") || bucket.contains("\\")) {
throw Exceptions.createHandled()
.withSystemErrorMessage(
"Invalid bucket name: %s. A bucket name must not contain '.... | java | public Bucket getBucket(String bucket) {
if (bucket.contains("..") || bucket.contains("/") || bucket.contains("\\")) {
throw Exceptions.createHandled()
.withSystemErrorMessage(
"Invalid bucket name: %s. A bucket name must not contain '.... | [
"public",
"Bucket",
"getBucket",
"(",
"String",
"bucket",
")",
"{",
"if",
"(",
"bucket",
".",
"contains",
"(",
"\"..\"",
")",
"||",
"bucket",
".",
"contains",
"(",
"\"/\"",
")",
"||",
"bucket",
".",
"contains",
"(",
"\"\\\\\"",
")",
")",
"{",
"throw",
... | Returns a bucket with the given name
@param bucket the name of the bucket to fetch. Must not contain .. or / or \
@return the bucket with the given id. Might not exist, but will never be <tt>null</tt> | [
"Returns",
"a",
"bucket",
"with",
"the",
"given",
"name"
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/Storage.java#L113-L122 | train |
scireum/s3ninja | src/main/java/ninja/StoredObject.java | StoredObject.delete | public void delete() {
if (!file.delete()) {
Storage.LOG.WARN("Failed to delete data file for object %s (%s).", getName(), file.getAbsolutePath());
}
if (!getPropertiesFile().delete()) {
Storage.LOG.WARN("Failed to delete properties file for object %s (%s).",
... | java | public void delete() {
if (!file.delete()) {
Storage.LOG.WARN("Failed to delete data file for object %s (%s).", getName(), file.getAbsolutePath());
}
if (!getPropertiesFile().delete()) {
Storage.LOG.WARN("Failed to delete properties file for object %s (%s).",
... | [
"public",
"void",
"delete",
"(",
")",
"{",
"if",
"(",
"!",
"file",
".",
"delete",
"(",
")",
")",
"{",
"Storage",
".",
"LOG",
".",
"WARN",
"(",
"\"Failed to delete data file for object %s (%s).\"",
",",
"getName",
"(",
")",
",",
"file",
".",
"getAbsolutePat... | Deletes the object | [
"Deletes",
"the",
"object"
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/StoredObject.java#L71-L80 | train |
scireum/s3ninja | src/main/java/ninja/StoredObject.java | StoredObject.storeProperties | public void storeProperties(Map<String, String> properties) throws IOException {
Properties props = new Properties();
properties.forEach(props::setProperty);
try (FileOutputStream out = new FileOutputStream(getPropertiesFile())) {
props.store(out, "");
}
} | java | public void storeProperties(Map<String, String> properties) throws IOException {
Properties props = new Properties();
properties.forEach(props::setProperty);
try (FileOutputStream out = new FileOutputStream(getPropertiesFile())) {
props.store(out, "");
}
} | [
"public",
"void",
"storeProperties",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"properties",
")",
"throws",
"IOException",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"properties",
".",
"forEach",
"(",
"props",
"::",
"setPropert... | Stores the given meta infos for the stored object.
@param properties properties to store
@throws IOException in case of an IO error | [
"Stores",
"the",
"given",
"meta",
"infos",
"for",
"the",
"stored",
"object",
"."
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/StoredObject.java#L134-L140 | train |
scireum/s3ninja | src/main/java/ninja/Bucket.java | Bucket.delete | public boolean delete() {
boolean deleted = false;
for (File child : file.listFiles()) {
deleted = child.delete() || deleted;
}
deleted = file.delete() || deleted;
return deleted;
} | java | public boolean delete() {
boolean deleted = false;
for (File child : file.listFiles()) {
deleted = child.delete() || deleted;
}
deleted = file.delete() || deleted;
return deleted;
} | [
"public",
"boolean",
"delete",
"(",
")",
"{",
"boolean",
"deleted",
"=",
"false",
";",
"for",
"(",
"File",
"child",
":",
"file",
".",
"listFiles",
"(",
")",
")",
"{",
"deleted",
"=",
"child",
".",
"delete",
"(",
")",
"||",
"deleted",
";",
"}",
"del... | Deletes the bucket and all of its contents.
@return true if all files of the bucket and the bucket itself was deleted successfully, false otherwise. | [
"Deletes",
"the",
"bucket",
"and",
"all",
"of",
"its",
"contents",
"."
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/Bucket.java#L64-L71 | train |
scireum/s3ninja | src/main/java/ninja/Bucket.java | Bucket.makePrivate | public void makePrivate() {
if (getPublicMarkerFile().exists()) {
if (getPublicMarkerFile().delete()) {
publicAccessCache.put(getName(), false);
} else {
Storage.LOG.WARN("Failed to delete public marker for bucket %s - it remains public!", getName());
... | java | public void makePrivate() {
if (getPublicMarkerFile().exists()) {
if (getPublicMarkerFile().delete()) {
publicAccessCache.put(getName(), false);
} else {
Storage.LOG.WARN("Failed to delete public marker for bucket %s - it remains public!", getName());
... | [
"public",
"void",
"makePrivate",
"(",
")",
"{",
"if",
"(",
"getPublicMarkerFile",
"(",
")",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"getPublicMarkerFile",
"(",
")",
".",
"delete",
"(",
")",
")",
"{",
"publicAccessCache",
".",
"put",
"(",
"getName... | Marks the bucket as private accessible. | [
"Marks",
"the",
"bucket",
"as",
"private",
"accessible",
"."
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/Bucket.java#L125-L133 | train |
scireum/s3ninja | src/main/java/ninja/Bucket.java | Bucket.makePublic | public void makePublic() {
if (!getPublicMarkerFile().exists()) {
try {
new FileOutputStream(getPublicMarkerFile()).close();
} catch (IOException e) {
throw Exceptions.handle(Storage.LOG, e);
}
}
publicAccessCache.put(getName(),... | java | public void makePublic() {
if (!getPublicMarkerFile().exists()) {
try {
new FileOutputStream(getPublicMarkerFile()).close();
} catch (IOException e) {
throw Exceptions.handle(Storage.LOG, e);
}
}
publicAccessCache.put(getName(),... | [
"public",
"void",
"makePublic",
"(",
")",
"{",
"if",
"(",
"!",
"getPublicMarkerFile",
"(",
")",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"new",
"FileOutputStream",
"(",
"getPublicMarkerFile",
"(",
")",
")",
".",
"close",
"(",
")",
";",
"}",
"ca... | Marks the bucket as public accessible. | [
"Marks",
"the",
"bucket",
"as",
"public",
"accessible",
"."
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/Bucket.java#L138-L147 | train |
scireum/s3ninja | src/main/java/ninja/Bucket.java | Bucket.getObject | public StoredObject getObject(String id) {
if (id.contains("..") || id.contains("/") || id.contains("\\")) {
throw Exceptions.createHandled()
.withSystemErrorMessage(
"Invalid object name: %s. A object name must not contain '..' '/' or ... | java | public StoredObject getObject(String id) {
if (id.contains("..") || id.contains("/") || id.contains("\\")) {
throw Exceptions.createHandled()
.withSystemErrorMessage(
"Invalid object name: %s. A object name must not contain '..' '/' or ... | [
"public",
"StoredObject",
"getObject",
"(",
"String",
"id",
")",
"{",
"if",
"(",
"id",
".",
"contains",
"(",
"\"..\"",
")",
"||",
"id",
".",
"contains",
"(",
"\"/\"",
")",
"||",
"id",
".",
"contains",
"(",
"\"\\\\\"",
")",
")",
"{",
"throw",
"Excepti... | Returns the child object with the given id.
@param id the name of the requested child object. Must not contain .. / or \
@return the object with the given id, might not exist, but is always non null | [
"Returns",
"the",
"child",
"object",
"with",
"the",
"given",
"id",
"."
] | 445eec55c91780267a7f987818b3fedecae009c5 | https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/Bucket.java#L173-L182 | train |
guardian/kinesis-logback-appender | src/main/java/com/gu/logback/appender/kinesis/BaseKinesisAppender.java | BaseKinesisAppender.start | @Override
public void start() {
if(layout == null) {
initializationFailed = true;
addError("Invalid configuration - No layout for appender: " + name);
return;
}
if(streamName == null) {
initializationFailed = true;
addError("Invalid configuration - streamName cannot be null ... | java | @Override
public void start() {
if(layout == null) {
initializationFailed = true;
addError("Invalid configuration - No layout for appender: " + name);
return;
}
if(streamName == null) {
initializationFailed = true;
addError("Invalid configuration - streamName cannot be null ... | [
"@",
"Override",
"public",
"void",
"start",
"(",
")",
"{",
"if",
"(",
"layout",
"==",
"null",
")",
"{",
"initializationFailed",
"=",
"true",
";",
"addError",
"(",
"\"Invalid configuration - No layout for appender: \"",
"+",
"name",
")",
";",
"return",
";",
"}"... | Configures appender instance and makes it ready for use by the consumers.
It validates mandatory parameters and confirms if the configured stream is
ready for publishing data yet.
Error details are made available through the fallback handler for this
appender
@throws IllegalStateException if we encounter issues confi... | [
"Configures",
"appender",
"instance",
"and",
"makes",
"it",
"ready",
"for",
"use",
"by",
"the",
"consumers",
".",
"It",
"validates",
"mandatory",
"parameters",
"and",
"confirms",
"if",
"the",
"configured",
"stream",
"is",
"ready",
"for",
"publishing",
"data",
... | 8873da42f5fd68b75894bc9bf52e393d12b46830 | https://github.com/guardian/kinesis-logback-appender/blob/8873da42f5fd68b75894bc9bf52e393d12b46830/src/main/java/com/gu/logback/appender/kinesis/BaseKinesisAppender.java#L68-L109 | train |
guardian/kinesis-logback-appender | src/main/java/com/gu/logback/appender/kinesis/BaseKinesisAppender.java | BaseKinesisAppender.stop | @Override
public void stop() {
threadPoolExecutor.shutdown();
BlockingQueue<Runnable> taskQueue = threadPoolExecutor.getQueue();
int bufferSizeBeforeShutdown = threadPoolExecutor.getQueue().size();
boolean gracefulShutdown = true;
try {
gracefulShutdown = threadPoolExecutor.awaitTermination(... | java | @Override
public void stop() {
threadPoolExecutor.shutdown();
BlockingQueue<Runnable> taskQueue = threadPoolExecutor.getQueue();
int bufferSizeBeforeShutdown = threadPoolExecutor.getQueue().size();
boolean gracefulShutdown = true;
try {
gracefulShutdown = threadPoolExecutor.awaitTermination(... | [
"@",
"Override",
"public",
"void",
"stop",
"(",
")",
"{",
"threadPoolExecutor",
".",
"shutdown",
"(",
")",
";",
"BlockingQueue",
"<",
"Runnable",
">",
"taskQueue",
"=",
"threadPoolExecutor",
".",
"getQueue",
"(",
")",
";",
"int",
"bufferSizeBeforeShutdown",
"=... | Closes this appender instance. Before exiting, the implementation tries to
flush out buffered log events within configured shutdownTimeout seconds. If
that doesn't finish within configured shutdownTimeout, it would drop all
the buffered log events. | [
"Closes",
"this",
"appender",
"instance",
".",
"Before",
"exiting",
"the",
"implementation",
"tries",
"to",
"flush",
"out",
"buffered",
"log",
"events",
"within",
"configured",
"shutdownTimeout",
"seconds",
".",
"If",
"that",
"doesn",
"t",
"finish",
"within",
"c... | 8873da42f5fd68b75894bc9bf52e393d12b46830 | https://github.com/guardian/kinesis-logback-appender/blob/8873da42f5fd68b75894bc9bf52e393d12b46830/src/main/java/com/gu/logback/appender/kinesis/BaseKinesisAppender.java#L117-L140 | train |
guardian/kinesis-logback-appender | src/main/java/com/gu/logback/appender/kinesis/BaseKinesisAppender.java | BaseKinesisAppender.findRegion | private Region findRegion() {
boolean regionProvided = !Validator.isBlank(this.region);
if(!regionProvided) {
// Determine region from where application is running, or fall back to default region
Region currentRegion = Regions.getCurrentRegion();
if(currentRegion != null) {
return curr... | java | private Region findRegion() {
boolean regionProvided = !Validator.isBlank(this.region);
if(!regionProvided) {
// Determine region from where application is running, or fall back to default region
Region currentRegion = Regions.getCurrentRegion();
if(currentRegion != null) {
return curr... | [
"private",
"Region",
"findRegion",
"(",
")",
"{",
"boolean",
"regionProvided",
"=",
"!",
"Validator",
".",
"isBlank",
"(",
"this",
".",
"region",
")",
";",
"if",
"(",
"!",
"regionProvided",
")",
"{",
"// Determine region from where application is running, or fall ba... | Determine region. If not specified tries to determine region from where the
application is running or fall back to the default.
@return Region to configure the client | [
"Determine",
"region",
".",
"If",
"not",
"specified",
"tries",
"to",
"determine",
"region",
"from",
"where",
"the",
"application",
"is",
"running",
"or",
"fall",
"back",
"to",
"the",
"default",
"."
] | 8873da42f5fd68b75894bc9bf52e393d12b46830 | https://github.com/guardian/kinesis-logback-appender/blob/8873da42f5fd68b75894bc9bf52e393d12b46830/src/main/java/com/gu/logback/appender/kinesis/BaseKinesisAppender.java#L195-L206 | train |
guardian/kinesis-logback-appender | src/main/java/com/gu/logback/appender/kinesis/BaseKinesisAppender.java | BaseKinesisAppender.setStreamName | public void setStreamName(String streamName) {
Validator.validate(!Validator.isBlank(streamName), "streamName cannot be blank");
this.streamName = streamName.trim();
} | java | public void setStreamName(String streamName) {
Validator.validate(!Validator.isBlank(streamName), "streamName cannot be blank");
this.streamName = streamName.trim();
} | [
"public",
"void",
"setStreamName",
"(",
"String",
"streamName",
")",
"{",
"Validator",
".",
"validate",
"(",
"!",
"Validator",
".",
"isBlank",
"(",
"streamName",
")",
",",
"\"streamName cannot be blank\"",
")",
";",
"this",
".",
"streamName",
"=",
"streamName",
... | Sets streamName for the kinesis stream to which data is to be published.
@param streamName name of the kinesis stream to which data is to be
published. | [
"Sets",
"streamName",
"for",
"the",
"kinesis",
"stream",
"to",
"which",
"data",
"is",
"to",
"be",
"published",
"."
] | 8873da42f5fd68b75894bc9bf52e393d12b46830 | https://github.com/guardian/kinesis-logback-appender/blob/8873da42f5fd68b75894bc9bf52e393d12b46830/src/main/java/com/gu/logback/appender/kinesis/BaseKinesisAppender.java#L231-L234 | train |
guardian/kinesis-logback-appender | src/main/java/com/gu/logback/appender/kinesis/BaseKinesisAppender.java | BaseKinesisAppender.setEncoding | public void setEncoding(String charset) {
Validator.validate(!Validator.isBlank(charset), "encoding cannot be blank");
this.encoding = charset.trim();
} | java | public void setEncoding(String charset) {
Validator.validate(!Validator.isBlank(charset), "encoding cannot be blank");
this.encoding = charset.trim();
} | [
"public",
"void",
"setEncoding",
"(",
"String",
"charset",
")",
"{",
"Validator",
".",
"validate",
"(",
"!",
"Validator",
".",
"isBlank",
"(",
"charset",
")",
",",
"\"encoding cannot be blank\"",
")",
";",
"this",
".",
"encoding",
"=",
"charset",
".",
"trim"... | Sets encoding for the data to be published. If none specified, default is
UTF-8
@param charset encoding for expected log messages | [
"Sets",
"encoding",
"for",
"the",
"data",
"to",
"be",
"published",
".",
"If",
"none",
"specified",
"default",
"is",
"UTF",
"-",
"8"
] | 8873da42f5fd68b75894bc9bf52e393d12b46830 | https://github.com/guardian/kinesis-logback-appender/blob/8873da42f5fd68b75894bc9bf52e393d12b46830/src/main/java/com/gu/logback/appender/kinesis/BaseKinesisAppender.java#L253-L256 | train |
httl/httl | httl/src/main/java/httl/spi/engines/DefaultEngine.java | DefaultEngine.getProperty | @SuppressWarnings("unchecked")
public <T> T getProperty(String key, Class<T> cls) {
if (properties != null) {
if (cls != null && cls != Object.class && cls != String.class
&& !cls.isInterface() && !cls.isArray()) {
// engine.getProperty("loaders", ClasspathLoa... | java | @SuppressWarnings("unchecked")
public <T> T getProperty(String key, Class<T> cls) {
if (properties != null) {
if (cls != null && cls != Object.class && cls != String.class
&& !cls.isInterface() && !cls.isArray()) {
// engine.getProperty("loaders", ClasspathLoa... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"getProperty",
"(",
"String",
"key",
",",
"Class",
"<",
"T",
">",
"cls",
")",
"{",
"if",
"(",
"properties",
"!=",
"null",
")",
"{",
"if",
"(",
"cls",
"!=",
"null",
"&... | Get config instantiated value.
@param key - config key
@param cls - config value type
@return config value
@see #getEngine() | [
"Get",
"config",
"instantiated",
"value",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/engines/DefaultEngine.java#L120-L137 | train |
httl/httl | httl/src/main/java/httl/spi/engines/DefaultEngine.java | DefaultEngine.createContext | public Map<String, Object> createContext(final Map<String, Object> parent, Map<String, Object> current) {
return new DelegateMap<String, Object>(parent, current) {
private static final long serialVersionUID = 1L;
@Override
public Object get(Object key) {
Obje... | java | public Map<String, Object> createContext(final Map<String, Object> parent, Map<String, Object> current) {
return new DelegateMap<String, Object>(parent, current) {
private static final long serialVersionUID = 1L;
@Override
public Object get(Object key) {
Obje... | [
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"createContext",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"parent",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"current",
")",
"{",
"return",
"new",
"DelegateMap",
"<",
"String",
",... | Create context map.
@return context map | [
"Create",
"context",
"map",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/engines/DefaultEngine.java#L144-L158 | train |
httl/httl | httl/src/main/java/httl/spi/engines/DefaultEngine.java | DefaultEngine.parseTemplate | public Template parseTemplate(String source, Object parameterTypes) throws ParseException {
String name = "/$" + Digest.getMD5(source);
if (!hasResource(name)) {
stringLoader.add(name, source);
}
try {
return getTemplate(name, parameterTypes);
} catch (IOE... | java | public Template parseTemplate(String source, Object parameterTypes) throws ParseException {
String name = "/$" + Digest.getMD5(source);
if (!hasResource(name)) {
stringLoader.add(name, source);
}
try {
return getTemplate(name, parameterTypes);
} catch (IOE... | [
"public",
"Template",
"parseTemplate",
"(",
"String",
"source",
",",
"Object",
"parameterTypes",
")",
"throws",
"ParseException",
"{",
"String",
"name",
"=",
"\"/$\"",
"+",
"Digest",
".",
"getMD5",
"(",
"source",
")",
";",
"if",
"(",
"!",
"hasResource",
"(",... | Parse string template.
@param source - template source
@return template instance
@throws IOException - If an I/O error occurs
@throws ParseException - If the template cannot be parsed
@see #getEngine() | [
"Parse",
"string",
"template",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/engines/DefaultEngine.java#L278-L288 | train |
httl/httl | httl/src/main/java/httl/spi/engines/DefaultEngine.java | DefaultEngine.getResource | public Resource getResource(String name, Locale locale, String encoding) throws IOException {
name = UrlUtils.cleanName(name);
locale = cleanLocale(locale);
return loadResource(name, locale, encoding);
} | java | public Resource getResource(String name, Locale locale, String encoding) throws IOException {
name = UrlUtils.cleanName(name);
locale = cleanLocale(locale);
return loadResource(name, locale, encoding);
} | [
"public",
"Resource",
"getResource",
"(",
"String",
"name",
",",
"Locale",
"locale",
",",
"String",
"encoding",
")",
"throws",
"IOException",
"{",
"name",
"=",
"UrlUtils",
".",
"cleanName",
"(",
"name",
")",
";",
"locale",
"=",
"cleanLocale",
"(",
"locale",
... | Get resource.
@param name - resource name
@param locale - resource locale
@param encoding - resource encoding
@return resource instance
@throws IOException - If an I/O error occurs
@see #getEngine() | [
"Get",
"resource",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/engines/DefaultEngine.java#L300-L304 | train |
httl/httl | httl/src/main/java/httl/spi/engines/DefaultEngine.java | DefaultEngine.hasResource | public boolean hasResource(String name, Locale locale) {
name = UrlUtils.cleanName(name);
locale = cleanLocale(locale);
return stringLoader.exists(name, locale) || loader.exists(name, locale);
} | java | public boolean hasResource(String name, Locale locale) {
name = UrlUtils.cleanName(name);
locale = cleanLocale(locale);
return stringLoader.exists(name, locale) || loader.exists(name, locale);
} | [
"public",
"boolean",
"hasResource",
"(",
"String",
"name",
",",
"Locale",
"locale",
")",
"{",
"name",
"=",
"UrlUtils",
".",
"cleanName",
"(",
"name",
")",
";",
"locale",
"=",
"cleanLocale",
"(",
"locale",
")",
";",
"return",
"stringLoader",
".",
"exists",
... | Tests whether the resource denoted by this abstract pathname exists.
@param name - template name
@param locale - resource locale
@return exists
@see #getEngine() | [
"Tests",
"whether",
"the",
"resource",
"denoted",
"by",
"this",
"abstract",
"pathname",
"exists",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/engines/DefaultEngine.java#L328-L332 | train |
httl/httl | httl/src/main/java/httl/spi/engines/DefaultEngine.java | DefaultEngine.init | public void init() {
if (logger != null && StringUtils.isNotEmpty(name)) {
if (logger.isWarnEnabled() && !ConfigUtils.isFilePath(name)) {
try {
List<String> realPaths = new ArrayList<String>();
Enumeration<URL> e = Thread.currentThread().getCon... | java | public void init() {
if (logger != null && StringUtils.isNotEmpty(name)) {
if (logger.isWarnEnabled() && !ConfigUtils.isFilePath(name)) {
try {
List<String> realPaths = new ArrayList<String>();
Enumeration<URL> e = Thread.currentThread().getCon... | [
"public",
"void",
"init",
"(",
")",
"{",
"if",
"(",
"logger",
"!=",
"null",
"&&",
"StringUtils",
".",
"isNotEmpty",
"(",
"name",
")",
")",
"{",
"if",
"(",
"logger",
".",
"isWarnEnabled",
"(",
")",
"&&",
"!",
"ConfigUtils",
".",
"isFilePath",
"(",
"na... | Init the engine. | [
"Init",
"the",
"engine",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/engines/DefaultEngine.java#L344-L368 | train |
httl/httl | httl/src/main/java/httl/spi/engines/DefaultEngine.java | DefaultEngine.inited | public void inited() {
if (preload) {
try {
int count = 0;
if (templateSuffix == null) {
templateSuffix = new String[]{".httl"};
}
for (String suffix : templateSuffix) {
List<String> list = loader... | java | public void inited() {
if (preload) {
try {
int count = 0;
if (templateSuffix == null) {
templateSuffix = new String[]{".httl"};
}
for (String suffix : templateSuffix) {
List<String> list = loader... | [
"public",
"void",
"inited",
"(",
")",
"{",
"if",
"(",
"preload",
")",
"{",
"try",
"{",
"int",
"count",
"=",
"0",
";",
"if",
"(",
"templateSuffix",
"==",
"null",
")",
"{",
"templateSuffix",
"=",
"new",
"String",
"[",
"]",
"{",
"\".httl\"",
"}",
";",... | On all inited. | [
"On",
"all",
"inited",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/engines/DefaultEngine.java#L373-L408 | train |
httl/httl | httl/src/main/java/httl/spi/codecs/json/JSONWriter.java | JSONWriter.objectBegin | public JSONWriter objectBegin() throws IOException {
beforeValue();
writer.write(JSON.LBRACE);
stack.push(state);
state = new State(OBJECT);
return this;
} | java | public JSONWriter objectBegin() throws IOException {
beforeValue();
writer.write(JSON.LBRACE);
stack.push(state);
state = new State(OBJECT);
return this;
} | [
"public",
"JSONWriter",
"objectBegin",
"(",
")",
"throws",
"IOException",
"{",
"beforeValue",
"(",
")",
";",
"writer",
".",
"write",
"(",
"JSON",
".",
"LBRACE",
")",
";",
"stack",
".",
"push",
"(",
"state",
")",
";",
"state",
"=",
"new",
"State",
"(",
... | object begin.
@return this.
@throws IOException. | [
"object",
"begin",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/codecs/json/JSONWriter.java#L96-L103 | train |
httl/httl | httl/src/main/java/httl/spi/codecs/json/JSONWriter.java | JSONWriter.objectEnd | public JSONWriter objectEnd() throws IOException {
writer.write(JSON.RBRACE);
state = stack.pop();
return this;
} | java | public JSONWriter objectEnd() throws IOException {
writer.write(JSON.RBRACE);
state = stack.pop();
return this;
} | [
"public",
"JSONWriter",
"objectEnd",
"(",
")",
"throws",
"IOException",
"{",
"writer",
".",
"write",
"(",
"JSON",
".",
"RBRACE",
")",
";",
"state",
"=",
"stack",
".",
"pop",
"(",
")",
";",
"return",
"this",
";",
"}"
] | object end.
@return this.
@throws IOException. | [
"object",
"end",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/codecs/json/JSONWriter.java#L111-L115 | train |
httl/httl | httl/src/main/java/httl/spi/codecs/json/JSONWriter.java | JSONWriter.objectItem | public JSONWriter objectItem(String name) throws IOException {
beforeObjectItem();
writer.write(JSON.QUOTE);
writer.write(escape(name));
writer.write(JSON.QUOTE);
writer.write(JSON.COLON);
return this;
} | java | public JSONWriter objectItem(String name) throws IOException {
beforeObjectItem();
writer.write(JSON.QUOTE);
writer.write(escape(name));
writer.write(JSON.QUOTE);
writer.write(JSON.COLON);
return this;
} | [
"public",
"JSONWriter",
"objectItem",
"(",
"String",
"name",
")",
"throws",
"IOException",
"{",
"beforeObjectItem",
"(",
")",
";",
"writer",
".",
"write",
"(",
"JSON",
".",
"QUOTE",
")",
";",
"writer",
".",
"write",
"(",
"escape",
"(",
"name",
")",
")",
... | object item.
@param name name.
@return this.
@throws IOException. | [
"object",
"item",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/codecs/json/JSONWriter.java#L124-L132 | train |
httl/httl | httl/src/main/java/httl/spi/codecs/json/JSONWriter.java | JSONWriter.arrayBegin | public JSONWriter arrayBegin() throws IOException {
beforeValue();
writer.write(JSON.LSQUARE);
stack.push(state);
state = new State(ARRAY);
return this;
} | java | public JSONWriter arrayBegin() throws IOException {
beforeValue();
writer.write(JSON.LSQUARE);
stack.push(state);
state = new State(ARRAY);
return this;
} | [
"public",
"JSONWriter",
"arrayBegin",
"(",
")",
"throws",
"IOException",
"{",
"beforeValue",
"(",
")",
";",
"writer",
".",
"write",
"(",
"JSON",
".",
"LSQUARE",
")",
";",
"stack",
".",
"push",
"(",
"state",
")",
";",
"state",
"=",
"new",
"State",
"(",
... | array begin.
@return this.
@throws IOException. | [
"array",
"begin",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/codecs/json/JSONWriter.java#L140-L147 | train |
httl/httl | httl/src/main/java/httl/spi/codecs/json/JSONWriter.java | JSONWriter.arrayEnd | public JSONWriter arrayEnd() throws IOException {
writer.write(JSON.RSQUARE);
state = stack.pop();
return this;
} | java | public JSONWriter arrayEnd() throws IOException {
writer.write(JSON.RSQUARE);
state = stack.pop();
return this;
} | [
"public",
"JSONWriter",
"arrayEnd",
"(",
")",
"throws",
"IOException",
"{",
"writer",
".",
"write",
"(",
"JSON",
".",
"RSQUARE",
")",
";",
"state",
"=",
"stack",
".",
"pop",
"(",
")",
";",
"return",
"this",
";",
"}"
] | array end, return array value.
@return this.
@throws IOException. | [
"array",
"end",
"return",
"array",
"value",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/codecs/json/JSONWriter.java#L155-L159 | train |
httl/httl | httl/src/main/java/httl/spi/formatters/MultiFormatter.java | MultiFormatter.add | public MultiFormatter add(Formatter<?>... formatters) {
if (formatter != null) {
MultiFormatter copy = new MultiFormatter();
copy.formatters.putAll(this.formatters);
copy.setFormatters(formatters);
return copy;
}
return this;
} | java | public MultiFormatter add(Formatter<?>... formatters) {
if (formatter != null) {
MultiFormatter copy = new MultiFormatter();
copy.formatters.putAll(this.formatters);
copy.setFormatters(formatters);
return copy;
}
return this;
} | [
"public",
"MultiFormatter",
"add",
"(",
"Formatter",
"<",
"?",
">",
"...",
"formatters",
")",
"{",
"if",
"(",
"formatter",
"!=",
"null",
")",
"{",
"MultiFormatter",
"copy",
"=",
"new",
"MultiFormatter",
"(",
")",
";",
"copy",
".",
"formatters",
".",
"put... | Add and copy the MultiFormatter.
@param formatters | [
"Add",
"and",
"copy",
"the",
"MultiFormatter",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/formatters/MultiFormatter.java#L157-L165 | train |
httl/httl | httl/src/main/java/httl/spi/formatters/MultiFormatter.java | MultiFormatter.remove | public MultiFormatter remove(Formatter<?>... formatters) {
if (formatter != null) {
MultiFormatter copy = new MultiFormatter();
copy.formatters.putAll(this.formatters);
if (formatters != null && formatters.length > 0) {
for (Formatter<?> formatter : formatters... | java | public MultiFormatter remove(Formatter<?>... formatters) {
if (formatter != null) {
MultiFormatter copy = new MultiFormatter();
copy.formatters.putAll(this.formatters);
if (formatters != null && formatters.length > 0) {
for (Formatter<?> formatter : formatters... | [
"public",
"MultiFormatter",
"remove",
"(",
"Formatter",
"<",
"?",
">",
"...",
"formatters",
")",
"{",
"if",
"(",
"formatter",
"!=",
"null",
")",
"{",
"MultiFormatter",
"copy",
"=",
"new",
"MultiFormatter",
"(",
")",
";",
"copy",
".",
"formatters",
".",
"... | Remove and copy the MultiFormatter.
@param formatters | [
"Remove",
"and",
"copy",
"the",
"MultiFormatter",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/formatters/MultiFormatter.java#L172-L189 | train |
httl/httl | httl/src/main/java/httl/util/ConfigUtils.java | ConfigUtils.loadProperties | public static Properties loadProperties(String path, boolean required) {
Properties properties = new Properties();
return loadProperties(properties, path, required);
} | java | public static Properties loadProperties(String path, boolean required) {
Properties properties = new Properties();
return loadProperties(properties, path, required);
} | [
"public",
"static",
"Properties",
"loadProperties",
"(",
"String",
"path",
",",
"boolean",
"required",
")",
"{",
"Properties",
"properties",
"=",
"new",
"Properties",
"(",
")",
";",
"return",
"loadProperties",
"(",
"properties",
",",
"path",
",",
"required",
"... | Load properties file
@param path - File path
@return Properties map | [
"Load",
"properties",
"file"
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/util/ConfigUtils.java#L61-L64 | train |
httl/httl | httl/src/main/java/httl/spi/codecs/json/JSON.java | JSON.json | public static String json(Object obj, boolean writeClass,
Converter<Object, Map<String, Object>> mc) throws IOException {
if (obj == null)
return NULL;
StringWriter sw = new StringWriter();
try {
json(obj, sw, writeClass, mc);
ret... | java | public static String json(Object obj, boolean writeClass,
Converter<Object, Map<String, Object>> mc) throws IOException {
if (obj == null)
return NULL;
StringWriter sw = new StringWriter();
try {
json(obj, sw, writeClass, mc);
ret... | [
"public",
"static",
"String",
"json",
"(",
"Object",
"obj",
",",
"boolean",
"writeClass",
",",
"Converter",
"<",
"Object",
",",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"mc",
")",
"throws",
"IOException",
"{",
"if",
"(",
"obj",
"==",
"null",
")",... | json string.
@param obj object.
@return json string.
@throws IOException. | [
"json",
"string",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/codecs/json/JSON.java#L54-L65 | train |
httl/httl | httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.tryToDrainBuffers | void tryToDrainBuffers() {
if (evictionLock.tryLock()) {
try {
drainStatus.set(PROCESSING);
drainBuffers();
} finally {
drainStatus.compareAndSet(PROCESSING, IDLE);
evictionLock.unlock();
}
}
} | java | void tryToDrainBuffers() {
if (evictionLock.tryLock()) {
try {
drainStatus.set(PROCESSING);
drainBuffers();
} finally {
drainStatus.compareAndSet(PROCESSING, IDLE);
evictionLock.unlock();
}
}
} | [
"void",
"tryToDrainBuffers",
"(",
")",
"{",
"if",
"(",
"evictionLock",
".",
"tryLock",
"(",
")",
")",
"{",
"try",
"{",
"drainStatus",
".",
"set",
"(",
"PROCESSING",
")",
";",
"drainBuffers",
"(",
")",
";",
"}",
"finally",
"{",
"drainStatus",
".",
"comp... | Attempts to acquire the eviction lock and apply the pending operations,
up to the amortized threshold, to the page replacement policy. | [
"Attempts",
"to",
"acquire",
"the",
"eviction",
"lock",
"and",
"apply",
"the",
"pending",
"operations",
"up",
"to",
"the",
"amortized",
"threshold",
"to",
"the",
"page",
"replacement",
"policy",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java#L412-L422 | train |
httl/httl | httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.drainBuffers | void drainBuffers() {
// A mostly strict ordering is achieved by observing that each buffer
// contains tasks in a weakly sorted order starting from the last drain.
// The buffers can be merged into a sorted array in O(n) time by using
// counting sort and chaining on a collision.
... | java | void drainBuffers() {
// A mostly strict ordering is achieved by observing that each buffer
// contains tasks in a weakly sorted order starting from the last drain.
// The buffers can be merged into a sorted array in O(n) time by using
// counting sort and chaining on a collision.
... | [
"void",
"drainBuffers",
"(",
")",
"{",
"// A mostly strict ordering is achieved by observing that each buffer",
"// contains tasks in a weakly sorted order starting from the last drain.",
"// The buffers can be merged into a sorted array in O(n) time by using",
"// counting sort and chaining on a co... | Drains the buffers up to the amortized threshold and applies the pending
operations. | [
"Drains",
"the",
"buffers",
"up",
"to",
"the",
"amortized",
"threshold",
"and",
"applies",
"the",
"pending",
"operations",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java#L428-L439 | train |
httl/httl | httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.moveTasksFromBuffers | int moveTasksFromBuffers(Task[] tasks) {
int maxTaskIndex = -1;
for (int i = 0; i < buffers.length; i++) {
int maxIndex = moveTasksFromBuffer(tasks, i);
maxTaskIndex = Math.max(maxIndex, maxTaskIndex);
}
return maxTaskIndex;
} | java | int moveTasksFromBuffers(Task[] tasks) {
int maxTaskIndex = -1;
for (int i = 0; i < buffers.length; i++) {
int maxIndex = moveTasksFromBuffer(tasks, i);
maxTaskIndex = Math.max(maxIndex, maxTaskIndex);
}
return maxTaskIndex;
} | [
"int",
"moveTasksFromBuffers",
"(",
"Task",
"[",
"]",
"tasks",
")",
"{",
"int",
"maxTaskIndex",
"=",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"buffers",
".",
"length",
";",
"i",
"++",
")",
"{",
"int",
"maxIndex",
"=",
"move... | Moves the tasks from the buffers into the output array.
@param tasks the ordered array of the pending operations
@return the highest index location of a task that was added to the array | [
"Moves",
"the",
"tasks",
"from",
"the",
"buffers",
"into",
"the",
"output",
"array",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java#L447-L454 | train |
httl/httl | httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.moveTasksFromBuffer | int moveTasksFromBuffer(Task[] tasks, int bufferIndex) {
// While a buffer is being drained it may be concurrently appended to.
// The
// number of tasks removed are tracked so that the length can be
// decremented
// by the delta rather than set to zero.
Queue<Task> buff... | java | int moveTasksFromBuffer(Task[] tasks, int bufferIndex) {
// While a buffer is being drained it may be concurrently appended to.
// The
// number of tasks removed are tracked so that the length can be
// decremented
// by the delta rather than set to zero.
Queue<Task> buff... | [
"int",
"moveTasksFromBuffer",
"(",
"Task",
"[",
"]",
"tasks",
",",
"int",
"bufferIndex",
")",
"{",
"// While a buffer is being drained it may be concurrently appended to.",
"// The",
"// number of tasks removed are tracked so that the length can be",
"// decremented",
"// by the delt... | Moves the tasks from the specified buffer into the output array.
@param tasks the ordered array of the pending operations
@param bufferIndex the buffer to drain into the tasks array
@return the highest index location of a task that was added to the array | [
"Moves",
"the",
"tasks",
"from",
"the",
"specified",
"buffer",
"into",
"the",
"output",
"array",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java#L463-L502 | train |
httl/httl | httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.addTaskToChain | void addTaskToChain(Task[] tasks, Task task, int index) {
task.setNext(tasks[index]);
tasks[index] = task;
} | java | void addTaskToChain(Task[] tasks, Task task, int index) {
task.setNext(tasks[index]);
tasks[index] = task;
} | [
"void",
"addTaskToChain",
"(",
"Task",
"[",
"]",
"tasks",
",",
"Task",
"task",
",",
"int",
"index",
")",
"{",
"task",
".",
"setNext",
"(",
"tasks",
"[",
"index",
"]",
")",
";",
"tasks",
"[",
"index",
"]",
"=",
"task",
";",
"}"
] | Adds the task as the head of the chain at the index location.
@param tasks the ordered array of the pending operations
@param task the pending operation to add
@param index the array location | [
"Adds",
"the",
"task",
"as",
"the",
"head",
"of",
"the",
"chain",
"at",
"the",
"index",
"location",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java#L511-L514 | train |
httl/httl | httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.updateDrainedOrder | void updateDrainedOrder(Task[] tasks, int maxTaskIndex) {
if (maxTaskIndex >= 0) {
Task task = tasks[maxTaskIndex];
drainedOrder = task.getOrder() + 1;
}
} | java | void updateDrainedOrder(Task[] tasks, int maxTaskIndex) {
if (maxTaskIndex >= 0) {
Task task = tasks[maxTaskIndex];
drainedOrder = task.getOrder() + 1;
}
} | [
"void",
"updateDrainedOrder",
"(",
"Task",
"[",
"]",
"tasks",
",",
"int",
"maxTaskIndex",
")",
"{",
"if",
"(",
"maxTaskIndex",
">=",
"0",
")",
"{",
"Task",
"task",
"=",
"tasks",
"[",
"maxTaskIndex",
"]",
";",
"drainedOrder",
"=",
"task",
".",
"getOrder",... | Updates the order to start the next drain from.
@param tasks the ordered array of operations
@param maxTaskIndex the maximum index of the array | [
"Updates",
"the",
"order",
"to",
"start",
"the",
"next",
"drain",
"from",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java#L549-L554 | train |
httl/httl | httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.put | V put(K key, V value, boolean onlyIfAbsent) {
checkNotNull(key);
checkNotNull(value);
final int weight = weigher.weightOf(key, value);
final WeightedValue<V> weightedValue = new WeightedValue<V>(value,
weight);
final Node node = new Node(key, weightedValue);
... | java | V put(K key, V value, boolean onlyIfAbsent) {
checkNotNull(key);
checkNotNull(value);
final int weight = weigher.weightOf(key, value);
final WeightedValue<V> weightedValue = new WeightedValue<V>(value,
weight);
final Node node = new Node(key, weightedValue);
... | [
"V",
"put",
"(",
"K",
"key",
",",
"V",
"value",
",",
"boolean",
"onlyIfAbsent",
")",
"{",
"checkNotNull",
"(",
"key",
")",
";",
"checkNotNull",
"(",
"value",
")",
";",
"final",
"int",
"weight",
"=",
"weigher",
".",
"weightOf",
"(",
"key",
",",
"value... | Adds a node to the list and the data store. If an existing node is found,
then its value is updated if allowed.
@param key key with which the specified value is to be associated
@param value value to be associated with the specified key
@param onlyIfAbsent a write is performed only if the key is not al... | [
"Adds",
"a",
"node",
"to",
"the",
"list",
"and",
"the",
"data",
"store",
".",
"If",
"an",
"existing",
"node",
"is",
"found",
"then",
"its",
"value",
"is",
"updated",
"if",
"allowed",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java#L673-L707 | train |
httl/httl | httl/src/main/java/httl/Engine.java | Engine.getEngine | public static Engine getEngine(String configPath, Properties configProperties) {
if (StringUtils.isEmpty(configPath)) {
configPath = HTTL_PROPERTIES;
}
VolatileReference<Engine> reference = ENGINES.get(configPath);
if (reference == null) {
reference = new Volatile... | java | public static Engine getEngine(String configPath, Properties configProperties) {
if (StringUtils.isEmpty(configPath)) {
configPath = HTTL_PROPERTIES;
}
VolatileReference<Engine> reference = ENGINES.get(configPath);
if (reference == null) {
reference = new Volatile... | [
"public",
"static",
"Engine",
"getEngine",
"(",
"String",
"configPath",
",",
"Properties",
"configProperties",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"configPath",
")",
")",
"{",
"configPath",
"=",
"HTTL_PROPERTIES",
";",
"}",
"VolatileReferenc... | Get template engine singleton.
@param configPath - config path
@param configProperties - config properties
@return template engine | [
"Get",
"template",
"engine",
"singleton",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Engine.java#L105-L130 | train |
httl/httl | httl/src/main/java/httl/Engine.java | Engine.getProperty | public String getProperty(String key, String defaultValue) {
String value = getProperty(key, String.class);
return StringUtils.isEmpty(value) ? defaultValue : value;
} | java | public String getProperty(String key, String defaultValue) {
String value = getProperty(key, String.class);
return StringUtils.isEmpty(value) ? defaultValue : value;
} | [
"public",
"String",
"getProperty",
"(",
"String",
"key",
",",
"String",
"defaultValue",
")",
"{",
"String",
"value",
"=",
"getProperty",
"(",
"key",
",",
"String",
".",
"class",
")",
";",
"return",
"StringUtils",
".",
"isEmpty",
"(",
"value",
")",
"?",
"... | Get config value.
@param key - config key
@param defaultValue - default value
@return config value
@see #getEngine() | [
"Get",
"config",
"value",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Engine.java#L194-L197 | train |
httl/httl | httl/src/main/java/httl/Engine.java | Engine.getProperty | public int getProperty(String key, int defaultValue) {
String value = getProperty(key, String.class);
return StringUtils.isEmpty(value) ? defaultValue : Integer.parseInt(value);
} | java | public int getProperty(String key, int defaultValue) {
String value = getProperty(key, String.class);
return StringUtils.isEmpty(value) ? defaultValue : Integer.parseInt(value);
} | [
"public",
"int",
"getProperty",
"(",
"String",
"key",
",",
"int",
"defaultValue",
")",
"{",
"String",
"value",
"=",
"getProperty",
"(",
"key",
",",
"String",
".",
"class",
")",
";",
"return",
"StringUtils",
".",
"isEmpty",
"(",
"value",
")",
"?",
"defaul... | Get config int value.
@param key - config key
@param defaultValue - default int value
@return config int value
@see #getEngine() | [
"Get",
"config",
"int",
"value",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Engine.java#L220-L223 | train |
httl/httl | httl/src/main/java/httl/Engine.java | Engine.getProperty | public boolean getProperty(String key, boolean defaultValue) {
String value = getProperty(key, String.class);
return StringUtils.isEmpty(value) ? defaultValue : Boolean.parseBoolean(value);
} | java | public boolean getProperty(String key, boolean defaultValue) {
String value = getProperty(key, String.class);
return StringUtils.isEmpty(value) ? defaultValue : Boolean.parseBoolean(value);
} | [
"public",
"boolean",
"getProperty",
"(",
"String",
"key",
",",
"boolean",
"defaultValue",
")",
"{",
"String",
"value",
"=",
"getProperty",
"(",
"key",
",",
"String",
".",
"class",
")",
";",
"return",
"StringUtils",
".",
"isEmpty",
"(",
"value",
")",
"?",
... | Get config boolean value.
@param key - config key
@param defaultValue - default boolean value
@return config boolean value
@see #getEngine() | [
"Get",
"config",
"boolean",
"value",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Engine.java#L233-L236 | train |
httl/httl | httl/src/main/java/httl/util/WriterOutputStream.java | WriterOutputStream.processInput | private void processInput(boolean endOfInput) throws IOException {
// Prepare decoderIn for reading
decoderIn.flip();
CoderResult coderResult;
while (true) {
coderResult = decoder.decode(decoderIn, decoderOut, endOfInput);
if (coderResult.isOverflow()) {
... | java | private void processInput(boolean endOfInput) throws IOException {
// Prepare decoderIn for reading
decoderIn.flip();
CoderResult coderResult;
while (true) {
coderResult = decoder.decode(decoderIn, decoderOut, endOfInput);
if (coderResult.isOverflow()) {
... | [
"private",
"void",
"processInput",
"(",
"boolean",
"endOfInput",
")",
"throws",
"IOException",
"{",
"// Prepare decoderIn for reading",
"decoderIn",
".",
"flip",
"(",
")",
";",
"CoderResult",
"coderResult",
";",
"while",
"(",
"true",
")",
"{",
"coderResult",
"=",
... | Decode the contents of the input ByteBuffer into a CharBuffer.
@param endOfInput indicates end of input
@throws IOException if an I/O error occurs | [
"Decode",
"the",
"contents",
"of",
"the",
"input",
"ByteBuffer",
"into",
"a",
"CharBuffer",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/util/WriterOutputStream.java#L274-L292 | train |
httl/httl | httl/src/main/java/httl/util/WriterOutputStream.java | WriterOutputStream.flushOutput | private void flushOutput() throws IOException {
if (decoderOut.position() > 0) {
writer.write(decoderOut.array(), 0, decoderOut.position());
decoderOut.rewind();
}
} | java | private void flushOutput() throws IOException {
if (decoderOut.position() > 0) {
writer.write(decoderOut.array(), 0, decoderOut.position());
decoderOut.rewind();
}
} | [
"private",
"void",
"flushOutput",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"decoderOut",
".",
"position",
"(",
")",
">",
"0",
")",
"{",
"writer",
".",
"write",
"(",
"decoderOut",
".",
"array",
"(",
")",
",",
"0",
",",
"decoderOut",
".",
"po... | Flush the output.
@throws IOException if an I/O error occurs | [
"Flush",
"the",
"output",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/util/WriterOutputStream.java#L299-L304 | train |
httl/httl | httl/src/main/java/httl/Context.java | Context.getContext | public static Context getContext() {
Context context = LOCAL.get();
if (context == null) {
context = new Context(null, null);
LOCAL.set(context);
}
return context;
} | java | public static Context getContext() {
Context context = LOCAL.get();
if (context == null) {
context = new Context(null, null);
LOCAL.set(context);
}
return context;
} | [
"public",
"static",
"Context",
"getContext",
"(",
")",
"{",
"Context",
"context",
"=",
"LOCAL",
".",
"get",
"(",
")",
";",
"if",
"(",
"context",
"==",
"null",
")",
"{",
"context",
"=",
"new",
"Context",
"(",
"null",
",",
"null",
")",
";",
"LOCAL",
... | Get the current context from thread local.
@return current context | [
"Get",
"the",
"current",
"context",
"from",
"thread",
"local",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Context.java#L83-L90 | train |
httl/httl | httl/src/main/java/httl/Context.java | Context.pushContext | public static Context pushContext(Map<String, Object> current) {
Context context = new Context(getContext(), current);
LOCAL.set(context);
return context;
} | java | public static Context pushContext(Map<String, Object> current) {
Context context = new Context(getContext(), current);
LOCAL.set(context);
return context;
} | [
"public",
"static",
"Context",
"pushContext",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"current",
")",
"{",
"Context",
"context",
"=",
"new",
"Context",
"(",
"getContext",
"(",
")",
",",
"current",
")",
";",
"LOCAL",
".",
"set",
"(",
"context",
"... | Push the current context to thread local.
@param current - current variables | [
"Push",
"the",
"current",
"context",
"to",
"thread",
"local",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Context.java#L104-L108 | train |
httl/httl | httl/src/main/java/httl/Context.java | Context.popContext | public static void popContext() {
Context context = LOCAL.get();
if (context != null) {
Context parent = context.getParent();
if (parent != null) {
LOCAL.set(parent);
} else {
LOCAL.remove();
}
}
} | java | public static void popContext() {
Context context = LOCAL.get();
if (context != null) {
Context parent = context.getParent();
if (parent != null) {
LOCAL.set(parent);
} else {
LOCAL.remove();
}
}
} | [
"public",
"static",
"void",
"popContext",
"(",
")",
"{",
"Context",
"context",
"=",
"LOCAL",
".",
"get",
"(",
")",
";",
"if",
"(",
"context",
"!=",
"null",
")",
"{",
"Context",
"parent",
"=",
"context",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"... | Pop the current context from thread local, and restore parent context to thread local. | [
"Pop",
"the",
"current",
"context",
"from",
"thread",
"local",
"and",
"restore",
"parent",
"context",
"to",
"thread",
"local",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Context.java#L113-L123 | train |
httl/httl | httl/src/main/java/httl/Context.java | Context.checkThread | private void checkThread() {
if (Thread.currentThread() != thread) {
throw new IllegalStateException("Don't cross-thread using the "
+ Context.class.getName() + " object, it's thread-local only. context thread: "
+ thread.getName() + ", current thread: " + Thr... | java | private void checkThread() {
if (Thread.currentThread() != thread) {
throw new IllegalStateException("Don't cross-thread using the "
+ Context.class.getName() + " object, it's thread-local only. context thread: "
+ thread.getName() + ", current thread: " + Thr... | [
"private",
"void",
"checkThread",
"(",
")",
"{",
"if",
"(",
"Thread",
".",
"currentThread",
"(",
")",
"!=",
"thread",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Don't cross-thread using the \"",
"+",
"Context",
".",
"class",
".",
"getName",
"("... | Check the cross-thread use. | [
"Check",
"the",
"cross",
"-",
"thread",
"use",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Context.java#L133-L139 | train |
httl/httl | httl/src/main/java/httl/Context.java | Context.setCurrent | private void setCurrent(Map<String, Object> current) {
if (current instanceof Context) {
throw new IllegalArgumentException("Don't using the " + Context.class.getName()
+ " object as a parameters, it's implicitly delivery by thread-local. parameter context: "
... | java | private void setCurrent(Map<String, Object> current) {
if (current instanceof Context) {
throw new IllegalArgumentException("Don't using the " + Context.class.getName()
+ " object as a parameters, it's implicitly delivery by thread-local. parameter context: "
... | [
"private",
"void",
"setCurrent",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"current",
")",
"{",
"if",
"(",
"current",
"instanceof",
"Context",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Don't using the \"",
"+",
"Context",
".",
"class",... | Set the current context | [
"Set",
"the",
"current",
"context"
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Context.java#L142-L149 | train |
httl/httl | httl/src/main/java/httl/Context.java | Context.setTemplate | public Context setTemplate(Template template) {
checkThread();
if (template != null) {
setEngine(template.getEngine());
}
this.template = template;
return this;
} | java | public Context setTemplate(Template template) {
checkThread();
if (template != null) {
setEngine(template.getEngine());
}
this.template = template;
return this;
} | [
"public",
"Context",
"setTemplate",
"(",
"Template",
"template",
")",
"{",
"checkThread",
"(",
")",
";",
"if",
"(",
"template",
"!=",
"null",
")",
"{",
"setEngine",
"(",
"template",
".",
"getEngine",
"(",
")",
")",
";",
"}",
"this",
".",
"template",
"=... | Set the current template.
@param template - current template | [
"Set",
"the",
"current",
"template",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Context.java#L189-L196 | train |
httl/httl | httl/src/main/java/httl/Context.java | Context.setEngine | public Context setEngine(Engine engine) {
checkThread();
if (engine != null) {
if (template != null && template.getEngine() != engine) {
throw new IllegalStateException("Failed to set the context engine, because is not the same to template engine. template engine: "
... | java | public Context setEngine(Engine engine) {
checkThread();
if (engine != null) {
if (template != null && template.getEngine() != engine) {
throw new IllegalStateException("Failed to set the context engine, because is not the same to template engine. template engine: "
... | [
"public",
"Context",
"setEngine",
"(",
"Engine",
"engine",
")",
"{",
"checkThread",
"(",
")",
";",
"if",
"(",
"engine",
"!=",
"null",
")",
"{",
"if",
"(",
"template",
"!=",
"null",
"&&",
"template",
".",
"getEngine",
"(",
")",
"!=",
"engine",
")",
"{... | Set the current engine.
@param engine - current engine | [
"Set",
"the",
"current",
"engine",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Context.java#L214-L231 | train |
httl/httl | httl/src/main/java/httl/Context.java | Context.get | public Object get(String key, Object defaultValue) {
Object value = get(key);
return value == null ? defaultValue : value;
} | java | public Object get(String key, Object defaultValue) {
Object value = get(key);
return value == null ? defaultValue : value;
} | [
"public",
"Object",
"get",
"(",
"String",
"key",
",",
"Object",
"defaultValue",
")",
"{",
"Object",
"value",
"=",
"get",
"(",
"key",
")",
";",
"return",
"value",
"==",
"null",
"?",
"defaultValue",
":",
"value",
";",
"}"
] | Get the variable value.
@param key - variable key
@param defaultValue - default value
@return variable value
@see #getContext() | [
"Get",
"the",
"variable",
"value",
"."
] | e13e00f4ab41252a8f53d6dafd4a6610be9dcaad | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Context.java#L274-L277 | train |
kobakei/Android-RateThisApp | ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java | RateThisApp.showRateDialogIfNeeded | public static boolean showRateDialogIfNeeded(final Context context, int themeId) {
if (shouldShowRateDialog()) {
showRateDialog(context, themeId);
return true;
} else {
return false;
}
} | java | public static boolean showRateDialogIfNeeded(final Context context, int themeId) {
if (shouldShowRateDialog()) {
showRateDialog(context, themeId);
return true;
} else {
return false;
}
} | [
"public",
"static",
"boolean",
"showRateDialogIfNeeded",
"(",
"final",
"Context",
"context",
",",
"int",
"themeId",
")",
"{",
"if",
"(",
"shouldShowRateDialog",
"(",
")",
")",
"{",
"showRateDialog",
"(",
"context",
",",
"themeId",
")",
";",
"return",
"true",
... | Show the rate dialog if the criteria is satisfied.
@param context Context
@param themeId Theme ID
@return true if shown, false otherwise. | [
"Show",
"the",
"rate",
"dialog",
"if",
"the",
"criteria",
"is",
"satisfied",
"."
] | c3d007c8c02beb6ff196745c2310c259737f5c81 | https://github.com/kobakei/Android-RateThisApp/blob/c3d007c8c02beb6ff196745c2310c259737f5c81/ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java#L145-L152 | train |
kobakei/Android-RateThisApp | ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java | RateThisApp.shouldShowRateDialog | public static boolean shouldShowRateDialog() {
if (mOptOut) {
return false;
} else {
if (mLaunchTimes >= sConfig.mCriteriaLaunchTimes) {
return true;
}
long threshold = TimeUnit.DAYS.toMillis(sConfig.mCriteriaInstallDays); // msec
... | java | public static boolean shouldShowRateDialog() {
if (mOptOut) {
return false;
} else {
if (mLaunchTimes >= sConfig.mCriteriaLaunchTimes) {
return true;
}
long threshold = TimeUnit.DAYS.toMillis(sConfig.mCriteriaInstallDays); // msec
... | [
"public",
"static",
"boolean",
"shouldShowRateDialog",
"(",
")",
"{",
"if",
"(",
"mOptOut",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"if",
"(",
"mLaunchTimes",
">=",
"sConfig",
".",
"mCriteriaLaunchTimes",
")",
"{",
"return",
"true",
";",
"}",
... | Check whether the rate dialog should be shown or not.
Developers may call this method directly if they want to show their own view instead of
dialog provided by this library.
@return | [
"Check",
"whether",
"the",
"rate",
"dialog",
"should",
"be",
"shown",
"or",
"not",
".",
"Developers",
"may",
"call",
"this",
"method",
"directly",
"if",
"they",
"want",
"to",
"show",
"their",
"own",
"view",
"instead",
"of",
"dialog",
"provided",
"by",
"thi... | c3d007c8c02beb6ff196745c2310c259737f5c81 | https://github.com/kobakei/Android-RateThisApp/blob/c3d007c8c02beb6ff196745c2310c259737f5c81/ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java#L160-L174 | train |
kobakei/Android-RateThisApp | ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java | RateThisApp.showRateDialog | public static void showRateDialog(final Context context) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
showRateDialog(context, builder);
} | java | public static void showRateDialog(final Context context) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
showRateDialog(context, builder);
} | [
"public",
"static",
"void",
"showRateDialog",
"(",
"final",
"Context",
"context",
")",
"{",
"AlertDialog",
".",
"Builder",
"builder",
"=",
"new",
"AlertDialog",
".",
"Builder",
"(",
"context",
")",
";",
"showRateDialog",
"(",
"context",
",",
"builder",
")",
... | Show the rate dialog
@param context | [
"Show",
"the",
"rate",
"dialog"
] | c3d007c8c02beb6ff196745c2310c259737f5c81 | https://github.com/kobakei/Android-RateThisApp/blob/c3d007c8c02beb6ff196745c2310c259737f5c81/ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java#L180-L183 | train |
kobakei/Android-RateThisApp | ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java | RateThisApp.getLaunchCount | public static int getLaunchCount(final Context context){
SharedPreferences pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
return pref.getInt(KEY_LAUNCH_TIMES, 0);
} | java | public static int getLaunchCount(final Context context){
SharedPreferences pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
return pref.getInt(KEY_LAUNCH_TIMES, 0);
} | [
"public",
"static",
"int",
"getLaunchCount",
"(",
"final",
"Context",
"context",
")",
"{",
"SharedPreferences",
"pref",
"=",
"context",
".",
"getSharedPreferences",
"(",
"PREF_NAME",
",",
"Context",
".",
"MODE_PRIVATE",
")",
";",
"return",
"pref",
".",
"getInt",... | Get count number of the rate dialog launches
@return | [
"Get",
"count",
"number",
"of",
"the",
"rate",
"dialog",
"launches"
] | c3d007c8c02beb6ff196745c2310c259737f5c81 | https://github.com/kobakei/Android-RateThisApp/blob/c3d007c8c02beb6ff196745c2310c259737f5c81/ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java#L207-L210 | train |
kobakei/Android-RateThisApp | ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java | RateThisApp.storeInstallDate | private static void storeInstallDate(final Context context, SharedPreferences.Editor editor) {
Date installDate = new Date();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
PackageManager packMan = context.getPackageManager();
try {
PackageInfo pk... | java | private static void storeInstallDate(final Context context, SharedPreferences.Editor editor) {
Date installDate = new Date();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
PackageManager packMan = context.getPackageManager();
try {
PackageInfo pk... | [
"private",
"static",
"void",
"storeInstallDate",
"(",
"final",
"Context",
"context",
",",
"SharedPreferences",
".",
"Editor",
"editor",
")",
"{",
"Date",
"installDate",
"=",
"new",
"Date",
"(",
")",
";",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
... | Store install date.
Install date is retrieved from package manager if possible.
@param context
@param editor | [
"Store",
"install",
"date",
".",
"Install",
"date",
"is",
"retrieved",
"from",
"package",
"manager",
"if",
"possible",
"."
] | c3d007c8c02beb6ff196745c2310c259737f5c81 | https://github.com/kobakei/Android-RateThisApp/blob/c3d007c8c02beb6ff196745c2310c259737f5c81/ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java#L338-L351 | train |
kobakei/Android-RateThisApp | ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java | RateThisApp.storeAskLaterDate | private static void storeAskLaterDate(final Context context) {
SharedPreferences pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
Editor editor = pref.edit();
editor.putLong(KEY_ASK_LATER_DATE, System.currentTimeMillis());
editor.apply();
} | java | private static void storeAskLaterDate(final Context context) {
SharedPreferences pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
Editor editor = pref.edit();
editor.putLong(KEY_ASK_LATER_DATE, System.currentTimeMillis());
editor.apply();
} | [
"private",
"static",
"void",
"storeAskLaterDate",
"(",
"final",
"Context",
"context",
")",
"{",
"SharedPreferences",
"pref",
"=",
"context",
".",
"getSharedPreferences",
"(",
"PREF_NAME",
",",
"Context",
".",
"MODE_PRIVATE",
")",
";",
"Editor",
"editor",
"=",
"p... | Store the date the user asked for being asked again later.
@param context | [
"Store",
"the",
"date",
"the",
"user",
"asked",
"for",
"being",
"asked",
"again",
"later",
"."
] | c3d007c8c02beb6ff196745c2310c259737f5c81 | https://github.com/kobakei/Android-RateThisApp/blob/c3d007c8c02beb6ff196745c2310c259737f5c81/ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java#L357-L362 | train |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/util/Panes.java | Panes.setContent | public static <T extends Pane> CompletionStage<T> setContent(final T parent, final Node content) {
return FxAsync.doOnFxThread(parent, parentNode -> {
parentNode.getChildren().clear();
parentNode.getChildren().add(content);
});
} | java | public static <T extends Pane> CompletionStage<T> setContent(final T parent, final Node content) {
return FxAsync.doOnFxThread(parent, parentNode -> {
parentNode.getChildren().clear();
parentNode.getChildren().add(content);
});
} | [
"public",
"static",
"<",
"T",
"extends",
"Pane",
">",
"CompletionStage",
"<",
"T",
">",
"setContent",
"(",
"final",
"T",
"parent",
",",
"final",
"Node",
"content",
")",
"{",
"return",
"FxAsync",
".",
"doOnFxThread",
"(",
"parent",
",",
"parentNode",
"->",
... | Sets as the sole content of a pane another Node. This is supposed to work as having a first Pane being the wanted
display zone and the second Node the displayed content.
@param parent The container defining the displayable zone, as a {@link Pane}.
@param content The content to display
@param <T> The subtype if ne... | [
"Sets",
"as",
"the",
"sole",
"content",
"of",
"a",
"pane",
"another",
"Node",
".",
"This",
"is",
"supposed",
"to",
"work",
"as",
"having",
"a",
"first",
"Pane",
"being",
"the",
"wanted",
"display",
"zone",
"and",
"the",
"second",
"Node",
"the",
"displaye... | f82cad1d54e62903ca5e4a250279ad315b028aef | https://github.com/Tristan971/EasyFXML/blob/f82cad1d54e62903ca5e4a250279ad315b028aef/easyfxml/src/main/java/moe/tristan/easyfxml/util/Panes.java#L26-L31 | train |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/model/exception/ExceptionHandler.java | ExceptionHandler.displayExceptionPane | public static CompletionStage<Stage> displayExceptionPane(
final String title,
final String readable,
final Throwable exception
) {
final Pane exceptionPane = new ExceptionHandler(exception).asPane(readable);
final CompletionStage<Stage> exceptionStage = Stages.stageOf(title,... | java | public static CompletionStage<Stage> displayExceptionPane(
final String title,
final String readable,
final Throwable exception
) {
final Pane exceptionPane = new ExceptionHandler(exception).asPane(readable);
final CompletionStage<Stage> exceptionStage = Stages.stageOf(title,... | [
"public",
"static",
"CompletionStage",
"<",
"Stage",
">",
"displayExceptionPane",
"(",
"final",
"String",
"title",
",",
"final",
"String",
"readable",
",",
"final",
"Throwable",
"exception",
")",
"{",
"final",
"Pane",
"exceptionPane",
"=",
"new",
"ExceptionHandler... | Creates a pop-up and displays it based on a given exception, pop-up title and custom error message.
@param title The title of the error pop-up
@param readable The custom label to display on top of the stack trace
@param exception The exception to use
@return a {@link CompletionStage} to know when the pop-up disp... | [
"Creates",
"a",
"pop",
"-",
"up",
"and",
"displays",
"it",
"based",
"on",
"a",
"given",
"exception",
"pop",
"-",
"up",
"title",
"and",
"custom",
"error",
"message",
"."
] | f82cad1d54e62903ca5e4a250279ad315b028aef | https://github.com/Tristan971/EasyFXML/blob/f82cad1d54e62903ca5e4a250279ad315b028aef/easyfxml/src/main/java/moe/tristan/easyfxml/model/exception/ExceptionHandler.java#L76-L84 | train |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/util/Stages.java | Stages.stageOf | public static CompletionStage<Stage> stageOf(final String title, final Pane rootPane) {
return FxAsync.computeOnFxThread(
Tuple.of(title, rootPane),
titleAndPane -> {
final Stage stage = new Stage(StageStyle.DECORATED);
stage.setTitle(title);
... | java | public static CompletionStage<Stage> stageOf(final String title, final Pane rootPane) {
return FxAsync.computeOnFxThread(
Tuple.of(title, rootPane),
titleAndPane -> {
final Stage stage = new Stage(StageStyle.DECORATED);
stage.setTitle(title);
... | [
"public",
"static",
"CompletionStage",
"<",
"Stage",
">",
"stageOf",
"(",
"final",
"String",
"title",
",",
"final",
"Pane",
"rootPane",
")",
"{",
"return",
"FxAsync",
".",
"computeOnFxThread",
"(",
"Tuple",
".",
"of",
"(",
"title",
",",
"rootPane",
")",
",... | Creates a Stage.
@param title The title of the stage
@param rootPane The scene's base
@return A {@link CompletionStage} to have monitoring over the state of the asynchronous creation. It will
eventually contain the newly created stage. | [
"Creates",
"a",
"Stage",
"."
] | f82cad1d54e62903ca5e4a250279ad315b028aef | https://github.com/Tristan971/EasyFXML/blob/f82cad1d54e62903ca5e4a250279ad315b028aef/easyfxml/src/main/java/moe/tristan/easyfxml/util/Stages.java#L36-L46 | train |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/util/Stages.java | Stages.scheduleDisplaying | public static CompletionStage<Stage> scheduleDisplaying(final Stage stage) {
LOG.debug(
"Requested displaying of stage {} with title : \"{}\"",
stage,
stage.getTitle()
);
return FxAsync.doOnFxThread(
stage,
Stage::show
);
} | java | public static CompletionStage<Stage> scheduleDisplaying(final Stage stage) {
LOG.debug(
"Requested displaying of stage {} with title : \"{}\"",
stage,
stage.getTitle()
);
return FxAsync.doOnFxThread(
stage,
Stage::show
);
} | [
"public",
"static",
"CompletionStage",
"<",
"Stage",
">",
"scheduleDisplaying",
"(",
"final",
"Stage",
"stage",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Requested displaying of stage {} with title : \\\"{}\\\"\"",
",",
"stage",
",",
"stage",
".",
"getTitle",
"(",
")",... | Schedules a stage for displaying.
@param stage The stage to schedule displaying of.
@return A {@link CompletionStage} to have monitoring over the state of the asynchronous operation | [
"Schedules",
"a",
"stage",
"for",
"displaying",
"."
] | f82cad1d54e62903ca5e4a250279ad315b028aef | https://github.com/Tristan971/EasyFXML/blob/f82cad1d54e62903ca5e4a250279ad315b028aef/easyfxml/src/main/java/moe/tristan/easyfxml/util/Stages.java#L55-L65 | train |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/util/Stages.java | Stages.scheduleHiding | public static CompletionStage<Stage> scheduleHiding(final Stage stage) {
LOG.debug(
"Requested hiding of stage {} with title : \"{}\"",
stage,
stage.getTitle()
);
return FxAsync.doOnFxThread(
stage,
Stage::hide
);
} | java | public static CompletionStage<Stage> scheduleHiding(final Stage stage) {
LOG.debug(
"Requested hiding of stage {} with title : \"{}\"",
stage,
stage.getTitle()
);
return FxAsync.doOnFxThread(
stage,
Stage::hide
);
} | [
"public",
"static",
"CompletionStage",
"<",
"Stage",
">",
"scheduleHiding",
"(",
"final",
"Stage",
"stage",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Requested hiding of stage {} with title : \\\"{}\\\"\"",
",",
"stage",
",",
"stage",
".",
"getTitle",
"(",
")",
")",
... | Schedules a stage for hiding
@param stage The stage to shcedule hiding of.
@return A {@link CompletionStage} to have monitoring over the state of the asynchronous operation | [
"Schedules",
"a",
"stage",
"for",
"hiding"
] | f82cad1d54e62903ca5e4a250279ad315b028aef | https://github.com/Tristan971/EasyFXML/blob/f82cad1d54e62903ca5e4a250279ad315b028aef/easyfxml/src/main/java/moe/tristan/easyfxml/util/Stages.java#L78-L88 | train |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/util/Stages.java | Stages.setStylesheet | public static CompletionStage<Stage> setStylesheet(final Stage stage, final String stylesheet) {
LOG.info(
"Setting stylesheet {} for stage {}({})",
stylesheet,
stage.toString(),
stage.getTitle()
);
return FxAsync.doOnFxThread(
stage,
... | java | public static CompletionStage<Stage> setStylesheet(final Stage stage, final String stylesheet) {
LOG.info(
"Setting stylesheet {} for stage {}({})",
stylesheet,
stage.toString(),
stage.getTitle()
);
return FxAsync.doOnFxThread(
stage,
... | [
"public",
"static",
"CompletionStage",
"<",
"Stage",
">",
"setStylesheet",
"(",
"final",
"Stage",
"stage",
",",
"final",
"String",
"stylesheet",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Setting stylesheet {} for stage {}({})\"",
",",
"stylesheet",
",",
"stage",
".",
... | Boilerplate for setting the stylesheet of a given stage via Java rather than FXML.
@param stage The stage whose stylesheet we are changing
@param stylesheet The new stylesheet in external form. That is, if it is a file, including the protocol info
"file:/" before the actual path. Use {@link Resources#getResourceU... | [
"Boilerplate",
"for",
"setting",
"the",
"stylesheet",
"of",
"a",
"given",
"stage",
"via",
"Java",
"rather",
"than",
"FXML",
"."
] | f82cad1d54e62903ca5e4a250279ad315b028aef | https://github.com/Tristan971/EasyFXML/blob/f82cad1d54e62903ca5e4a250279ad315b028aef/easyfxml/src/main/java/moe/tristan/easyfxml/util/Stages.java#L104-L119 | train |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/util/FxAsync.java | FxAsync.doOnFxThread | public static <T> CompletionStage<T> doOnFxThread(final T element, final Consumer<T> action) {
return CompletableFuture.supplyAsync(() -> {
action.accept(element);
return element;
}, Platform::runLater);
} | java | public static <T> CompletionStage<T> doOnFxThread(final T element, final Consumer<T> action) {
return CompletableFuture.supplyAsync(() -> {
action.accept(element);
return element;
}, Platform::runLater);
} | [
"public",
"static",
"<",
"T",
">",
"CompletionStage",
"<",
"T",
">",
"doOnFxThread",
"(",
"final",
"T",
"element",
",",
"final",
"Consumer",
"<",
"T",
">",
"action",
")",
"{",
"return",
"CompletableFuture",
".",
"supplyAsync",
"(",
"(",
")",
"->",
"{",
... | Asynchronously executes a consuming operation on the JavaFX thread.
@param element The element to consume
@param action How to consume it
@param <T> The type of the element consumed
@return A {@link CompletionStage} to have monitoring over the state of the asynchronous operation.
<p>
Please make sure to read thi... | [
"Asynchronously",
"executes",
"a",
"consuming",
"operation",
"on",
"the",
"JavaFX",
"thread",
"."
] | f82cad1d54e62903ca5e4a250279ad315b028aef | https://github.com/Tristan971/EasyFXML/blob/f82cad1d54e62903ca5e4a250279ad315b028aef/easyfxml/src/main/java/moe/tristan/easyfxml/util/FxAsync.java#L39-L44 | train |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/util/FxAsync.java | FxAsync.computeOnFxThread | public static <T, U> CompletionStage<U> computeOnFxThread(final T element, final Function<T, U> compute) {
return CompletableFuture.supplyAsync(() -> compute.apply(element), Platform::runLater);
} | java | public static <T, U> CompletionStage<U> computeOnFxThread(final T element, final Function<T, U> compute) {
return CompletableFuture.supplyAsync(() -> compute.apply(element), Platform::runLater);
} | [
"public",
"static",
"<",
"T",
",",
"U",
">",
"CompletionStage",
"<",
"U",
">",
"computeOnFxThread",
"(",
"final",
"T",
"element",
",",
"final",
"Function",
"<",
"T",
",",
"U",
">",
"compute",
")",
"{",
"return",
"CompletableFuture",
".",
"supplyAsync",
"... | Asynchronously executes a computing operation on the JavaFX thread.
@param element The element(s) required for the computation (use {@link Tuple2} for pair-based for example)
@param compute The computation to perform
@param <T> The type of the (aggregated if necessary) inputs
@param <U> The output type
@retur... | [
"Asynchronously",
"executes",
"a",
"computing",
"operation",
"on",
"the",
"JavaFX",
"thread",
"."
] | f82cad1d54e62903ca5e4a250279ad315b028aef | https://github.com/Tristan971/EasyFXML/blob/f82cad1d54e62903ca5e4a250279ad315b028aef/easyfxml/src/main/java/moe/tristan/easyfxml/util/FxAsync.java#L58-L60 | train |
jenkins-x/jx-java-client | src/main/java/io/jenkins/x/client/util/Strings.java | Strings.capitalise | public static String capitalise(String text) {
if (empty(text)) {
return "";
}
return text.substring(0, 1).toUpperCase() + text.substring(1);
} | java | public static String capitalise(String text) {
if (empty(text)) {
return "";
}
return text.substring(0, 1).toUpperCase() + text.substring(1);
} | [
"public",
"static",
"String",
"capitalise",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"empty",
"(",
"text",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"return",
"text",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
")",
"+",... | Capitalise the given text | [
"Capitalise",
"the",
"given",
"text"
] | 4909b74d9ff02db999be0689a84956af1bcee5ab | https://github.com/jenkins-x/jx-java-client/blob/4909b74d9ff02db999be0689a84956af1bcee5ab/src/main/java/io/jenkins/x/client/util/Strings.java#L49-L54 | train |
jenkins-x/jx-java-client | src/main/java/io/jenkins/x/client/PipelineClient.java | PipelineClient.startAsync | public void startAsync() {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
start();
} catch (Exception e) {
LOG.error("Failed to connect to kubernetes: " + e, e);
}
... | java | public void startAsync() {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
start();
} catch (Exception e) {
LOG.error("Failed to connect to kubernetes: " + e, e);
}
... | [
"public",
"void",
"startAsync",
"(",
")",
"{",
"Thread",
"thread",
"=",
"new",
"Thread",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"Excepti... | Starts listening in a background thread to avoid blocking the calling thread | [
"Starts",
"listening",
"in",
"a",
"background",
"thread",
"to",
"avoid",
"blocking",
"the",
"calling",
"thread"
] | 4909b74d9ff02db999be0689a84956af1bcee5ab | https://github.com/jenkins-x/jx-java-client/blob/4909b74d9ff02db999be0689a84956af1bcee5ab/src/main/java/io/jenkins/x/client/PipelineClient.java#L103-L115 | train |
jenkins-x/jx-java-client | src/main/java/io/jenkins/x/client/PipelineClient.java | PipelineClient.start | public void start() {
doClose();
Watcher<PipelineActivity> listener = new Watcher<PipelineActivity>() {
@Override
public void eventReceived(Action action, PipelineActivity pipelineActivity) {
onEventReceived(action, pipelineActivity);
}
@... | java | public void start() {
doClose();
Watcher<PipelineActivity> listener = new Watcher<PipelineActivity>() {
@Override
public void eventReceived(Action action, PipelineActivity pipelineActivity) {
onEventReceived(action, pipelineActivity);
}
@... | [
"public",
"void",
"start",
"(",
")",
"{",
"doClose",
"(",
")",
";",
"Watcher",
"<",
"PipelineActivity",
">",
"listener",
"=",
"new",
"Watcher",
"<",
"PipelineActivity",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"eventReceived",
"(",
"Action",
... | Starts listing and watching the pipelines in the namespace and firing events. | [
"Starts",
"listing",
"and",
"watching",
"the",
"pipelines",
"in",
"the",
"namespace",
"and",
"firing",
"events",
"."
] | 4909b74d9ff02db999be0689a84956af1bcee5ab | https://github.com/jenkins-x/jx-java-client/blob/4909b74d9ff02db999be0689a84956af1bcee5ab/src/main/java/io/jenkins/x/client/PipelineClient.java#L120-L149 | train |
jenkins-x/jx-java-client | src/main/java/io/jenkins/x/client/kube/KubeHelpers.java | KubeHelpers.isNewer | public static boolean isNewer(HasMetadata newer, HasMetadata older) {
long n1 = parseResourceVersion(newer);
long n2 = parseResourceVersion(older);
return n1 >= n2;
} | java | public static boolean isNewer(HasMetadata newer, HasMetadata older) {
long n1 = parseResourceVersion(newer);
long n2 = parseResourceVersion(older);
return n1 >= n2;
} | [
"public",
"static",
"boolean",
"isNewer",
"(",
"HasMetadata",
"newer",
",",
"HasMetadata",
"older",
")",
"{",
"long",
"n1",
"=",
"parseResourceVersion",
"(",
"newer",
")",
";",
"long",
"n2",
"=",
"parseResourceVersion",
"(",
"older",
")",
";",
"return",
"n1"... | Returns true if the first parameter is newer than the second | [
"Returns",
"true",
"if",
"the",
"first",
"parameter",
"is",
"newer",
"than",
"the",
"second"
] | 4909b74d9ff02db999be0689a84956af1bcee5ab | https://github.com/jenkins-x/jx-java-client/blob/4909b74d9ff02db999be0689a84956af1bcee5ab/src/main/java/io/jenkins/x/client/kube/KubeHelpers.java#L31-L35 | train |
jenkins-x/jx-java-client | src/main/java/io/jenkins/x/client/kube/KubeHelpers.java | KubeHelpers.parseResourceVersion | public static long parseResourceVersion(HasMetadata obj) {
ObjectMeta metadata = obj.getMetadata();
if (metadata != null) {
String resourceVersion = metadata.getResourceVersion();
if (notEmpty(resourceVersion)) {
try {
return Long.parseLong(res... | java | public static long parseResourceVersion(HasMetadata obj) {
ObjectMeta metadata = obj.getMetadata();
if (metadata != null) {
String resourceVersion = metadata.getResourceVersion();
if (notEmpty(resourceVersion)) {
try {
return Long.parseLong(res... | [
"public",
"static",
"long",
"parseResourceVersion",
"(",
"HasMetadata",
"obj",
")",
"{",
"ObjectMeta",
"metadata",
"=",
"obj",
".",
"getMetadata",
"(",
")",
";",
"if",
"(",
"metadata",
"!=",
"null",
")",
"{",
"String",
"resourceVersion",
"=",
"metadata",
"."... | Returns the numeric resource version of the resource | [
"Returns",
"the",
"numeric",
"resource",
"version",
"of",
"the",
"resource"
] | 4909b74d9ff02db999be0689a84956af1bcee5ab | https://github.com/jenkins-x/jx-java-client/blob/4909b74d9ff02db999be0689a84956af1bcee5ab/src/main/java/io/jenkins/x/client/kube/KubeHelpers.java#L41-L54 | train |
jenkins-x/jx-java-client | src/main/java/io/jenkins/x/client/Pipelines.java | Pipelines.getPullRequestName | public static String getPullRequestName(String prUrl) {
if (notEmpty(prUrl)) {
int idx = prUrl.lastIndexOf("/");
if (idx > 0) {
return " #" + prUrl.substring(idx + 1);
}
}
return "";
} | java | public static String getPullRequestName(String prUrl) {
if (notEmpty(prUrl)) {
int idx = prUrl.lastIndexOf("/");
if (idx > 0) {
return " #" + prUrl.substring(idx + 1);
}
}
return "";
} | [
"public",
"static",
"String",
"getPullRequestName",
"(",
"String",
"prUrl",
")",
"{",
"if",
"(",
"notEmpty",
"(",
"prUrl",
")",
")",
"{",
"int",
"idx",
"=",
"prUrl",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
";",
"if",
"(",
"idx",
">",
"0",
")",
"{",
... | Returns the Pull Request name from the given URL prefixed with space or an empty string if there is no URL | [
"Returns",
"the",
"Pull",
"Request",
"name",
"from",
"the",
"given",
"URL",
"prefixed",
"with",
"space",
"or",
"an",
"empty",
"string",
"if",
"there",
"is",
"no",
"URL"
] | 4909b74d9ff02db999be0689a84956af1bcee5ab | https://github.com/jenkins-x/jx-java-client/blob/4909b74d9ff02db999be0689a84956af1bcee5ab/src/main/java/io/jenkins/x/client/Pipelines.java#L42-L50 | train |
jenkins-x/jx-java-client | src/main/java/io/jenkins/x/client/kube/KubernetesNames.java | KubernetesNames.convertToKubernetesName | public static String convertToKubernetesName(String text, boolean allowDots) {
String lower = text.toLowerCase();
StringBuilder builder = new StringBuilder();
boolean started = false;
char lastCh = ' ';
for (int i = 0, last = lower.length() - 1; i <= last; i++) {
char... | java | public static String convertToKubernetesName(String text, boolean allowDots) {
String lower = text.toLowerCase();
StringBuilder builder = new StringBuilder();
boolean started = false;
char lastCh = ' ';
for (int i = 0, last = lower.length() - 1; i <= last; i++) {
char... | [
"public",
"static",
"String",
"convertToKubernetesName",
"(",
"String",
"text",
",",
"boolean",
"allowDots",
")",
"{",
"String",
"lower",
"=",
"text",
".",
"toLowerCase",
"(",
")",
";",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
... | Lets convert the string to btw a valid kubernetes resource name
@param text the text to convert
@param allowDots whether or not to allow dots in the name
@return the converted name | [
"Lets",
"convert",
"the",
"string",
"to",
"btw",
"a",
"valid",
"kubernetes",
"resource",
"name"
] | 4909b74d9ff02db999be0689a84956af1bcee5ab | https://github.com/jenkins-x/jx-java-client/blob/4909b74d9ff02db999be0689a84956af1bcee5ab/src/main/java/io/jenkins/x/client/kube/KubernetesNames.java#L15-L45 | train |
alipay/sofa-hessian | src/main/java/com/caucho/hessian/io/AbstractHessianOutput.java | AbstractHessianOutput.findSerializerFactory | protected final SerializerFactory findSerializerFactory()
{
SerializerFactory factory = _serializerFactory;
if (factory == null) {
factory = SerializerFactory.createDefault();
_defaultSerializerFactory = factory;
_serializerFactory = factory;
}
r... | java | protected final SerializerFactory findSerializerFactory()
{
SerializerFactory factory = _serializerFactory;
if (factory == null) {
factory = SerializerFactory.createDefault();
_defaultSerializerFactory = factory;
_serializerFactory = factory;
}
r... | [
"protected",
"final",
"SerializerFactory",
"findSerializerFactory",
"(",
")",
"{",
"SerializerFactory",
"factory",
"=",
"_serializerFactory",
";",
"if",
"(",
"factory",
"==",
"null",
")",
"{",
"factory",
"=",
"SerializerFactory",
".",
"createDefault",
"(",
")",
";... | Gets the serializer factory. | [
"Gets",
"the",
"serializer",
"factory",
"."
] | 89e4f5af28602101dab7b498995018871616357b | https://github.com/alipay/sofa-hessian/blob/89e4f5af28602101dab7b498995018871616357b/src/main/java/com/caucho/hessian/io/AbstractHessianOutput.java#L102-L113 | train |
alipay/sofa-hessian | src/main/java/com/caucho/hessian/io/Hessian2StreamingInput.java | Hessian2StreamingInput.readObject | public Object readObject()
throws IOException
{
_is.startPacket();
Object obj = _in.readStreamingObject();
_is.endPacket();
return obj;
} | java | public Object readObject()
throws IOException
{
_is.startPacket();
Object obj = _in.readStreamingObject();
_is.endPacket();
return obj;
} | [
"public",
"Object",
"readObject",
"(",
")",
"throws",
"IOException",
"{",
"_is",
".",
"startPacket",
"(",
")",
";",
"Object",
"obj",
"=",
"_in",
".",
"readStreamingObject",
"(",
")",
";",
"_is",
".",
"endPacket",
"(",
")",
";",
"return",
"obj",
";",
"}... | Read the next object | [
"Read",
"the",
"next",
"object"
] | 89e4f5af28602101dab7b498995018871616357b | https://github.com/alipay/sofa-hessian/blob/89e4f5af28602101dab7b498995018871616357b/src/main/java/com/caucho/hessian/io/Hessian2StreamingInput.java#L124-L134 | train |
alipay/sofa-hessian | src/main/java/com/caucho/hessian/io/HessianOutput.java | HessianOutput.init | public void init(OutputStream os)
{
this.os = os;
_refs = null;
if (_serializerFactory == null)
_serializerFactory = new SerializerFactory();
} | java | public void init(OutputStream os)
{
this.os = os;
_refs = null;
if (_serializerFactory == null)
_serializerFactory = new SerializerFactory();
} | [
"public",
"void",
"init",
"(",
"OutputStream",
"os",
")",
"{",
"this",
".",
"os",
"=",
"os",
";",
"_refs",
"=",
"null",
";",
"if",
"(",
"_serializerFactory",
"==",
"null",
")",
"_serializerFactory",
"=",
"new",
"SerializerFactory",
"(",
")",
";",
"}"
] | Initializes the output | [
"Initializes",
"the",
"output"
] | 89e4f5af28602101dab7b498995018871616357b | https://github.com/alipay/sofa-hessian/blob/89e4f5af28602101dab7b498995018871616357b/src/main/java/com/caucho/hessian/io/HessianOutput.java#L103-L111 | train |
alipay/sofa-hessian | src/main/java/com/caucho/hessian/io/HessianOutput.java | HessianOutput.writeRemote | public void writeRemote(String type, String url)
throws IOException
{
os.write('r');
os.write('t');
printLenString(type);
os.write('S');
printLenString(url);
} | java | public void writeRemote(String type, String url)
throws IOException
{
os.write('r');
os.write('t');
printLenString(type);
os.write('S');
printLenString(url);
} | [
"public",
"void",
"writeRemote",
"(",
"String",
"type",
",",
"String",
"url",
")",
"throws",
"IOException",
"{",
"os",
".",
"write",
"(",
"'",
"'",
")",
";",
"os",
".",
"write",
"(",
"'",
"'",
")",
";",
"printLenString",
"(",
"type",
")",
";",
"os"... | Writes a remote object reference to the stream. The type is the
type of the remote interface.
<code><pre>
'r' 't' b16 b8 type url
</pre></code> | [
"Writes",
"a",
"remote",
"object",
"reference",
"to",
"the",
"stream",
".",
"The",
"type",
"is",
"the",
"type",
"of",
"the",
"remote",
"interface",
"."
] | 89e4f5af28602101dab7b498995018871616357b | https://github.com/alipay/sofa-hessian/blob/89e4f5af28602101dab7b498995018871616357b/src/main/java/com/caucho/hessian/io/HessianOutput.java#L402-L410 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.