id
int32 0
165k
| 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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
153,500
|
jbundle/jbundle
|
main/calendar/src/main/java/org/jbundle/main/calendar/db/CalendarControl.java
|
CalendarControl.updateCalendar
|
public void updateCalendar(Calendar calStart, Calendar calEnd)
{
Anniversary recAnniversary = new Anniversary(this.getRecordOwner());
AnnivMaster recAnnivMaster = new AnnivMaster(this.getRecordOwner());
recAnniversary.setKeyArea(Anniversary.START_DATE_TIME_KEY);
try {
while (recAnniversary.hasNext())
{
recAnniversary.next();
if (recAnniversary.getField(Anniversary.START_DATE_TIME).compareTo(this.getField(CalendarControl.START_ANNIV_DATE)) > 0)
break; // end of the entries that are not in the current range.
recAnniversary.edit();
recAnniversary.remove();
}
while (recAnnivMaster.hasNext())
{
recAnnivMaster.next();
recAnnivMaster.addAppointments(recAnniversary, calStart, calEnd);
}
} catch (DBException ex) {
ex.printStackTrace();
} finally {
recAnniversary.free();
recAnnivMaster.free();
}
}
|
java
|
public void updateCalendar(Calendar calStart, Calendar calEnd)
{
Anniversary recAnniversary = new Anniversary(this.getRecordOwner());
AnnivMaster recAnnivMaster = new AnnivMaster(this.getRecordOwner());
recAnniversary.setKeyArea(Anniversary.START_DATE_TIME_KEY);
try {
while (recAnniversary.hasNext())
{
recAnniversary.next();
if (recAnniversary.getField(Anniversary.START_DATE_TIME).compareTo(this.getField(CalendarControl.START_ANNIV_DATE)) > 0)
break; // end of the entries that are not in the current range.
recAnniversary.edit();
recAnniversary.remove();
}
while (recAnnivMaster.hasNext())
{
recAnnivMaster.next();
recAnnivMaster.addAppointments(recAnniversary, calStart, calEnd);
}
} catch (DBException ex) {
ex.printStackTrace();
} finally {
recAnniversary.free();
recAnnivMaster.free();
}
}
|
[
"public",
"void",
"updateCalendar",
"(",
"Calendar",
"calStart",
",",
"Calendar",
"calEnd",
")",
"{",
"Anniversary",
"recAnniversary",
"=",
"new",
"Anniversary",
"(",
"this",
".",
"getRecordOwner",
"(",
")",
")",
";",
"AnnivMaster",
"recAnnivMaster",
"=",
"new",
"AnnivMaster",
"(",
"this",
".",
"getRecordOwner",
"(",
")",
")",
";",
"recAnniversary",
".",
"setKeyArea",
"(",
"Anniversary",
".",
"START_DATE_TIME_KEY",
")",
";",
"try",
"{",
"while",
"(",
"recAnniversary",
".",
"hasNext",
"(",
")",
")",
"{",
"recAnniversary",
".",
"next",
"(",
")",
";",
"if",
"(",
"recAnniversary",
".",
"getField",
"(",
"Anniversary",
".",
"START_DATE_TIME",
")",
".",
"compareTo",
"(",
"this",
".",
"getField",
"(",
"CalendarControl",
".",
"START_ANNIV_DATE",
")",
")",
">",
"0",
")",
"break",
";",
"// end of the entries that are not in the current range.",
"recAnniversary",
".",
"edit",
"(",
")",
";",
"recAnniversary",
".",
"remove",
"(",
")",
";",
"}",
"while",
"(",
"recAnnivMaster",
".",
"hasNext",
"(",
")",
")",
"{",
"recAnnivMaster",
".",
"next",
"(",
")",
";",
"recAnnivMaster",
".",
"addAppointments",
"(",
"recAnniversary",
",",
"calStart",
",",
"calEnd",
")",
";",
"}",
"}",
"catch",
"(",
"DBException",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"recAnniversary",
".",
"free",
"(",
")",
";",
"recAnnivMaster",
".",
"free",
"(",
")",
";",
"}",
"}"
] |
UpdateCalendar Method.
|
[
"UpdateCalendar",
"Method",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/calendar/src/main/java/org/jbundle/main/calendar/db/CalendarControl.java#L199-L225
|
153,501
|
jbundle/jbundle
|
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageReceiver.java
|
BaseMessageReceiver.createDefaultFilter
|
public BaseMessageFilter createDefaultFilter(JMessageListener listener)
{
BaseMessageFilter messageFilter = null;
String strQueueName = MessageConstants.RECORD_QUEUE_NAME; // Default queue name=
String strQueueType = MessageConstants.INTRANET_QUEUE; // Default queue type
if (m_baseMessageQueue != null)
{
strQueueName = m_baseMessageQueue.getQueueName();
strQueueType = m_baseMessageQueue.getQueueType();
}
messageFilter = new BaseMessageFilter(strQueueName, strQueueType, null, null); // Take all messages
messageFilter.addMessageListener(listener);
//xif (bAddToReceiver) // Already added at previous line.
//x this.addMessageFilter(messageFilter);
return messageFilter;
}
|
java
|
public BaseMessageFilter createDefaultFilter(JMessageListener listener)
{
BaseMessageFilter messageFilter = null;
String strQueueName = MessageConstants.RECORD_QUEUE_NAME; // Default queue name=
String strQueueType = MessageConstants.INTRANET_QUEUE; // Default queue type
if (m_baseMessageQueue != null)
{
strQueueName = m_baseMessageQueue.getQueueName();
strQueueType = m_baseMessageQueue.getQueueType();
}
messageFilter = new BaseMessageFilter(strQueueName, strQueueType, null, null); // Take all messages
messageFilter.addMessageListener(listener);
//xif (bAddToReceiver) // Already added at previous line.
//x this.addMessageFilter(messageFilter);
return messageFilter;
}
|
[
"public",
"BaseMessageFilter",
"createDefaultFilter",
"(",
"JMessageListener",
"listener",
")",
"{",
"BaseMessageFilter",
"messageFilter",
"=",
"null",
";",
"String",
"strQueueName",
"=",
"MessageConstants",
".",
"RECORD_QUEUE_NAME",
";",
"// Default queue name=",
"String",
"strQueueType",
"=",
"MessageConstants",
".",
"INTRANET_QUEUE",
";",
"// Default queue type",
"if",
"(",
"m_baseMessageQueue",
"!=",
"null",
")",
"{",
"strQueueName",
"=",
"m_baseMessageQueue",
".",
"getQueueName",
"(",
")",
";",
"strQueueType",
"=",
"m_baseMessageQueue",
".",
"getQueueType",
"(",
")",
";",
"}",
"messageFilter",
"=",
"new",
"BaseMessageFilter",
"(",
"strQueueName",
",",
"strQueueType",
",",
"null",
",",
"null",
")",
";",
"// Take all messages",
"messageFilter",
".",
"addMessageListener",
"(",
"listener",
")",
";",
"//xif (bAddToReceiver) // Already added at previous line.",
"//x this.addMessageFilter(messageFilter);",
"return",
"messageFilter",
";",
"}"
] |
Create a message filter that will send all messages to this listener.
@param listener The listener to create a filter for.
@return The new filter for this listener.
|
[
"Create",
"a",
"message",
"filter",
"that",
"will",
"send",
"all",
"messages",
"to",
"this",
"listener",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageReceiver.java#L201-L216
|
153,502
|
jbundle/jbundle
|
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageReceiver.java
|
BaseMessageReceiver.run
|
public void run()
{
m_thread = this;
while (m_thread != null)
{
int iErrorCode = Constant.NORMAL_RETURN;
BaseMessage message = (BaseMessage)this.receiveMessage(); // Hang until a message comes through
if ((message == null) || (m_thread == null))
return; // End of processing, stop this thread.
Iterator<BaseMessageFilter> iterator = this.getFilterList(message.getMessageHeader());
while (iterator.hasNext())
{
if (message.isConsumed())
break; // All done. with this message, continue with the next message.
try {
BaseMessageFilter filter = iterator.next();
if (filter.isFilterMatch(message.getMessageHeader()))
{
BaseMessage messageToSend = message;
for (int i = 0; ; i++)
{
JMessageListener listener = filter.getMessageListener(i);
if (listener == null)
break;
if (filter.isThinTarget())
if (listener.isThinListener())
{
if (messageToSend == message)
messageToSend = message.convertToThinMessage(); // If you are sending a thick message to a thin client, convert it first. Note: don't worry about calling this with a thin message... no conversion will be done there.
else
messageToSend = messageToSend.convertToThinMessage(); // Previously processed but not converted
}
if (listener instanceof org.jbundle.model.Remote)
if (filter.getRegistryID() != null)
if (messageToSend.getMessageHeader() != null)
if (messageToSend.getMessageHeader().getRegistryIDMatch() == null)
{
try {
if (messageToSend == message)
messageToSend = (BaseMessage)messageToSend.clone(); // If I change the message, I need a new copy
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
messageToSend.getMessageHeader().setRegistryIDMatch(filter.getRegistryID()); // Typically used for remote filters to match filter ID.
}
iErrorCode = listener.handleMessage(messageToSend);
if (iErrorCode != Constant.NORMAL_RETURN)
break;
message.setConsumed(messageToSend.isConsumed());
if (message.isConsumed())
break; // All done. with this message, continue with the next message.
}
}
} catch (ConcurrentModificationException ex) {
Util.getLogger().warning("Message filter Concurrent Modification"); // Warning: Someone modified the filter list while I was cruzin it.
iterator = this.getFilterList(message.getMessageHeader()); // Start from the beginning again
}
}
}
}
|
java
|
public void run()
{
m_thread = this;
while (m_thread != null)
{
int iErrorCode = Constant.NORMAL_RETURN;
BaseMessage message = (BaseMessage)this.receiveMessage(); // Hang until a message comes through
if ((message == null) || (m_thread == null))
return; // End of processing, stop this thread.
Iterator<BaseMessageFilter> iterator = this.getFilterList(message.getMessageHeader());
while (iterator.hasNext())
{
if (message.isConsumed())
break; // All done. with this message, continue with the next message.
try {
BaseMessageFilter filter = iterator.next();
if (filter.isFilterMatch(message.getMessageHeader()))
{
BaseMessage messageToSend = message;
for (int i = 0; ; i++)
{
JMessageListener listener = filter.getMessageListener(i);
if (listener == null)
break;
if (filter.isThinTarget())
if (listener.isThinListener())
{
if (messageToSend == message)
messageToSend = message.convertToThinMessage(); // If you are sending a thick message to a thin client, convert it first. Note: don't worry about calling this with a thin message... no conversion will be done there.
else
messageToSend = messageToSend.convertToThinMessage(); // Previously processed but not converted
}
if (listener instanceof org.jbundle.model.Remote)
if (filter.getRegistryID() != null)
if (messageToSend.getMessageHeader() != null)
if (messageToSend.getMessageHeader().getRegistryIDMatch() == null)
{
try {
if (messageToSend == message)
messageToSend = (BaseMessage)messageToSend.clone(); // If I change the message, I need a new copy
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
messageToSend.getMessageHeader().setRegistryIDMatch(filter.getRegistryID()); // Typically used for remote filters to match filter ID.
}
iErrorCode = listener.handleMessage(messageToSend);
if (iErrorCode != Constant.NORMAL_RETURN)
break;
message.setConsumed(messageToSend.isConsumed());
if (message.isConsumed())
break; // All done. with this message, continue with the next message.
}
}
} catch (ConcurrentModificationException ex) {
Util.getLogger().warning("Message filter Concurrent Modification"); // Warning: Someone modified the filter list while I was cruzin it.
iterator = this.getFilterList(message.getMessageHeader()); // Start from the beginning again
}
}
}
}
|
[
"public",
"void",
"run",
"(",
")",
"{",
"m_thread",
"=",
"this",
";",
"while",
"(",
"m_thread",
"!=",
"null",
")",
"{",
"int",
"iErrorCode",
"=",
"Constant",
".",
"NORMAL_RETURN",
";",
"BaseMessage",
"message",
"=",
"(",
"BaseMessage",
")",
"this",
".",
"receiveMessage",
"(",
")",
";",
"// Hang until a message comes through",
"if",
"(",
"(",
"message",
"==",
"null",
")",
"||",
"(",
"m_thread",
"==",
"null",
")",
")",
"return",
";",
"// End of processing, stop this thread.",
"Iterator",
"<",
"BaseMessageFilter",
">",
"iterator",
"=",
"this",
".",
"getFilterList",
"(",
"message",
".",
"getMessageHeader",
"(",
")",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"message",
".",
"isConsumed",
"(",
")",
")",
"break",
";",
"// All done. with this message, continue with the next message.",
"try",
"{",
"BaseMessageFilter",
"filter",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"filter",
".",
"isFilterMatch",
"(",
"message",
".",
"getMessageHeader",
"(",
")",
")",
")",
"{",
"BaseMessage",
"messageToSend",
"=",
"message",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
";",
"i",
"++",
")",
"{",
"JMessageListener",
"listener",
"=",
"filter",
".",
"getMessageListener",
"(",
"i",
")",
";",
"if",
"(",
"listener",
"==",
"null",
")",
"break",
";",
"if",
"(",
"filter",
".",
"isThinTarget",
"(",
")",
")",
"if",
"(",
"listener",
".",
"isThinListener",
"(",
")",
")",
"{",
"if",
"(",
"messageToSend",
"==",
"message",
")",
"messageToSend",
"=",
"message",
".",
"convertToThinMessage",
"(",
")",
";",
"// If you are sending a thick message to a thin client, convert it first. Note: don't worry about calling this with a thin message... no conversion will be done there.",
"else",
"messageToSend",
"=",
"messageToSend",
".",
"convertToThinMessage",
"(",
")",
";",
"// Previously processed but not converted",
"}",
"if",
"(",
"listener",
"instanceof",
"org",
".",
"jbundle",
".",
"model",
".",
"Remote",
")",
"if",
"(",
"filter",
".",
"getRegistryID",
"(",
")",
"!=",
"null",
")",
"if",
"(",
"messageToSend",
".",
"getMessageHeader",
"(",
")",
"!=",
"null",
")",
"if",
"(",
"messageToSend",
".",
"getMessageHeader",
"(",
")",
".",
"getRegistryIDMatch",
"(",
")",
"==",
"null",
")",
"{",
"try",
"{",
"if",
"(",
"messageToSend",
"==",
"message",
")",
"messageToSend",
"=",
"(",
"BaseMessage",
")",
"messageToSend",
".",
"clone",
"(",
")",
";",
"// If I change the message, I need a new copy",
"}",
"catch",
"(",
"CloneNotSupportedException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"messageToSend",
".",
"getMessageHeader",
"(",
")",
".",
"setRegistryIDMatch",
"(",
"filter",
".",
"getRegistryID",
"(",
")",
")",
";",
"// Typically used for remote filters to match filter ID.",
"}",
"iErrorCode",
"=",
"listener",
".",
"handleMessage",
"(",
"messageToSend",
")",
";",
"if",
"(",
"iErrorCode",
"!=",
"Constant",
".",
"NORMAL_RETURN",
")",
"break",
";",
"message",
".",
"setConsumed",
"(",
"messageToSend",
".",
"isConsumed",
"(",
")",
")",
";",
"if",
"(",
"message",
".",
"isConsumed",
"(",
")",
")",
"break",
";",
"// All done. with this message, continue with the next message.",
"}",
"}",
"}",
"catch",
"(",
"ConcurrentModificationException",
"ex",
")",
"{",
"Util",
".",
"getLogger",
"(",
")",
".",
"warning",
"(",
"\"Message filter Concurrent Modification\"",
")",
";",
"// Warning: Someone modified the filter list while I was cruzin it.",
"iterator",
"=",
"this",
".",
"getFilterList",
"(",
"message",
".",
"getMessageHeader",
"(",
")",
")",
";",
"// Start from the beginning again",
"}",
"}",
"}",
"}"
] |
Start running this thread.
This method hangs on receiveMessage, then processes the message if it matches
the filter and continues with the next message.
|
[
"Start",
"running",
"this",
"thread",
".",
"This",
"method",
"hangs",
"on",
"receiveMessage",
"then",
"processes",
"the",
"message",
"if",
"it",
"matches",
"the",
"filter",
"and",
"continues",
"with",
"the",
"next",
"message",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageReceiver.java#L222-L281
|
153,503
|
Multifarious/MacroManager
|
src/main/java/com/fasterxml/mama/balancing/BalancingPolicy.java
|
BalancingPolicy.getUnclaimed
|
public Set<String> getUnclaimed() {
synchronized (cluster.allWorkUnits) {
LinkedHashSet<String> result = new LinkedHashSet<String>(cluster.allWorkUnits.keySet());
result.removeAll(cluster.workUnitMap.keySet());
result.addAll(cluster.getHandoffWorkUnits());
result.removeAll(cluster.getHandoffResultWorkUnits());
result.removeAll(cluster.myWorkUnits);
return result;
}
}
|
java
|
public Set<String> getUnclaimed() {
synchronized (cluster.allWorkUnits) {
LinkedHashSet<String> result = new LinkedHashSet<String>(cluster.allWorkUnits.keySet());
result.removeAll(cluster.workUnitMap.keySet());
result.addAll(cluster.getHandoffWorkUnits());
result.removeAll(cluster.getHandoffResultWorkUnits());
result.removeAll(cluster.myWorkUnits);
return result;
}
}
|
[
"public",
"Set",
"<",
"String",
">",
"getUnclaimed",
"(",
")",
"{",
"synchronized",
"(",
"cluster",
".",
"allWorkUnits",
")",
"{",
"LinkedHashSet",
"<",
"String",
">",
"result",
"=",
"new",
"LinkedHashSet",
"<",
"String",
">",
"(",
"cluster",
".",
"allWorkUnits",
".",
"keySet",
"(",
")",
")",
";",
"result",
".",
"removeAll",
"(",
"cluster",
".",
"workUnitMap",
".",
"keySet",
"(",
")",
")",
";",
"result",
".",
"addAll",
"(",
"cluster",
".",
"getHandoffWorkUnits",
"(",
")",
")",
";",
"result",
".",
"removeAll",
"(",
"cluster",
".",
"getHandoffResultWorkUnits",
"(",
")",
")",
";",
"result",
".",
"removeAll",
"(",
"cluster",
".",
"myWorkUnits",
")",
";",
"return",
"result",
";",
"}",
"}"
] |
Returns a set of work units which are unclaimed throughout the cluster.
|
[
"Returns",
"a",
"set",
"of",
"work",
"units",
"which",
"are",
"unclaimed",
"throughout",
"the",
"cluster",
"."
] |
559785839981f460aaeba3c3fddff7fb667d9581
|
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/balancing/BalancingPolicy.java#L56-L65
|
153,504
|
Multifarious/MacroManager
|
src/main/java/com/fasterxml/mama/balancing/BalancingPolicy.java
|
BalancingPolicy.isFairGame
|
public boolean isFairGame(String workUnit)
{
ObjectNode workUnitData = cluster.allWorkUnits.get(workUnit);
if (workUnitData == null || workUnitData.size() == 0) {
return true;
}
try {
JsonNode pegged = workUnitData.get(cluster.name);
if (pegged == null) {
return true;
}
LOG.debug("Pegged status for {}: {}.", workUnit, pegged);
return pegged.asText().equals(cluster.myNodeID);
} catch (Exception e) {
LOG.error(String.format("Error parsing mapping for %s: %s", workUnit, workUnitData), e);
return true;
}
}
|
java
|
public boolean isFairGame(String workUnit)
{
ObjectNode workUnitData = cluster.allWorkUnits.get(workUnit);
if (workUnitData == null || workUnitData.size() == 0) {
return true;
}
try {
JsonNode pegged = workUnitData.get(cluster.name);
if (pegged == null) {
return true;
}
LOG.debug("Pegged status for {}: {}.", workUnit, pegged);
return pegged.asText().equals(cluster.myNodeID);
} catch (Exception e) {
LOG.error(String.format("Error parsing mapping for %s: %s", workUnit, workUnitData), e);
return true;
}
}
|
[
"public",
"boolean",
"isFairGame",
"(",
"String",
"workUnit",
")",
"{",
"ObjectNode",
"workUnitData",
"=",
"cluster",
".",
"allWorkUnits",
".",
"get",
"(",
"workUnit",
")",
";",
"if",
"(",
"workUnitData",
"==",
"null",
"||",
"workUnitData",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"try",
"{",
"JsonNode",
"pegged",
"=",
"workUnitData",
".",
"get",
"(",
"cluster",
".",
"name",
")",
";",
"if",
"(",
"pegged",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"LOG",
".",
"debug",
"(",
"\"Pegged status for {}: {}.\"",
",",
"workUnit",
",",
"pegged",
")",
";",
"return",
"pegged",
".",
"asText",
"(",
")",
".",
"equals",
"(",
"cluster",
".",
"myNodeID",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"String",
".",
"format",
"(",
"\"Error parsing mapping for %s: %s\"",
",",
"workUnit",
",",
"workUnitData",
")",
",",
"e",
")",
";",
"return",
"true",
";",
"}",
"}"
] |
Determines whether or not a given work unit is designated "claimable" by this node.
If the ZNode for this work unit is empty, or contains JSON mapping this node to that
work unit, it's considered "claimable."
|
[
"Determines",
"whether",
"or",
"not",
"a",
"given",
"work",
"unit",
"is",
"designated",
"claimable",
"by",
"this",
"node",
".",
"If",
"the",
"ZNode",
"for",
"this",
"work",
"unit",
"is",
"empty",
"or",
"contains",
"JSON",
"mapping",
"this",
"node",
"to",
"that",
"work",
"unit",
"it",
"s",
"considered",
"claimable",
"."
] |
559785839981f460aaeba3c3fddff7fb667d9581
|
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/balancing/BalancingPolicy.java#L72-L90
|
153,505
|
Multifarious/MacroManager
|
src/main/java/com/fasterxml/mama/balancing/BalancingPolicy.java
|
BalancingPolicy.isPeggedToMe
|
public boolean isPeggedToMe(String workUnitId)
{
ObjectNode zkWorkData = cluster.allWorkUnits.get(workUnitId);
if (zkWorkData == null || zkWorkData.size() == 0) {
cluster.workUnitsPeggedToMe.remove(workUnitId);
return false;
}
try {
JsonNode pegged = zkWorkData.get(cluster.name);
final boolean isPegged = (pegged != null) && pegged.asText().equals(cluster.myNodeID);
if (isPegged) {
cluster.workUnitsPeggedToMe.add(workUnitId);
} else {
cluster.workUnitsPeggedToMe.remove(workUnitId);
}
return isPegged;
} catch (Exception e) {
LOG.error(String.format("Error parsing mapping for %s: %s", workUnitId, zkWorkData), e);
return false;
}
}
|
java
|
public boolean isPeggedToMe(String workUnitId)
{
ObjectNode zkWorkData = cluster.allWorkUnits.get(workUnitId);
if (zkWorkData == null || zkWorkData.size() == 0) {
cluster.workUnitsPeggedToMe.remove(workUnitId);
return false;
}
try {
JsonNode pegged = zkWorkData.get(cluster.name);
final boolean isPegged = (pegged != null) && pegged.asText().equals(cluster.myNodeID);
if (isPegged) {
cluster.workUnitsPeggedToMe.add(workUnitId);
} else {
cluster.workUnitsPeggedToMe.remove(workUnitId);
}
return isPegged;
} catch (Exception e) {
LOG.error(String.format("Error parsing mapping for %s: %s", workUnitId, zkWorkData), e);
return false;
}
}
|
[
"public",
"boolean",
"isPeggedToMe",
"(",
"String",
"workUnitId",
")",
"{",
"ObjectNode",
"zkWorkData",
"=",
"cluster",
".",
"allWorkUnits",
".",
"get",
"(",
"workUnitId",
")",
";",
"if",
"(",
"zkWorkData",
"==",
"null",
"||",
"zkWorkData",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"cluster",
".",
"workUnitsPeggedToMe",
".",
"remove",
"(",
"workUnitId",
")",
";",
"return",
"false",
";",
"}",
"try",
"{",
"JsonNode",
"pegged",
"=",
"zkWorkData",
".",
"get",
"(",
"cluster",
".",
"name",
")",
";",
"final",
"boolean",
"isPegged",
"=",
"(",
"pegged",
"!=",
"null",
")",
"&&",
"pegged",
".",
"asText",
"(",
")",
".",
"equals",
"(",
"cluster",
".",
"myNodeID",
")",
";",
"if",
"(",
"isPegged",
")",
"{",
"cluster",
".",
"workUnitsPeggedToMe",
".",
"add",
"(",
"workUnitId",
")",
";",
"}",
"else",
"{",
"cluster",
".",
"workUnitsPeggedToMe",
".",
"remove",
"(",
"workUnitId",
")",
";",
"}",
"return",
"isPegged",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"String",
".",
"format",
"(",
"\"Error parsing mapping for %s: %s\"",
",",
"workUnitId",
",",
"zkWorkData",
")",
",",
"e",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Determines whether or not a given work unit is pegged to this instance.
|
[
"Determines",
"whether",
"or",
"not",
"a",
"given",
"work",
"unit",
"is",
"pegged",
"to",
"this",
"instance",
"."
] |
559785839981f460aaeba3c3fddff7fb667d9581
|
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/balancing/BalancingPolicy.java#L95-L117
|
153,506
|
Multifarious/MacroManager
|
src/main/java/com/fasterxml/mama/balancing/BalancingPolicy.java
|
BalancingPolicy.attemptToClaim
|
boolean attemptToClaim(String workUnit, boolean claimForHandoff)
throws InterruptedException
{
LOG.debug("Attempting to claim {}. For handoff? {}", workUnit, claimForHandoff);
String path = claimForHandoff
? String.format("/%s/handoff-result/%s", cluster.name, workUnit)
: cluster.workUnitClaimPath(workUnit);
final boolean created = ZKUtils.createEphemeral(cluster.zk, path, cluster.myNodeID);
if (created) {
if (claimForHandoff) {
cluster.claimedForHandoff.add(workUnit);
}
cluster.startWork(workUnit);
return true;
}
if (isPeggedToMe(workUnit)) {
claimWorkPeggedToMe(workUnit);
return true;
}
return false;
}
|
java
|
boolean attemptToClaim(String workUnit, boolean claimForHandoff)
throws InterruptedException
{
LOG.debug("Attempting to claim {}. For handoff? {}", workUnit, claimForHandoff);
String path = claimForHandoff
? String.format("/%s/handoff-result/%s", cluster.name, workUnit)
: cluster.workUnitClaimPath(workUnit);
final boolean created = ZKUtils.createEphemeral(cluster.zk, path, cluster.myNodeID);
if (created) {
if (claimForHandoff) {
cluster.claimedForHandoff.add(workUnit);
}
cluster.startWork(workUnit);
return true;
}
if (isPeggedToMe(workUnit)) {
claimWorkPeggedToMe(workUnit);
return true;
}
return false;
}
|
[
"boolean",
"attemptToClaim",
"(",
"String",
"workUnit",
",",
"boolean",
"claimForHandoff",
")",
"throws",
"InterruptedException",
"{",
"LOG",
".",
"debug",
"(",
"\"Attempting to claim {}. For handoff? {}\"",
",",
"workUnit",
",",
"claimForHandoff",
")",
";",
"String",
"path",
"=",
"claimForHandoff",
"?",
"String",
".",
"format",
"(",
"\"/%s/handoff-result/%s\"",
",",
"cluster",
".",
"name",
",",
"workUnit",
")",
":",
"cluster",
".",
"workUnitClaimPath",
"(",
"workUnit",
")",
";",
"final",
"boolean",
"created",
"=",
"ZKUtils",
".",
"createEphemeral",
"(",
"cluster",
".",
"zk",
",",
"path",
",",
"cluster",
".",
"myNodeID",
")",
";",
"if",
"(",
"created",
")",
"{",
"if",
"(",
"claimForHandoff",
")",
"{",
"cluster",
".",
"claimedForHandoff",
".",
"add",
"(",
"workUnit",
")",
";",
"}",
"cluster",
".",
"startWork",
"(",
"workUnit",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"isPeggedToMe",
"(",
"workUnit",
")",
")",
"{",
"claimWorkPeggedToMe",
"(",
"workUnit",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Attempts to claim a given work unit by creating an ephemeral node in ZooKeeper
with this node's ID. If the claim succeeds, start work. If not, move on.
@throws ZooKeeperConnectionException
@throws KeeperException
|
[
"Attempts",
"to",
"claim",
"a",
"given",
"work",
"unit",
"by",
"creating",
"an",
"ephemeral",
"node",
"in",
"ZooKeeper",
"with",
"this",
"node",
"s",
"ID",
".",
"If",
"the",
"claim",
"succeeds",
"start",
"work",
".",
"If",
"not",
"move",
"on",
"."
] |
559785839981f460aaeba3c3fddff7fb667d9581
|
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/balancing/BalancingPolicy.java#L130-L153
|
153,507
|
Multifarious/MacroManager
|
src/main/java/com/fasterxml/mama/balancing/BalancingPolicy.java
|
BalancingPolicy.drainToCount
|
protected void drainToCount(final int targetCount, final boolean doShutdown, /* Boolean = false */
final boolean useHandoff, /* : Boolean = config.useSoftHandoff */
final CountDownLatch latch)
{
String msg = useHandoff ? " with handoff" : "";
LOG.info(String.format("Draining %s%s. Target count: %s, Current: %s",
config.workUnitName, msg, targetCount, cluster.myWorkUnits.size()));
if (targetCount >= cluster.myWorkUnits.size()) {
if (!doShutdown) {
return;
}
} else if (targetCount == 0 && doShutdown) {
cluster.completeShutdown();
}
final int amountToDrain = cluster.myWorkUnits.size() - targetCount;
String msgPrefix = (useHandoff) ? "Requesting handoff for" : "Shutting down";
LOG.info("{} {} of {} {} over {} seconds",
msgPrefix, amountToDrain, cluster.myWorkUnits.size(), config.workUnitName, config.drainTime);
// Build a list of work units to hand off.
LinkedHashSet<String> wuList = new LinkedHashSet<String>(cluster.myWorkUnits);
wuList.removeAll(cluster.workUnitsPeggedToMe);
final ArrayList<String> toHandOff = new ArrayList<String>();
Iterator<String> it = wuList.iterator();
for (int i = amountToDrain; it.hasNext() && i > 0; --i) {
toHandOff.add(it.next());
}
final int drainInterval = (int) (((double) config.drainTime / (double) toHandOff.size()) * 1000);
final Iterator<String> drainIt = toHandOff.iterator();
TimerTask handoffTask = new TimerTask() {
@Override
public void run() {
if (!drainIt.hasNext()) {
if (targetCount == 0 && doShutdown) {
cluster.completeShutdown();
}
if (latch != null) {
latch.countDown();
}
return;
}
String workUnit = drainIt.next();
if (useHandoff && !isPeggedToMe(workUnit)) {
try {
cluster.requestHandoff(workUnit);
} catch (Exception e) {
LOG.warn("Problems trying to request handoff of "+workUnit, e);
}
} else {
cluster.shutdownWork(workUnit, true);
}
cluster.schedule(this, drainInterval, TimeUnit.MILLISECONDS);
}
};
LOG.info("Releasing {} / {} work units over {} seconds: {}",
amountToDrain, cluster.myWorkUnits.size(), config.drainTime,
Strings.mkstring(toHandOff, ", "));
if (!cluster.myWorkUnits.isEmpty()) {
cluster.schedule(handoffTask, 0, TimeUnit.SECONDS);
}
}
|
java
|
protected void drainToCount(final int targetCount, final boolean doShutdown, /* Boolean = false */
final boolean useHandoff, /* : Boolean = config.useSoftHandoff */
final CountDownLatch latch)
{
String msg = useHandoff ? " with handoff" : "";
LOG.info(String.format("Draining %s%s. Target count: %s, Current: %s",
config.workUnitName, msg, targetCount, cluster.myWorkUnits.size()));
if (targetCount >= cluster.myWorkUnits.size()) {
if (!doShutdown) {
return;
}
} else if (targetCount == 0 && doShutdown) {
cluster.completeShutdown();
}
final int amountToDrain = cluster.myWorkUnits.size() - targetCount;
String msgPrefix = (useHandoff) ? "Requesting handoff for" : "Shutting down";
LOG.info("{} {} of {} {} over {} seconds",
msgPrefix, amountToDrain, cluster.myWorkUnits.size(), config.workUnitName, config.drainTime);
// Build a list of work units to hand off.
LinkedHashSet<String> wuList = new LinkedHashSet<String>(cluster.myWorkUnits);
wuList.removeAll(cluster.workUnitsPeggedToMe);
final ArrayList<String> toHandOff = new ArrayList<String>();
Iterator<String> it = wuList.iterator();
for (int i = amountToDrain; it.hasNext() && i > 0; --i) {
toHandOff.add(it.next());
}
final int drainInterval = (int) (((double) config.drainTime / (double) toHandOff.size()) * 1000);
final Iterator<String> drainIt = toHandOff.iterator();
TimerTask handoffTask = new TimerTask() {
@Override
public void run() {
if (!drainIt.hasNext()) {
if (targetCount == 0 && doShutdown) {
cluster.completeShutdown();
}
if (latch != null) {
latch.countDown();
}
return;
}
String workUnit = drainIt.next();
if (useHandoff && !isPeggedToMe(workUnit)) {
try {
cluster.requestHandoff(workUnit);
} catch (Exception e) {
LOG.warn("Problems trying to request handoff of "+workUnit, e);
}
} else {
cluster.shutdownWork(workUnit, true);
}
cluster.schedule(this, drainInterval, TimeUnit.MILLISECONDS);
}
};
LOG.info("Releasing {} / {} work units over {} seconds: {}",
amountToDrain, cluster.myWorkUnits.size(), config.drainTime,
Strings.mkstring(toHandOff, ", "));
if (!cluster.myWorkUnits.isEmpty()) {
cluster.schedule(handoffTask, 0, TimeUnit.SECONDS);
}
}
|
[
"protected",
"void",
"drainToCount",
"(",
"final",
"int",
"targetCount",
",",
"final",
"boolean",
"doShutdown",
",",
"/* Boolean = false */",
"final",
"boolean",
"useHandoff",
",",
"/* : Boolean = config.useSoftHandoff */",
"final",
"CountDownLatch",
"latch",
")",
"{",
"String",
"msg",
"=",
"useHandoff",
"?",
"\" with handoff\"",
":",
"\"\"",
";",
"LOG",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Draining %s%s. Target count: %s, Current: %s\"",
",",
"config",
".",
"workUnitName",
",",
"msg",
",",
"targetCount",
",",
"cluster",
".",
"myWorkUnits",
".",
"size",
"(",
")",
")",
")",
";",
"if",
"(",
"targetCount",
">=",
"cluster",
".",
"myWorkUnits",
".",
"size",
"(",
")",
")",
"{",
"if",
"(",
"!",
"doShutdown",
")",
"{",
"return",
";",
"}",
"}",
"else",
"if",
"(",
"targetCount",
"==",
"0",
"&&",
"doShutdown",
")",
"{",
"cluster",
".",
"completeShutdown",
"(",
")",
";",
"}",
"final",
"int",
"amountToDrain",
"=",
"cluster",
".",
"myWorkUnits",
".",
"size",
"(",
")",
"-",
"targetCount",
";",
"String",
"msgPrefix",
"=",
"(",
"useHandoff",
")",
"?",
"\"Requesting handoff for\"",
":",
"\"Shutting down\"",
";",
"LOG",
".",
"info",
"(",
"\"{} {} of {} {} over {} seconds\"",
",",
"msgPrefix",
",",
"amountToDrain",
",",
"cluster",
".",
"myWorkUnits",
".",
"size",
"(",
")",
",",
"config",
".",
"workUnitName",
",",
"config",
".",
"drainTime",
")",
";",
"// Build a list of work units to hand off.",
"LinkedHashSet",
"<",
"String",
">",
"wuList",
"=",
"new",
"LinkedHashSet",
"<",
"String",
">",
"(",
"cluster",
".",
"myWorkUnits",
")",
";",
"wuList",
".",
"removeAll",
"(",
"cluster",
".",
"workUnitsPeggedToMe",
")",
";",
"final",
"ArrayList",
"<",
"String",
">",
"toHandOff",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"Iterator",
"<",
"String",
">",
"it",
"=",
"wuList",
".",
"iterator",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"amountToDrain",
";",
"it",
".",
"hasNext",
"(",
")",
"&&",
"i",
">",
"0",
";",
"--",
"i",
")",
"{",
"toHandOff",
".",
"add",
"(",
"it",
".",
"next",
"(",
")",
")",
";",
"}",
"final",
"int",
"drainInterval",
"=",
"(",
"int",
")",
"(",
"(",
"(",
"double",
")",
"config",
".",
"drainTime",
"/",
"(",
"double",
")",
"toHandOff",
".",
"size",
"(",
")",
")",
"*",
"1000",
")",
";",
"final",
"Iterator",
"<",
"String",
">",
"drainIt",
"=",
"toHandOff",
".",
"iterator",
"(",
")",
";",
"TimerTask",
"handoffTask",
"=",
"new",
"TimerTask",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"if",
"(",
"!",
"drainIt",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"targetCount",
"==",
"0",
"&&",
"doShutdown",
")",
"{",
"cluster",
".",
"completeShutdown",
"(",
")",
";",
"}",
"if",
"(",
"latch",
"!=",
"null",
")",
"{",
"latch",
".",
"countDown",
"(",
")",
";",
"}",
"return",
";",
"}",
"String",
"workUnit",
"=",
"drainIt",
".",
"next",
"(",
")",
";",
"if",
"(",
"useHandoff",
"&&",
"!",
"isPeggedToMe",
"(",
"workUnit",
")",
")",
"{",
"try",
"{",
"cluster",
".",
"requestHandoff",
"(",
"workUnit",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Problems trying to request handoff of \"",
"+",
"workUnit",
",",
"e",
")",
";",
"}",
"}",
"else",
"{",
"cluster",
".",
"shutdownWork",
"(",
"workUnit",
",",
"true",
")",
";",
"}",
"cluster",
".",
"schedule",
"(",
"this",
",",
"drainInterval",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"}",
";",
"LOG",
".",
"info",
"(",
"\"Releasing {} / {} work units over {} seconds: {}\"",
",",
"amountToDrain",
",",
"cluster",
".",
"myWorkUnits",
".",
"size",
"(",
")",
",",
"config",
".",
"drainTime",
",",
"Strings",
".",
"mkstring",
"(",
"toHandOff",
",",
"\", \"",
")",
")",
";",
"if",
"(",
"!",
"cluster",
".",
"myWorkUnits",
".",
"isEmpty",
"(",
")",
")",
"{",
"cluster",
".",
"schedule",
"(",
"handoffTask",
",",
"0",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}",
"}"
] |
Drains this node's share of the cluster workload down to a specific number
of work units over a period of time specified in the configuration with
soft handoff if enabled..
|
[
"Drains",
"this",
"node",
"s",
"share",
"of",
"the",
"cluster",
"workload",
"down",
"to",
"a",
"specific",
"number",
"of",
"work",
"units",
"over",
"a",
"period",
"of",
"time",
"specified",
"in",
"the",
"configuration",
"with",
"soft",
"handoff",
"if",
"enabled",
".."
] |
559785839981f460aaeba3c3fddff7fb667d9581
|
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/balancing/BalancingPolicy.java#L186-L254
|
153,508
|
jbundle/jbundle
|
main/schedule/src/main/java/org/jbundle/main/schedule/app/JobSchedulerProcess.java
|
JobSchedulerProcess.runCalendarEntry
|
public void runCalendarEntry(Map<String,Object> properties)
{
ProcessRunnerTask task = new ProcessRunnerTask(null, null, properties);
((Application)this.getTask().getApplication()).getTaskScheduler().addTask(task);
}
|
java
|
public void runCalendarEntry(Map<String,Object> properties)
{
ProcessRunnerTask task = new ProcessRunnerTask(null, null, properties);
((Application)this.getTask().getApplication()).getTaskScheduler().addTask(task);
}
|
[
"public",
"void",
"runCalendarEntry",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
")",
"{",
"ProcessRunnerTask",
"task",
"=",
"new",
"ProcessRunnerTask",
"(",
"null",
",",
"null",
",",
"properties",
")",
";",
"(",
"(",
"Application",
")",
"this",
".",
"getTask",
"(",
")",
".",
"getApplication",
"(",
")",
")",
".",
"getTaskScheduler",
"(",
")",
".",
"addTask",
"(",
"task",
")",
";",
"}"
] |
RunCalendarEntry Method.
|
[
"RunCalendarEntry",
"Method",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/schedule/src/main/java/org/jbundle/main/schedule/app/JobSchedulerProcess.java#L122-L126
|
153,509
|
jbundle/jbundle
|
app/program/script/src/main/java/org/jbundle/app/program/script/scan/CalendarScanListener.java
|
CalendarScanListener.getNewCalendarPath
|
public String getNewCalendarPath(File file)
{
StringTokenizer st = new StringTokenizer(file.getName());
int iPlace = 0, iMonth = 0, iYear = 0;
while (st.hasMoreTokens())
{
String strToken = st.nextToken();
if (strToken.length() > 2)
break; // Not a date
if (!Utility.isNumeric(strToken))
break; // Not a date
if (strToken.indexOf('.') != -1)
break;
int iNumber = Integer.parseInt(strToken);
iPlace++;
if (iPlace == 1)
{ // Month
if ((iNumber < 1) || (iNumber > 12))
break; // Invalid month
iMonth = iNumber;
}
else if (iPlace == 2)
{ // day
if ((iNumber < 1) || (iNumber > 31))
break; // Invalid day
}
else if (iPlace == 3)
{ // Year
if ((iNumber < 1) || (iNumber > 2020))
break; // Invalid year
iYear = iNumber;
if (iYear <= 20)
iYear = iYear + 2000;
return Integer.toString(iYear) + '/' + m_rgstrMonths[iMonth - 1];
}
}
return null; // Not formatted correctly
}
|
java
|
public String getNewCalendarPath(File file)
{
StringTokenizer st = new StringTokenizer(file.getName());
int iPlace = 0, iMonth = 0, iYear = 0;
while (st.hasMoreTokens())
{
String strToken = st.nextToken();
if (strToken.length() > 2)
break; // Not a date
if (!Utility.isNumeric(strToken))
break; // Not a date
if (strToken.indexOf('.') != -1)
break;
int iNumber = Integer.parseInt(strToken);
iPlace++;
if (iPlace == 1)
{ // Month
if ((iNumber < 1) || (iNumber > 12))
break; // Invalid month
iMonth = iNumber;
}
else if (iPlace == 2)
{ // day
if ((iNumber < 1) || (iNumber > 31))
break; // Invalid day
}
else if (iPlace == 3)
{ // Year
if ((iNumber < 1) || (iNumber > 2020))
break; // Invalid year
iYear = iNumber;
if (iYear <= 20)
iYear = iYear + 2000;
return Integer.toString(iYear) + '/' + m_rgstrMonths[iMonth - 1];
}
}
return null; // Not formatted correctly
}
|
[
"public",
"String",
"getNewCalendarPath",
"(",
"File",
"file",
")",
"{",
"StringTokenizer",
"st",
"=",
"new",
"StringTokenizer",
"(",
"file",
".",
"getName",
"(",
")",
")",
";",
"int",
"iPlace",
"=",
"0",
",",
"iMonth",
"=",
"0",
",",
"iYear",
"=",
"0",
";",
"while",
"(",
"st",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"strToken",
"=",
"st",
".",
"nextToken",
"(",
")",
";",
"if",
"(",
"strToken",
".",
"length",
"(",
")",
">",
"2",
")",
"break",
";",
"// Not a date",
"if",
"(",
"!",
"Utility",
".",
"isNumeric",
"(",
"strToken",
")",
")",
"break",
";",
"// Not a date",
"if",
"(",
"strToken",
".",
"indexOf",
"(",
"'",
"'",
")",
"!=",
"-",
"1",
")",
"break",
";",
"int",
"iNumber",
"=",
"Integer",
".",
"parseInt",
"(",
"strToken",
")",
";",
"iPlace",
"++",
";",
"if",
"(",
"iPlace",
"==",
"1",
")",
"{",
"// Month",
"if",
"(",
"(",
"iNumber",
"<",
"1",
")",
"||",
"(",
"iNumber",
">",
"12",
")",
")",
"break",
";",
"// Invalid month",
"iMonth",
"=",
"iNumber",
";",
"}",
"else",
"if",
"(",
"iPlace",
"==",
"2",
")",
"{",
"// day",
"if",
"(",
"(",
"iNumber",
"<",
"1",
")",
"||",
"(",
"iNumber",
">",
"31",
")",
")",
"break",
";",
"// Invalid day",
"}",
"else",
"if",
"(",
"iPlace",
"==",
"3",
")",
"{",
"// Year",
"if",
"(",
"(",
"iNumber",
"<",
"1",
")",
"||",
"(",
"iNumber",
">",
"2020",
")",
")",
"break",
";",
"// Invalid year",
"iYear",
"=",
"iNumber",
";",
"if",
"(",
"iYear",
"<=",
"20",
")",
"iYear",
"=",
"iYear",
"+",
"2000",
";",
"return",
"Integer",
".",
"toString",
"(",
"iYear",
")",
"+",
"'",
"'",
"+",
"m_rgstrMonths",
"[",
"iMonth",
"-",
"1",
"]",
";",
"}",
"}",
"return",
"null",
";",
"// Not formatted correctly",
"}"
] |
GetNewCalendarPath Method.
|
[
"GetNewCalendarPath",
"Method",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/script/src/main/java/org/jbundle/app/program/script/scan/CalendarScanListener.java#L108-L145
|
153,510
|
jbundle/jbundle
|
main/db/src/main/java/org/jbundle/main/user/db/UserContactHandler.java
|
UserContactHandler.getContactType
|
public ContactType getContactType(Person recPerson)
{
if (m_recContactType == null)
{
m_recContactType = (ContactType)Record.makeRecordFromClassName(ContactTypeModel.CONTACT_TYPE_FILE, this.getOwner().getRecord().findRecordOwner());
if (((Record)m_recContactType).getRecordOwner() != null)
((Record)m_recContactType).getRecordOwner().removeRecord((Record)m_recContactType);
}
return m_recContactType.getContactType(recPerson);
}
|
java
|
public ContactType getContactType(Person recPerson)
{
if (m_recContactType == null)
{
m_recContactType = (ContactType)Record.makeRecordFromClassName(ContactTypeModel.CONTACT_TYPE_FILE, this.getOwner().getRecord().findRecordOwner());
if (((Record)m_recContactType).getRecordOwner() != null)
((Record)m_recContactType).getRecordOwner().removeRecord((Record)m_recContactType);
}
return m_recContactType.getContactType(recPerson);
}
|
[
"public",
"ContactType",
"getContactType",
"(",
"Person",
"recPerson",
")",
"{",
"if",
"(",
"m_recContactType",
"==",
"null",
")",
"{",
"m_recContactType",
"=",
"(",
"ContactType",
")",
"Record",
".",
"makeRecordFromClassName",
"(",
"ContactTypeModel",
".",
"CONTACT_TYPE_FILE",
",",
"this",
".",
"getOwner",
"(",
")",
".",
"getRecord",
"(",
")",
".",
"findRecordOwner",
"(",
")",
")",
";",
"if",
"(",
"(",
"(",
"Record",
")",
"m_recContactType",
")",
".",
"getRecordOwner",
"(",
")",
"!=",
"null",
")",
"(",
"(",
"Record",
")",
"m_recContactType",
")",
".",
"getRecordOwner",
"(",
")",
".",
"removeRecord",
"(",
"(",
"Record",
")",
"m_recContactType",
")",
";",
"}",
"return",
"m_recContactType",
".",
"getContactType",
"(",
"recPerson",
")",
";",
"}"
] |
GetContactType Method.
|
[
"GetContactType",
"Method",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/db/src/main/java/org/jbundle/main/user/db/UserContactHandler.java#L107-L116
|
153,511
|
jbundle/jbundle
|
base/remote/src/main/java/org/jbundle/base/remote/BaseTaskSession.java
|
BaseTaskSession.init
|
public void init(BaseSession parentSessionObject, Record record, Map<String, Object> objectID)
{
if (m_application == null)
m_application = new MainApplication(null, null, null);
this.addToApplication();
super.init(parentSessionObject, record, objectID);
}
|
java
|
public void init(BaseSession parentSessionObject, Record record, Map<String, Object> objectID)
{
if (m_application == null)
m_application = new MainApplication(null, null, null);
this.addToApplication();
super.init(parentSessionObject, record, objectID);
}
|
[
"public",
"void",
"init",
"(",
"BaseSession",
"parentSessionObject",
",",
"Record",
"record",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"objectID",
")",
"{",
"if",
"(",
"m_application",
"==",
"null",
")",
"m_application",
"=",
"new",
"MainApplication",
"(",
"null",
",",
"null",
",",
"null",
")",
";",
"this",
".",
"addToApplication",
"(",
")",
";",
"super",
".",
"init",
"(",
"parentSessionObject",
",",
"record",
",",
"objectID",
")",
";",
"}"
] |
Build a new task session.
@param parentSessionObject Parent that created this session object (usually null for task sessions).
@param record Main record for this session (always null for task sessions).
@param objectID ObjectID of the object that this SessionObject represents (usually null for task sessions).
|
[
"Build",
"a",
"new",
"task",
"session",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/remote/src/main/java/org/jbundle/base/remote/BaseTaskSession.java#L92-L98
|
153,512
|
jbundle/jbundle
|
base/remote/src/main/java/org/jbundle/base/remote/BaseTaskSession.java
|
BaseTaskSession.removeFromApplication
|
public void removeFromApplication(boolean bFreeIfDone)
{
if (m_application == null)
return; // In free.
Application app = m_application;
m_application = null;
boolean bEmptyTaskList = app.removeTask(this); // Remove this session from the list
if (bFreeIfDone)
if (bEmptyTaskList)
app.free(); // No more tasks -> Quit app!
}
|
java
|
public void removeFromApplication(boolean bFreeIfDone)
{
if (m_application == null)
return; // In free.
Application app = m_application;
m_application = null;
boolean bEmptyTaskList = app.removeTask(this); // Remove this session from the list
if (bFreeIfDone)
if (bEmptyTaskList)
app.free(); // No more tasks -> Quit app!
}
|
[
"public",
"void",
"removeFromApplication",
"(",
"boolean",
"bFreeIfDone",
")",
"{",
"if",
"(",
"m_application",
"==",
"null",
")",
"return",
";",
"// In free.",
"Application",
"app",
"=",
"m_application",
";",
"m_application",
"=",
"null",
";",
"boolean",
"bEmptyTaskList",
"=",
"app",
".",
"removeTask",
"(",
"this",
")",
";",
"// Remove this session from the list",
"if",
"(",
"bFreeIfDone",
")",
"if",
"(",
"bEmptyTaskList",
")",
"app",
".",
"free",
"(",
")",
";",
"// No more tasks -> Quit app!",
"}"
] |
Remove this task or session to my parent application.
@param bFreeIfDone If true and the application is empty, free the application.
|
[
"Remove",
"this",
"task",
"or",
"session",
"to",
"my",
"parent",
"application",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/remote/src/main/java/org/jbundle/base/remote/BaseTaskSession.java#L119-L129
|
153,513
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/AbstractThinTableModel.java
|
AbstractThinTableModel.getFieldInfo
|
public Convert getFieldInfo(int iColumnIndex)
{
Converter converter = m_table.getRecord().getField(iColumnIndex);
if (converter != null)
converter = converter.getFieldConverter(); // Make sure you have the front converter.
return converter;
}
|
java
|
public Convert getFieldInfo(int iColumnIndex)
{
Converter converter = m_table.getRecord().getField(iColumnIndex);
if (converter != null)
converter = converter.getFieldConverter(); // Make sure you have the front converter.
return converter;
}
|
[
"public",
"Convert",
"getFieldInfo",
"(",
"int",
"iColumnIndex",
")",
"{",
"Converter",
"converter",
"=",
"m_table",
".",
"getRecord",
"(",
")",
".",
"getField",
"(",
"iColumnIndex",
")",
";",
"if",
"(",
"converter",
"!=",
"null",
")",
"converter",
"=",
"converter",
".",
"getFieldConverter",
"(",
")",
";",
"// Make sure you have the front converter.",
"return",
"converter",
";",
"}"
] |
Returns the field at columnIndex.
This should be overidden if don't want to just return the corresponding field in the record.
@param iColumn The column to get the field from.
@return The field in this column.
|
[
"Returns",
"the",
"field",
"at",
"columnIndex",
".",
"This",
"should",
"be",
"overidden",
"if",
"don",
"t",
"want",
"to",
"just",
"return",
"the",
"corresponding",
"field",
"in",
"the",
"record",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/AbstractThinTableModel.java#L108-L114
|
153,514
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/AbstractThinTableModel.java
|
AbstractThinTableModel.getColumnName
|
public String getColumnName(int iColumnIndex)
{
Convert fieldInfo = this.getFieldInfo(iColumnIndex);
if (fieldInfo != null)
return fieldInfo.getFieldDesc();
return Constants.BLANK;
}
|
java
|
public String getColumnName(int iColumnIndex)
{
Convert fieldInfo = this.getFieldInfo(iColumnIndex);
if (fieldInfo != null)
return fieldInfo.getFieldDesc();
return Constants.BLANK;
}
|
[
"public",
"String",
"getColumnName",
"(",
"int",
"iColumnIndex",
")",
"{",
"Convert",
"fieldInfo",
"=",
"this",
".",
"getFieldInfo",
"(",
"iColumnIndex",
")",
";",
"if",
"(",
"fieldInfo",
"!=",
"null",
")",
"return",
"fieldInfo",
".",
"getFieldDesc",
"(",
")",
";",
"return",
"Constants",
".",
"BLANK",
";",
"}"
] |
Returns the name of the column at columnIndex.
@param The column to get the name of.
@return The column's field description.
|
[
"Returns",
"the",
"name",
"of",
"the",
"column",
"at",
"columnIndex",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/AbstractThinTableModel.java#L226-L232
|
153,515
|
jbundle/jbundle
|
thin/base/message/src/main/java/org/jbundle/thin/base/message/TreeMessage.java
|
TreeMessage.keySet
|
public Iterator<String> keySet()
{
Node node = getNode(true);
NodeList nodeList = node.getChildNodes();
return new NodeIterator(nodeList);
}
|
java
|
public Iterator<String> keySet()
{
Node node = getNode(true);
NodeList nodeList = node.getChildNodes();
return new NodeIterator(nodeList);
}
|
[
"public",
"Iterator",
"<",
"String",
">",
"keySet",
"(",
")",
"{",
"Node",
"node",
"=",
"getNode",
"(",
"true",
")",
";",
"NodeList",
"nodeList",
"=",
"node",
".",
"getChildNodes",
"(",
")",
";",
"return",
"new",
"NodeIterator",
"(",
"nodeList",
")",
";",
"}"
] |
Get a Iterator of the keys in this message.
@return An iterator of the keys in this message.
|
[
"Get",
"a",
"Iterator",
"of",
"the",
"keys",
"in",
"this",
"message",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/TreeMessage.java#L139-L144
|
153,516
|
jbundle/jbundle
|
thin/base/message/src/main/java/org/jbundle/thin/base/message/TreeMessage.java
|
TreeMessage.getNodeCount
|
public int getNodeCount(String strKey)
{
int iCount = 0;
Node node = this.getNode(null, strKey, CreateMode.DONT_CREATE, false);
if (node != null)
{
String key = strKey;
if (key.lastIndexOf('/') != -1)
key = key.substring(key.lastIndexOf('/') + 1);
Node nodeStart = node.getParentNode();
NodeList nodeList = ((Element)nodeStart).getElementsByTagName(key);
if (nodeList != null)
{
for (int i = 0; i < nodeList.getLength(); i++)
{
if (nodeList.item(i).getParentNode() == nodeStart)
iCount++; // Get the last child.
}
}
}
return iCount; // Override this
}
|
java
|
public int getNodeCount(String strKey)
{
int iCount = 0;
Node node = this.getNode(null, strKey, CreateMode.DONT_CREATE, false);
if (node != null)
{
String key = strKey;
if (key.lastIndexOf('/') != -1)
key = key.substring(key.lastIndexOf('/') + 1);
Node nodeStart = node.getParentNode();
NodeList nodeList = ((Element)nodeStart).getElementsByTagName(key);
if (nodeList != null)
{
for (int i = 0; i < nodeList.getLength(); i++)
{
if (nodeList.item(i).getParentNode() == nodeStart)
iCount++; // Get the last child.
}
}
}
return iCount; // Override this
}
|
[
"public",
"int",
"getNodeCount",
"(",
"String",
"strKey",
")",
"{",
"int",
"iCount",
"=",
"0",
";",
"Node",
"node",
"=",
"this",
".",
"getNode",
"(",
"null",
",",
"strKey",
",",
"CreateMode",
".",
"DONT_CREATE",
",",
"false",
")",
";",
"if",
"(",
"node",
"!=",
"null",
")",
"{",
"String",
"key",
"=",
"strKey",
";",
"if",
"(",
"key",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"!=",
"-",
"1",
")",
"key",
"=",
"key",
".",
"substring",
"(",
"key",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
";",
"Node",
"nodeStart",
"=",
"node",
".",
"getParentNode",
"(",
")",
";",
"NodeList",
"nodeList",
"=",
"(",
"(",
"Element",
")",
"nodeStart",
")",
".",
"getElementsByTagName",
"(",
"key",
")",
";",
"if",
"(",
"nodeList",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nodeList",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"nodeList",
".",
"item",
"(",
"i",
")",
".",
"getParentNode",
"(",
")",
"==",
"nodeStart",
")",
"iCount",
"++",
";",
"// Get the last child.",
"}",
"}",
"}",
"return",
"iCount",
";",
"// Override this",
"}"
] |
Get the number of data nodes at this path in the data.
@param strKey The xpath key to the data.
@return The number of data nodes at this location.
|
[
"Get",
"the",
"number",
"of",
"data",
"nodes",
"at",
"this",
"path",
"in",
"the",
"data",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/TreeMessage.java#L186-L207
|
153,517
|
kirgor/enklib
|
common/src/main/java/com/kirgor/enklib/common/AsyncRunner.java
|
AsyncRunner.start
|
public void start(boolean isDaemon) {
synchronized (this) {
if (!isUsed) {
isUsed = true;
isRunning = true;
Thread thread = new Thread(new RunnableImpl());
thread.setDaemon(isDaemon);
thread.start();
} else {
throw new IllegalStateException("Async runner has been already used once.");
}
}
}
|
java
|
public void start(boolean isDaemon) {
synchronized (this) {
if (!isUsed) {
isUsed = true;
isRunning = true;
Thread thread = new Thread(new RunnableImpl());
thread.setDaemon(isDaemon);
thread.start();
} else {
throw new IllegalStateException("Async runner has been already used once.");
}
}
}
|
[
"public",
"void",
"start",
"(",
"boolean",
"isDaemon",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"!",
"isUsed",
")",
"{",
"isUsed",
"=",
"true",
";",
"isRunning",
"=",
"true",
";",
"Thread",
"thread",
"=",
"new",
"Thread",
"(",
"new",
"RunnableImpl",
"(",
")",
")",
";",
"thread",
".",
"setDaemon",
"(",
"isDaemon",
")",
";",
"thread",
".",
"start",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Async runner has been already used once.\"",
")",
";",
"}",
"}",
"}"
] |
Starts processing the items queue. This method can be called only once.
@param isDaemon Specifies whether underlying thread will be daemon thread.
|
[
"Starts",
"processing",
"the",
"items",
"queue",
".",
"This",
"method",
"can",
"be",
"called",
"only",
"once",
"."
] |
8a24db296dc43db5d8fe509cf64ace0a0c7be8f2
|
https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/common/src/main/java/com/kirgor/enklib/common/AsyncRunner.java#L22-L34
|
153,518
|
kirgor/enklib
|
common/src/main/java/com/kirgor/enklib/common/AsyncRunner.java
|
AsyncRunner.addItems
|
public void addItems(Iterable<T> items) {
synchronized (this) {
for (T i : items) {
this.items.add(i);
}
semaphore.release();
}
}
|
java
|
public void addItems(Iterable<T> items) {
synchronized (this) {
for (T i : items) {
this.items.add(i);
}
semaphore.release();
}
}
|
[
"public",
"void",
"addItems",
"(",
"Iterable",
"<",
"T",
">",
"items",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"for",
"(",
"T",
"i",
":",
"items",
")",
"{",
"this",
".",
"items",
".",
"add",
"(",
"i",
")",
";",
"}",
"semaphore",
".",
"release",
"(",
")",
";",
"}",
"}"
] |
Adds multiple items to the processing queue. Can be called even before the start.
This method is preferred to calling addItem multiple times in row, because it will
make synchronization only once.
@param items Items to add.
|
[
"Adds",
"multiple",
"items",
"to",
"the",
"processing",
"queue",
".",
"Can",
"be",
"called",
"even",
"before",
"the",
"start",
".",
"This",
"method",
"is",
"preferred",
"to",
"calling",
"addItem",
"multiple",
"times",
"in",
"row",
"because",
"it",
"will",
"make",
"synchronization",
"only",
"once",
"."
] |
8a24db296dc43db5d8fe509cf64ace0a0c7be8f2
|
https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/common/src/main/java/com/kirgor/enklib/common/AsyncRunner.java#L66-L73
|
153,519
|
lightblueseas/file-worker
|
src/main/java/de/alpharogroup/file/csv/CsvToSqlExtensions.java
|
CsvToSqlExtensions.extractSqlColumns
|
public static String extractSqlColumns(final String[] headers)
{
final StringBuffer sqlColumns = new StringBuffer();
sqlColumns.append("");
for (int i = 0; i < headers.length; i++)
{
sqlColumns.append(headers[i]);
if (i < headers.length - 1)
{
sqlColumns.append(", ");
}
else
{
sqlColumns.append("");
}
}
return sqlColumns.toString();
}
|
java
|
public static String extractSqlColumns(final String[] headers)
{
final StringBuffer sqlColumns = new StringBuffer();
sqlColumns.append("");
for (int i = 0; i < headers.length; i++)
{
sqlColumns.append(headers[i]);
if (i < headers.length - 1)
{
sqlColumns.append(", ");
}
else
{
sqlColumns.append("");
}
}
return sqlColumns.toString();
}
|
[
"public",
"static",
"String",
"extractSqlColumns",
"(",
"final",
"String",
"[",
"]",
"headers",
")",
"{",
"final",
"StringBuffer",
"sqlColumns",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"sqlColumns",
".",
"append",
"(",
"\"\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"headers",
".",
"length",
";",
"i",
"++",
")",
"{",
"sqlColumns",
".",
"append",
"(",
"headers",
"[",
"i",
"]",
")",
";",
"if",
"(",
"i",
"<",
"headers",
".",
"length",
"-",
"1",
")",
"{",
"sqlColumns",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"else",
"{",
"sqlColumns",
".",
"append",
"(",
"\"\"",
")",
";",
"}",
"}",
"return",
"sqlColumns",
".",
"toString",
"(",
")",
";",
"}"
] |
Extract sql columns.
@param headers
the headers
@return the string
|
[
"Extract",
"sql",
"columns",
"."
] |
2c81de10fb5d68de64c1abc3ed64ca681ce76da8
|
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/csv/CsvToSqlExtensions.java#L47-L64
|
153,520
|
AlexLandau/gdl-validation
|
src/main/java/net/alloyggp/griddle/indentation/GameIndenter.java
|
GameIndenter.reindentGameDescription
|
public static String reindentGameDescription(String gameRules) throws Exception {
List<Symbol> tokens = ParserHelper.scan(gameRules, true);
tokens = collapseWhitespaceTokens(tokens);
StringBuilder result = new StringBuilder();
int parensLevel = 0; // "( so far" minus ") so far"
int nestingLevel = 0; // "<=" and "or" level; when == parens level, use newlines
for (int i = 0; i < tokens.size(); i++) {
Symbol token = tokens.get(i);
switch (token.sym) {
case Symbols.CONSTANT:
case Symbols.VARIABLE:
result.append(token.value);
break;
case Symbols.POPEN:
result.append("(");
parensLevel++;
break;
case Symbols.PCLOSE:
result.append(")");
if (parensLevel > 0) {
parensLevel--;
}
if (nestingLevel > parensLevel) {
nestingLevel = parensLevel;
}
break;
case Symbols.IMPLIES:
result.append("<=");
nestingLevel++;
break;
case Symbols.NOT:
result.append("not");
break;
case Symbols.DISTINCT:
result.append("distinct");
break;
case Symbols.OR:
result.append("or");
nestingLevel++;
break;
case Symbols.EOF:
break;
case Symbols2.COMMENT:
result.append(token.value);
break;
case Symbols2.WHITESPACE:
result.append(rewriteWhitespace((String) token.value, tokens, i,
parensLevel, nestingLevel));
break;
}
}
return result.toString();
}
|
java
|
public static String reindentGameDescription(String gameRules) throws Exception {
List<Symbol> tokens = ParserHelper.scan(gameRules, true);
tokens = collapseWhitespaceTokens(tokens);
StringBuilder result = new StringBuilder();
int parensLevel = 0; // "( so far" minus ") so far"
int nestingLevel = 0; // "<=" and "or" level; when == parens level, use newlines
for (int i = 0; i < tokens.size(); i++) {
Symbol token = tokens.get(i);
switch (token.sym) {
case Symbols.CONSTANT:
case Symbols.VARIABLE:
result.append(token.value);
break;
case Symbols.POPEN:
result.append("(");
parensLevel++;
break;
case Symbols.PCLOSE:
result.append(")");
if (parensLevel > 0) {
parensLevel--;
}
if (nestingLevel > parensLevel) {
nestingLevel = parensLevel;
}
break;
case Symbols.IMPLIES:
result.append("<=");
nestingLevel++;
break;
case Symbols.NOT:
result.append("not");
break;
case Symbols.DISTINCT:
result.append("distinct");
break;
case Symbols.OR:
result.append("or");
nestingLevel++;
break;
case Symbols.EOF:
break;
case Symbols2.COMMENT:
result.append(token.value);
break;
case Symbols2.WHITESPACE:
result.append(rewriteWhitespace((String) token.value, tokens, i,
parensLevel, nestingLevel));
break;
}
}
return result.toString();
}
|
[
"public",
"static",
"String",
"reindentGameDescription",
"(",
"String",
"gameRules",
")",
"throws",
"Exception",
"{",
"List",
"<",
"Symbol",
">",
"tokens",
"=",
"ParserHelper",
".",
"scan",
"(",
"gameRules",
",",
"true",
")",
";",
"tokens",
"=",
"collapseWhitespaceTokens",
"(",
"tokens",
")",
";",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"int",
"parensLevel",
"=",
"0",
";",
"// \"( so far\" minus \") so far\"",
"int",
"nestingLevel",
"=",
"0",
";",
"// \"<=\" and \"or\" level; when == parens level, use newlines",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tokens",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Symbol",
"token",
"=",
"tokens",
".",
"get",
"(",
"i",
")",
";",
"switch",
"(",
"token",
".",
"sym",
")",
"{",
"case",
"Symbols",
".",
"CONSTANT",
":",
"case",
"Symbols",
".",
"VARIABLE",
":",
"result",
".",
"append",
"(",
"token",
".",
"value",
")",
";",
"break",
";",
"case",
"Symbols",
".",
"POPEN",
":",
"result",
".",
"append",
"(",
"\"(\"",
")",
";",
"parensLevel",
"++",
";",
"break",
";",
"case",
"Symbols",
".",
"PCLOSE",
":",
"result",
".",
"append",
"(",
"\")\"",
")",
";",
"if",
"(",
"parensLevel",
">",
"0",
")",
"{",
"parensLevel",
"--",
";",
"}",
"if",
"(",
"nestingLevel",
">",
"parensLevel",
")",
"{",
"nestingLevel",
"=",
"parensLevel",
";",
"}",
"break",
";",
"case",
"Symbols",
".",
"IMPLIES",
":",
"result",
".",
"append",
"(",
"\"<=\"",
")",
";",
"nestingLevel",
"++",
";",
"break",
";",
"case",
"Symbols",
".",
"NOT",
":",
"result",
".",
"append",
"(",
"\"not\"",
")",
";",
"break",
";",
"case",
"Symbols",
".",
"DISTINCT",
":",
"result",
".",
"append",
"(",
"\"distinct\"",
")",
";",
"break",
";",
"case",
"Symbols",
".",
"OR",
":",
"result",
".",
"append",
"(",
"\"or\"",
")",
";",
"nestingLevel",
"++",
";",
"break",
";",
"case",
"Symbols",
".",
"EOF",
":",
"break",
";",
"case",
"Symbols2",
".",
"COMMENT",
":",
"result",
".",
"append",
"(",
"token",
".",
"value",
")",
";",
"break",
";",
"case",
"Symbols2",
".",
"WHITESPACE",
":",
"result",
".",
"append",
"(",
"rewriteWhitespace",
"(",
"(",
"String",
")",
"token",
".",
"value",
",",
"tokens",
",",
"i",
",",
"parensLevel",
",",
"nestingLevel",
")",
")",
";",
"break",
";",
"}",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Returns null if the indentation fails.
|
[
"Returns",
"null",
"if",
"the",
"indentation",
"fails",
"."
] |
ec87cc9fdd8af32d79aa7d130b7cb062f29834fb
|
https://github.com/AlexLandau/gdl-validation/blob/ec87cc9fdd8af32d79aa7d130b7cb062f29834fb/src/main/java/net/alloyggp/griddle/indentation/GameIndenter.java#L17-L70
|
153,521
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/RecordReferenceField.java
|
RecordReferenceField.getReferenceRecord
|
public Record getReferenceRecord()
{
Record recordReference = this.getReferenceRecord(null);
if (recordReference != null)
if (recordReference.getRecordOwner() == null) // Only add it if it doesn't belong to any other screen.
{
RecordOwner recordOwner = null;
if (this.getRecord() != null)
recordOwner = Record.findRecordOwner(this.getRecord());
if (recordOwner != null)
recordOwner.addRecord(recordReference, false);
if (this.getRecord() != null)
{ // Make sure record is freed when this record is freed.
FreeOnFreeHandler listener = (FreeOnFreeHandler)this.getRecord().getListener(FreeOnFreeHandler.class);
while (listener != null)
{
if (listener.getDependentObject() == recordReference)
break; // listener is already there
listener = (FreeOnFreeHandler)listener.getListener(FreeOnFreeHandler.class);
}
if (listener == null)
this.getRecord().addListener(new FreeOnFreeHandler(recordReference));
}
}
return recordReference;
}
|
java
|
public Record getReferenceRecord()
{
Record recordReference = this.getReferenceRecord(null);
if (recordReference != null)
if (recordReference.getRecordOwner() == null) // Only add it if it doesn't belong to any other screen.
{
RecordOwner recordOwner = null;
if (this.getRecord() != null)
recordOwner = Record.findRecordOwner(this.getRecord());
if (recordOwner != null)
recordOwner.addRecord(recordReference, false);
if (this.getRecord() != null)
{ // Make sure record is freed when this record is freed.
FreeOnFreeHandler listener = (FreeOnFreeHandler)this.getRecord().getListener(FreeOnFreeHandler.class);
while (listener != null)
{
if (listener.getDependentObject() == recordReference)
break; // listener is already there
listener = (FreeOnFreeHandler)listener.getListener(FreeOnFreeHandler.class);
}
if (listener == null)
this.getRecord().addListener(new FreeOnFreeHandler(recordReference));
}
}
return recordReference;
}
|
[
"public",
"Record",
"getReferenceRecord",
"(",
")",
"{",
"Record",
"recordReference",
"=",
"this",
".",
"getReferenceRecord",
"(",
"null",
")",
";",
"if",
"(",
"recordReference",
"!=",
"null",
")",
"if",
"(",
"recordReference",
".",
"getRecordOwner",
"(",
")",
"==",
"null",
")",
"// Only add it if it doesn't belong to any other screen.",
"{",
"RecordOwner",
"recordOwner",
"=",
"null",
";",
"if",
"(",
"this",
".",
"getRecord",
"(",
")",
"!=",
"null",
")",
"recordOwner",
"=",
"Record",
".",
"findRecordOwner",
"(",
"this",
".",
"getRecord",
"(",
")",
")",
";",
"if",
"(",
"recordOwner",
"!=",
"null",
")",
"recordOwner",
".",
"addRecord",
"(",
"recordReference",
",",
"false",
")",
";",
"if",
"(",
"this",
".",
"getRecord",
"(",
")",
"!=",
"null",
")",
"{",
"// Make sure record is freed when this record is freed.",
"FreeOnFreeHandler",
"listener",
"=",
"(",
"FreeOnFreeHandler",
")",
"this",
".",
"getRecord",
"(",
")",
".",
"getListener",
"(",
"FreeOnFreeHandler",
".",
"class",
")",
";",
"while",
"(",
"listener",
"!=",
"null",
")",
"{",
"if",
"(",
"listener",
".",
"getDependentObject",
"(",
")",
"==",
"recordReference",
")",
"break",
";",
"// listener is already there",
"listener",
"=",
"(",
"FreeOnFreeHandler",
")",
"listener",
".",
"getListener",
"(",
"FreeOnFreeHandler",
".",
"class",
")",
";",
"}",
"if",
"(",
"listener",
"==",
"null",
")",
"this",
".",
"getRecord",
"(",
")",
".",
"addListener",
"(",
"new",
"FreeOnFreeHandler",
"(",
"recordReference",
")",
")",
";",
"}",
"}",
"return",
"recordReference",
";",
"}"
] |
Get the record that this field references.
This is the default method, so if a record by this name doesn't belong to this screen, add this one!
@return tour.db.Record
|
[
"Get",
"the",
"record",
"that",
"this",
"field",
"references",
".",
"This",
"is",
"the",
"default",
"method",
"so",
"if",
"a",
"record",
"by",
"this",
"name",
"doesn",
"t",
"belong",
"to",
"this",
"screen",
"add",
"this",
"one!"
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/RecordReferenceField.java#L69-L94
|
153,522
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/RecordReferenceField.java
|
RecordReferenceField.getReferenceRecord
|
public Record getReferenceRecord(RecordOwner screen, boolean bCreateIfNotFound)
{
if ((m_recordReference == null)
&& (bCreateIfNotFound))
{
RecordOwner recordOwner = screen;
if (recordOwner == null)
if (this.getRecord() != null)
recordOwner = Record.findRecordOwner(this.getRecord());
this.setReferenceRecord(this.makeReferenceRecord(recordOwner));
if (m_recordReference != null) // getReferenceRecord() would cause an endless loop
{
m_recordReference.setOpenMode(m_recordReference.getOpenMode() | DBConstants.OPEN_READ_ONLY); // By default a reference record can't be changed
if (screen == null)
if (recordOwner != null) // The caller wanted to have a record without a recordowner.
{
recordOwner.removeRecord(m_recordReference); // Set it is not on the recordowner's list
if (this.getRecord() != null)
{ // Make sure record is freed when this record is freed.
FreeOnFreeHandler listener = (FreeOnFreeHandler)this.getRecord().getListener(FreeOnFreeHandler.class);
while (listener != null)
{
if (listener.getDependentObject() == m_recordReference)
break; // listener is already there
listener = (FreeOnFreeHandler)listener.getListener(FreeOnFreeHandler.class);
}
if (listener == null)
this.getRecord().addListener(new FreeOnFreeHandler(m_recordReference));
}
}
}
}
else if ((m_recordReference != null)
&& (m_recordReference.getRecordOwner() == null)
&& (screen != null))
{
screen.addRecord(m_recordReference, false);
m_recordReference.setRecordOwner(screen); // Now you have a record owner.
}
return m_recordReference;
}
|
java
|
public Record getReferenceRecord(RecordOwner screen, boolean bCreateIfNotFound)
{
if ((m_recordReference == null)
&& (bCreateIfNotFound))
{
RecordOwner recordOwner = screen;
if (recordOwner == null)
if (this.getRecord() != null)
recordOwner = Record.findRecordOwner(this.getRecord());
this.setReferenceRecord(this.makeReferenceRecord(recordOwner));
if (m_recordReference != null) // getReferenceRecord() would cause an endless loop
{
m_recordReference.setOpenMode(m_recordReference.getOpenMode() | DBConstants.OPEN_READ_ONLY); // By default a reference record can't be changed
if (screen == null)
if (recordOwner != null) // The caller wanted to have a record without a recordowner.
{
recordOwner.removeRecord(m_recordReference); // Set it is not on the recordowner's list
if (this.getRecord() != null)
{ // Make sure record is freed when this record is freed.
FreeOnFreeHandler listener = (FreeOnFreeHandler)this.getRecord().getListener(FreeOnFreeHandler.class);
while (listener != null)
{
if (listener.getDependentObject() == m_recordReference)
break; // listener is already there
listener = (FreeOnFreeHandler)listener.getListener(FreeOnFreeHandler.class);
}
if (listener == null)
this.getRecord().addListener(new FreeOnFreeHandler(m_recordReference));
}
}
}
}
else if ((m_recordReference != null)
&& (m_recordReference.getRecordOwner() == null)
&& (screen != null))
{
screen.addRecord(m_recordReference, false);
m_recordReference.setRecordOwner(screen); // Now you have a record owner.
}
return m_recordReference;
}
|
[
"public",
"Record",
"getReferenceRecord",
"(",
"RecordOwner",
"screen",
",",
"boolean",
"bCreateIfNotFound",
")",
"{",
"if",
"(",
"(",
"m_recordReference",
"==",
"null",
")",
"&&",
"(",
"bCreateIfNotFound",
")",
")",
"{",
"RecordOwner",
"recordOwner",
"=",
"screen",
";",
"if",
"(",
"recordOwner",
"==",
"null",
")",
"if",
"(",
"this",
".",
"getRecord",
"(",
")",
"!=",
"null",
")",
"recordOwner",
"=",
"Record",
".",
"findRecordOwner",
"(",
"this",
".",
"getRecord",
"(",
")",
")",
";",
"this",
".",
"setReferenceRecord",
"(",
"this",
".",
"makeReferenceRecord",
"(",
"recordOwner",
")",
")",
";",
"if",
"(",
"m_recordReference",
"!=",
"null",
")",
"// getReferenceRecord() would cause an endless loop",
"{",
"m_recordReference",
".",
"setOpenMode",
"(",
"m_recordReference",
".",
"getOpenMode",
"(",
")",
"|",
"DBConstants",
".",
"OPEN_READ_ONLY",
")",
";",
"// By default a reference record can't be changed",
"if",
"(",
"screen",
"==",
"null",
")",
"if",
"(",
"recordOwner",
"!=",
"null",
")",
"// The caller wanted to have a record without a recordowner.",
"{",
"recordOwner",
".",
"removeRecord",
"(",
"m_recordReference",
")",
";",
"// Set it is not on the recordowner's list",
"if",
"(",
"this",
".",
"getRecord",
"(",
")",
"!=",
"null",
")",
"{",
"// Make sure record is freed when this record is freed.",
"FreeOnFreeHandler",
"listener",
"=",
"(",
"FreeOnFreeHandler",
")",
"this",
".",
"getRecord",
"(",
")",
".",
"getListener",
"(",
"FreeOnFreeHandler",
".",
"class",
")",
";",
"while",
"(",
"listener",
"!=",
"null",
")",
"{",
"if",
"(",
"listener",
".",
"getDependentObject",
"(",
")",
"==",
"m_recordReference",
")",
"break",
";",
"// listener is already there",
"listener",
"=",
"(",
"FreeOnFreeHandler",
")",
"listener",
".",
"getListener",
"(",
"FreeOnFreeHandler",
".",
"class",
")",
";",
"}",
"if",
"(",
"listener",
"==",
"null",
")",
"this",
".",
"getRecord",
"(",
")",
".",
"addListener",
"(",
"new",
"FreeOnFreeHandler",
"(",
"m_recordReference",
")",
")",
";",
"}",
"}",
"}",
"}",
"else",
"if",
"(",
"(",
"m_recordReference",
"!=",
"null",
")",
"&&",
"(",
"m_recordReference",
".",
"getRecordOwner",
"(",
")",
"==",
"null",
")",
"&&",
"(",
"screen",
"!=",
"null",
")",
")",
"{",
"screen",
".",
"addRecord",
"(",
"m_recordReference",
",",
"false",
")",
";",
"m_recordReference",
".",
"setRecordOwner",
"(",
"screen",
")",
";",
"// Now you have a record owner.",
"}",
"return",
"m_recordReference",
";",
"}"
] |
Get the record that this field references.
@param recordOwner The recordowner to initialize the reference record to if it doesn't already exist.
@param bCreateIfNotFound Create the record reference if it isn't set up yet.
@return tour.db.Record The record this field references.
|
[
"Get",
"the",
"record",
"that",
"this",
"field",
"references",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/RecordReferenceField.java#L110-L150
|
153,523
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/RecordReferenceField.java
|
RecordReferenceField.setReferenceRecord
|
public void setReferenceRecord(Record record)
{
if (m_recordReference != record)
{
if (m_recordReference != null)
{ // Take behaviors off old references
// You only want to disconnect the referenced record (not free it).
if (this.getRecord() != null)
{
FreeOnFreeHandler freeListener = (FreeOnFreeHandler)this.getRecord().getListener(FreeOnFreeHandler.class);
while (freeListener != null)
{
if (freeListener.getDependentObject() == m_recordReference)
{
freeListener.setDependentObject(null);
this.getRecord().removeListener(freeListener, true);
break;
}
freeListener = (FreeOnFreeHandler)freeListener.getListener(FreeOnFreeHandler.class);
}
}
ClearFieldReferenceOnCloseHandler listener = (ClearFieldReferenceOnCloseHandler)m_recordReference.getListener(ClearFieldReferenceOnCloseHandler.class.getName());
while (listener != null)
{
if (listener.getField() == this)
{
Record recordTemp = m_recordReference;
m_recordReference = null; // Cancel echo
recordTemp.removeListener(listener, true);
listener = null; // Got it!
}
else
listener = (ClearFieldReferenceOnCloseHandler)listener.getListener(ClearFieldReferenceOnCloseHandler.class.getName());
}
}
if (record != null)
{ // Make sure reference is cleared when record is discarded
record.addListener(new ClearFieldReferenceOnCloseHandler(this));
}
m_recordReference = record;
}
}
|
java
|
public void setReferenceRecord(Record record)
{
if (m_recordReference != record)
{
if (m_recordReference != null)
{ // Take behaviors off old references
// You only want to disconnect the referenced record (not free it).
if (this.getRecord() != null)
{
FreeOnFreeHandler freeListener = (FreeOnFreeHandler)this.getRecord().getListener(FreeOnFreeHandler.class);
while (freeListener != null)
{
if (freeListener.getDependentObject() == m_recordReference)
{
freeListener.setDependentObject(null);
this.getRecord().removeListener(freeListener, true);
break;
}
freeListener = (FreeOnFreeHandler)freeListener.getListener(FreeOnFreeHandler.class);
}
}
ClearFieldReferenceOnCloseHandler listener = (ClearFieldReferenceOnCloseHandler)m_recordReference.getListener(ClearFieldReferenceOnCloseHandler.class.getName());
while (listener != null)
{
if (listener.getField() == this)
{
Record recordTemp = m_recordReference;
m_recordReference = null; // Cancel echo
recordTemp.removeListener(listener, true);
listener = null; // Got it!
}
else
listener = (ClearFieldReferenceOnCloseHandler)listener.getListener(ClearFieldReferenceOnCloseHandler.class.getName());
}
}
if (record != null)
{ // Make sure reference is cleared when record is discarded
record.addListener(new ClearFieldReferenceOnCloseHandler(this));
}
m_recordReference = record;
}
}
|
[
"public",
"void",
"setReferenceRecord",
"(",
"Record",
"record",
")",
"{",
"if",
"(",
"m_recordReference",
"!=",
"record",
")",
"{",
"if",
"(",
"m_recordReference",
"!=",
"null",
")",
"{",
"// Take behaviors off old references",
"// You only want to disconnect the referenced record (not free it).",
"if",
"(",
"this",
".",
"getRecord",
"(",
")",
"!=",
"null",
")",
"{",
"FreeOnFreeHandler",
"freeListener",
"=",
"(",
"FreeOnFreeHandler",
")",
"this",
".",
"getRecord",
"(",
")",
".",
"getListener",
"(",
"FreeOnFreeHandler",
".",
"class",
")",
";",
"while",
"(",
"freeListener",
"!=",
"null",
")",
"{",
"if",
"(",
"freeListener",
".",
"getDependentObject",
"(",
")",
"==",
"m_recordReference",
")",
"{",
"freeListener",
".",
"setDependentObject",
"(",
"null",
")",
";",
"this",
".",
"getRecord",
"(",
")",
".",
"removeListener",
"(",
"freeListener",
",",
"true",
")",
";",
"break",
";",
"}",
"freeListener",
"=",
"(",
"FreeOnFreeHandler",
")",
"freeListener",
".",
"getListener",
"(",
"FreeOnFreeHandler",
".",
"class",
")",
";",
"}",
"}",
"ClearFieldReferenceOnCloseHandler",
"listener",
"=",
"(",
"ClearFieldReferenceOnCloseHandler",
")",
"m_recordReference",
".",
"getListener",
"(",
"ClearFieldReferenceOnCloseHandler",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"while",
"(",
"listener",
"!=",
"null",
")",
"{",
"if",
"(",
"listener",
".",
"getField",
"(",
")",
"==",
"this",
")",
"{",
"Record",
"recordTemp",
"=",
"m_recordReference",
";",
"m_recordReference",
"=",
"null",
";",
"// Cancel echo",
"recordTemp",
".",
"removeListener",
"(",
"listener",
",",
"true",
")",
";",
"listener",
"=",
"null",
";",
"// Got it!",
"}",
"else",
"listener",
"=",
"(",
"ClearFieldReferenceOnCloseHandler",
")",
"listener",
".",
"getListener",
"(",
"ClearFieldReferenceOnCloseHandler",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"record",
"!=",
"null",
")",
"{",
"// Make sure reference is cleared when record is discarded",
"record",
".",
"addListener",
"(",
"new",
"ClearFieldReferenceOnCloseHandler",
"(",
"this",
")",
")",
";",
"}",
"m_recordReference",
"=",
"record",
";",
"}",
"}"
] |
Set the record that this field references.
@param record The record to set as the record reference.
|
[
"Set",
"the",
"record",
"that",
"this",
"field",
"references",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/RecordReferenceField.java#L189-L231
|
153,524
|
the-fascinator/plugin-subscriber-solrEventLog
|
src/main/java/com/googlecode/fascinator/subscriber/solrEventLog/SolrEventLogSubscriber.java
|
SolrEventLogSubscriber.init
|
@Override
public void init(File jsonFile) throws SubscriberException {
try {
setConfig(new JsonSimpleConfig(jsonFile));
} catch (IOException ioe) {
throw new SubscriberException(ioe);
}
}
|
java
|
@Override
public void init(File jsonFile) throws SubscriberException {
try {
setConfig(new JsonSimpleConfig(jsonFile));
} catch (IOException ioe) {
throw new SubscriberException(ioe);
}
}
|
[
"@",
"Override",
"public",
"void",
"init",
"(",
"File",
"jsonFile",
")",
"throws",
"SubscriberException",
"{",
"try",
"{",
"setConfig",
"(",
"new",
"JsonSimpleConfig",
"(",
"jsonFile",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"SubscriberException",
"(",
"ioe",
")",
";",
"}",
"}"
] |
Initializes the plugin using the specified JSON configuration
@param jsonFile JSON configuration file
@throws SubscriberException if there was an error in initialization
|
[
"Initializes",
"the",
"plugin",
"using",
"the",
"specified",
"JSON",
"configuration"
] |
2c9da188887a622a6d43d33ea9099aff53a0516d
|
https://github.com/the-fascinator/plugin-subscriber-solrEventLog/blob/2c9da188887a622a6d43d33ea9099aff53a0516d/src/main/java/com/googlecode/fascinator/subscriber/solrEventLog/SolrEventLogSubscriber.java#L223-L230
|
153,525
|
the-fascinator/plugin-subscriber-solrEventLog
|
src/main/java/com/googlecode/fascinator/subscriber/solrEventLog/SolrEventLogSubscriber.java
|
SolrEventLogSubscriber.setConfig
|
private void setConfig(JsonSimpleConfig config) throws SubscriberException {
try {
// Find our solr index
uri = new URI(config.getString(null, "subscriber", getId(), "uri"));
if (uri == null) {
throw new SubscriberException("No Solr URI provided");
}
core = new CommonsHttpSolrServer(uri.toURL());
boolean serverOnline = false;
int retryCount = 0;
// Small sleep whilst the solr index is still coming online
while (!serverOnline) {
Thread.sleep(200);
// Make sure it is online
try {
core.ping();
serverOnline = true;
} catch (Exception ex) {
retryCount++;
log.error("Server not yet online. Attempt: "+retryCount + " of "+SOLR_SERVER_RETRY_COUNT,ex);
if(retryCount == SOLR_SERVER_RETRY_COUNT) {
throw ex;
}
}
}
// Buffering
docBuffer = new ArrayList<String>();
bufferSize = 0;
bufferOldest = 0;
bufferDocLimit = config.getInteger(BUFFER_LIMIT_DOCS,
"subscriber", getId(), "buffer", "docLimit");
bufferSizeLimit = config.getInteger(BUFFER_LIMIT_SIZE,
"subscriber", getId(), "buffer", "sizeLimit");
bufferTimeLimit = config.getInteger(BUFFER_LIMIT_TIME,
"subscriber", getId(), "buffer", "timeLimit");
// Timeout 'tick' for buffer (10s)
timer = new Timer("SolrEventLog:" + this.toString(), true);
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
checkTimeout();
}
}, 0, 10000);
} catch (Exception ex) {
throw new SubscriberException(ex);
}
}
|
java
|
private void setConfig(JsonSimpleConfig config) throws SubscriberException {
try {
// Find our solr index
uri = new URI(config.getString(null, "subscriber", getId(), "uri"));
if (uri == null) {
throw new SubscriberException("No Solr URI provided");
}
core = new CommonsHttpSolrServer(uri.toURL());
boolean serverOnline = false;
int retryCount = 0;
// Small sleep whilst the solr index is still coming online
while (!serverOnline) {
Thread.sleep(200);
// Make sure it is online
try {
core.ping();
serverOnline = true;
} catch (Exception ex) {
retryCount++;
log.error("Server not yet online. Attempt: "+retryCount + " of "+SOLR_SERVER_RETRY_COUNT,ex);
if(retryCount == SOLR_SERVER_RETRY_COUNT) {
throw ex;
}
}
}
// Buffering
docBuffer = new ArrayList<String>();
bufferSize = 0;
bufferOldest = 0;
bufferDocLimit = config.getInteger(BUFFER_LIMIT_DOCS,
"subscriber", getId(), "buffer", "docLimit");
bufferSizeLimit = config.getInteger(BUFFER_LIMIT_SIZE,
"subscriber", getId(), "buffer", "sizeLimit");
bufferTimeLimit = config.getInteger(BUFFER_LIMIT_TIME,
"subscriber", getId(), "buffer", "timeLimit");
// Timeout 'tick' for buffer (10s)
timer = new Timer("SolrEventLog:" + this.toString(), true);
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
checkTimeout();
}
}, 0, 10000);
} catch (Exception ex) {
throw new SubscriberException(ex);
}
}
|
[
"private",
"void",
"setConfig",
"(",
"JsonSimpleConfig",
"config",
")",
"throws",
"SubscriberException",
"{",
"try",
"{",
"// Find our solr index",
"uri",
"=",
"new",
"URI",
"(",
"config",
".",
"getString",
"(",
"null",
",",
"\"subscriber\"",
",",
"getId",
"(",
")",
",",
"\"uri\"",
")",
")",
";",
"if",
"(",
"uri",
"==",
"null",
")",
"{",
"throw",
"new",
"SubscriberException",
"(",
"\"No Solr URI provided\"",
")",
";",
"}",
"core",
"=",
"new",
"CommonsHttpSolrServer",
"(",
"uri",
".",
"toURL",
"(",
")",
")",
";",
"boolean",
"serverOnline",
"=",
"false",
";",
"int",
"retryCount",
"=",
"0",
";",
"// Small sleep whilst the solr index is still coming online",
"while",
"(",
"!",
"serverOnline",
")",
"{",
"Thread",
".",
"sleep",
"(",
"200",
")",
";",
"// Make sure it is online",
"try",
"{",
"core",
".",
"ping",
"(",
")",
";",
"serverOnline",
"=",
"true",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"retryCount",
"++",
";",
"log",
".",
"error",
"(",
"\"Server not yet online. Attempt: \"",
"+",
"retryCount",
"+",
"\" of \"",
"+",
"SOLR_SERVER_RETRY_COUNT",
",",
"ex",
")",
";",
"if",
"(",
"retryCount",
"==",
"SOLR_SERVER_RETRY_COUNT",
")",
"{",
"throw",
"ex",
";",
"}",
"}",
"}",
"// Buffering",
"docBuffer",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"bufferSize",
"=",
"0",
";",
"bufferOldest",
"=",
"0",
";",
"bufferDocLimit",
"=",
"config",
".",
"getInteger",
"(",
"BUFFER_LIMIT_DOCS",
",",
"\"subscriber\"",
",",
"getId",
"(",
")",
",",
"\"buffer\"",
",",
"\"docLimit\"",
")",
";",
"bufferSizeLimit",
"=",
"config",
".",
"getInteger",
"(",
"BUFFER_LIMIT_SIZE",
",",
"\"subscriber\"",
",",
"getId",
"(",
")",
",",
"\"buffer\"",
",",
"\"sizeLimit\"",
")",
";",
"bufferTimeLimit",
"=",
"config",
".",
"getInteger",
"(",
"BUFFER_LIMIT_TIME",
",",
"\"subscriber\"",
",",
"getId",
"(",
")",
",",
"\"buffer\"",
",",
"\"timeLimit\"",
")",
";",
"// Timeout 'tick' for buffer (10s)",
"timer",
"=",
"new",
"Timer",
"(",
"\"SolrEventLog:\"",
"+",
"this",
".",
"toString",
"(",
")",
",",
"true",
")",
";",
"timer",
".",
"scheduleAtFixedRate",
"(",
"new",
"TimerTask",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"checkTimeout",
"(",
")",
";",
"}",
"}",
",",
"0",
",",
"10000",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"SubscriberException",
"(",
"ex",
")",
";",
"}",
"}"
] |
Initialization of Solr Access Control plugin
@param config The configuration to use
@throws AuthenticationException if fails to initialize
|
[
"Initialization",
"of",
"Solr",
"Access",
"Control",
"plugin"
] |
2c9da188887a622a6d43d33ea9099aff53a0516d
|
https://github.com/the-fascinator/plugin-subscriber-solrEventLog/blob/2c9da188887a622a6d43d33ea9099aff53a0516d/src/main/java/com/googlecode/fascinator/subscriber/solrEventLog/SolrEventLogSubscriber.java#L238-L289
|
153,526
|
the-fascinator/plugin-subscriber-solrEventLog
|
src/main/java/com/googlecode/fascinator/subscriber/solrEventLog/SolrEventLogSubscriber.java
|
SolrEventLogSubscriber.checkBuffer
|
private void checkBuffer() {
// Doc count limit
if (docBuffer.size() >= bufferDocLimit) {
log.debug("=== Buffer check: Doc limit reached '{}'", docBuffer.size());
submitBuffer(false);
return;
}
// Size limit
if (bufferSize > bufferSizeLimit) {
log.debug("=== Buffer check: Size exceeded '{}'", bufferSize);
submitBuffer(false);
return;
}
// Time limit
long age = ((new Date().getTime()) - bufferOldest) / 1000;
if (age > bufferTimeLimit) {
log.debug("=== Buffer check: Age exceeded '{}s'", age);
submitBuffer(false);
return;
}
}
|
java
|
private void checkBuffer() {
// Doc count limit
if (docBuffer.size() >= bufferDocLimit) {
log.debug("=== Buffer check: Doc limit reached '{}'", docBuffer.size());
submitBuffer(false);
return;
}
// Size limit
if (bufferSize > bufferSizeLimit) {
log.debug("=== Buffer check: Size exceeded '{}'", bufferSize);
submitBuffer(false);
return;
}
// Time limit
long age = ((new Date().getTime()) - bufferOldest) / 1000;
if (age > bufferTimeLimit) {
log.debug("=== Buffer check: Age exceeded '{}s'", age);
submitBuffer(false);
return;
}
}
|
[
"private",
"void",
"checkBuffer",
"(",
")",
"{",
"// Doc count limit",
"if",
"(",
"docBuffer",
".",
"size",
"(",
")",
">=",
"bufferDocLimit",
")",
"{",
"log",
".",
"debug",
"(",
"\"=== Buffer check: Doc limit reached '{}'\"",
",",
"docBuffer",
".",
"size",
"(",
")",
")",
";",
"submitBuffer",
"(",
"false",
")",
";",
"return",
";",
"}",
"// Size limit",
"if",
"(",
"bufferSize",
">",
"bufferSizeLimit",
")",
"{",
"log",
".",
"debug",
"(",
"\"=== Buffer check: Size exceeded '{}'\"",
",",
"bufferSize",
")",
";",
"submitBuffer",
"(",
"false",
")",
";",
"return",
";",
"}",
"// Time limit",
"long",
"age",
"=",
"(",
"(",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
")",
"-",
"bufferOldest",
")",
"/",
"1000",
";",
"if",
"(",
"age",
">",
"bufferTimeLimit",
")",
"{",
"log",
".",
"debug",
"(",
"\"=== Buffer check: Age exceeded '{}s'\"",
",",
"age",
")",
";",
"submitBuffer",
"(",
"false",
")",
";",
"return",
";",
"}",
"}"
] |
Assess the document buffer and decide is it is ready to submit
|
[
"Assess",
"the",
"document",
"buffer",
"and",
"decide",
"is",
"it",
"is",
"ready",
"to",
"submit"
] |
2c9da188887a622a6d43d33ea9099aff53a0516d
|
https://github.com/the-fascinator/plugin-subscriber-solrEventLog/blob/2c9da188887a622a6d43d33ea9099aff53a0516d/src/main/java/com/googlecode/fascinator/subscriber/solrEventLog/SolrEventLogSubscriber.java#L340-L360
|
153,527
|
the-fascinator/plugin-subscriber-solrEventLog
|
src/main/java/com/googlecode/fascinator/subscriber/solrEventLog/SolrEventLogSubscriber.java
|
SolrEventLogSubscriber.addToIndex
|
private void addToIndex(Map<String, String> param) throws Exception {
String doc = writeUpdateString(param);
addToBuffer(doc);
}
|
java
|
private void addToIndex(Map<String, String> param) throws Exception {
String doc = writeUpdateString(param);
addToBuffer(doc);
}
|
[
"private",
"void",
"addToIndex",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"param",
")",
"throws",
"Exception",
"{",
"String",
"doc",
"=",
"writeUpdateString",
"(",
"param",
")",
";",
"addToBuffer",
"(",
"doc",
")",
";",
"}"
] |
Add the event to the index
@param param : Map of key/value pairs to add to the index
@throws Exception if there was an error
|
[
"Add",
"the",
"event",
"to",
"the",
"index"
] |
2c9da188887a622a6d43d33ea9099aff53a0516d
|
https://github.com/the-fascinator/plugin-subscriber-solrEventLog/blob/2c9da188887a622a6d43d33ea9099aff53a0516d/src/main/java/com/googlecode/fascinator/subscriber/solrEventLog/SolrEventLogSubscriber.java#L437-L440
|
153,528
|
the-fascinator/plugin-subscriber-solrEventLog
|
src/main/java/com/googlecode/fascinator/subscriber/solrEventLog/SolrEventLogSubscriber.java
|
SolrEventLogSubscriber.writeUpdateString
|
private String writeUpdateString(Map<String, String> param) {
StringBuffer fieldStringBuffer = new StringBuffer();
for(Entry<String, String> entry : param.entrySet()){
fieldStringBuffer.append("<field name=\"").append(entry.getKey()).append("\">")
.append(StringEscapeUtils.escapeXml(entry.getValue())).append("</field>");
}
fieldStringBuffer.insert(0,"<add><doc>").append("</doc></add>");
return fieldStringBuffer.toString();
}
|
java
|
private String writeUpdateString(Map<String, String> param) {
StringBuffer fieldStringBuffer = new StringBuffer();
for(Entry<String, String> entry : param.entrySet()){
fieldStringBuffer.append("<field name=\"").append(entry.getKey()).append("\">")
.append(StringEscapeUtils.escapeXml(entry.getValue())).append("</field>");
}
fieldStringBuffer.insert(0,"<add><doc>").append("</doc></add>");
return fieldStringBuffer.toString();
}
|
[
"private",
"String",
"writeUpdateString",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"param",
")",
"{",
"StringBuffer",
"fieldStringBuffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"param",
".",
"entrySet",
"(",
")",
")",
"{",
"fieldStringBuffer",
".",
"append",
"(",
"\"<field name=\\\"\"",
")",
".",
"append",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
".",
"append",
"(",
"\"\\\">\"",
")",
".",
"append",
"(",
"StringEscapeUtils",
".",
"escapeXml",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
")",
".",
"append",
"(",
"\"</field>\"",
")",
";",
"}",
"fieldStringBuffer",
".",
"insert",
"(",
"0",
",",
"\"<add><doc>\"",
")",
".",
"append",
"(",
"\"</doc></add>\"",
")",
";",
"return",
"fieldStringBuffer",
".",
"toString",
"(",
")",
";",
"}"
] |
Turn a a message into a Solr document
@param param : Map of key/value pairs to add to the index
|
[
"Turn",
"a",
"a",
"message",
"into",
"a",
"Solr",
"document"
] |
2c9da188887a622a6d43d33ea9099aff53a0516d
|
https://github.com/the-fascinator/plugin-subscriber-solrEventLog/blob/2c9da188887a622a6d43d33ea9099aff53a0516d/src/main/java/com/googlecode/fascinator/subscriber/solrEventLog/SolrEventLogSubscriber.java#L447-L456
|
153,529
|
the-fascinator/plugin-subscriber-solrEventLog
|
src/main/java/com/googlecode/fascinator/subscriber/solrEventLog/SolrEventLogSubscriber.java
|
SolrEventLogSubscriber.onEvent
|
@Override
public void onEvent(Map<String, String> param) throws SubscriberException {
try {
addToIndex(param);
} catch (Exception e) {
throw new SubscriberException("Fail to add log to solr"
+ e.getMessage());
}
}
|
java
|
@Override
public void onEvent(Map<String, String> param) throws SubscriberException {
try {
addToIndex(param);
} catch (Exception e) {
throw new SubscriberException("Fail to add log to solr"
+ e.getMessage());
}
}
|
[
"@",
"Override",
"public",
"void",
"onEvent",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"param",
")",
"throws",
"SubscriberException",
"{",
"try",
"{",
"addToIndex",
"(",
"param",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"SubscriberException",
"(",
"\"Fail to add log to solr\"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Method to fire for incoming events
@param param : Map of key/value pairs to add to the index
@throws SubscriberException if there was an error
|
[
"Method",
"to",
"fire",
"for",
"incoming",
"events"
] |
2c9da188887a622a6d43d33ea9099aff53a0516d
|
https://github.com/the-fascinator/plugin-subscriber-solrEventLog/blob/2c9da188887a622a6d43d33ea9099aff53a0516d/src/main/java/com/googlecode/fascinator/subscriber/solrEventLog/SolrEventLogSubscriber.java#L464-L472
|
153,530
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/util/concurrent/ConcurrentArraySet.java
|
ConcurrentArraySet.iterator
|
@Override
public Iterator<T> iterator()
{
writeLock.lock();
if (iterator == null)
{
iterator = new Iter();
}
else
{
iterator.reset();
}
return iterator;
}
|
java
|
@Override
public Iterator<T> iterator()
{
writeLock.lock();
if (iterator == null)
{
iterator = new Iter();
}
else
{
iterator.reset();
}
return iterator;
}
|
[
"@",
"Override",
"public",
"Iterator",
"<",
"T",
">",
"iterator",
"(",
")",
"{",
"writeLock",
".",
"lock",
"(",
")",
";",
"if",
"(",
"iterator",
"==",
"null",
")",
"{",
"iterator",
"=",
"new",
"Iter",
"(",
")",
";",
"}",
"else",
"{",
"iterator",
".",
"reset",
"(",
")",
";",
"}",
"return",
"iterator",
";",
"}"
] |
Returned iterator is write-locked until hasNext returns false or unlock
method is called.
@return
|
[
"Returned",
"iterator",
"is",
"write",
"-",
"locked",
"until",
"hasNext",
"returns",
"false",
"or",
"unlock",
"method",
"is",
"called",
"."
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/concurrent/ConcurrentArraySet.java#L73-L86
|
153,531
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/report/parser/XMLParser.java
|
XMLParser.printHtmlData
|
public void printHtmlData(PrintWriter out, InputStream streamIn)
{
String str = null;
if (streamIn != null)
str = Utility.transferURLStream(null, null, new InputStreamReader(streamIn));
if ((str == null) || (str.length() == 0))
str = this.getDefaultXML();
this.parseHtmlData(out, str);
}
|
java
|
public void printHtmlData(PrintWriter out, InputStream streamIn)
{
String str = null;
if (streamIn != null)
str = Utility.transferURLStream(null, null, new InputStreamReader(streamIn));
if ((str == null) || (str.length() == 0))
str = this.getDefaultXML();
this.parseHtmlData(out, str);
}
|
[
"public",
"void",
"printHtmlData",
"(",
"PrintWriter",
"out",
",",
"InputStream",
"streamIn",
")",
"{",
"String",
"str",
"=",
"null",
";",
"if",
"(",
"streamIn",
"!=",
"null",
")",
"str",
"=",
"Utility",
".",
"transferURLStream",
"(",
"null",
",",
"null",
",",
"new",
"InputStreamReader",
"(",
"streamIn",
")",
")",
";",
"if",
"(",
"(",
"str",
"==",
"null",
")",
"||",
"(",
"str",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"str",
"=",
"this",
".",
"getDefaultXML",
"(",
")",
";",
"this",
".",
"parseHtmlData",
"(",
"out",
",",
"str",
")",
";",
"}"
] |
Output this screen using HTML.
Override this to print your XML.
|
[
"Output",
"this",
"screen",
"using",
"HTML",
".",
"Override",
"this",
"to",
"print",
"your",
"XML",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/report/parser/XMLParser.java#L60-L68
|
153,532
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/report/parser/XMLParser.java
|
XMLParser.getTagData
|
public String getTagData(String strData, String strTag)
{
int iStartData = strData.indexOf('<' + strTag + '>');
if (iStartData == -1)
return null;
iStartData = iStartData + strTag.length() + 2;
int iEndData = strData.indexOf("</" + strTag + '>');
if (iStartData == -1)
return null;
return strData.substring(iStartData, iEndData);
}
|
java
|
public String getTagData(String strData, String strTag)
{
int iStartData = strData.indexOf('<' + strTag + '>');
if (iStartData == -1)
return null;
iStartData = iStartData + strTag.length() + 2;
int iEndData = strData.indexOf("</" + strTag + '>');
if (iStartData == -1)
return null;
return strData.substring(iStartData, iEndData);
}
|
[
"public",
"String",
"getTagData",
"(",
"String",
"strData",
",",
"String",
"strTag",
")",
"{",
"int",
"iStartData",
"=",
"strData",
".",
"indexOf",
"(",
"'",
"'",
"+",
"strTag",
"+",
"'",
"'",
")",
";",
"if",
"(",
"iStartData",
"==",
"-",
"1",
")",
"return",
"null",
";",
"iStartData",
"=",
"iStartData",
"+",
"strTag",
".",
"length",
"(",
")",
"+",
"2",
";",
"int",
"iEndData",
"=",
"strData",
".",
"indexOf",
"(",
"\"</\"",
"+",
"strTag",
"+",
"'",
"'",
")",
";",
"if",
"(",
"iStartData",
"==",
"-",
"1",
")",
"return",
"null",
";",
"return",
"strData",
".",
"substring",
"(",
"iStartData",
",",
"iEndData",
")",
";",
"}"
] |
Find the data between these XML tags.
@param strData The XML code to find the tags in.
@param strTag The tag to find.
|
[
"Find",
"the",
"data",
"between",
"these",
"XML",
"tags",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/report/parser/XMLParser.java#L81-L91
|
153,533
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/report/parser/XMLParser.java
|
XMLParser.getProperty
|
public String getProperty(String strProperty, String strParams)
{
String strValue = null;
strValue = this.parseArg(strProperty, strParams);
if (strValue == null)
strValue = this.getRecordOwner().getProperty(strProperty);
return strValue;
}
|
java
|
public String getProperty(String strProperty, String strParams)
{
String strValue = null;
strValue = this.parseArg(strProperty, strParams);
if (strValue == null)
strValue = this.getRecordOwner().getProperty(strProperty);
return strValue;
}
|
[
"public",
"String",
"getProperty",
"(",
"String",
"strProperty",
",",
"String",
"strParams",
")",
"{",
"String",
"strValue",
"=",
"null",
";",
"strValue",
"=",
"this",
".",
"parseArg",
"(",
"strProperty",
",",
"strParams",
")",
";",
"if",
"(",
"strValue",
"==",
"null",
")",
"strValue",
"=",
"this",
".",
"getRecordOwner",
"(",
")",
".",
"getProperty",
"(",
"strProperty",
")",
";",
"return",
"strValue",
";",
"}"
] |
Get this property.
First, see if it's in the param tag, then work your way up the hierarchy.
|
[
"Get",
"this",
"property",
".",
"First",
"see",
"if",
"it",
"s",
"in",
"the",
"param",
"tag",
"then",
"work",
"your",
"way",
"up",
"the",
"hierarchy",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/report/parser/XMLParser.java#L206-L213
|
153,534
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/report/parser/XMLParser.java
|
XMLParser.parseArg
|
public String parseArg(String strProperty, String strURL)
{
if ((strURL == null) || (strProperty == null))
return null;
int iStartIndex = strURL.toUpperCase().indexOf(strProperty.toUpperCase() + '='); // Start of first param (0 if no ?)
if (iStartIndex == -1)
return null;
iStartIndex = iStartIndex + strProperty.length() + 1;
if (iStartIndex < strURL.length())
if (strURL.charAt(iStartIndex) == '\"')
iStartIndex++;
int iEndIndex = strURL.indexOf(' ', iStartIndex);
if (iEndIndex == -1)
iEndIndex = strURL.length();
if (strURL.charAt(iEndIndex - 1) == '\"')
iEndIndex--;
return strURL.substring(iStartIndex, iEndIndex);
}
|
java
|
public String parseArg(String strProperty, String strURL)
{
if ((strURL == null) || (strProperty == null))
return null;
int iStartIndex = strURL.toUpperCase().indexOf(strProperty.toUpperCase() + '='); // Start of first param (0 if no ?)
if (iStartIndex == -1)
return null;
iStartIndex = iStartIndex + strProperty.length() + 1;
if (iStartIndex < strURL.length())
if (strURL.charAt(iStartIndex) == '\"')
iStartIndex++;
int iEndIndex = strURL.indexOf(' ', iStartIndex);
if (iEndIndex == -1)
iEndIndex = strURL.length();
if (strURL.charAt(iEndIndex - 1) == '\"')
iEndIndex--;
return strURL.substring(iStartIndex, iEndIndex);
}
|
[
"public",
"String",
"parseArg",
"(",
"String",
"strProperty",
",",
"String",
"strURL",
")",
"{",
"if",
"(",
"(",
"strURL",
"==",
"null",
")",
"||",
"(",
"strProperty",
"==",
"null",
")",
")",
"return",
"null",
";",
"int",
"iStartIndex",
"=",
"strURL",
".",
"toUpperCase",
"(",
")",
".",
"indexOf",
"(",
"strProperty",
".",
"toUpperCase",
"(",
")",
"+",
"'",
"'",
")",
";",
"// Start of first param (0 if no ?)",
"if",
"(",
"iStartIndex",
"==",
"-",
"1",
")",
"return",
"null",
";",
"iStartIndex",
"=",
"iStartIndex",
"+",
"strProperty",
".",
"length",
"(",
")",
"+",
"1",
";",
"if",
"(",
"iStartIndex",
"<",
"strURL",
".",
"length",
"(",
")",
")",
"if",
"(",
"strURL",
".",
"charAt",
"(",
"iStartIndex",
")",
"==",
"'",
"'",
")",
"iStartIndex",
"++",
";",
"int",
"iEndIndex",
"=",
"strURL",
".",
"indexOf",
"(",
"'",
"'",
",",
"iStartIndex",
")",
";",
"if",
"(",
"iEndIndex",
"==",
"-",
"1",
")",
"iEndIndex",
"=",
"strURL",
".",
"length",
"(",
")",
";",
"if",
"(",
"strURL",
".",
"charAt",
"(",
"iEndIndex",
"-",
"1",
")",
"==",
"'",
"'",
")",
"iEndIndex",
"--",
";",
"return",
"strURL",
".",
"substring",
"(",
"iStartIndex",
",",
"iEndIndex",
")",
";",
"}"
] |
Parse this URL formatted string into properties.
|
[
"Parse",
"this",
"URL",
"formatted",
"string",
"into",
"properties",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/report/parser/XMLParser.java#L217-L234
|
153,535
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/sort/quadratic/Bubble.java
|
Bubble.sort
|
public static <E extends Comparable<E>> void sort(List<E> list) {
boolean swapped = true;
while(swapped) {
swapped = false;
for(int i = 0; i < (list.size() - 1); i++) {
if(list.get(i).compareTo(list.get(i + 1)) > 0) {
TrivialSwap.swap(list, i, i + 1);
swapped = true;
}
}
}
}
|
java
|
public static <E extends Comparable<E>> void sort(List<E> list) {
boolean swapped = true;
while(swapped) {
swapped = false;
for(int i = 0; i < (list.size() - 1); i++) {
if(list.get(i).compareTo(list.get(i + 1)) > 0) {
TrivialSwap.swap(list, i, i + 1);
swapped = true;
}
}
}
}
|
[
"public",
"static",
"<",
"E",
"extends",
"Comparable",
"<",
"E",
">",
">",
"void",
"sort",
"(",
"List",
"<",
"E",
">",
"list",
")",
"{",
"boolean",
"swapped",
"=",
"true",
";",
"while",
"(",
"swapped",
")",
"{",
"swapped",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"(",
"list",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"list",
".",
"get",
"(",
"i",
")",
".",
"compareTo",
"(",
"list",
".",
"get",
"(",
"i",
"+",
"1",
")",
")",
">",
"0",
")",
"{",
"TrivialSwap",
".",
"swap",
"(",
"list",
",",
"i",
",",
"i",
"+",
"1",
")",
";",
"swapped",
"=",
"true",
";",
"}",
"}",
"}",
"}"
] |
Sort the list in ascending order using this algorithm. The run time of this algorithm depends on the
implementation of the list since it has elements added and removed from it.
@param <E> the type of elements in this list.
@param list the list that we want to sort
|
[
"Sort",
"the",
"list",
"in",
"ascending",
"order",
"using",
"this",
"algorithm",
".",
"The",
"run",
"time",
"of",
"this",
"algorithm",
"depends",
"on",
"the",
"implementation",
"of",
"the",
"list",
"since",
"it",
"has",
"elements",
"added",
"and",
"removed",
"from",
"it",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/sort/quadratic/Bubble.java#L62-L76
|
153,536
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/util/stream/ObserverSpliterator.java
|
ObserverSpliterator.offer
|
public boolean offer(T t)
{
try
{
return queue.offer(t, offerTimeout, timeUnit);
}
catch (InterruptedException ex)
{
throw new IllegalArgumentException(ex);
}
}
|
java
|
public boolean offer(T t)
{
try
{
return queue.offer(t, offerTimeout, timeUnit);
}
catch (InterruptedException ex)
{
throw new IllegalArgumentException(ex);
}
}
|
[
"public",
"boolean",
"offer",
"(",
"T",
"t",
")",
"{",
"try",
"{",
"return",
"queue",
".",
"offer",
"(",
"t",
",",
"offerTimeout",
",",
"timeUnit",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"ex",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"ex",
")",
";",
"}",
"}"
] |
Offers new item. Return true if item was consumed.
False if another thread was not waiting for the item.
@param t
@return
|
[
"Offers",
"new",
"item",
".",
"Return",
"true",
"if",
"item",
"was",
"consumed",
".",
"False",
"if",
"another",
"thread",
"was",
"not",
"waiting",
"for",
"the",
"item",
"."
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/stream/ObserverSpliterator.java#L75-L85
|
153,537
|
lightblueseas/file-worker
|
src/main/java/de/alpharogroup/file/zip/Zipper.java
|
Zipper.zip
|
public Optional<ZipErrorCodes> zip()
{
try (FileOutputStream fos = new FileOutputStream(this.zipFile);
ZipOutputStream zos = new ZipOutputStream(fos);)
{
if (!this.directoryToZip.exists())
{
return Optional.of(ZipErrorCodes.DIRECTORY_TO_ZIP_DOES_NOT_EXIST);
}
if (!this.zipFile.exists())
{
return Optional.of(ZipErrorCodes.ZIP_FILE_DOES_NOT_EXIST);
}
if (0 < this.zipLevel)
{
zos.setLevel(this.zipLevel);
}
else
{
zos.setLevel(9);
}
if (null != this.zipFileComment)
{
zos.setComment(this.zipFileComment);
}
if (0 < this.compressionMethod)
{
zos.setMethod(this.compressionMethod);
}
this.zipFiles(this.directoryToZip, zos);
zos.flush();
zos.finish();
fos.flush();
}
catch (IOException e)
{
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
return Optional.of(ZipErrorCodes.IO_ERROR);
}
return Optional.empty();
}
|
java
|
public Optional<ZipErrorCodes> zip()
{
try (FileOutputStream fos = new FileOutputStream(this.zipFile);
ZipOutputStream zos = new ZipOutputStream(fos);)
{
if (!this.directoryToZip.exists())
{
return Optional.of(ZipErrorCodes.DIRECTORY_TO_ZIP_DOES_NOT_EXIST);
}
if (!this.zipFile.exists())
{
return Optional.of(ZipErrorCodes.ZIP_FILE_DOES_NOT_EXIST);
}
if (0 < this.zipLevel)
{
zos.setLevel(this.zipLevel);
}
else
{
zos.setLevel(9);
}
if (null != this.zipFileComment)
{
zos.setComment(this.zipFileComment);
}
if (0 < this.compressionMethod)
{
zos.setMethod(this.compressionMethod);
}
this.zipFiles(this.directoryToZip, zos);
zos.flush();
zos.finish();
fos.flush();
}
catch (IOException e)
{
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
return Optional.of(ZipErrorCodes.IO_ERROR);
}
return Optional.empty();
}
|
[
"public",
"Optional",
"<",
"ZipErrorCodes",
">",
"zip",
"(",
")",
"{",
"try",
"(",
"FileOutputStream",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"this",
".",
"zipFile",
")",
";",
"ZipOutputStream",
"zos",
"=",
"new",
"ZipOutputStream",
"(",
"fos",
")",
";",
")",
"{",
"if",
"(",
"!",
"this",
".",
"directoryToZip",
".",
"exists",
"(",
")",
")",
"{",
"return",
"Optional",
".",
"of",
"(",
"ZipErrorCodes",
".",
"DIRECTORY_TO_ZIP_DOES_NOT_EXIST",
")",
";",
"}",
"if",
"(",
"!",
"this",
".",
"zipFile",
".",
"exists",
"(",
")",
")",
"{",
"return",
"Optional",
".",
"of",
"(",
"ZipErrorCodes",
".",
"ZIP_FILE_DOES_NOT_EXIST",
")",
";",
"}",
"if",
"(",
"0",
"<",
"this",
".",
"zipLevel",
")",
"{",
"zos",
".",
"setLevel",
"(",
"this",
".",
"zipLevel",
")",
";",
"}",
"else",
"{",
"zos",
".",
"setLevel",
"(",
"9",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"this",
".",
"zipFileComment",
")",
"{",
"zos",
".",
"setComment",
"(",
"this",
".",
"zipFileComment",
")",
";",
"}",
"if",
"(",
"0",
"<",
"this",
".",
"compressionMethod",
")",
"{",
"zos",
".",
"setMethod",
"(",
"this",
".",
"compressionMethod",
")",
";",
"}",
"this",
".",
"zipFiles",
"(",
"this",
".",
"directoryToZip",
",",
"zos",
")",
";",
"zos",
".",
"flush",
"(",
")",
";",
"zos",
".",
"finish",
"(",
")",
";",
"fos",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"e",
".",
"getLocalizedMessage",
"(",
")",
",",
"e",
")",
";",
"return",
"Optional",
".",
"of",
"(",
"ZipErrorCodes",
".",
"IO_ERROR",
")",
";",
"}",
"return",
"Optional",
".",
"empty",
"(",
")",
";",
"}"
] |
Zip the given files of this objects
@return the optional with the possibles errors
|
[
"Zip",
"the",
"given",
"files",
"of",
"this",
"objects"
] |
2c81de10fb5d68de64c1abc3ed64ca681ce76da8
|
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/zip/Zipper.java#L142-L183
|
153,538
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java
|
SolverWorldModelInterface.setConnector
|
protected boolean setConnector() {
if (this.host == null) {
log.error("No host value set, cannot set up socket connector.");
return false;
}
if (this.port < 0 || this.port > 65535) {
log.error("Port value is invalid {}.", Integer.valueOf(this.port));
return false;
}
if (this.executors == null) {
this.executors = new ExecutorFilter(1);
}
this.connector = new NioSocketConnector();
this.connector.getSessionConfig().setWriterIdleTime(
SolverWorldModelInterface.TIMEOUT_PERIOD /2);
this.connector.getSessionConfig().setReaderIdleTime(
(int) Math.ceil(TIMEOUT_PERIOD * 1.1));
if (!this.connector.getFilterChain().contains(
WorldModelSolverProtocolCodecFactory.CODEC_NAME)) {
this.connector.getFilterChain().addLast(
WorldModelSolverProtocolCodecFactory.CODEC_NAME,
new ProtocolCodecFilter(
new WorldModelSolverProtocolCodecFactory(true)));
}
this.connector.getFilterChain().addLast("ExecutorPool", this.executors);
this.connector.setHandler(this.ioHandler);
log.debug("Connector set up successful.");
return true;
}
|
java
|
protected boolean setConnector() {
if (this.host == null) {
log.error("No host value set, cannot set up socket connector.");
return false;
}
if (this.port < 0 || this.port > 65535) {
log.error("Port value is invalid {}.", Integer.valueOf(this.port));
return false;
}
if (this.executors == null) {
this.executors = new ExecutorFilter(1);
}
this.connector = new NioSocketConnector();
this.connector.getSessionConfig().setWriterIdleTime(
SolverWorldModelInterface.TIMEOUT_PERIOD /2);
this.connector.getSessionConfig().setReaderIdleTime(
(int) Math.ceil(TIMEOUT_PERIOD * 1.1));
if (!this.connector.getFilterChain().contains(
WorldModelSolverProtocolCodecFactory.CODEC_NAME)) {
this.connector.getFilterChain().addLast(
WorldModelSolverProtocolCodecFactory.CODEC_NAME,
new ProtocolCodecFilter(
new WorldModelSolverProtocolCodecFactory(true)));
}
this.connector.getFilterChain().addLast("ExecutorPool", this.executors);
this.connector.setHandler(this.ioHandler);
log.debug("Connector set up successful.");
return true;
}
|
[
"protected",
"boolean",
"setConnector",
"(",
")",
"{",
"if",
"(",
"this",
".",
"host",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"No host value set, cannot set up socket connector.\"",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"this",
".",
"port",
"<",
"0",
"||",
"this",
".",
"port",
">",
"65535",
")",
"{",
"log",
".",
"error",
"(",
"\"Port value is invalid {}.\"",
",",
"Integer",
".",
"valueOf",
"(",
"this",
".",
"port",
")",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"this",
".",
"executors",
"==",
"null",
")",
"{",
"this",
".",
"executors",
"=",
"new",
"ExecutorFilter",
"(",
"1",
")",
";",
"}",
"this",
".",
"connector",
"=",
"new",
"NioSocketConnector",
"(",
")",
";",
"this",
".",
"connector",
".",
"getSessionConfig",
"(",
")",
".",
"setWriterIdleTime",
"(",
"SolverWorldModelInterface",
".",
"TIMEOUT_PERIOD",
"/",
"2",
")",
";",
"this",
".",
"connector",
".",
"getSessionConfig",
"(",
")",
".",
"setReaderIdleTime",
"(",
"(",
"int",
")",
"Math",
".",
"ceil",
"(",
"TIMEOUT_PERIOD",
"*",
"1.1",
")",
")",
";",
"if",
"(",
"!",
"this",
".",
"connector",
".",
"getFilterChain",
"(",
")",
".",
"contains",
"(",
"WorldModelSolverProtocolCodecFactory",
".",
"CODEC_NAME",
")",
")",
"{",
"this",
".",
"connector",
".",
"getFilterChain",
"(",
")",
".",
"addLast",
"(",
"WorldModelSolverProtocolCodecFactory",
".",
"CODEC_NAME",
",",
"new",
"ProtocolCodecFilter",
"(",
"new",
"WorldModelSolverProtocolCodecFactory",
"(",
"true",
")",
")",
")",
";",
"}",
"this",
".",
"connector",
".",
"getFilterChain",
"(",
")",
".",
"addLast",
"(",
"\"ExecutorPool\"",
",",
"this",
".",
"executors",
")",
";",
"this",
".",
"connector",
".",
"setHandler",
"(",
"this",
".",
"ioHandler",
")",
";",
"log",
".",
"debug",
"(",
"\"Connector set up successful.\"",
")",
";",
"return",
"true",
";",
"}"
] |
Sets the MINA connector and establishes the connection to the world
model. Adds protocol filters.
@return {@code true} if connection is set-up correctly, else
{@code false}.
|
[
"Sets",
"the",
"MINA",
"connector",
"and",
"establishes",
"the",
"connection",
"to",
"the",
"world",
"model",
".",
"Adds",
"protocol",
"filters",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java#L276-L304
|
153,539
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java
|
SolverWorldModelInterface.announceAttributes
|
protected void announceAttributes() {
if (this.originString == null) {
log.error("Unable to announce solution types, no Origin String set.");
return;
}
this.sentAttrSpecifications = true;
if (this.attributes.size() > 0) {
AttributeAnnounceMessage message = new AttributeAnnounceMessage();
message.setOrigin(this.originString);
ArrayList<AttributeSpecification> specificationList = new ArrayList<AttributeSpecification>();
specificationList.addAll(this.attributes);
AttributeSpecification[] specs = new AttributeSpecification[specificationList
.size()];
int specAlias = 0;
for (AttributeSpecification spec : specificationList) {
specs[specAlias] = spec;
spec.setAlias(specAlias++);
this.attributeAliases.put(spec.getAttributeName(),
Integer.valueOf(spec.getAlias()));
}
message.setTypeSpecifications(specs);
this.session.write(message);
this.sentAttrSpecifications = true;
}
}
|
java
|
protected void announceAttributes() {
if (this.originString == null) {
log.error("Unable to announce solution types, no Origin String set.");
return;
}
this.sentAttrSpecifications = true;
if (this.attributes.size() > 0) {
AttributeAnnounceMessage message = new AttributeAnnounceMessage();
message.setOrigin(this.originString);
ArrayList<AttributeSpecification> specificationList = new ArrayList<AttributeSpecification>();
specificationList.addAll(this.attributes);
AttributeSpecification[] specs = new AttributeSpecification[specificationList
.size()];
int specAlias = 0;
for (AttributeSpecification spec : specificationList) {
specs[specAlias] = spec;
spec.setAlias(specAlias++);
this.attributeAliases.put(spec.getAttributeName(),
Integer.valueOf(spec.getAlias()));
}
message.setTypeSpecifications(specs);
this.session.write(message);
this.sentAttrSpecifications = true;
}
}
|
[
"protected",
"void",
"announceAttributes",
"(",
")",
"{",
"if",
"(",
"this",
".",
"originString",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Unable to announce solution types, no Origin String set.\"",
")",
";",
"return",
";",
"}",
"this",
".",
"sentAttrSpecifications",
"=",
"true",
";",
"if",
"(",
"this",
".",
"attributes",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"AttributeAnnounceMessage",
"message",
"=",
"new",
"AttributeAnnounceMessage",
"(",
")",
";",
"message",
".",
"setOrigin",
"(",
"this",
".",
"originString",
")",
";",
"ArrayList",
"<",
"AttributeSpecification",
">",
"specificationList",
"=",
"new",
"ArrayList",
"<",
"AttributeSpecification",
">",
"(",
")",
";",
"specificationList",
".",
"addAll",
"(",
"this",
".",
"attributes",
")",
";",
"AttributeSpecification",
"[",
"]",
"specs",
"=",
"new",
"AttributeSpecification",
"[",
"specificationList",
".",
"size",
"(",
")",
"]",
";",
"int",
"specAlias",
"=",
"0",
";",
"for",
"(",
"AttributeSpecification",
"spec",
":",
"specificationList",
")",
"{",
"specs",
"[",
"specAlias",
"]",
"=",
"spec",
";",
"spec",
".",
"setAlias",
"(",
"specAlias",
"++",
")",
";",
"this",
".",
"attributeAliases",
".",
"put",
"(",
"spec",
".",
"getAttributeName",
"(",
")",
",",
"Integer",
".",
"valueOf",
"(",
"spec",
".",
"getAlias",
"(",
")",
")",
")",
";",
"}",
"message",
".",
"setTypeSpecifications",
"(",
"specs",
")",
";",
"this",
".",
"session",
".",
"write",
"(",
"message",
")",
";",
"this",
".",
"sentAttrSpecifications",
"=",
"true",
";",
"}",
"}"
] |
Sends the Attribute aliases to the world model.
|
[
"Sends",
"the",
"Attribute",
"aliases",
"to",
"the",
"world",
"model",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java#L560-L586
|
153,540
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java
|
SolverWorldModelInterface.updateAttribute
|
public boolean updateAttribute(final Attribute attribute) {
if (!this.sentAttrSpecifications) {
log.error("Haven't sent type specifications yet, can't send solutions.");
return false;
}
AttributeUpdateMessage message = new AttributeUpdateMessage();
message.setCreateId(this.createIds);
message.setAttributes(new Attribute[] { attribute });
Integer attributeAlias = this.attributeAliases.get(attribute
.getAttributeName());
if (attributeAlias == null) {
log.error(
"Cannot update attribute: Unregistered attribute type: {}",
attribute.getAttributeName());
return false;
}
attribute.setAttributeNameAlias(attributeAlias.intValue());
this.session.write(message);
log.debug("Sent {} to {}", message, this);
return true;
}
|
java
|
public boolean updateAttribute(final Attribute attribute) {
if (!this.sentAttrSpecifications) {
log.error("Haven't sent type specifications yet, can't send solutions.");
return false;
}
AttributeUpdateMessage message = new AttributeUpdateMessage();
message.setCreateId(this.createIds);
message.setAttributes(new Attribute[] { attribute });
Integer attributeAlias = this.attributeAliases.get(attribute
.getAttributeName());
if (attributeAlias == null) {
log.error(
"Cannot update attribute: Unregistered attribute type: {}",
attribute.getAttributeName());
return false;
}
attribute.setAttributeNameAlias(attributeAlias.intValue());
this.session.write(message);
log.debug("Sent {} to {}", message, this);
return true;
}
|
[
"public",
"boolean",
"updateAttribute",
"(",
"final",
"Attribute",
"attribute",
")",
"{",
"if",
"(",
"!",
"this",
".",
"sentAttrSpecifications",
")",
"{",
"log",
".",
"error",
"(",
"\"Haven't sent type specifications yet, can't send solutions.\"",
")",
";",
"return",
"false",
";",
"}",
"AttributeUpdateMessage",
"message",
"=",
"new",
"AttributeUpdateMessage",
"(",
")",
";",
"message",
".",
"setCreateId",
"(",
"this",
".",
"createIds",
")",
";",
"message",
".",
"setAttributes",
"(",
"new",
"Attribute",
"[",
"]",
"{",
"attribute",
"}",
")",
";",
"Integer",
"attributeAlias",
"=",
"this",
".",
"attributeAliases",
".",
"get",
"(",
"attribute",
".",
"getAttributeName",
"(",
")",
")",
";",
"if",
"(",
"attributeAlias",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Cannot update attribute: Unregistered attribute type: {}\"",
",",
"attribute",
".",
"getAttributeName",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"attribute",
".",
"setAttributeNameAlias",
"(",
"attributeAlias",
".",
"intValue",
"(",
")",
")",
";",
"this",
".",
"session",
".",
"write",
"(",
"message",
")",
";",
"log",
".",
"debug",
"(",
"\"Sent {} to {}\"",
",",
"message",
",",
"this",
")",
";",
"return",
"true",
";",
"}"
] |
Sends a single Attribute update message to the world model.
@param attribute
the new Attribute value.
@return {@code true} if the message was sent successfully, else
{@code false}.
|
[
"Sends",
"a",
"single",
"Attribute",
"update",
"message",
"to",
"the",
"world",
"model",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java#L746-L773
|
153,541
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java
|
SolverWorldModelInterface.updateAttributes
|
public boolean updateAttributes(final Collection<Attribute> attrToSend) {
if (!this.sentAttrSpecifications) {
log.error("Haven't sent type specifications yet, can't send solutions.");
return false;
}
for (Iterator<Attribute> iter = attrToSend.iterator(); iter.hasNext();) {
Attribute soln = iter.next();
Integer solutionTypeAlias = this.attributeAliases.get(soln
.getAttributeName());
if (solutionTypeAlias == null) {
log.error(
"Cannot send solution: Unregistered attribute type: {}",
soln.getAttributeName());
iter.remove();
continue;
}
soln.setAttributeNameAlias(solutionTypeAlias.intValue());
}
AttributeUpdateMessage message = new AttributeUpdateMessage();
message.setCreateId(this.createIds);
message.setAttributes(attrToSend.toArray(new Attribute[] {}));
this.session.write(message);
log.debug("Sent {} to {}", message, this);
return true;
}
|
java
|
public boolean updateAttributes(final Collection<Attribute> attrToSend) {
if (!this.sentAttrSpecifications) {
log.error("Haven't sent type specifications yet, can't send solutions.");
return false;
}
for (Iterator<Attribute> iter = attrToSend.iterator(); iter.hasNext();) {
Attribute soln = iter.next();
Integer solutionTypeAlias = this.attributeAliases.get(soln
.getAttributeName());
if (solutionTypeAlias == null) {
log.error(
"Cannot send solution: Unregistered attribute type: {}",
soln.getAttributeName());
iter.remove();
continue;
}
soln.setAttributeNameAlias(solutionTypeAlias.intValue());
}
AttributeUpdateMessage message = new AttributeUpdateMessage();
message.setCreateId(this.createIds);
message.setAttributes(attrToSend.toArray(new Attribute[] {}));
this.session.write(message);
log.debug("Sent {} to {}", message, this);
return true;
}
|
[
"public",
"boolean",
"updateAttributes",
"(",
"final",
"Collection",
"<",
"Attribute",
">",
"attrToSend",
")",
"{",
"if",
"(",
"!",
"this",
".",
"sentAttrSpecifications",
")",
"{",
"log",
".",
"error",
"(",
"\"Haven't sent type specifications yet, can't send solutions.\"",
")",
";",
"return",
"false",
";",
"}",
"for",
"(",
"Iterator",
"<",
"Attribute",
">",
"iter",
"=",
"attrToSend",
".",
"iterator",
"(",
")",
";",
"iter",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Attribute",
"soln",
"=",
"iter",
".",
"next",
"(",
")",
";",
"Integer",
"solutionTypeAlias",
"=",
"this",
".",
"attributeAliases",
".",
"get",
"(",
"soln",
".",
"getAttributeName",
"(",
")",
")",
";",
"if",
"(",
"solutionTypeAlias",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Cannot send solution: Unregistered attribute type: {}\"",
",",
"soln",
".",
"getAttributeName",
"(",
")",
")",
";",
"iter",
".",
"remove",
"(",
")",
";",
"continue",
";",
"}",
"soln",
".",
"setAttributeNameAlias",
"(",
"solutionTypeAlias",
".",
"intValue",
"(",
")",
")",
";",
"}",
"AttributeUpdateMessage",
"message",
"=",
"new",
"AttributeUpdateMessage",
"(",
")",
";",
"message",
".",
"setCreateId",
"(",
"this",
".",
"createIds",
")",
";",
"message",
".",
"setAttributes",
"(",
"attrToSend",
".",
"toArray",
"(",
"new",
"Attribute",
"[",
"]",
"{",
"}",
")",
")",
";",
"this",
".",
"session",
".",
"write",
"(",
"message",
")",
";",
"log",
".",
"debug",
"(",
"\"Sent {} to {}\"",
",",
"message",
",",
"this",
")",
";",
"return",
"true",
";",
"}"
] |
Sends a multiple Attribute update messages to the world model.
@param attrToSend
the Attribute values to update
@return {@code true} if the messages were written, or {@code false} if
one or more messages failed to send.
|
[
"Sends",
"a",
"multiple",
"Attribute",
"update",
"messages",
"to",
"the",
"world",
"model",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java#L783-L812
|
153,542
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java
|
SolverWorldModelInterface.addAttribute
|
public void addAttribute(AttributeSpecification specification) {
synchronized (this.attributes) {
if (!this.attributes.contains(specification)) {
this.attributes.add(specification);
if (this.sentAttrSpecifications) {
this.announceAttributes();
}
}
}
}
|
java
|
public void addAttribute(AttributeSpecification specification) {
synchronized (this.attributes) {
if (!this.attributes.contains(specification)) {
this.attributes.add(specification);
if (this.sentAttrSpecifications) {
this.announceAttributes();
}
}
}
}
|
[
"public",
"void",
"addAttribute",
"(",
"AttributeSpecification",
"specification",
")",
"{",
"synchronized",
"(",
"this",
".",
"attributes",
")",
"{",
"if",
"(",
"!",
"this",
".",
"attributes",
".",
"contains",
"(",
"specification",
")",
")",
"{",
"this",
".",
"attributes",
".",
"add",
"(",
"specification",
")",
";",
"if",
"(",
"this",
".",
"sentAttrSpecifications",
")",
"{",
"this",
".",
"announceAttributes",
"(",
")",
";",
"}",
"}",
"}",
"}"
] |
Adds an attribute specification to the world model session.
@param specification
the Attribute that will be sent later.
|
[
"Adds",
"an",
"attribute",
"specification",
"to",
"the",
"world",
"model",
"session",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java#L820-L830
|
153,543
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java
|
SolverWorldModelInterface.setOriginString
|
public void setOriginString(String originString) {
this.originString = originString;
if (this.sentAttrSpecifications) {
AttributeAnnounceMessage msg = new AttributeAnnounceMessage();
msg.setOrigin(originString);
this.session.write(msg);
}
}
|
java
|
public void setOriginString(String originString) {
this.originString = originString;
if (this.sentAttrSpecifications) {
AttributeAnnounceMessage msg = new AttributeAnnounceMessage();
msg.setOrigin(originString);
this.session.write(msg);
}
}
|
[
"public",
"void",
"setOriginString",
"(",
"String",
"originString",
")",
"{",
"this",
".",
"originString",
"=",
"originString",
";",
"if",
"(",
"this",
".",
"sentAttrSpecifications",
")",
"{",
"AttributeAnnounceMessage",
"msg",
"=",
"new",
"AttributeAnnounceMessage",
"(",
")",
";",
"msg",
".",
"setOrigin",
"(",
"originString",
")",
";",
"this",
".",
"session",
".",
"write",
"(",
"msg",
")",
";",
"}",
"}"
] |
Sets the origin value for this connection.
@param originString
the new origin value.
|
[
"Sets",
"the",
"origin",
"value",
"for",
"this",
"connection",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java#L972-L979
|
153,544
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java
|
SolverWorldModelInterface.expireId
|
public boolean expireId(final String identifier, final long expirationTime) {
if (identifier == null) {
log.error("Unable to expire a null Identifier value.");
return false;
}
if (this.originString == null) {
log.error("Origin has not been set. Cannot expire Ids without a valid origin.");
return false;
}
ExpireIdentifierMessage message = new ExpireIdentifierMessage();
message.setOrigin(this.originString);
message.setId(identifier);
message.setExpirationTime(expirationTime);
this.session.write(message);
log.debug("Sent {}", message);
return true;
}
|
java
|
public boolean expireId(final String identifier, final long expirationTime) {
if (identifier == null) {
log.error("Unable to expire a null Identifier value.");
return false;
}
if (this.originString == null) {
log.error("Origin has not been set. Cannot expire Ids without a valid origin.");
return false;
}
ExpireIdentifierMessage message = new ExpireIdentifierMessage();
message.setOrigin(this.originString);
message.setId(identifier);
message.setExpirationTime(expirationTime);
this.session.write(message);
log.debug("Sent {}", message);
return true;
}
|
[
"public",
"boolean",
"expireId",
"(",
"final",
"String",
"identifier",
",",
"final",
"long",
"expirationTime",
")",
"{",
"if",
"(",
"identifier",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Unable to expire a null Identifier value.\"",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"this",
".",
"originString",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Origin has not been set. Cannot expire Ids without a valid origin.\"",
")",
";",
"return",
"false",
";",
"}",
"ExpireIdentifierMessage",
"message",
"=",
"new",
"ExpireIdentifierMessage",
"(",
")",
";",
"message",
".",
"setOrigin",
"(",
"this",
".",
"originString",
")",
";",
"message",
".",
"setId",
"(",
"identifier",
")",
";",
"message",
".",
"setExpirationTime",
"(",
"expirationTime",
")",
";",
"this",
".",
"session",
".",
"write",
"(",
"message",
")",
";",
"log",
".",
"debug",
"(",
"\"Sent {}\"",
",",
"message",
")",
";",
"return",
"true",
";",
"}"
] |
Expires all Attributes for an Identifier in the world model.
@param identifier
the identifier to expire.
@param expirationTime
the expiration timestamp.
@return {@code true} if the message is sent successfully, else
{@code false}.
|
[
"Expires",
"all",
"Attributes",
"for",
"an",
"Identifier",
"in",
"the",
"world",
"model",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java#L1005-L1025
|
153,545
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java
|
SolverWorldModelInterface.expireAttribute
|
public boolean expireAttribute(final String identifier,
final String attribute, final long expirationTime) {
if (identifier == null) {
log.error("Unable to expire an attribute with a null Identifier value.");
return false;
}
if (attribute == null) {
log.error("Unable to expire a null attribute.");
return false;
}
if (this.originString == null) {
log.error("Origin has not been set. Cannot expire attributes without a valid origin.");
return false;
}
ExpireAttributeMessage message = new ExpireAttributeMessage();
message.setId(identifier);
message.setAttributeName(attribute);
message.setExpirationTime(expirationTime);
message.setOrigin(this.originString);
this.session.write(message);
log.debug("Sent {}", message);
return true;
}
|
java
|
public boolean expireAttribute(final String identifier,
final String attribute, final long expirationTime) {
if (identifier == null) {
log.error("Unable to expire an attribute with a null Identifier value.");
return false;
}
if (attribute == null) {
log.error("Unable to expire a null attribute.");
return false;
}
if (this.originString == null) {
log.error("Origin has not been set. Cannot expire attributes without a valid origin.");
return false;
}
ExpireAttributeMessage message = new ExpireAttributeMessage();
message.setId(identifier);
message.setAttributeName(attribute);
message.setExpirationTime(expirationTime);
message.setOrigin(this.originString);
this.session.write(message);
log.debug("Sent {}", message);
return true;
}
|
[
"public",
"boolean",
"expireAttribute",
"(",
"final",
"String",
"identifier",
",",
"final",
"String",
"attribute",
",",
"final",
"long",
"expirationTime",
")",
"{",
"if",
"(",
"identifier",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Unable to expire an attribute with a null Identifier value.\"",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"attribute",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Unable to expire a null attribute.\"",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"this",
".",
"originString",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Origin has not been set. Cannot expire attributes without a valid origin.\"",
")",
";",
"return",
"false",
";",
"}",
"ExpireAttributeMessage",
"message",
"=",
"new",
"ExpireAttributeMessage",
"(",
")",
";",
"message",
".",
"setId",
"(",
"identifier",
")",
";",
"message",
".",
"setAttributeName",
"(",
"attribute",
")",
";",
"message",
".",
"setExpirationTime",
"(",
"expirationTime",
")",
";",
"message",
".",
"setOrigin",
"(",
"this",
".",
"originString",
")",
";",
"this",
".",
"session",
".",
"write",
"(",
"message",
")",
";",
"log",
".",
"debug",
"(",
"\"Sent {}\"",
",",
"message",
")",
";",
"return",
"true",
";",
"}"
] |
Expire a particular Attribute for an Identifier in the world model.
@param identifier
the Identifier to expire.
@param attribute
the Attribute to expire.
@param expirationTime
the expiration timestamp.
@return {@code true} if the message was sent successfully, else
{@code false}.
|
[
"Expire",
"a",
"particular",
"Attribute",
"for",
"an",
"Identifier",
"in",
"the",
"world",
"model",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java#L1039-L1067
|
153,546
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java
|
SolverWorldModelInterface.deleteId
|
public boolean deleteId(final String identifier) {
if (identifier == null) {
log.error("Unable to delete a null Identifier value.");
return false;
}
if (this.originString == null) {
log.error("Origin has not been set. Cannot delete Identifiers without a valid origin.");
return false;
}
DeleteIdentifierMessage message = new DeleteIdentifierMessage();
message.setOrigin(this.originString);
message.setId(identifier);
this.session.write(message);
log.debug("Sent {}", message);
return true;
}
|
java
|
public boolean deleteId(final String identifier) {
if (identifier == null) {
log.error("Unable to delete a null Identifier value.");
return false;
}
if (this.originString == null) {
log.error("Origin has not been set. Cannot delete Identifiers without a valid origin.");
return false;
}
DeleteIdentifierMessage message = new DeleteIdentifierMessage();
message.setOrigin(this.originString);
message.setId(identifier);
this.session.write(message);
log.debug("Sent {}", message);
return true;
}
|
[
"public",
"boolean",
"deleteId",
"(",
"final",
"String",
"identifier",
")",
"{",
"if",
"(",
"identifier",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Unable to delete a null Identifier value.\"",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"this",
".",
"originString",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Origin has not been set. Cannot delete Identifiers without a valid origin.\"",
")",
";",
"return",
"false",
";",
"}",
"DeleteIdentifierMessage",
"message",
"=",
"new",
"DeleteIdentifierMessage",
"(",
")",
";",
"message",
".",
"setOrigin",
"(",
"this",
".",
"originString",
")",
";",
"message",
".",
"setId",
"(",
"identifier",
")",
";",
"this",
".",
"session",
".",
"write",
"(",
"message",
")",
";",
"log",
".",
"debug",
"(",
"\"Sent {}\"",
",",
"message",
")",
";",
"return",
"true",
";",
"}"
] |
Deletes an Identifier and all of its Attributes from the world model. All
data for the Identifier will be removed permanently. Callers may also
wish to consider expiring the Identifier instead.
@param identifier
the Identifier to delete
@return {@code true} if the message was sent successfully
|
[
"Deletes",
"an",
"Identifier",
"and",
"all",
"of",
"its",
"Attributes",
"from",
"the",
"world",
"model",
".",
"All",
"data",
"for",
"the",
"Identifier",
"will",
"be",
"removed",
"permanently",
".",
"Callers",
"may",
"also",
"wish",
"to",
"consider",
"expiring",
"the",
"Identifier",
"instead",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java#L1078-L1097
|
153,547
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java
|
SolverWorldModelInterface.deleteAttribute
|
public boolean deleteAttribute(final String identifier,
final String attribute) {
if (identifier == null) {
log.error("Unable to delete an attribute with a null Identifier value.");
return false;
}
if (attribute == null) {
log.error("Unable to delete a null attribute.");
return false;
}
if (this.originString == null) {
log.error("Origin has not been set. Cannot delete attributes without a valid origin.");
return false;
}
DeleteAttributeMessage message = new DeleteAttributeMessage();
message.setOrigin(this.originString);
message.setId(identifier);
message.setAttributeName(attribute);
this.session.write(message);
log.debug("Sent {}", message);
return true;
}
|
java
|
public boolean deleteAttribute(final String identifier,
final String attribute) {
if (identifier == null) {
log.error("Unable to delete an attribute with a null Identifier value.");
return false;
}
if (attribute == null) {
log.error("Unable to delete a null attribute.");
return false;
}
if (this.originString == null) {
log.error("Origin has not been set. Cannot delete attributes without a valid origin.");
return false;
}
DeleteAttributeMessage message = new DeleteAttributeMessage();
message.setOrigin(this.originString);
message.setId(identifier);
message.setAttributeName(attribute);
this.session.write(message);
log.debug("Sent {}", message);
return true;
}
|
[
"public",
"boolean",
"deleteAttribute",
"(",
"final",
"String",
"identifier",
",",
"final",
"String",
"attribute",
")",
"{",
"if",
"(",
"identifier",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Unable to delete an attribute with a null Identifier value.\"",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"attribute",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Unable to delete a null attribute.\"",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"this",
".",
"originString",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Origin has not been set. Cannot delete attributes without a valid origin.\"",
")",
";",
"return",
"false",
";",
"}",
"DeleteAttributeMessage",
"message",
"=",
"new",
"DeleteAttributeMessage",
"(",
")",
";",
"message",
".",
"setOrigin",
"(",
"this",
".",
"originString",
")",
";",
"message",
".",
"setId",
"(",
"identifier",
")",
";",
"message",
".",
"setAttributeName",
"(",
"attribute",
")",
";",
"this",
".",
"session",
".",
"write",
"(",
"message",
")",
";",
"log",
".",
"debug",
"(",
"\"Sent {}\"",
",",
"message",
")",
";",
"return",
"true",
";",
"}"
] |
Deletes an Attribute and its entire history from the world model. Callers
may wish to expire the Attribute value instead.
@param identifier
the Identifier of the Attribute to expire.
@param attribute
the Attribute to expire.
@return {@code true} if the message was sent successfully.
|
[
"Deletes",
"an",
"Attribute",
"and",
"its",
"entire",
"history",
"from",
"the",
"world",
"model",
".",
"Callers",
"may",
"wish",
"to",
"expire",
"the",
"Attribute",
"value",
"instead",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java#L1109-L1135
|
153,548
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java
|
SolverWorldModelInterface.createId
|
public boolean createId(final String identifier) {
if (identifier == null) {
log.error("Unable to create a null Identifier.");
return false;
}
if (this.originString == null) {
log.error("Origin has not been set. Cannot create Identifiers without a valid origin.");
return false;
}
CreateIdentifierMessage message = new CreateIdentifierMessage();
message.setCreationTime(System.currentTimeMillis());
message.setOrigin(this.originString);
message.setId(identifier);
this.session.write(message);
log.debug("Sent {}", message);
return true;
}
|
java
|
public boolean createId(final String identifier) {
if (identifier == null) {
log.error("Unable to create a null Identifier.");
return false;
}
if (this.originString == null) {
log.error("Origin has not been set. Cannot create Identifiers without a valid origin.");
return false;
}
CreateIdentifierMessage message = new CreateIdentifierMessage();
message.setCreationTime(System.currentTimeMillis());
message.setOrigin(this.originString);
message.setId(identifier);
this.session.write(message);
log.debug("Sent {}", message);
return true;
}
|
[
"public",
"boolean",
"createId",
"(",
"final",
"String",
"identifier",
")",
"{",
"if",
"(",
"identifier",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Unable to create a null Identifier.\"",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"this",
".",
"originString",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Origin has not been set. Cannot create Identifiers without a valid origin.\"",
")",
";",
"return",
"false",
";",
"}",
"CreateIdentifierMessage",
"message",
"=",
"new",
"CreateIdentifierMessage",
"(",
")",
";",
"message",
".",
"setCreationTime",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"message",
".",
"setOrigin",
"(",
"this",
".",
"originString",
")",
";",
"message",
".",
"setId",
"(",
"identifier",
")",
";",
"this",
".",
"session",
".",
"write",
"(",
"message",
")",
";",
"log",
".",
"debug",
"(",
"\"Sent {}\"",
",",
"message",
")",
";",
"return",
"true",
";",
"}"
] |
Creates a new Identifier in the world model.
@param identifier
the Identifier to create
@return {@code true} if the message was sent successfully.
|
[
"Creates",
"a",
"new",
"Identifier",
"in",
"the",
"world",
"model",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/solver/SolverWorldModelInterface.java#L1144-L1165
|
153,549
|
jbundle/jbundle
|
thin/base/screen/util/src/main/java/org/jbundle/thin/base/screen/util/JMainScreen.java
|
JMainScreen.getModel
|
public AbstractThinTableModel getModel(JTable table)
{
AbstractThinTableModel model = null;
if (table != null)
model = (AbstractThinTableModel)table.getModel();
return model;
}
|
java
|
public AbstractThinTableModel getModel(JTable table)
{
AbstractThinTableModel model = null;
if (table != null)
model = (AbstractThinTableModel)table.getModel();
return model;
}
|
[
"public",
"AbstractThinTableModel",
"getModel",
"(",
"JTable",
"table",
")",
"{",
"AbstractThinTableModel",
"model",
"=",
"null",
";",
"if",
"(",
"table",
"!=",
"null",
")",
"model",
"=",
"(",
"AbstractThinTableModel",
")",
"table",
".",
"getModel",
"(",
")",
";",
"return",
"model",
";",
"}"
] |
Get the model in this screen's sub-screen.
Override if the model is not in the sub-screen.
@param table
@return
|
[
"Get",
"the",
"model",
"in",
"this",
"screen",
"s",
"sub",
"-",
"screen",
".",
"Override",
"if",
"the",
"model",
"is",
"not",
"in",
"the",
"sub",
"-",
"screen",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/util/src/main/java/org/jbundle/thin/base/screen/util/JMainScreen.java#L173-L179
|
153,550
|
wigforss/Ka-Commons-Reflection
|
src/main/java/org/kasource/commons/reflection/util/MethodUtils.java
|
MethodUtils.getMethod
|
public static Method getMethod(Class<?> target, MethodFilter methodFilter) {
Set<Method> methods = getMethods(target, methodFilter);
if (!methods.isEmpty()) {
return methods.iterator().next();
}
return null;
}
|
java
|
public static Method getMethod(Class<?> target, MethodFilter methodFilter) {
Set<Method> methods = getMethods(target, methodFilter);
if (!methods.isEmpty()) {
return methods.iterator().next();
}
return null;
}
|
[
"public",
"static",
"Method",
"getMethod",
"(",
"Class",
"<",
"?",
">",
"target",
",",
"MethodFilter",
"methodFilter",
")",
"{",
"Set",
"<",
"Method",
">",
"methods",
"=",
"getMethods",
"(",
"target",
",",
"methodFilter",
")",
";",
"if",
"(",
"!",
"methods",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"methods",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the method declared by the target class and any of its super classes, which matches the supplied
methodFilter, if method is found null is returned. If more than one method is found the
first in the resulting set iterator is returned.
@param methodFilter
The method filter to apply.
@return method that match the methodFilter or null if no such method was found.
|
[
"Returns",
"the",
"method",
"declared",
"by",
"the",
"target",
"class",
"and",
"any",
"of",
"its",
"super",
"classes",
"which",
"matches",
"the",
"supplied",
"methodFilter",
"if",
"method",
"is",
"found",
"null",
"is",
"returned",
".",
"If",
"more",
"than",
"one",
"method",
"is",
"found",
"the",
"first",
"in",
"the",
"resulting",
"set",
"iterator",
"is",
"returned",
"."
] |
a80f7a164cd800089e4f4dd948ca6f0e7badcf33
|
https://github.com/wigforss/Ka-Commons-Reflection/blob/a80f7a164cd800089e4f4dd948ca6f0e7badcf33/src/main/java/org/kasource/commons/reflection/util/MethodUtils.java#L130-L136
|
153,551
|
wigforss/Ka-Commons-Reflection
|
src/main/java/org/kasource/commons/reflection/util/MethodUtils.java
|
MethodUtils.verifyMethodSignature
|
public static void verifyMethodSignature(Method method, Class<?> returnType, Class<?>... parameters) {
if(method == null) {
throw new IllegalArgumentException("Method is null");
}
if (!method.getReturnType().equals(returnType)) {
throw new IllegalArgumentException("Method " + method + " return type " + method.getReturnType()
+ " does not match: " + returnType);
}
Class<?>[] actualParameters = method.getParameterTypes();
if (actualParameters.length != parameters.length) {
throw new IllegalArgumentException("Method " + method + " number of parameters " + actualParameters.length
+ " does not match: " + parameters.length);
}
if (!Arrays.equals(actualParameters,parameters)) {
throw new IllegalArgumentException("Method " + method + " types of parameters "
+ Arrays.toString(actualParameters) + " does not match: " + Arrays.toString(parameters));
}
}
|
java
|
public static void verifyMethodSignature(Method method, Class<?> returnType, Class<?>... parameters) {
if(method == null) {
throw new IllegalArgumentException("Method is null");
}
if (!method.getReturnType().equals(returnType)) {
throw new IllegalArgumentException("Method " + method + " return type " + method.getReturnType()
+ " does not match: " + returnType);
}
Class<?>[] actualParameters = method.getParameterTypes();
if (actualParameters.length != parameters.length) {
throw new IllegalArgumentException("Method " + method + " number of parameters " + actualParameters.length
+ " does not match: " + parameters.length);
}
if (!Arrays.equals(actualParameters,parameters)) {
throw new IllegalArgumentException("Method " + method + " types of parameters "
+ Arrays.toString(actualParameters) + " does not match: " + Arrays.toString(parameters));
}
}
|
[
"public",
"static",
"void",
"verifyMethodSignature",
"(",
"Method",
"method",
",",
"Class",
"<",
"?",
">",
"returnType",
",",
"Class",
"<",
"?",
">",
"...",
"parameters",
")",
"{",
"if",
"(",
"method",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Method is null\"",
")",
";",
"}",
"if",
"(",
"!",
"method",
".",
"getReturnType",
"(",
")",
".",
"equals",
"(",
"returnType",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Method \"",
"+",
"method",
"+",
"\" return type \"",
"+",
"method",
".",
"getReturnType",
"(",
")",
"+",
"\" does not match: \"",
"+",
"returnType",
")",
";",
"}",
"Class",
"<",
"?",
">",
"[",
"]",
"actualParameters",
"=",
"method",
".",
"getParameterTypes",
"(",
")",
";",
"if",
"(",
"actualParameters",
".",
"length",
"!=",
"parameters",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Method \"",
"+",
"method",
"+",
"\" number of parameters \"",
"+",
"actualParameters",
".",
"length",
"+",
"\" does not match: \"",
"+",
"parameters",
".",
"length",
")",
";",
"}",
"if",
"(",
"!",
"Arrays",
".",
"equals",
"(",
"actualParameters",
",",
"parameters",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Method \"",
"+",
"method",
"+",
"\" types of parameters \"",
"+",
"Arrays",
".",
"toString",
"(",
"actualParameters",
")",
"+",
"\" does not match: \"",
"+",
"Arrays",
".",
"toString",
"(",
"parameters",
")",
")",
";",
"}",
"}"
] |
Verify that the supplied method's signature matches return type and
parameters types
@param method
Method to inspect
@param returnType
Return type to match
@param parameters
Parameter types to match
@throws IllegalArgumentException
if method fails to match return type or parameters types
|
[
"Verify",
"that",
"the",
"supplied",
"method",
"s",
"signature",
"matches",
"return",
"type",
"and",
"parameters",
"types"
] |
a80f7a164cd800089e4f4dd948ca6f0e7badcf33
|
https://github.com/wigforss/Ka-Commons-Reflection/blob/a80f7a164cd800089e4f4dd948ca6f0e7badcf33/src/main/java/org/kasource/commons/reflection/util/MethodUtils.java#L188-L205
|
153,552
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/JScreenToolbar.java
|
JScreenToolbar.addButtons
|
public void addButtons()
{
this.addButton(Constants.BACK);
this.addButton(Constants.GRID);
this.addButton(Constants.SUBMIT);
this.addButton(Constants.RESET);
this.addButton(Constants.DELETE);
this.addButton(Constants.HELP);
}
|
java
|
public void addButtons()
{
this.addButton(Constants.BACK);
this.addButton(Constants.GRID);
this.addButton(Constants.SUBMIT);
this.addButton(Constants.RESET);
this.addButton(Constants.DELETE);
this.addButton(Constants.HELP);
}
|
[
"public",
"void",
"addButtons",
"(",
")",
"{",
"this",
".",
"addButton",
"(",
"Constants",
".",
"BACK",
")",
";",
"this",
".",
"addButton",
"(",
"Constants",
".",
"GRID",
")",
";",
"this",
".",
"addButton",
"(",
"Constants",
".",
"SUBMIT",
")",
";",
"this",
".",
"addButton",
"(",
"Constants",
".",
"RESET",
")",
";",
"this",
".",
"addButton",
"(",
"Constants",
".",
"DELETE",
")",
";",
"this",
".",
"addButton",
"(",
"Constants",
".",
"HELP",
")",
";",
"}"
] |
Add the buttons to this window.
|
[
"Add",
"the",
"buttons",
"to",
"this",
"window",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/JScreenToolbar.java#L50-L58
|
153,553
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/db/filter/SubCurrentFilter.java
|
SubCurrentFilter.setOwner
|
public void setOwner(ListenerOwner owner)
{
if (owner != null)
if (m_buffer == null)
{ // Save the current key
KeyArea keyArea = ((Record)owner).getKeyArea(-1);
m_buffer = new VectorBuffer(null);
keyArea.setupKeyBuffer(m_buffer, DBConstants.FILE_KEY_AREA);
}
super.setOwner(owner);
}
|
java
|
public void setOwner(ListenerOwner owner)
{
if (owner != null)
if (m_buffer == null)
{ // Save the current key
KeyArea keyArea = ((Record)owner).getKeyArea(-1);
m_buffer = new VectorBuffer(null);
keyArea.setupKeyBuffer(m_buffer, DBConstants.FILE_KEY_AREA);
}
super.setOwner(owner);
}
|
[
"public",
"void",
"setOwner",
"(",
"ListenerOwner",
"owner",
")",
"{",
"if",
"(",
"owner",
"!=",
"null",
")",
"if",
"(",
"m_buffer",
"==",
"null",
")",
"{",
"// Save the current key",
"KeyArea",
"keyArea",
"=",
"(",
"(",
"Record",
")",
"owner",
")",
".",
"getKeyArea",
"(",
"-",
"1",
")",
";",
"m_buffer",
"=",
"new",
"VectorBuffer",
"(",
"null",
")",
";",
"keyArea",
".",
"setupKeyBuffer",
"(",
"m_buffer",
",",
"DBConstants",
".",
"FILE_KEY_AREA",
")",
";",
"}",
"super",
".",
"setOwner",
"(",
"owner",
")",
";",
"}"
] |
Set the record that owns this listener.
This method caches the current key values.
@param owner My owner.
|
[
"Set",
"the",
"record",
"that",
"owns",
"this",
"listener",
".",
"This",
"method",
"caches",
"the",
"current",
"key",
"values",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/filter/SubCurrentFilter.java#L112-L122
|
153,554
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/ui/AreaFiller.java
|
AreaFiller.fill
|
public void fill(IntBiPredicate isInside, int replacement)
{
fill(0, 0, width, height, isInside, (x,y)->replacement);
}
|
java
|
public void fill(IntBiPredicate isInside, int replacement)
{
fill(0, 0, width, height, isInside, (x,y)->replacement);
}
|
[
"public",
"void",
"fill",
"(",
"IntBiPredicate",
"isInside",
",",
"int",
"replacement",
")",
"{",
"fill",
"(",
"0",
",",
"0",
",",
"width",
",",
"height",
",",
"isInside",
",",
"(",
"x",
",",
"y",
")",
"->",
"replacement",
")",
";",
"}"
] |
Fills area . Pixels fullfilling target are replaced with
replacement color.
@param isInside
@param replacement
|
[
"Fills",
"area",
".",
"Pixels",
"fullfilling",
"target",
"are",
"replaced",
"with",
"replacement",
"color",
"."
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/ui/AreaFiller.java#L50-L53
|
153,555
|
DDTH/ddth-dlock
|
ddth-dlock-core/src/main/java/com/github/ddth/dlock/impl/AbstractDLockFactory.java
|
AbstractDLockFactory.getLockProperties
|
protected Properties getLockProperties(String name) {
return lockProperties != null ? lockProperties.get(name) : null;
}
|
java
|
protected Properties getLockProperties(String name) {
return lockProperties != null ? lockProperties.get(name) : null;
}
|
[
"protected",
"Properties",
"getLockProperties",
"(",
"String",
"name",
")",
"{",
"return",
"lockProperties",
"!=",
"null",
"?",
"lockProperties",
".",
"get",
"(",
"name",
")",
":",
"null",
";",
"}"
] |
Get a lock's properties
@param name
@return
|
[
"Get",
"a",
"lock",
"s",
"properties"
] |
56786c61a04fe505556a834133b3de36562c6cb6
|
https://github.com/DDTH/ddth-dlock/blob/56786c61a04fe505556a834133b3de36562c6cb6/ddth-dlock-core/src/main/java/com/github/ddth/dlock/impl/AbstractDLockFactory.java#L108-L110
|
153,556
|
caspervg/SC4D-LEX4J
|
lex4j/src/main/java/net/caspervg/lex4j/route/UserRoute.java
|
UserRoute.getUser
|
public User getUser() {
ClientResource resource = new ClientResource(Route.ME.url());
resource.setChallengeResponse(this.auth.toChallenge());
try {
Representation repr = resource.get();
return mapper.readValue(repr.getText(), User.class);
} catch (IOException ex) {
LEX4JLogger.log(Level.WARNING, "Could not retrieve user (me) correctly!");
return null;
}
}
|
java
|
public User getUser() {
ClientResource resource = new ClientResource(Route.ME.url());
resource.setChallengeResponse(this.auth.toChallenge());
try {
Representation repr = resource.get();
return mapper.readValue(repr.getText(), User.class);
} catch (IOException ex) {
LEX4JLogger.log(Level.WARNING, "Could not retrieve user (me) correctly!");
return null;
}
}
|
[
"public",
"User",
"getUser",
"(",
")",
"{",
"ClientResource",
"resource",
"=",
"new",
"ClientResource",
"(",
"Route",
".",
"ME",
".",
"url",
"(",
")",
")",
";",
"resource",
".",
"setChallengeResponse",
"(",
"this",
".",
"auth",
".",
"toChallenge",
"(",
")",
")",
";",
"try",
"{",
"Representation",
"repr",
"=",
"resource",
".",
"get",
"(",
")",
";",
"return",
"mapper",
".",
"readValue",
"(",
"repr",
".",
"getText",
"(",
")",
",",
"User",
".",
"class",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"LEX4JLogger",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Could not retrieve user (me) correctly!\"",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Returns the current user
@return the current user
@custom.require Authentication
|
[
"Returns",
"the",
"current",
"user"
] |
3d086ec70c817119a88573c2e23af27276cdb1d6
|
https://github.com/caspervg/SC4D-LEX4J/blob/3d086ec70c817119a88573c2e23af27276cdb1d6/lex4j/src/main/java/net/caspervg/lex4j/route/UserRoute.java#L56-L67
|
153,557
|
caspervg/SC4D-LEX4J
|
lex4j/src/main/java/net/caspervg/lex4j/route/UserRoute.java
|
UserRoute.getUserList
|
public List<User> getUserList(boolean concise, int start, int amount) {
ClientResource resource = new ClientResource(Route.ALL_USER.url());
Reference ref = resource.getReference();
Map<String, Object> param = new HashMap<>();
param.put("concise", concise);
param.put("start", start);
param.put("amount", amount);
Route.addParameters(ref, param);
resource.setChallengeResponse(this.auth.toChallenge());
try {
Representation repr = resource.get();
return mapper.readValue(repr.getText(), new TypeReference<List<User>>() {});
} catch (IOException ex) {
LEX4JLogger.log(Level.WARNING, "Could not retrieve user list correctly!");
return null;
}
}
|
java
|
public List<User> getUserList(boolean concise, int start, int amount) {
ClientResource resource = new ClientResource(Route.ALL_USER.url());
Reference ref = resource.getReference();
Map<String, Object> param = new HashMap<>();
param.put("concise", concise);
param.put("start", start);
param.put("amount", amount);
Route.addParameters(ref, param);
resource.setChallengeResponse(this.auth.toChallenge());
try {
Representation repr = resource.get();
return mapper.readValue(repr.getText(), new TypeReference<List<User>>() {});
} catch (IOException ex) {
LEX4JLogger.log(Level.WARNING, "Could not retrieve user list correctly!");
return null;
}
}
|
[
"public",
"List",
"<",
"User",
">",
"getUserList",
"(",
"boolean",
"concise",
",",
"int",
"start",
",",
"int",
"amount",
")",
"{",
"ClientResource",
"resource",
"=",
"new",
"ClientResource",
"(",
"Route",
".",
"ALL_USER",
".",
"url",
"(",
")",
")",
";",
"Reference",
"ref",
"=",
"resource",
".",
"getReference",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"param",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"param",
".",
"put",
"(",
"\"concise\"",
",",
"concise",
")",
";",
"param",
".",
"put",
"(",
"\"start\"",
",",
"start",
")",
";",
"param",
".",
"put",
"(",
"\"amount\"",
",",
"amount",
")",
";",
"Route",
".",
"addParameters",
"(",
"ref",
",",
"param",
")",
";",
"resource",
".",
"setChallengeResponse",
"(",
"this",
".",
"auth",
".",
"toChallenge",
"(",
")",
")",
";",
"try",
"{",
"Representation",
"repr",
"=",
"resource",
".",
"get",
"(",
")",
";",
"return",
"mapper",
".",
"readValue",
"(",
"repr",
".",
"getText",
"(",
")",
",",
"new",
"TypeReference",
"<",
"List",
"<",
"User",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"LEX4JLogger",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Could not retrieve user list correctly!\"",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Returns all users
@param concise <code>true</code> if you only want the primary key and the username;
<code>false</code> otherwise
@param start start number of results
@param amount number of results to return
@return all users
@custom.require Authentication and Administrator
|
[
"Returns",
"all",
"users"
] |
3d086ec70c817119a88573c2e23af27276cdb1d6
|
https://github.com/caspervg/SC4D-LEX4J/blob/3d086ec70c817119a88573c2e23af27276cdb1d6/lex4j/src/main/java/net/caspervg/lex4j/route/UserRoute.java#L99-L119
|
153,558
|
caspervg/SC4D-LEX4J
|
lex4j/src/main/java/net/caspervg/lex4j/route/UserRoute.java
|
UserRoute.getDownloadList
|
public List<DownloadListItem> getDownloadList() {
ClientResource resource = new ClientResource(Route.DOWNLOAD_LIST.url());
resource.setChallengeResponse(this.auth.toChallenge());
try {
Representation repr = resource.get();
return mapper.readValue(repr.getText(), new TypeReference<List<DownloadListItem>>() {});
} catch (IOException ex) {
LEX4JLogger.log(Level.WARNING, "Could not retrieve download list correctly!");
return null;
}
}
|
java
|
public List<DownloadListItem> getDownloadList() {
ClientResource resource = new ClientResource(Route.DOWNLOAD_LIST.url());
resource.setChallengeResponse(this.auth.toChallenge());
try {
Representation repr = resource.get();
return mapper.readValue(repr.getText(), new TypeReference<List<DownloadListItem>>() {});
} catch (IOException ex) {
LEX4JLogger.log(Level.WARNING, "Could not retrieve download list correctly!");
return null;
}
}
|
[
"public",
"List",
"<",
"DownloadListItem",
">",
"getDownloadList",
"(",
")",
"{",
"ClientResource",
"resource",
"=",
"new",
"ClientResource",
"(",
"Route",
".",
"DOWNLOAD_LIST",
".",
"url",
"(",
")",
")",
";",
"resource",
".",
"setChallengeResponse",
"(",
"this",
".",
"auth",
".",
"toChallenge",
"(",
")",
")",
";",
"try",
"{",
"Representation",
"repr",
"=",
"resource",
".",
"get",
"(",
")",
";",
"return",
"mapper",
".",
"readValue",
"(",
"repr",
".",
"getText",
"(",
")",
",",
"new",
"TypeReference",
"<",
"List",
"<",
"DownloadListItem",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"LEX4JLogger",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Could not retrieve download list correctly!\"",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Returns the download list of the current user
@return the download list of the current user
@custom.require Authentication
|
[
"Returns",
"the",
"download",
"list",
"of",
"the",
"current",
"user"
] |
3d086ec70c817119a88573c2e23af27276cdb1d6
|
https://github.com/caspervg/SC4D-LEX4J/blob/3d086ec70c817119a88573c2e23af27276cdb1d6/lex4j/src/main/java/net/caspervg/lex4j/route/UserRoute.java#L127-L138
|
153,559
|
caspervg/SC4D-LEX4J
|
lex4j/src/main/java/net/caspervg/lex4j/route/UserRoute.java
|
UserRoute.getDownloadHistory
|
public List<DownloadHistoryItem> getDownloadHistory() {
ClientResource resource = new ClientResource(Route.DOWNLOAD_HISTORY.url());
resource.setChallengeResponse(this.auth.toChallenge());
try {
String result = resource.get().getText();
return mapper.readValue(result, new TypeReference<List<DownloadHistoryItem>>() {});
} catch (IOException e) {
LEX4JLogger.log(Level.WARNING, "Could not retrieve download history correctly!");
return null;
}
}
|
java
|
public List<DownloadHistoryItem> getDownloadHistory() {
ClientResource resource = new ClientResource(Route.DOWNLOAD_HISTORY.url());
resource.setChallengeResponse(this.auth.toChallenge());
try {
String result = resource.get().getText();
return mapper.readValue(result, new TypeReference<List<DownloadHistoryItem>>() {});
} catch (IOException e) {
LEX4JLogger.log(Level.WARNING, "Could not retrieve download history correctly!");
return null;
}
}
|
[
"public",
"List",
"<",
"DownloadHistoryItem",
">",
"getDownloadHistory",
"(",
")",
"{",
"ClientResource",
"resource",
"=",
"new",
"ClientResource",
"(",
"Route",
".",
"DOWNLOAD_HISTORY",
".",
"url",
"(",
")",
")",
";",
"resource",
".",
"setChallengeResponse",
"(",
"this",
".",
"auth",
".",
"toChallenge",
"(",
")",
")",
";",
"try",
"{",
"String",
"result",
"=",
"resource",
".",
"get",
"(",
")",
".",
"getText",
"(",
")",
";",
"return",
"mapper",
".",
"readValue",
"(",
"result",
",",
"new",
"TypeReference",
"<",
"List",
"<",
"DownloadHistoryItem",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LEX4JLogger",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Could not retrieve download history correctly!\"",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Returns the download history of the current user
@return the download list of the current user
@custom.require Authentication
|
[
"Returns",
"the",
"download",
"history",
"of",
"the",
"current",
"user"
] |
3d086ec70c817119a88573c2e23af27276cdb1d6
|
https://github.com/caspervg/SC4D-LEX4J/blob/3d086ec70c817119a88573c2e23af27276cdb1d6/lex4j/src/main/java/net/caspervg/lex4j/route/UserRoute.java#L146-L158
|
153,560
|
caspervg/SC4D-LEX4J
|
lex4j/src/main/java/net/caspervg/lex4j/route/UserRoute.java
|
UserRoute.postRegistration
|
public void postRegistration(String username, String password, String email, String fullname) {
ClientResource resource = new ClientResource(Route.REGISTER.url());
Form form = new Form();
form.add("username", username);
form.add("password_1", password);
form.add("password_2", password);
form.add("email", email);
form.add("fullname", fullname);
resource.post(form);
}
|
java
|
public void postRegistration(String username, String password, String email, String fullname) {
ClientResource resource = new ClientResource(Route.REGISTER.url());
Form form = new Form();
form.add("username", username);
form.add("password_1", password);
form.add("password_2", password);
form.add("email", email);
form.add("fullname", fullname);
resource.post(form);
}
|
[
"public",
"void",
"postRegistration",
"(",
"String",
"username",
",",
"String",
"password",
",",
"String",
"email",
",",
"String",
"fullname",
")",
"{",
"ClientResource",
"resource",
"=",
"new",
"ClientResource",
"(",
"Route",
".",
"REGISTER",
".",
"url",
"(",
")",
")",
";",
"Form",
"form",
"=",
"new",
"Form",
"(",
")",
";",
"form",
".",
"add",
"(",
"\"username\"",
",",
"username",
")",
";",
"form",
".",
"add",
"(",
"\"password_1\"",
",",
"password",
")",
";",
"form",
".",
"add",
"(",
"\"password_2\"",
",",
"password",
")",
";",
"form",
".",
"add",
"(",
"\"email\"",
",",
"email",
")",
";",
"form",
".",
"add",
"(",
"\"fullname\"",
",",
"fullname",
")",
";",
"resource",
".",
"post",
"(",
"form",
")",
";",
"}"
] |
Registers a new user for the SC4D LEX
@param username the username for the new user
@param password the password for the new user
@param email the e-mail for the new user
@param fullname the name for the new user (can be blank)
|
[
"Registers",
"a",
"new",
"user",
"for",
"the",
"SC4D",
"LEX"
] |
3d086ec70c817119a88573c2e23af27276cdb1d6
|
https://github.com/caspervg/SC4D-LEX4J/blob/3d086ec70c817119a88573c2e23af27276cdb1d6/lex4j/src/main/java/net/caspervg/lex4j/route/UserRoute.java#L168-L179
|
153,561
|
caspervg/SC4D-LEX4J
|
lex4j/src/main/java/net/caspervg/lex4j/route/UserRoute.java
|
UserRoute.getActivation
|
public void getActivation(String key) {
ClientResource resource = new ClientResource(Route.ACTIVATE.url());
Reference ref = resource.getReference();
Map<String, Object> param = new HashMap<>();
param.put("activation_key", key);
Route.addParameters(ref, param);
resource.get();
}
|
java
|
public void getActivation(String key) {
ClientResource resource = new ClientResource(Route.ACTIVATE.url());
Reference ref = resource.getReference();
Map<String, Object> param = new HashMap<>();
param.put("activation_key", key);
Route.addParameters(ref, param);
resource.get();
}
|
[
"public",
"void",
"getActivation",
"(",
"String",
"key",
")",
"{",
"ClientResource",
"resource",
"=",
"new",
"ClientResource",
"(",
"Route",
".",
"ACTIVATE",
".",
"url",
"(",
")",
")",
";",
"Reference",
"ref",
"=",
"resource",
".",
"getReference",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"param",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"param",
".",
"put",
"(",
"\"activation_key\"",
",",
"key",
")",
";",
"Route",
".",
"addParameters",
"(",
"ref",
",",
"param",
")",
";",
"resource",
".",
"get",
"(",
")",
";",
"}"
] |
Activates a user on the SC4D LEX
@param key the activation key to use
|
[
"Activates",
"a",
"user",
"on",
"the",
"SC4D",
"LEX"
] |
3d086ec70c817119a88573c2e23af27276cdb1d6
|
https://github.com/caspervg/SC4D-LEX4J/blob/3d086ec70c817119a88573c2e23af27276cdb1d6/lex4j/src/main/java/net/caspervg/lex4j/route/UserRoute.java#L186-L196
|
153,562
|
avaje-common/avaje-jetty-runner
|
src/main/java/org/avaje/jettyrunner/BaseRunner.java
|
BaseRunner.createWebAppContext
|
protected void createWebAppContext() {
webapp = new WebAppContext();
webapp.setThrowUnavailableOnStartupException(true);
webapp.setServerClasses(getServerClasses());
webapp.setContextPath(getContextPath());
webapp.setTempDirectory(createTempDir("jetty-app-"));
setSecureCookies();
}
|
java
|
protected void createWebAppContext() {
webapp = new WebAppContext();
webapp.setThrowUnavailableOnStartupException(true);
webapp.setServerClasses(getServerClasses());
webapp.setContextPath(getContextPath());
webapp.setTempDirectory(createTempDir("jetty-app-"));
setSecureCookies();
}
|
[
"protected",
"void",
"createWebAppContext",
"(",
")",
"{",
"webapp",
"=",
"new",
"WebAppContext",
"(",
")",
";",
"webapp",
".",
"setThrowUnavailableOnStartupException",
"(",
"true",
")",
";",
"webapp",
".",
"setServerClasses",
"(",
"getServerClasses",
"(",
")",
")",
";",
"webapp",
".",
"setContextPath",
"(",
"getContextPath",
"(",
")",
")",
";",
"webapp",
".",
"setTempDirectory",
"(",
"createTempDir",
"(",
"\"jetty-app-\"",
")",
")",
";",
"setSecureCookies",
"(",
")",
";",
"}"
] |
Create the WebAppContext with basic configurations set like context path
etc.
|
[
"Create",
"the",
"WebAppContext",
"with",
"basic",
"configurations",
"set",
"like",
"context",
"path",
"etc",
"."
] |
acddc23754facc339233fa0b9736e94abc8ae842
|
https://github.com/avaje-common/avaje-jetty-runner/blob/acddc23754facc339233fa0b9736e94abc8ae842/src/main/java/org/avaje/jettyrunner/BaseRunner.java#L95-L102
|
153,563
|
avaje-common/avaje-jetty-runner
|
src/main/java/org/avaje/jettyrunner/BaseRunner.java
|
BaseRunner.startServer
|
public void startServer() {
server = new Server(httpPort);
server.setHandler(wrapHandlers());
if (isWebSocketInClassPath()) {
setupForWebSocket();
}
try {
server.start();
log().info("server started");
Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownRunnable()));
if (useStdInShutdown) {
// generally for use in IDE via JettyRun, Use CTRL-D in IDE console to shutdown
BufferedReader systemIn = new BufferedReader(new InputStreamReader(System.in, "UTF-8"));
while((systemIn.readLine()) != null) {
// ignore anything except CTRL-D by itself
}
System.out.println("Shutdown via CTRL-D");
System.exit(0);
}
} catch (Exception e) {
e.printStackTrace();
System.exit(100);
}
}
|
java
|
public void startServer() {
server = new Server(httpPort);
server.setHandler(wrapHandlers());
if (isWebSocketInClassPath()) {
setupForWebSocket();
}
try {
server.start();
log().info("server started");
Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownRunnable()));
if (useStdInShutdown) {
// generally for use in IDE via JettyRun, Use CTRL-D in IDE console to shutdown
BufferedReader systemIn = new BufferedReader(new InputStreamReader(System.in, "UTF-8"));
while((systemIn.readLine()) != null) {
// ignore anything except CTRL-D by itself
}
System.out.println("Shutdown via CTRL-D");
System.exit(0);
}
} catch (Exception e) {
e.printStackTrace();
System.exit(100);
}
}
|
[
"public",
"void",
"startServer",
"(",
")",
"{",
"server",
"=",
"new",
"Server",
"(",
"httpPort",
")",
";",
"server",
".",
"setHandler",
"(",
"wrapHandlers",
"(",
")",
")",
";",
"if",
"(",
"isWebSocketInClassPath",
"(",
")",
")",
"{",
"setupForWebSocket",
"(",
")",
";",
"}",
"try",
"{",
"server",
".",
"start",
"(",
")",
";",
"log",
"(",
")",
".",
"info",
"(",
"\"server started\"",
")",
";",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"addShutdownHook",
"(",
"new",
"Thread",
"(",
"new",
"ShutdownRunnable",
"(",
")",
")",
")",
";",
"if",
"(",
"useStdInShutdown",
")",
"{",
"// generally for use in IDE via JettyRun, Use CTRL-D in IDE console to shutdown",
"BufferedReader",
"systemIn",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"System",
".",
"in",
",",
"\"UTF-8\"",
")",
")",
";",
"while",
"(",
"(",
"systemIn",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"// ignore anything except CTRL-D by itself",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"Shutdown via CTRL-D\"",
")",
";",
"System",
".",
"exit",
"(",
"0",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"System",
".",
"exit",
"(",
"100",
")",
";",
"}",
"}"
] |
Start the Jetty server.
|
[
"Start",
"the",
"Jetty",
"server",
"."
] |
acddc23754facc339233fa0b9736e94abc8ae842
|
https://github.com/avaje-common/avaje-jetty-runner/blob/acddc23754facc339233fa0b9736e94abc8ae842/src/main/java/org/avaje/jettyrunner/BaseRunner.java#L161-L189
|
153,564
|
avaje-common/avaje-jetty-runner
|
src/main/java/org/avaje/jettyrunner/BaseRunner.java
|
BaseRunner.setSecureCookies
|
protected void setSecureCookies() {
SessionManager sessionManager = webapp.getSessionHandler().getSessionManager();
if (!(sessionManager instanceof AbstractSessionManager)) {
throw new RuntimeException("Cannot set secure cookies on session manager.");
}
AbstractSessionManager abstractSessionManager = (AbstractSessionManager) sessionManager;
abstractSessionManager.getSessionCookieConfig().setSecure(isSecureCookies());
abstractSessionManager.setHttpOnly(true);
}
|
java
|
protected void setSecureCookies() {
SessionManager sessionManager = webapp.getSessionHandler().getSessionManager();
if (!(sessionManager instanceof AbstractSessionManager)) {
throw new RuntimeException("Cannot set secure cookies on session manager.");
}
AbstractSessionManager abstractSessionManager = (AbstractSessionManager) sessionManager;
abstractSessionManager.getSessionCookieConfig().setSecure(isSecureCookies());
abstractSessionManager.setHttpOnly(true);
}
|
[
"protected",
"void",
"setSecureCookies",
"(",
")",
"{",
"SessionManager",
"sessionManager",
"=",
"webapp",
".",
"getSessionHandler",
"(",
")",
".",
"getSessionManager",
"(",
")",
";",
"if",
"(",
"!",
"(",
"sessionManager",
"instanceof",
"AbstractSessionManager",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Cannot set secure cookies on session manager.\"",
")",
";",
"}",
"AbstractSessionManager",
"abstractSessionManager",
"=",
"(",
"AbstractSessionManager",
")",
"sessionManager",
";",
"abstractSessionManager",
".",
"getSessionCookieConfig",
"(",
")",
".",
"setSecure",
"(",
"isSecureCookies",
"(",
")",
")",
";",
"abstractSessionManager",
".",
"setHttpOnly",
"(",
"true",
")",
";",
"}"
] |
Set the secure cookies setting on the jetty session manager.
|
[
"Set",
"the",
"secure",
"cookies",
"setting",
"on",
"the",
"jetty",
"session",
"manager",
"."
] |
acddc23754facc339233fa0b9736e94abc8ae842
|
https://github.com/avaje-common/avaje-jetty-runner/blob/acddc23754facc339233fa0b9736e94abc8ae842/src/main/java/org/avaje/jettyrunner/BaseRunner.java#L218-L229
|
153,565
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.copy
|
public static File copy(InputStream stream) throws IOException
{
File file = createTempFile();
copy(stream, new FileOutputStream(file));
return file;
}
|
java
|
public static File copy(InputStream stream) throws IOException
{
File file = createTempFile();
copy(stream, new FileOutputStream(file));
return file;
}
|
[
"public",
"static",
"File",
"copy",
"(",
"InputStream",
"stream",
")",
"throws",
"IOException",
"{",
"File",
"file",
"=",
"createTempFile",
"(",
")",
";",
"copy",
"(",
"stream",
",",
"new",
"FileOutputStream",
"(",
"file",
")",
")",
";",
"return",
"file",
";",
"}"
] |
Binary copy to temporary file. Be aware that temporary file is removed at JVM exit.
@param stream source stream.
@return temporarily created file.
@throws IOException if copy operation fails.
|
[
"Binary",
"copy",
"to",
"temporary",
"file",
".",
"Be",
"aware",
"that",
"temporary",
"file",
"is",
"removed",
"at",
"JVM",
"exit",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L136-L141
|
153,566
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.copy
|
public static File copy(URL url, String encoding) throws IOException, IllegalArgumentException
{
Params.notNull(url, "Source URL");
URLConnection connection = url.openConnection();
connection.setDoInput(true);
return copy(connection.getInputStream(), encoding);
}
|
java
|
public static File copy(URL url, String encoding) throws IOException, IllegalArgumentException
{
Params.notNull(url, "Source URL");
URLConnection connection = url.openConnection();
connection.setDoInput(true);
return copy(connection.getInputStream(), encoding);
}
|
[
"public",
"static",
"File",
"copy",
"(",
"URL",
"url",
",",
"String",
"encoding",
")",
"throws",
"IOException",
",",
"IllegalArgumentException",
"{",
"Params",
".",
"notNull",
"(",
"url",
",",
"\"Source URL\"",
")",
";",
"URLConnection",
"connection",
"=",
"url",
".",
"openConnection",
"(",
")",
";",
"connection",
".",
"setDoInput",
"(",
"true",
")",
";",
"return",
"copy",
"(",
"connection",
".",
"getInputStream",
"(",
")",
",",
"encoding",
")",
";",
"}"
] |
Copy text from URL using specified encoding to local temporary file then close both URL input stream and temporary
file.
@param url source file URL,
@param encoding character encoding to use.
@return temporarily created file.
@throws IOException if copy operation fails.
@throws IllegalArgumentException if <code>url</code> parameter is null.
|
[
"Copy",
"text",
"from",
"URL",
"using",
"specified",
"encoding",
"to",
"local",
"temporary",
"file",
"then",
"close",
"both",
"URL",
"input",
"stream",
"and",
"temporary",
"file",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L153-L159
|
153,567
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.copy
|
public static File copy(InputStream stream, String encoding) throws IOException
{
File file = createTempFile();
copy(new InputStreamReader(stream, encoding), new OutputStreamWriter(new FileOutputStream(file), encoding));
return file;
}
|
java
|
public static File copy(InputStream stream, String encoding) throws IOException
{
File file = createTempFile();
copy(new InputStreamReader(stream, encoding), new OutputStreamWriter(new FileOutputStream(file), encoding));
return file;
}
|
[
"public",
"static",
"File",
"copy",
"(",
"InputStream",
"stream",
",",
"String",
"encoding",
")",
"throws",
"IOException",
"{",
"File",
"file",
"=",
"createTempFile",
"(",
")",
";",
"copy",
"(",
"new",
"InputStreamReader",
"(",
"stream",
",",
"encoding",
")",
",",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"file",
")",
",",
"encoding",
")",
")",
";",
"return",
"file",
";",
"}"
] |
Copy text from byte stream using specified encoding to temporary file then close both input stream and temporary
file. Be aware that temporary file is removed at JVM exit.
@param stream input stream to read from,
@param encoding used character encoding.
@return temporarily created file.
@throws IOException if copy operation fails.
|
[
"Copy",
"text",
"from",
"byte",
"stream",
"using",
"specified",
"encoding",
"to",
"temporary",
"file",
"then",
"close",
"both",
"input",
"stream",
"and",
"temporary",
"file",
".",
"Be",
"aware",
"that",
"temporary",
"file",
"is",
"removed",
"at",
"JVM",
"exit",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L170-L175
|
153,568
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.copy
|
public static File copy(Reader reader) throws IOException
{
File file = createTempFile();
copy(reader, new FileWriter(file));
return file;
}
|
java
|
public static File copy(Reader reader) throws IOException
{
File file = createTempFile();
copy(reader, new FileWriter(file));
return file;
}
|
[
"public",
"static",
"File",
"copy",
"(",
"Reader",
"reader",
")",
"throws",
"IOException",
"{",
"File",
"file",
"=",
"createTempFile",
"(",
")",
";",
"copy",
"(",
"reader",
",",
"new",
"FileWriter",
"(",
"file",
")",
")",
";",
"return",
"file",
";",
"}"
] |
Copy text from character stream to temporary file then close both the source reader and temporary file. Be aware
that temporary file is removed at JVM exit.
@param reader source character reader.
@return the newly created temporarily file.
@throws IOException if copy operation fails.
|
[
"Copy",
"text",
"from",
"character",
"stream",
"to",
"temporary",
"file",
"then",
"close",
"both",
"the",
"source",
"reader",
"and",
"temporary",
"file",
".",
"Be",
"aware",
"that",
"temporary",
"file",
"is",
"removed",
"at",
"JVM",
"exit",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L185-L190
|
153,569
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.copy
|
public static long copy(File source, File target) throws FileNotFoundException, IOException
{
return copy(new FileInputStream(source), new FileOutputStream(target));
}
|
java
|
public static long copy(File source, File target) throws FileNotFoundException, IOException
{
return copy(new FileInputStream(source), new FileOutputStream(target));
}
|
[
"public",
"static",
"long",
"copy",
"(",
"File",
"source",
",",
"File",
"target",
")",
"throws",
"FileNotFoundException",
",",
"IOException",
"{",
"return",
"copy",
"(",
"new",
"FileInputStream",
"(",
"source",
")",
",",
"new",
"FileOutputStream",
"(",
"target",
")",
")",
";",
"}"
] |
Copy source file to target. Copy destination should be a file and this method throws access denied if attempt to
write to a directory. Source file should exist but target is created by this method, but if not already exist.
@param source file to read from, should exist,
@param target file to write to.
@return the number of bytes transfered.
@throws FileNotFoundException if source file does not exist or target file does not exist and cannot be created.
@throws IOException if copy operation fails, including if <code>target</code> is a directory.
|
[
"Copy",
"source",
"file",
"to",
"target",
".",
"Copy",
"destination",
"should",
"be",
"a",
"file",
"and",
"this",
"method",
"throws",
"access",
"denied",
"if",
"attempt",
"to",
"write",
"to",
"a",
"directory",
".",
"Source",
"file",
"should",
"exist",
"but",
"target",
"is",
"created",
"by",
"this",
"method",
"but",
"if",
"not",
"already",
"exist",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L202-L205
|
153,570
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.copy
|
public static int copy(Reader reader, Writer writer) throws IOException
{
Params.notNull(reader, "Reader");
Params.notNull(writer, "Writer");
if(!(reader instanceof BufferedReader)) {
reader = new BufferedReader(reader);
}
if(!(writer instanceof BufferedWriter)) {
writer = new BufferedWriter(writer);
}
int charsCount = 0;
try {
char[] buffer = new char[BUFFER_SIZE];
for(;;) {
int readChars = reader.read(buffer);
if(readChars == -1) {
break;
}
charsCount += readChars;
writer.write(buffer, 0, readChars);
}
}
finally {
close(reader);
close(writer);
}
return charsCount;
}
|
java
|
public static int copy(Reader reader, Writer writer) throws IOException
{
Params.notNull(reader, "Reader");
Params.notNull(writer, "Writer");
if(!(reader instanceof BufferedReader)) {
reader = new BufferedReader(reader);
}
if(!(writer instanceof BufferedWriter)) {
writer = new BufferedWriter(writer);
}
int charsCount = 0;
try {
char[] buffer = new char[BUFFER_SIZE];
for(;;) {
int readChars = reader.read(buffer);
if(readChars == -1) {
break;
}
charsCount += readChars;
writer.write(buffer, 0, readChars);
}
}
finally {
close(reader);
close(writer);
}
return charsCount;
}
|
[
"public",
"static",
"int",
"copy",
"(",
"Reader",
"reader",
",",
"Writer",
"writer",
")",
"throws",
"IOException",
"{",
"Params",
".",
"notNull",
"(",
"reader",
",",
"\"Reader\"",
")",
";",
"Params",
".",
"notNull",
"(",
"writer",
",",
"\"Writer\"",
")",
";",
"if",
"(",
"!",
"(",
"reader",
"instanceof",
"BufferedReader",
")",
")",
"{",
"reader",
"=",
"new",
"BufferedReader",
"(",
"reader",
")",
";",
"}",
"if",
"(",
"!",
"(",
"writer",
"instanceof",
"BufferedWriter",
")",
")",
"{",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"writer",
")",
";",
"}",
"int",
"charsCount",
"=",
"0",
";",
"try",
"{",
"char",
"[",
"]",
"buffer",
"=",
"new",
"char",
"[",
"BUFFER_SIZE",
"]",
";",
"for",
"(",
";",
";",
")",
"{",
"int",
"readChars",
"=",
"reader",
".",
"read",
"(",
"buffer",
")",
";",
"if",
"(",
"readChars",
"==",
"-",
"1",
")",
"{",
"break",
";",
"}",
"charsCount",
"+=",
"readChars",
";",
"writer",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"readChars",
")",
";",
"}",
"}",
"finally",
"{",
"close",
"(",
"reader",
")",
";",
"close",
"(",
"writer",
")",
";",
"}",
"return",
"charsCount",
";",
"}"
] |
Copy characters from a reader to a given writer then close both character streams.
@param reader character stream to read from,
@param writer character stream to write to.
@return the number of characters processed.
@throws IOException if read or write operation fails.
@throws IllegalArgumentException if reader or writer is null.
|
[
"Copy",
"characters",
"from",
"a",
"reader",
"to",
"a",
"given",
"writer",
"then",
"close",
"both",
"character",
"streams",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L216-L245
|
153,571
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.copy
|
public static long copy(InputStream inputStream, File file) throws FileNotFoundException, IOException
{
return copy(inputStream, new FileOutputStream(file));
}
|
java
|
public static long copy(InputStream inputStream, File file) throws FileNotFoundException, IOException
{
return copy(inputStream, new FileOutputStream(file));
}
|
[
"public",
"static",
"long",
"copy",
"(",
"InputStream",
"inputStream",
",",
"File",
"file",
")",
"throws",
"FileNotFoundException",
",",
"IOException",
"{",
"return",
"copy",
"(",
"inputStream",
",",
"new",
"FileOutputStream",
"(",
"file",
")",
")",
";",
"}"
] |
Copy bytes from requested input stream to given target file. This method creates the target file if does not
already exist.
@param inputStream source input stream,
@param file target file.
@return the number of bytes processed.
@throws FileNotFoundException if given <code>file</code> does not exist and cannot be created.
@throws IOException if bytes transfer fails.
|
[
"Copy",
"bytes",
"from",
"requested",
"input",
"stream",
"to",
"given",
"target",
"file",
".",
"This",
"method",
"creates",
"the",
"target",
"file",
"if",
"does",
"not",
"already",
"exist",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L296-L299
|
153,572
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.copy
|
public static long copy(URL url, File file) throws FileNotFoundException, IOException
{
return copy(url, new FileOutputStream(file));
}
|
java
|
public static long copy(URL url, File file) throws FileNotFoundException, IOException
{
return copy(url, new FileOutputStream(file));
}
|
[
"public",
"static",
"long",
"copy",
"(",
"URL",
"url",
",",
"File",
"file",
")",
"throws",
"FileNotFoundException",
",",
"IOException",
"{",
"return",
"copy",
"(",
"url",
",",
"new",
"FileOutputStream",
"(",
"file",
")",
")",
";",
"}"
] |
Copy bytes from remote file denoted by given URL to specified local file. This method creates local file if not
already exists.
@param url source remote file URL,
@param file target local file.
@return the number of bytes transfered.
@throws FileNotFoundException if given <code>file</code> does not exist and cannot be created.
@throws IOException if bytes transfer fails.
|
[
"Copy",
"bytes",
"from",
"remote",
"file",
"denoted",
"by",
"given",
"URL",
"to",
"specified",
"local",
"file",
".",
"This",
"method",
"creates",
"local",
"file",
"if",
"not",
"already",
"exists",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L311-L314
|
153,573
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.copy
|
public static long copy(File file, OutputStream outputStream) throws IOException
{
Params.notNull(file, "Input file");
return copy(new FileInputStream(file), outputStream);
}
|
java
|
public static long copy(File file, OutputStream outputStream) throws IOException
{
Params.notNull(file, "Input file");
return copy(new FileInputStream(file), outputStream);
}
|
[
"public",
"static",
"long",
"copy",
"(",
"File",
"file",
",",
"OutputStream",
"outputStream",
")",
"throws",
"IOException",
"{",
"Params",
".",
"notNull",
"(",
"file",
",",
"\"Input file\"",
")",
";",
"return",
"copy",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
",",
"outputStream",
")",
";",
"}"
] |
Copy source file bytes to requested output stream. Note that output stream is closed after transfer completes,
including on error.
@param file source file,
@param outputStream destination output stream.
@return the number of bytes processed.
@throws FileNotFoundException if <code>file</code> does not exist.
@throws IOException bytes processing fails.
@throws IllegalArgumentException if input file or output stream is null.
|
[
"Copy",
"source",
"file",
"bytes",
"to",
"requested",
"output",
"stream",
".",
"Note",
"that",
"output",
"stream",
"is",
"closed",
"after",
"transfer",
"completes",
"including",
"on",
"error",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L346-L350
|
153,574
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.dump
|
public static void dump(InputStream inputStream) throws IOException
{
if(!(inputStream instanceof BufferedInputStream)) {
inputStream = new BufferedInputStream(inputStream);
}
try {
byte[] buffer = new byte[BUFFER_SIZE];
int length;
while((length = inputStream.read(buffer)) != -1) {
System.out.write(buffer, 0, length);
}
}
finally {
inputStream.close();
}
}
|
java
|
public static void dump(InputStream inputStream) throws IOException
{
if(!(inputStream instanceof BufferedInputStream)) {
inputStream = new BufferedInputStream(inputStream);
}
try {
byte[] buffer = new byte[BUFFER_SIZE];
int length;
while((length = inputStream.read(buffer)) != -1) {
System.out.write(buffer, 0, length);
}
}
finally {
inputStream.close();
}
}
|
[
"public",
"static",
"void",
"dump",
"(",
"InputStream",
"inputStream",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"(",
"inputStream",
"instanceof",
"BufferedInputStream",
")",
")",
"{",
"inputStream",
"=",
"new",
"BufferedInputStream",
"(",
"inputStream",
")",
";",
"}",
"try",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"BUFFER_SIZE",
"]",
";",
"int",
"length",
";",
"while",
"(",
"(",
"length",
"=",
"inputStream",
".",
"read",
"(",
"buffer",
")",
")",
"!=",
"-",
"1",
")",
"{",
"System",
".",
"out",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"length",
")",
";",
"}",
"}",
"finally",
"{",
"inputStream",
".",
"close",
"(",
")",
";",
"}",
"}"
] |
Dump byte input stream content to standard output till end of input stream. Input stream is closed.
@param inputStream source byte input stream.
@throws IOException if reading from input stream fails.
|
[
"Dump",
"byte",
"input",
"stream",
"content",
"to",
"standard",
"output",
"till",
"end",
"of",
"input",
"stream",
".",
"Input",
"stream",
"is",
"closed",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L425-L440
|
153,575
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.move
|
public static boolean move(String sourcePath, String targetPath) throws IllegalArgumentException
{
Params.notNull(sourcePath, "Source path");
Params.notNull(targetPath, "Target path");
File sourceFile = new File(sourcePath);
if(!sourceFile.exists()) {
log.error("Missing file to move |%s|.", sourcePath);
return false;
}
File targetFile = new File(targetPath);
if(targetFile.exists()) {
log.debug("Target file exists |%s|. File moving aborted.", targetPath);
return false;
}
return sourceFile.renameTo(targetFile);
}
|
java
|
public static boolean move(String sourcePath, String targetPath) throws IllegalArgumentException
{
Params.notNull(sourcePath, "Source path");
Params.notNull(targetPath, "Target path");
File sourceFile = new File(sourcePath);
if(!sourceFile.exists()) {
log.error("Missing file to move |%s|.", sourcePath);
return false;
}
File targetFile = new File(targetPath);
if(targetFile.exists()) {
log.debug("Target file exists |%s|. File moving aborted.", targetPath);
return false;
}
return sourceFile.renameTo(targetFile);
}
|
[
"public",
"static",
"boolean",
"move",
"(",
"String",
"sourcePath",
",",
"String",
"targetPath",
")",
"throws",
"IllegalArgumentException",
"{",
"Params",
".",
"notNull",
"(",
"sourcePath",
",",
"\"Source path\"",
")",
";",
"Params",
".",
"notNull",
"(",
"targetPath",
",",
"\"Target path\"",
")",
";",
"File",
"sourceFile",
"=",
"new",
"File",
"(",
"sourcePath",
")",
";",
"if",
"(",
"!",
"sourceFile",
".",
"exists",
"(",
")",
")",
"{",
"log",
".",
"error",
"(",
"\"Missing file to move |%s|.\"",
",",
"sourcePath",
")",
";",
"return",
"false",
";",
"}",
"File",
"targetFile",
"=",
"new",
"File",
"(",
"targetPath",
")",
";",
"if",
"(",
"targetFile",
".",
"exists",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"Target file exists |%s|. File moving aborted.\"",
",",
"targetPath",
")",
";",
"return",
"false",
";",
"}",
"return",
"sourceFile",
".",
"renameTo",
"(",
"targetFile",
")",
";",
"}"
] |
Move source file to requested destination but do not overwrite. This method takes care to not overwrite destination
file and returns false if it already exists. Note that this method does not throw exceptions if move fails and
caller should always test returned boolean to determine if operation completes.
@param sourcePath source file path,
@param targetPath target file path.
@return true if move completes, false if source does not exist, destination already exists or move fails.
@throws IllegalArgumentException if source or target path parameter is null.
|
[
"Move",
"source",
"file",
"to",
"requested",
"destination",
"but",
"do",
"not",
"overwrite",
".",
"This",
"method",
"takes",
"care",
"to",
"not",
"overwrite",
"destination",
"file",
"and",
"returns",
"false",
"if",
"it",
"already",
"exists",
".",
"Note",
"that",
"this",
"method",
"does",
"not",
"throw",
"exceptions",
"if",
"move",
"fails",
"and",
"caller",
"should",
"always",
"test",
"returned",
"boolean",
"to",
"determine",
"if",
"operation",
"completes",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L517-L533
|
153,576
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.getPathComponents
|
public static List<String> getPathComponents(File file)
{
if(file == null) {
return Collections.emptyList();
}
List<String> pathComponents = new ArrayList<String>();
do {
pathComponents.add(0, file.getName());
file = file.getParentFile();
}
while(file != null);
return pathComponents;
}
|
java
|
public static List<String> getPathComponents(File file)
{
if(file == null) {
return Collections.emptyList();
}
List<String> pathComponents = new ArrayList<String>();
do {
pathComponents.add(0, file.getName());
file = file.getParentFile();
}
while(file != null);
return pathComponents;
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"getPathComponents",
"(",
"File",
"file",
")",
"{",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"List",
"<",
"String",
">",
"pathComponents",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"do",
"{",
"pathComponents",
".",
"add",
"(",
"0",
",",
"file",
".",
"getName",
"(",
")",
")",
";",
"file",
"=",
"file",
".",
"getParentFile",
"(",
")",
";",
"}",
"while",
"(",
"file",
"!=",
"null",
")",
";",
"return",
"pathComponents",
";",
"}"
] |
Get file path components. Return a list of path components in their natural order. List first item is path root
stored as an empty string; if file argument is empty returned list contains only root. If file argument is null
returns empty list.
@param file file to retrieve path components.
@return file path components.
|
[
"Get",
"file",
"path",
"components",
".",
"Return",
"a",
"list",
"of",
"path",
"components",
"in",
"their",
"natural",
"order",
".",
"List",
"first",
"item",
"is",
"path",
"root",
"stored",
"as",
"an",
"empty",
"string",
";",
"if",
"file",
"argument",
"is",
"empty",
"returned",
"list",
"contains",
"only",
"root",
".",
"If",
"file",
"argument",
"is",
"null",
"returns",
"empty",
"list",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L599-L611
|
153,577
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.removeExtension
|
public static String removeExtension(String path) throws IllegalArgumentException
{
Params.notNull(path, "Path");
int extensionIndex = path.lastIndexOf('.');
return extensionIndex != -1 ? path.substring(0, extensionIndex) : path;
}
|
java
|
public static String removeExtension(String path) throws IllegalArgumentException
{
Params.notNull(path, "Path");
int extensionIndex = path.lastIndexOf('.');
return extensionIndex != -1 ? path.substring(0, extensionIndex) : path;
}
|
[
"public",
"static",
"String",
"removeExtension",
"(",
"String",
"path",
")",
"throws",
"IllegalArgumentException",
"{",
"Params",
".",
"notNull",
"(",
"path",
",",
"\"Path\"",
")",
";",
"int",
"extensionIndex",
"=",
"path",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"return",
"extensionIndex",
"!=",
"-",
"1",
"?",
"path",
".",
"substring",
"(",
"0",
",",
"extensionIndex",
")",
":",
"path",
";",
"}"
] |
Remove extension from given file path and return resulting path.
@param path file path to remove extension from.
@return newly created path without extension.
@throws IllegalArgumentException if <code>path</code> parameter is null.
|
[
"Remove",
"extension",
"from",
"given",
"file",
"path",
"and",
"return",
"resulting",
"path",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L620-L625
|
153,578
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.removeExtension
|
public static File removeExtension(File file) throws IllegalArgumentException
{
Params.notNull(file, "File");
return new File(removeExtension(file.getPath()));
}
|
java
|
public static File removeExtension(File file) throws IllegalArgumentException
{
Params.notNull(file, "File");
return new File(removeExtension(file.getPath()));
}
|
[
"public",
"static",
"File",
"removeExtension",
"(",
"File",
"file",
")",
"throws",
"IllegalArgumentException",
"{",
"Params",
".",
"notNull",
"(",
"file",
",",
"\"File\"",
")",
";",
"return",
"new",
"File",
"(",
"removeExtension",
"(",
"file",
".",
"getPath",
"(",
")",
")",
")",
";",
"}"
] |
Remove extension from given file and create a new one with resulting path.
@param file file to remove extension from.
@return newly created file without extension.
@throws IllegalArgumentException if <code>file</code> parameter is null.
|
[
"Remove",
"extension",
"from",
"given",
"file",
"and",
"create",
"a",
"new",
"one",
"with",
"resulting",
"path",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L634-L638
|
153,579
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.replaceExtension
|
public static String replaceExtension(String path, String newExtension) throws IllegalArgumentException
{
Params.notNull(path, "Path");
Params.notNull(newExtension, "New extension");
if(newExtension.charAt(0) == '.') {
newExtension = newExtension.substring(1);
}
int extensionDotIndex = path.lastIndexOf('.') + 1;
if(extensionDotIndex == 0) {
extensionDotIndex = path.length();
}
StringBuilder sb = new StringBuilder(path.length());
sb.append(path.substring(0, extensionDotIndex));
sb.append(newExtension);
return sb.toString();
}
|
java
|
public static String replaceExtension(String path, String newExtension) throws IllegalArgumentException
{
Params.notNull(path, "Path");
Params.notNull(newExtension, "New extension");
if(newExtension.charAt(0) == '.') {
newExtension = newExtension.substring(1);
}
int extensionDotIndex = path.lastIndexOf('.') + 1;
if(extensionDotIndex == 0) {
extensionDotIndex = path.length();
}
StringBuilder sb = new StringBuilder(path.length());
sb.append(path.substring(0, extensionDotIndex));
sb.append(newExtension);
return sb.toString();
}
|
[
"public",
"static",
"String",
"replaceExtension",
"(",
"String",
"path",
",",
"String",
"newExtension",
")",
"throws",
"IllegalArgumentException",
"{",
"Params",
".",
"notNull",
"(",
"path",
",",
"\"Path\"",
")",
";",
"Params",
".",
"notNull",
"(",
"newExtension",
",",
"\"New extension\"",
")",
";",
"if",
"(",
"newExtension",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
")",
"{",
"newExtension",
"=",
"newExtension",
".",
"substring",
"(",
"1",
")",
";",
"}",
"int",
"extensionDotIndex",
"=",
"path",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
";",
"if",
"(",
"extensionDotIndex",
"==",
"0",
")",
"{",
"extensionDotIndex",
"=",
"path",
".",
"length",
"(",
")",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"path",
".",
"length",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"path",
".",
"substring",
"(",
"0",
",",
"extensionDotIndex",
")",
")",
";",
"sb",
".",
"append",
"(",
"newExtension",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Replace extension on given file path and return resulting path. Is legal for new extension parameter to start with
dot extension separator, but is not mandatory.
@param path file path to replace extension,
@param newExtension newly extension, with optional dot separator prefix.
@return newly created file path.
@throws IllegalArgumentException if path or new extension parameter is null.
|
[
"Replace",
"extension",
"on",
"given",
"file",
"path",
"and",
"return",
"resulting",
"path",
".",
"Is",
"legal",
"for",
"new",
"extension",
"parameter",
"to",
"start",
"with",
"dot",
"extension",
"separator",
"but",
"is",
"not",
"mandatory",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L649-L666
|
153,580
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.replaceExtension
|
public static File replaceExtension(File file, String newExtension) throws IllegalArgumentException
{
Params.notNull(file, "File");
return new File(replaceExtension(file.getPath(), newExtension));
}
|
java
|
public static File replaceExtension(File file, String newExtension) throws IllegalArgumentException
{
Params.notNull(file, "File");
return new File(replaceExtension(file.getPath(), newExtension));
}
|
[
"public",
"static",
"File",
"replaceExtension",
"(",
"File",
"file",
",",
"String",
"newExtension",
")",
"throws",
"IllegalArgumentException",
"{",
"Params",
".",
"notNull",
"(",
"file",
",",
"\"File\"",
")",
";",
"return",
"new",
"File",
"(",
"replaceExtension",
"(",
"file",
".",
"getPath",
"(",
")",
",",
"newExtension",
")",
")",
";",
"}"
] |
Replace extension on given file and return resulting file.
@param file file to replace extension,
@param newExtension newly extension.
@return newly created file.
@throws IllegalArgumentException if file parameter is null.
|
[
"Replace",
"extension",
"on",
"given",
"file",
"and",
"return",
"resulting",
"file",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L676-L680
|
153,581
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.dot2path
|
public static String dot2path(String qualifiedName)
{
return qualifiedName != null ? DOT_PATTERN.matcher(qualifiedName).replaceAll(Matcher.quoteReplacement(File.separator)) : null;
}
|
java
|
public static String dot2path(String qualifiedName)
{
return qualifiedName != null ? DOT_PATTERN.matcher(qualifiedName).replaceAll(Matcher.quoteReplacement(File.separator)) : null;
}
|
[
"public",
"static",
"String",
"dot2path",
"(",
"String",
"qualifiedName",
")",
"{",
"return",
"qualifiedName",
"!=",
"null",
"?",
"DOT_PATTERN",
".",
"matcher",
"(",
"qualifiedName",
")",
".",
"replaceAll",
"(",
"Matcher",
".",
"quoteReplacement",
"(",
"File",
".",
"separator",
")",
")",
":",
"null",
";",
"}"
] |
Replace all dots from given qualified name with platform specific path separator.
<pre>
js.net.Transaction -> js/net/Transaction or js\net\Transaction
</pre>
Returns null if <code>qualifiedName</code> parameter is null.
@param qualifiedName qualified name.
@return resulting path or null.
|
[
"Replace",
"all",
"dots",
"from",
"given",
"qualified",
"name",
"with",
"platform",
"specific",
"path",
"separator",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L750-L753
|
153,582
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.basename
|
public static String basename(String path)
{
return path != null ? basename(new File(path)) : null;
}
|
java
|
public static String basename(String path)
{
return path != null ? basename(new File(path)) : null;
}
|
[
"public",
"static",
"String",
"basename",
"(",
"String",
"path",
")",
"{",
"return",
"path",
"!=",
"null",
"?",
"basename",
"(",
"new",
"File",
"(",
"path",
")",
")",
":",
"null",
";",
"}"
] |
Return base name for given file path. Returns null if given path parameter is null.
@param path file path string.
@return file name without extension or null.
|
[
"Return",
"base",
"name",
"for",
"given",
"file",
"path",
".",
"Returns",
"null",
"if",
"given",
"path",
"parameter",
"is",
"null",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L883-L886
|
153,583
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.createTempFile
|
private static File createTempFile() throws IOException
{
File file = File.createTempFile(TMP_FILE_PREFIX, TMP_FILE_EXTENSION);
file.deleteOnExit();
return file;
}
|
java
|
private static File createTempFile() throws IOException
{
File file = File.createTempFile(TMP_FILE_PREFIX, TMP_FILE_EXTENSION);
file.deleteOnExit();
return file;
}
|
[
"private",
"static",
"File",
"createTempFile",
"(",
")",
"throws",
"IOException",
"{",
"File",
"file",
"=",
"File",
".",
"createTempFile",
"(",
"TMP_FILE_PREFIX",
",",
"TMP_FILE_EXTENSION",
")",
";",
"file",
".",
"deleteOnExit",
"(",
")",
";",
"return",
"file",
";",
"}"
] |
Create temporary file using library specific prefix and extension. Created file is removed at JVM exit.
@return newly create temporary file.
@throws IOException if file creation fails.
|
[
"Create",
"temporary",
"file",
"using",
"library",
"specific",
"prefix",
"and",
"extension",
".",
"Created",
"file",
"is",
"removed",
"at",
"JVM",
"exit",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L899-L904
|
153,584
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.isImage
|
public static boolean isImage(File file)
{
return file != null ? IMAGE_FILE_EXTENSIONS.contains(Files.getExtension(file)) : false;
}
|
java
|
public static boolean isImage(File file)
{
return file != null ? IMAGE_FILE_EXTENSIONS.contains(Files.getExtension(file)) : false;
}
|
[
"public",
"static",
"boolean",
"isImage",
"(",
"File",
"file",
")",
"{",
"return",
"file",
"!=",
"null",
"?",
"IMAGE_FILE_EXTENSIONS",
".",
"contains",
"(",
"Files",
".",
"getExtension",
"(",
"file",
")",
")",
":",
"false",
";",
"}"
] |
Guess if file is an image file based on file extension. This is a very trivial test relying on file extension and
obviously cannot guarantee correct results.
@param file file to test.
@return true if given file is an image file.
|
[
"Guess",
"if",
"file",
"is",
"an",
"image",
"file",
"based",
"on",
"file",
"extension",
".",
"This",
"is",
"a",
"very",
"trivial",
"test",
"relying",
"on",
"file",
"extension",
"and",
"obviously",
"cannot",
"guarantee",
"correct",
"results",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L924-L927
|
153,585
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.getFileDigest
|
public static byte[] getFileDigest(InputStream inputStream) throws IOException
{
if(!(inputStream instanceof BufferedInputStream)) {
inputStream = new BufferedInputStream(inputStream);
}
MessageDigest messageDigest = null;
try {
byte[] buffer = new byte[1024];
messageDigest = MessageDigest.getInstance("MD5");
for(;;) {
int bytesRead = inputStream.read(buffer);
if(bytesRead <= 0) {
break;
}
messageDigest.update(buffer, 0, bytesRead);
}
}
catch(NoSuchAlgorithmException e) {
throw new BugError("JVM with missing MD5 algorithm for message digest.");
}
finally {
inputStream.close();
}
return messageDigest.digest();
}
|
java
|
public static byte[] getFileDigest(InputStream inputStream) throws IOException
{
if(!(inputStream instanceof BufferedInputStream)) {
inputStream = new BufferedInputStream(inputStream);
}
MessageDigest messageDigest = null;
try {
byte[] buffer = new byte[1024];
messageDigest = MessageDigest.getInstance("MD5");
for(;;) {
int bytesRead = inputStream.read(buffer);
if(bytesRead <= 0) {
break;
}
messageDigest.update(buffer, 0, bytesRead);
}
}
catch(NoSuchAlgorithmException e) {
throw new BugError("JVM with missing MD5 algorithm for message digest.");
}
finally {
inputStream.close();
}
return messageDigest.digest();
}
|
[
"public",
"static",
"byte",
"[",
"]",
"getFileDigest",
"(",
"InputStream",
"inputStream",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"(",
"inputStream",
"instanceof",
"BufferedInputStream",
")",
")",
"{",
"inputStream",
"=",
"new",
"BufferedInputStream",
"(",
"inputStream",
")",
";",
"}",
"MessageDigest",
"messageDigest",
"=",
"null",
";",
"try",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"1024",
"]",
";",
"messageDigest",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"\"MD5\"",
")",
";",
"for",
"(",
";",
";",
")",
"{",
"int",
"bytesRead",
"=",
"inputStream",
".",
"read",
"(",
"buffer",
")",
";",
"if",
"(",
"bytesRead",
"<=",
"0",
")",
"{",
"break",
";",
"}",
"messageDigest",
".",
"update",
"(",
"buffer",
",",
"0",
",",
"bytesRead",
")",
";",
"}",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"throw",
"new",
"BugError",
"(",
"\"JVM with missing MD5 algorithm for message digest.\"",
")",
";",
"}",
"finally",
"{",
"inputStream",
".",
"close",
"(",
")",
";",
"}",
"return",
"messageDigest",
".",
"digest",
"(",
")",
";",
"}"
] |
Create MD5 message digest for bytes produced by given input stream till its end. This method returns a 16-bytes
array with computed MD5 message digest value. Note that input stream is read till its end and is closed before this
method returning, including on stream read error.
@param inputStream input stream for source bytes.
@return 16-bytes array of message digest.
@throws IOException if file read operation fails.
|
[
"Create",
"MD5",
"message",
"digest",
"for",
"bytes",
"produced",
"by",
"given",
"input",
"stream",
"till",
"its",
"end",
".",
"This",
"method",
"returns",
"a",
"16",
"-",
"bytes",
"array",
"with",
"computed",
"MD5",
"message",
"digest",
"value",
".",
"Note",
"that",
"input",
"stream",
"is",
"read",
"till",
"its",
"end",
"and",
"is",
"closed",
"before",
"this",
"method",
"returning",
"including",
"on",
"stream",
"read",
"error",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L963-L989
|
153,586
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.delete
|
public static void delete(File file) throws IOException
{
Params.notNull(file, "File");
if(file.exists() && !file.delete()) {
throw new IOException(Strings.format("Fail to delete file |%s|.", file));
}
}
|
java
|
public static void delete(File file) throws IOException
{
Params.notNull(file, "File");
if(file.exists() && !file.delete()) {
throw new IOException(Strings.format("Fail to delete file |%s|.", file));
}
}
|
[
"public",
"static",
"void",
"delete",
"(",
"File",
"file",
")",
"throws",
"IOException",
"{",
"Params",
".",
"notNull",
"(",
"file",
",",
"\"File\"",
")",
";",
"if",
"(",
"file",
".",
"exists",
"(",
")",
"&&",
"!",
"file",
".",
"delete",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"Strings",
".",
"format",
"(",
"\"Fail to delete file |%s|.\"",
",",
"file",
")",
")",
";",
"}",
"}"
] |
Delete file if exists throwing exception if delete fails. Note that this method does nothing if file does not
exist; anyway, null parameter sanity check is still performed.
@param file file path.
@throws IOException if delete operation fails.
@throws IllegalArgumentException if <code>file</code> parameter is null.
|
[
"Delete",
"file",
"if",
"exists",
"throwing",
"exception",
"if",
"delete",
"fails",
".",
"Note",
"that",
"this",
"method",
"does",
"nothing",
"if",
"file",
"does",
"not",
"exist",
";",
"anyway",
"null",
"parameter",
"sanity",
"check",
"is",
"still",
"performed",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L1025-L1031
|
153,587
|
js-lib-com/commons
|
src/main/java/js/util/Files.java
|
Files.normalizePath
|
public static String normalizePath(String path)
{
if(File.separatorChar == '/') {
return path.replace('\\', '/');
}
return path.replace('/', '\\');
}
|
java
|
public static String normalizePath(String path)
{
if(File.separatorChar == '/') {
return path.replace('\\', '/');
}
return path.replace('/', '\\');
}
|
[
"public",
"static",
"String",
"normalizePath",
"(",
"String",
"path",
")",
"{",
"if",
"(",
"File",
".",
"separatorChar",
"==",
"'",
"'",
")",
"{",
"return",
"path",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"}",
"return",
"path",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"}"
] |
Ensure that path separators are compatible with current operating system.
@param path path to normalize.
@return normalized path.
|
[
"Ensure",
"that",
"path",
"separators",
"are",
"compatible",
"with",
"current",
"operating",
"system",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L1159-L1165
|
153,588
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/SCannedBox.java
|
SCannedBox.getProperties
|
public String getProperties(String strCommand, Map<String,Object> properties)
{
int iIndex = strCommand.indexOf('=');
if (iIndex != -1)
{
if (this.getParentScreen().getTask() != null)
Util.parseArgs(properties, strCommand);
if (properties.get(DBParams.COMMAND) != null)
strCommand = (String)properties.get(DBParams.COMMAND);
}
return strCommand;
}
|
java
|
public String getProperties(String strCommand, Map<String,Object> properties)
{
int iIndex = strCommand.indexOf('=');
if (iIndex != -1)
{
if (this.getParentScreen().getTask() != null)
Util.parseArgs(properties, strCommand);
if (properties.get(DBParams.COMMAND) != null)
strCommand = (String)properties.get(DBParams.COMMAND);
}
return strCommand;
}
|
[
"public",
"String",
"getProperties",
"(",
"String",
"strCommand",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
")",
"{",
"int",
"iIndex",
"=",
"strCommand",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"iIndex",
"!=",
"-",
"1",
")",
"{",
"if",
"(",
"this",
".",
"getParentScreen",
"(",
")",
".",
"getTask",
"(",
")",
"!=",
"null",
")",
"Util",
".",
"parseArgs",
"(",
"properties",
",",
"strCommand",
")",
";",
"if",
"(",
"properties",
".",
"get",
"(",
"DBParams",
".",
"COMMAND",
")",
"!=",
"null",
")",
"strCommand",
"=",
"(",
"String",
")",
"properties",
".",
"get",
"(",
"DBParams",
".",
"COMMAND",
")",
";",
"}",
"return",
"strCommand",
";",
"}"
] |
Parse the command string into properties.
@param strCommand
@param properties
@return
|
[
"Parse",
"the",
"command",
"string",
"into",
"properties",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/SCannedBox.java#L418-L429
|
153,589
|
nwillc/almost-functional
|
src/main/java/almost/functional/utils/Predicates.java
|
Predicates.notEmptyString
|
public static Predicate<String> notEmptyString() {
return new Predicate<String>() {
@Override
public boolean test(String testValue) {
if (notNull().test(testValue)) {
for (Character c : testValue.toCharArray()) {
if (!Character.isWhitespace(c)) {
return true;
}
}
}
return false;
}
};
}
|
java
|
public static Predicate<String> notEmptyString() {
return new Predicate<String>() {
@Override
public boolean test(String testValue) {
if (notNull().test(testValue)) {
for (Character c : testValue.toCharArray()) {
if (!Character.isWhitespace(c)) {
return true;
}
}
}
return false;
}
};
}
|
[
"public",
"static",
"Predicate",
"<",
"String",
">",
"notEmptyString",
"(",
")",
"{",
"return",
"new",
"Predicate",
"<",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"test",
"(",
"String",
"testValue",
")",
"{",
"if",
"(",
"notNull",
"(",
")",
".",
"test",
"(",
"testValue",
")",
")",
"{",
"for",
"(",
"Character",
"c",
":",
"testValue",
".",
"toCharArray",
"(",
")",
")",
"{",
"if",
"(",
"!",
"Character",
".",
"isWhitespace",
"(",
"c",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}",
"}",
";",
"}"
] |
Predicate to check that a String is not empty, i.e. not null and contains other than whitespace characters.
@return true if the tested string is not empty.
|
[
"Predicate",
"to",
"check",
"that",
"a",
"String",
"is",
"not",
"empty",
"i",
".",
"e",
".",
"not",
"null",
"and",
"contains",
"other",
"than",
"whitespace",
"characters",
"."
] |
a6cc7c73b2be475ed1bce5128c24b2eb9c27d666
|
https://github.com/nwillc/almost-functional/blob/a6cc7c73b2be475ed1bce5128c24b2eb9c27d666/src/main/java/almost/functional/utils/Predicates.java#L35-L49
|
153,590
|
nwillc/almost-functional
|
src/main/java/almost/functional/utils/Predicates.java
|
Predicates.notNull
|
public static <T> Predicate<T> notNull() {
return new Predicate<T>() {
@Override
public boolean test(T testValue) {
return testValue != null;
}
};
}
|
java
|
public static <T> Predicate<T> notNull() {
return new Predicate<T>() {
@Override
public boolean test(T testValue) {
return testValue != null;
}
};
}
|
[
"public",
"static",
"<",
"T",
">",
"Predicate",
"<",
"T",
">",
"notNull",
"(",
")",
"{",
"return",
"new",
"Predicate",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"test",
"(",
"T",
"testValue",
")",
"{",
"return",
"testValue",
"!=",
"null",
";",
"}",
"}",
";",
"}"
] |
Predicate to check that a value is not null.
@param <T> Type of the value
@return true if the value is not null
|
[
"Predicate",
"to",
"check",
"that",
"a",
"value",
"is",
"not",
"null",
"."
] |
a6cc7c73b2be475ed1bce5128c24b2eb9c27d666
|
https://github.com/nwillc/almost-functional/blob/a6cc7c73b2be475ed1bce5128c24b2eb9c27d666/src/main/java/almost/functional/utils/Predicates.java#L57-L64
|
153,591
|
nwillc/almost-functional
|
src/main/java/almost/functional/utils/Predicates.java
|
Predicates.contains
|
public static <T> Predicate<T> contains(final Iterable<T> iterable) {
return new Predicate<T>() {
@Override
public boolean test(final T testValue) {
return Iterables.contains(iterable, testValue);
}
};
}
|
java
|
public static <T> Predicate<T> contains(final Iterable<T> iterable) {
return new Predicate<T>() {
@Override
public boolean test(final T testValue) {
return Iterables.contains(iterable, testValue);
}
};
}
|
[
"public",
"static",
"<",
"T",
">",
"Predicate",
"<",
"T",
">",
"contains",
"(",
"final",
"Iterable",
"<",
"T",
">",
"iterable",
")",
"{",
"return",
"new",
"Predicate",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"test",
"(",
"final",
"T",
"testValue",
")",
"{",
"return",
"Iterables",
".",
"contains",
"(",
"iterable",
",",
"testValue",
")",
";",
"}",
"}",
";",
"}"
] |
Returns a predicate that that tests if an iterable contains an argument.
@param iterable the iterable, may not be null
@param <T> the type of the argument to the predicate
@return a predicate that that tests if an iterable contains an argument
|
[
"Returns",
"a",
"predicate",
"that",
"that",
"tests",
"if",
"an",
"iterable",
"contains",
"an",
"argument",
"."
] |
a6cc7c73b2be475ed1bce5128c24b2eb9c27d666
|
https://github.com/nwillc/almost-functional/blob/a6cc7c73b2be475ed1bce5128c24b2eb9c27d666/src/main/java/almost/functional/utils/Predicates.java#L89-L96
|
153,592
|
nwillc/almost-functional
|
src/main/java/almost/functional/utils/Predicates.java
|
Predicates.negate
|
public static <T> Predicate<T> negate(final Predicate<? super T> predicate) {
return new Predicate<T>() {
@Override
public boolean test(final T testValue) {
return !predicate.test(testValue);
}
};
}
|
java
|
public static <T> Predicate<T> negate(final Predicate<? super T> predicate) {
return new Predicate<T>() {
@Override
public boolean test(final T testValue) {
return !predicate.test(testValue);
}
};
}
|
[
"public",
"static",
"<",
"T",
">",
"Predicate",
"<",
"T",
">",
"negate",
"(",
"final",
"Predicate",
"<",
"?",
"super",
"T",
">",
"predicate",
")",
"{",
"return",
"new",
"Predicate",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"test",
"(",
"final",
"T",
"testValue",
")",
"{",
"return",
"!",
"predicate",
".",
"test",
"(",
"testValue",
")",
";",
"}",
"}",
";",
"}"
] |
Negate an existing predicate's test result.
@param predicate An existing predicate.
@param <T> type of the predicate.
@return new predicate.
@since 1.5
|
[
"Negate",
"an",
"existing",
"predicate",
"s",
"test",
"result",
"."
] |
a6cc7c73b2be475ed1bce5128c24b2eb9c27d666
|
https://github.com/nwillc/almost-functional/blob/a6cc7c73b2be475ed1bce5128c24b2eb9c27d666/src/main/java/almost/functional/utils/Predicates.java#L106-L113
|
153,593
|
nwillc/almost-functional
|
src/main/java/almost/functional/utils/Predicates.java
|
Predicates.and
|
public static <T> Predicate<T> and(final Predicate<? super T> first, final Predicate<? super T> second) {
return new Predicate<T>() {
@Override
public boolean test(final T testValue) {
return first.test(testValue) && second.test(testValue);
}
};
}
|
java
|
public static <T> Predicate<T> and(final Predicate<? super T> first, final Predicate<? super T> second) {
return new Predicate<T>() {
@Override
public boolean test(final T testValue) {
return first.test(testValue) && second.test(testValue);
}
};
}
|
[
"public",
"static",
"<",
"T",
">",
"Predicate",
"<",
"T",
">",
"and",
"(",
"final",
"Predicate",
"<",
"?",
"super",
"T",
">",
"first",
",",
"final",
"Predicate",
"<",
"?",
"super",
"T",
">",
"second",
")",
"{",
"return",
"new",
"Predicate",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"test",
"(",
"final",
"T",
"testValue",
")",
"{",
"return",
"first",
".",
"test",
"(",
"testValue",
")",
"&&",
"second",
".",
"test",
"(",
"testValue",
")",
";",
"}",
"}",
";",
"}"
] |
Create a predicate which is a logical and of two existing predicate.
@param first first predicate.
@param second second predicate.
@param <T> type of the predicates
@return resultant predicate
@since 1.5
|
[
"Create",
"a",
"predicate",
"which",
"is",
"a",
"logical",
"and",
"of",
"two",
"existing",
"predicate",
"."
] |
a6cc7c73b2be475ed1bce5128c24b2eb9c27d666
|
https://github.com/nwillc/almost-functional/blob/a6cc7c73b2be475ed1bce5128c24b2eb9c27d666/src/main/java/almost/functional/utils/Predicates.java#L124-L131
|
153,594
|
nwillc/almost-functional
|
src/main/java/almost/functional/utils/Predicates.java
|
Predicates.or
|
public static <T> Predicate<T> or(final Predicate<? super T> first, final Predicate<? super T> second) { //NOPMD
return new Predicate<T>() {
@Override
public boolean test(final T testValue) {
return first.test(testValue) || second.test(testValue);
}
};
}
|
java
|
public static <T> Predicate<T> or(final Predicate<? super T> first, final Predicate<? super T> second) { //NOPMD
return new Predicate<T>() {
@Override
public boolean test(final T testValue) {
return first.test(testValue) || second.test(testValue);
}
};
}
|
[
"public",
"static",
"<",
"T",
">",
"Predicate",
"<",
"T",
">",
"or",
"(",
"final",
"Predicate",
"<",
"?",
"super",
"T",
">",
"first",
",",
"final",
"Predicate",
"<",
"?",
"super",
"T",
">",
"second",
")",
"{",
"//NOPMD",
"return",
"new",
"Predicate",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"test",
"(",
"final",
"T",
"testValue",
")",
"{",
"return",
"first",
".",
"test",
"(",
"testValue",
")",
"||",
"second",
".",
"test",
"(",
"testValue",
")",
";",
"}",
"}",
";",
"}"
] |
Create a predicate which is a logical or of two existing predicate.
@param first first predicate.
@param second second predicate.
@param <T> type of the predicates
@return resultant predicate
@since 1.5
|
[
"Create",
"a",
"predicate",
"which",
"is",
"a",
"logical",
"or",
"of",
"two",
"existing",
"predicate",
"."
] |
a6cc7c73b2be475ed1bce5128c24b2eb9c27d666
|
https://github.com/nwillc/almost-functional/blob/a6cc7c73b2be475ed1bce5128c24b2eb9c27d666/src/main/java/almost/functional/utils/Predicates.java#L142-L149
|
153,595
|
thorinii/lct
|
src/main/java/me/lachlanap/lct/LCTManager.java
|
LCTManager.addConstant
|
public void addConstant(ConstantField field) {
constantList.add(field);
constants.put(field.name, field);
}
|
java
|
public void addConstant(ConstantField field) {
constantList.add(field);
constants.put(field.name, field);
}
|
[
"public",
"void",
"addConstant",
"(",
"ConstantField",
"field",
")",
"{",
"constantList",
".",
"add",
"(",
"field",
")",
";",
"constants",
".",
"put",
"(",
"field",
".",
"name",
",",
"field",
")",
";",
"}"
] |
Manually add a field to the list of constants.
@param field the field
|
[
"Manually",
"add",
"a",
"field",
"to",
"the",
"list",
"of",
"constants",
"."
] |
83d9dd94aac1efec4815b5658faa395a081592dc
|
https://github.com/thorinii/lct/blob/83d9dd94aac1efec4815b5658faa395a081592dc/src/main/java/me/lachlanap/lct/LCTManager.java#L65-L68
|
153,596
|
thorinii/lct
|
src/main/java/me/lachlanap/lct/LCTManager.java
|
LCTManager.register
|
public void register(Class<?> aClass) {
List<ConstantField> tmp = inspector.getConstants(aClass);
constantList.addAll(tmp);
for (ConstantField constant : tmp)
constants.put(constant.name, constant);
}
|
java
|
public void register(Class<?> aClass) {
List<ConstantField> tmp = inspector.getConstants(aClass);
constantList.addAll(tmp);
for (ConstantField constant : tmp)
constants.put(constant.name, constant);
}
|
[
"public",
"void",
"register",
"(",
"Class",
"<",
"?",
">",
"aClass",
")",
"{",
"List",
"<",
"ConstantField",
">",
"tmp",
"=",
"inspector",
".",
"getConstants",
"(",
"aClass",
")",
";",
"constantList",
".",
"addAll",
"(",
"tmp",
")",
";",
"for",
"(",
"ConstantField",
"constant",
":",
"tmp",
")",
"constants",
".",
"put",
"(",
"constant",
".",
"name",
",",
"constant",
")",
";",
"}"
] |
Extracts the constant fields from the specified class using the ClassInspector.
|
[
"Extracts",
"the",
"constant",
"fields",
"from",
"the",
"specified",
"class",
"using",
"the",
"ClassInspector",
"."
] |
83d9dd94aac1efec4815b5658faa395a081592dc
|
https://github.com/thorinii/lct/blob/83d9dd94aac1efec4815b5658faa395a081592dc/src/main/java/me/lachlanap/lct/LCTManager.java#L81-L87
|
153,597
|
thorinii/lct
|
src/main/java/me/lachlanap/lct/LCTManager.java
|
LCTManager.loadSettings
|
public void loadSettings(String file) throws IOException {
Path path = Paths.get(file);
try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
Properties props = new Properties();
props.load(reader);
loadSettings(props);
}
}
|
java
|
public void loadSettings(String file) throws IOException {
Path path = Paths.get(file);
try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
Properties props = new Properties();
props.load(reader);
loadSettings(props);
}
}
|
[
"public",
"void",
"loadSettings",
"(",
"String",
"file",
")",
"throws",
"IOException",
"{",
"Path",
"path",
"=",
"Paths",
".",
"get",
"(",
"file",
")",
";",
"try",
"(",
"BufferedReader",
"reader",
"=",
"Files",
".",
"newBufferedReader",
"(",
"path",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"props",
".",
"load",
"(",
"reader",
")",
";",
"loadSettings",
"(",
"props",
")",
";",
"}",
"}"
] |
Loads constant settings from a file in Properties format.
@param file the path to the file to read from
@throws IOException when file reading fails
|
[
"Loads",
"constant",
"settings",
"from",
"a",
"file",
"in",
"Properties",
"format",
"."
] |
83d9dd94aac1efec4815b5658faa395a081592dc
|
https://github.com/thorinii/lct/blob/83d9dd94aac1efec4815b5658faa395a081592dc/src/main/java/me/lachlanap/lct/LCTManager.java#L103-L111
|
153,598
|
thorinii/lct
|
src/main/java/me/lachlanap/lct/LCTManager.java
|
LCTManager.saveSettings
|
public void saveSettings(String file) throws IOException {
Path path = Paths.get(file);
try (BufferedWriter reader = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
Properties props = new Properties();
saveSettings(props);
props.store(reader, "Saved by LiveConstantTweaker");
}
}
|
java
|
public void saveSettings(String file) throws IOException {
Path path = Paths.get(file);
try (BufferedWriter reader = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
Properties props = new Properties();
saveSettings(props);
props.store(reader, "Saved by LiveConstantTweaker");
}
}
|
[
"public",
"void",
"saveSettings",
"(",
"String",
"file",
")",
"throws",
"IOException",
"{",
"Path",
"path",
"=",
"Paths",
".",
"get",
"(",
"file",
")",
";",
"try",
"(",
"BufferedWriter",
"reader",
"=",
"Files",
".",
"newBufferedWriter",
"(",
"path",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"saveSettings",
"(",
"props",
")",
";",
"props",
".",
"store",
"(",
"reader",
",",
"\"Saved by LiveConstantTweaker\"",
")",
";",
"}",
"}"
] |
Saves constant settings to a file in Properties format.
@param file the path to the file to write tp
@throws IOException if writing fails
|
[
"Saves",
"constant",
"settings",
"to",
"a",
"file",
"in",
"Properties",
"format",
"."
] |
83d9dd94aac1efec4815b5658faa395a081592dc
|
https://github.com/thorinii/lct/blob/83d9dd94aac1efec4815b5658faa395a081592dc/src/main/java/me/lachlanap/lct/LCTManager.java#L127-L135
|
153,599
|
thorinii/lct
|
src/main/java/me/lachlanap/lct/LCTManager.java
|
LCTManager.set
|
@Deprecated
public void set(String name, int i) {
ConstantField constant = constants.get(name);
((IntConstantField) constant).set(i);
}
|
java
|
@Deprecated
public void set(String name, int i) {
ConstantField constant = constants.get(name);
((IntConstantField) constant).set(i);
}
|
[
"@",
"Deprecated",
"public",
"void",
"set",
"(",
"String",
"name",
",",
"int",
"i",
")",
"{",
"ConstantField",
"constant",
"=",
"constants",
".",
"get",
"(",
"name",
")",
";",
"(",
"(",
"IntConstantField",
")",
"constant",
")",
".",
"set",
"(",
"i",
")",
";",
"}"
] |
Set an integer field with name given.
@deprecated design flaw - cannot support all types of fields like this. Get the field from the list of fields and set it from there.
|
[
"Set",
"an",
"integer",
"field",
"with",
"name",
"given",
"."
] |
83d9dd94aac1efec4815b5658faa395a081592dc
|
https://github.com/thorinii/lct/blob/83d9dd94aac1efec4815b5658faa395a081592dc/src/main/java/me/lachlanap/lct/LCTManager.java#L141-L145
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.