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,700
|
jbundle/jbundle
|
base/db/jdbc/src/main/java/org/jbundle/base/db/jdbc/JdbcDatabase.java
|
JdbcDatabase.addDatabaseProperty
|
public void addDatabaseProperty(String strKey, String strValue)
{
this.setProperty(strKey, strValue);
Environment env = (Environment)this.getDatabaseOwner().getEnvironment();
if (env.getCachedDatabaseProperties(this.getDatabaseName(true)) != null) // Always
if (env.getCachedDatabaseProperties(this.getDatabaseName(true)) != Environment.DATABASE_DOESNT_EXIST) // Always
env.getCachedDatabaseProperties(this.getDatabaseName(true)).put(strKey, strValue);
}
|
java
|
public void addDatabaseProperty(String strKey, String strValue)
{
this.setProperty(strKey, strValue);
Environment env = (Environment)this.getDatabaseOwner().getEnvironment();
if (env.getCachedDatabaseProperties(this.getDatabaseName(true)) != null) // Always
if (env.getCachedDatabaseProperties(this.getDatabaseName(true)) != Environment.DATABASE_DOESNT_EXIST) // Always
env.getCachedDatabaseProperties(this.getDatabaseName(true)).put(strKey, strValue);
}
|
[
"public",
"void",
"addDatabaseProperty",
"(",
"String",
"strKey",
",",
"String",
"strValue",
")",
"{",
"this",
".",
"setProperty",
"(",
"strKey",
",",
"strValue",
")",
";",
"Environment",
"env",
"=",
"(",
"Environment",
")",
"this",
".",
"getDatabaseOwner",
"(",
")",
".",
"getEnvironment",
"(",
")",
";",
"if",
"(",
"env",
".",
"getCachedDatabaseProperties",
"(",
"this",
".",
"getDatabaseName",
"(",
"true",
")",
")",
"!=",
"null",
")",
"// Always",
"if",
"(",
"env",
".",
"getCachedDatabaseProperties",
"(",
"this",
".",
"getDatabaseName",
"(",
"true",
")",
")",
"!=",
"Environment",
".",
"DATABASE_DOESNT_EXIST",
")",
"// Always",
"env",
".",
"getCachedDatabaseProperties",
"(",
"this",
".",
"getDatabaseName",
"(",
"true",
")",
")",
".",
"put",
"(",
"strKey",
",",
"strValue",
")",
";",
"}"
] |
Add this database property.
@param strKey
@param strValue
|
[
"Add",
"this",
"database",
"property",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/db/jdbc/src/main/java/org/jbundle/base/db/jdbc/JdbcDatabase.java#L886-L893
|
153,701
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/message/record/GridSyncRecordMessageFilterHandler.java
|
GridSyncRecordMessageFilterHandler.clearBookmarkFilters
|
public void clearBookmarkFilters(String strKeyName, Object objKeyData)
{
Map<String,Object> properties = new Hashtable<String,Object>();
properties.put(GridRecordMessageFilter.ADD_BOOKMARK, GridRecordMessageFilter.CLEAR_BOOKMARKS);
if (objKeyData != null)
{
properties.put(GridRecordMessageFilter.SECOND_KEY_HINT, strKeyName);
properties.put(strKeyName, objKeyData);
}
m_recordMessageFilter.updateFilterMap(properties);
}
|
java
|
public void clearBookmarkFilters(String strKeyName, Object objKeyData)
{
Map<String,Object> properties = new Hashtable<String,Object>();
properties.put(GridRecordMessageFilter.ADD_BOOKMARK, GridRecordMessageFilter.CLEAR_BOOKMARKS);
if (objKeyData != null)
{
properties.put(GridRecordMessageFilter.SECOND_KEY_HINT, strKeyName);
properties.put(strKeyName, objKeyData);
}
m_recordMessageFilter.updateFilterMap(properties);
}
|
[
"public",
"void",
"clearBookmarkFilters",
"(",
"String",
"strKeyName",
",",
"Object",
"objKeyData",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
"=",
"new",
"Hashtable",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"properties",
".",
"put",
"(",
"GridRecordMessageFilter",
".",
"ADD_BOOKMARK",
",",
"GridRecordMessageFilter",
".",
"CLEAR_BOOKMARKS",
")",
";",
"if",
"(",
"objKeyData",
"!=",
"null",
")",
"{",
"properties",
".",
"put",
"(",
"GridRecordMessageFilter",
".",
"SECOND_KEY_HINT",
",",
"strKeyName",
")",
";",
"properties",
".",
"put",
"(",
"strKeyName",
",",
"objKeyData",
")",
";",
"}",
"m_recordMessageFilter",
".",
"updateFilterMap",
"(",
"properties",
")",
";",
"}"
] |
Update the listener to listen for changes to no records.
@param strKeyName The (optional) key area the query is being of.
@param objKeyData The (optional) reference value of the key area.
|
[
"Update",
"the",
"listener",
"to",
"listen",
"for",
"changes",
"to",
"no",
"records",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/message/record/GridSyncRecordMessageFilterHandler.java#L166-L176
|
153,702
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/io/BasicChannel.java
|
BasicChannel.transmit
|
public synchronized void transmit(Object o, ReceiverQueue t) {
if (!closed) {
ArrayList<Receiver> toBeRemoved = new ArrayList<Receiver>();
for (Receiver r : receivers) {
//cleanup
//TODO separate cleanup from transmit
//
if (r instanceof ReceiverQueue && ((ReceiverQueue)r).isClosed()) {
toBeRemoved.add(r);
}
else {
if (echo || r != t) {
r.onReceive(o);
}
}
}
for (Receiver r : toBeRemoved) {
receivers.remove(r);
}
}
}
|
java
|
public synchronized void transmit(Object o, ReceiverQueue t) {
if (!closed) {
ArrayList<Receiver> toBeRemoved = new ArrayList<Receiver>();
for (Receiver r : receivers) {
//cleanup
//TODO separate cleanup from transmit
//
if (r instanceof ReceiverQueue && ((ReceiverQueue)r).isClosed()) {
toBeRemoved.add(r);
}
else {
if (echo || r != t) {
r.onReceive(o);
}
}
}
for (Receiver r : toBeRemoved) {
receivers.remove(r);
}
}
}
|
[
"public",
"synchronized",
"void",
"transmit",
"(",
"Object",
"o",
",",
"ReceiverQueue",
"t",
")",
"{",
"if",
"(",
"!",
"closed",
")",
"{",
"ArrayList",
"<",
"Receiver",
">",
"toBeRemoved",
"=",
"new",
"ArrayList",
"<",
"Receiver",
">",
"(",
")",
";",
"for",
"(",
"Receiver",
"r",
":",
"receivers",
")",
"{",
"//cleanup",
"//TODO separate cleanup from transmit",
"//",
"if",
"(",
"r",
"instanceof",
"ReceiverQueue",
"&&",
"(",
"(",
"ReceiverQueue",
")",
"r",
")",
".",
"isClosed",
"(",
")",
")",
"{",
"toBeRemoved",
".",
"add",
"(",
"r",
")",
";",
"}",
"else",
"{",
"if",
"(",
"echo",
"||",
"r",
"!=",
"t",
")",
"{",
"r",
".",
"onReceive",
"(",
"o",
")",
";",
"}",
"}",
"}",
"for",
"(",
"Receiver",
"r",
":",
"toBeRemoved",
")",
"{",
"receivers",
".",
"remove",
"(",
"r",
")",
";",
"}",
"}",
"}"
] |
Dispatches an object to all connected receivers.
@param o the object to dispatch
@param t the transceiver sending the object
|
[
"Dispatches",
"an",
"object",
"to",
"all",
"connected",
"receivers",
"."
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/io/BasicChannel.java#L102-L122
|
153,703
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/io/BasicChannel.java
|
BasicChannel.createReceiver
|
public ReceiverQueue createReceiver(int limit) {
synchronized (receivers) {
ReceiverQueue q = null;
if (!closed && (maxNrofReceivers == 0 || receivers.size() < maxNrofReceivers)) {
q = new ReceiverQueue(/*this, */limit);
receivers.add(q);
}
return q;
}
}
|
java
|
public ReceiverQueue createReceiver(int limit) {
synchronized (receivers) {
ReceiverQueue q = null;
if (!closed && (maxNrofReceivers == 0 || receivers.size() < maxNrofReceivers)) {
q = new ReceiverQueue(/*this, */limit);
receivers.add(q);
}
return q;
}
}
|
[
"public",
"ReceiverQueue",
"createReceiver",
"(",
"int",
"limit",
")",
"{",
"synchronized",
"(",
"receivers",
")",
"{",
"ReceiverQueue",
"q",
"=",
"null",
";",
"if",
"(",
"!",
"closed",
"&&",
"(",
"maxNrofReceivers",
"==",
"0",
"||",
"receivers",
".",
"size",
"(",
")",
"<",
"maxNrofReceivers",
")",
")",
"{",
"q",
"=",
"new",
"ReceiverQueue",
"(",
"/*this, */",
"limit",
")",
";",
"receivers",
".",
"add",
"(",
"q",
")",
";",
"}",
"return",
"q",
";",
"}",
"}"
] |
Creates a receiver for this channel.
@param limit the maximum number of objects stored in the receiver queue
@return a receiver
|
[
"Creates",
"a",
"receiver",
"for",
"this",
"channel",
"."
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/io/BasicChannel.java#L148-L157
|
153,704
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/io/BasicChannel.java
|
BasicChannel.registerReceiver
|
public Receiver registerReceiver(Receiver receiver) {
synchronized (receivers) {
if (!closed && (maxNrofReceivers == 0 || receivers.size() < maxNrofReceivers)) {
receivers.add(receiver);
}
else {
return null;
}
return receiver;
}
}
|
java
|
public Receiver registerReceiver(Receiver receiver) {
synchronized (receivers) {
if (!closed && (maxNrofReceivers == 0 || receivers.size() < maxNrofReceivers)) {
receivers.add(receiver);
}
else {
return null;
}
return receiver;
}
}
|
[
"public",
"Receiver",
"registerReceiver",
"(",
"Receiver",
"receiver",
")",
"{",
"synchronized",
"(",
"receivers",
")",
"{",
"if",
"(",
"!",
"closed",
"&&",
"(",
"maxNrofReceivers",
"==",
"0",
"||",
"receivers",
".",
"size",
"(",
")",
"<",
"maxNrofReceivers",
")",
")",
"{",
"receivers",
".",
"add",
"(",
"receiver",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"return",
"receiver",
";",
"}",
"}"
] |
Adds a receiver so that it will receive transmitted messages.
@param receiver
@return the registered receiver for convenience or null if the channel is closed or the maximum
number of receivers is reached
|
[
"Adds",
"a",
"receiver",
"so",
"that",
"it",
"will",
"receive",
"transmitted",
"messages",
"."
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/io/BasicChannel.java#L166-L176
|
153,705
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/io/BasicChannel.java
|
BasicChannel.close
|
public void close() {
synchronized (receivers) {
Iterator i = receivers.iterator();
while (i.hasNext()) {
ReceiverQueue r = (ReceiverQueue) i.next();
r.onTransmissionClose();
}
closed = true;
receivers.clear();
}
}
|
java
|
public void close() {
synchronized (receivers) {
Iterator i = receivers.iterator();
while (i.hasNext()) {
ReceiverQueue r = (ReceiverQueue) i.next();
r.onTransmissionClose();
}
closed = true;
receivers.clear();
}
}
|
[
"public",
"void",
"close",
"(",
")",
"{",
"synchronized",
"(",
"receivers",
")",
"{",
"Iterator",
"i",
"=",
"receivers",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"i",
".",
"hasNext",
"(",
")",
")",
"{",
"ReceiverQueue",
"r",
"=",
"(",
"ReceiverQueue",
")",
"i",
".",
"next",
"(",
")",
";",
"r",
".",
"onTransmissionClose",
"(",
")",
";",
"}",
"closed",
"=",
"true",
";",
"receivers",
".",
"clear",
"(",
")",
";",
"}",
"}"
] |
Closes the channel and all receivers.
|
[
"Closes",
"the",
"channel",
"and",
"all",
"receivers",
"."
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/io/BasicChannel.java#L182-L192
|
153,706
|
jbundle/jbundle
|
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageManager.java
|
BaseMessageManager.free
|
public void free()
{
if (m_messageMap != null)
{
for (BaseMessageQueue messageQueue : m_messageMap.values())
{
if (messageQueue != null)
{ // Don't worry about removing these, since you are removing them all.
messageQueue.setMessageManager(null); // Make sure it doesn't try to remove itself again
messageQueue.free();
}
}
}
m_messageMap = null;
super.free();
}
|
java
|
public void free()
{
if (m_messageMap != null)
{
for (BaseMessageQueue messageQueue : m_messageMap.values())
{
if (messageQueue != null)
{ // Don't worry about removing these, since you are removing them all.
messageQueue.setMessageManager(null); // Make sure it doesn't try to remove itself again
messageQueue.free();
}
}
}
m_messageMap = null;
super.free();
}
|
[
"public",
"void",
"free",
"(",
")",
"{",
"if",
"(",
"m_messageMap",
"!=",
"null",
")",
"{",
"for",
"(",
"BaseMessageQueue",
"messageQueue",
":",
"m_messageMap",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"messageQueue",
"!=",
"null",
")",
"{",
"// Don't worry about removing these, since you are removing them all.",
"messageQueue",
".",
"setMessageManager",
"(",
"null",
")",
";",
"// Make sure it doesn't try to remove itself again",
"messageQueue",
".",
"free",
"(",
")",
";",
"}",
"}",
"}",
"m_messageMap",
"=",
"null",
";",
"super",
".",
"free",
"(",
")",
";",
"}"
] |
Free this message manager.
|
[
"Free",
"this",
"message",
"manager",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageManager.java#L65-L80
|
153,707
|
jbundle/jbundle
|
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageManager.java
|
BaseMessageManager.addMessageFilter
|
public int addMessageFilter(MessageFilter messageFilter)
{
MessageReceiver receiver = this.getMessageQueue(messageFilter.getQueueName(), messageFilter.getQueueType()).getMessageReceiver();
receiver.addMessageFilter(messageFilter);
return Constant.NORMAL_RETURN;
}
|
java
|
public int addMessageFilter(MessageFilter messageFilter)
{
MessageReceiver receiver = this.getMessageQueue(messageFilter.getQueueName(), messageFilter.getQueueType()).getMessageReceiver();
receiver.addMessageFilter(messageFilter);
return Constant.NORMAL_RETURN;
}
|
[
"public",
"int",
"addMessageFilter",
"(",
"MessageFilter",
"messageFilter",
")",
"{",
"MessageReceiver",
"receiver",
"=",
"this",
".",
"getMessageQueue",
"(",
"messageFilter",
".",
"getQueueName",
"(",
")",
",",
"messageFilter",
".",
"getQueueType",
"(",
")",
")",
".",
"getMessageReceiver",
"(",
")",
";",
"receiver",
".",
"addMessageFilter",
"(",
"messageFilter",
")",
";",
"return",
"Constant",
".",
"NORMAL_RETURN",
";",
"}"
] |
Add this message filter to the appropriate queue.
The message filter contains the queue name and type and a listener to send the message to.
@param messageFilter The message filter to add.
@return An error code.
|
[
"Add",
"this",
"message",
"filter",
"to",
"the",
"appropriate",
"queue",
".",
"The",
"message",
"filter",
"contains",
"the",
"queue",
"name",
"and",
"type",
"and",
"a",
"listener",
"to",
"send",
"the",
"message",
"to",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageManager.java#L161-L166
|
153,708
|
jbundle/jbundle
|
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageManager.java
|
BaseMessageManager.sendMessage
|
public int sendMessage(Message message)
{
BaseMessageHeader messageHeader = ((BaseMessage)message).getMessageHeader();
String strQueueType = messageHeader.getQueueType();
String strQueueName = messageHeader.getQueueName();
MessageSender sender = this.getMessageQueue(strQueueName, strQueueType).getMessageSender();
if (sender != null)
sender.sendMessage(message);
else
return Constant.ERROR_RETURN; // Queue doesn't exist
return Constant.NORMAL_RETURN;
}
|
java
|
public int sendMessage(Message message)
{
BaseMessageHeader messageHeader = ((BaseMessage)message).getMessageHeader();
String strQueueType = messageHeader.getQueueType();
String strQueueName = messageHeader.getQueueName();
MessageSender sender = this.getMessageQueue(strQueueName, strQueueType).getMessageSender();
if (sender != null)
sender.sendMessage(message);
else
return Constant.ERROR_RETURN; // Queue doesn't exist
return Constant.NORMAL_RETURN;
}
|
[
"public",
"int",
"sendMessage",
"(",
"Message",
"message",
")",
"{",
"BaseMessageHeader",
"messageHeader",
"=",
"(",
"(",
"BaseMessage",
")",
"message",
")",
".",
"getMessageHeader",
"(",
")",
";",
"String",
"strQueueType",
"=",
"messageHeader",
".",
"getQueueType",
"(",
")",
";",
"String",
"strQueueName",
"=",
"messageHeader",
".",
"getQueueName",
"(",
")",
";",
"MessageSender",
"sender",
"=",
"this",
".",
"getMessageQueue",
"(",
"strQueueName",
",",
"strQueueType",
")",
".",
"getMessageSender",
"(",
")",
";",
"if",
"(",
"sender",
"!=",
"null",
")",
"sender",
".",
"sendMessage",
"(",
"message",
")",
";",
"else",
"return",
"Constant",
".",
"ERROR_RETURN",
";",
"// Queue doesn't exist",
"return",
"Constant",
".",
"NORMAL_RETURN",
";",
"}"
] |
Send this message to the appropriate queue.
The message's message header has the queue name and type.
@param The message to send.
@return An error code.
|
[
"Send",
"this",
"message",
"to",
"the",
"appropriate",
"queue",
".",
"The",
"message",
"s",
"message",
"header",
"has",
"the",
"queue",
"name",
"and",
"type",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageManager.java#L173-L184
|
153,709
|
marssa/footprint
|
src/main/java/org/marssa/footprint/logger/MDBAppender.java
|
MDBAppender.updateExceptionStatement
|
void updateExceptionStatement(PreparedStatement exceptionStatement,
String txt, short i, long eventId) throws SQLException {
exceptionStatement.setLong(1, eventId);
exceptionStatement.setShort(2, i);
exceptionStatement.setString(3, txt);
if (cnxSupportsBatchUpdates) {
exceptionStatement.addBatch();
} else {
exceptionStatement.execute();
}
}
|
java
|
void updateExceptionStatement(PreparedStatement exceptionStatement,
String txt, short i, long eventId) throws SQLException {
exceptionStatement.setLong(1, eventId);
exceptionStatement.setShort(2, i);
exceptionStatement.setString(3, txt);
if (cnxSupportsBatchUpdates) {
exceptionStatement.addBatch();
} else {
exceptionStatement.execute();
}
}
|
[
"void",
"updateExceptionStatement",
"(",
"PreparedStatement",
"exceptionStatement",
",",
"String",
"txt",
",",
"short",
"i",
",",
"long",
"eventId",
")",
"throws",
"SQLException",
"{",
"exceptionStatement",
".",
"setLong",
"(",
"1",
",",
"eventId",
")",
";",
"exceptionStatement",
".",
"setShort",
"(",
"2",
",",
"i",
")",
";",
"exceptionStatement",
".",
"setString",
"(",
"3",
",",
"txt",
")",
";",
"if",
"(",
"cnxSupportsBatchUpdates",
")",
"{",
"exceptionStatement",
".",
"addBatch",
"(",
")",
";",
"}",
"else",
"{",
"exceptionStatement",
".",
"execute",
"(",
")",
";",
"}",
"}"
] |
Add an exception statement either as a batch or execute immediately if
batch updates are not supported.
|
[
"Add",
"an",
"exception",
"statement",
"either",
"as",
"a",
"batch",
"or",
"execute",
"immediately",
"if",
"batch",
"updates",
"are",
"not",
"supported",
"."
] |
2ca953c14f46adc320927c87c5ce1c36eb6c82de
|
https://github.com/marssa/footprint/blob/2ca953c14f46adc320927c87c5ce1c36eb6c82de/src/main/java/org/marssa/footprint/logger/MDBAppender.java#L261-L271
|
153,710
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/report/BaseReportScreen.java
|
BaseReportScreen.addScreenParams
|
public String addScreenParams(BasePanel screen, String strURL)
{
int iNumCols = screen.getSFieldCount();
for (int iIndex = 0; iIndex < iNumCols; iIndex++)
{
ScreenField sField = screen.getSField(iIndex);
boolean bPrintControl = true;
if (sField instanceof BasePanel)
{
strURL = this.addScreenParams((BasePanel)sField, strURL);
bPrintControl = false; // ie., Don't print buttons
}
if (sField.getConverter() == null)
bPrintControl = false;
if (screen == this)
bPrintControl = false; // My children are the report detail (Not params).
if (!sField.isInputField())
bPrintControl = false;
if (!sField.isEnabled())
bPrintControl = false;
if (bPrintControl)
if (sField.getScreenFieldView() != null)
{
String strData = sField.getSFieldValue(false, false); // Match HTML submit (input format/go through converters).
strURL = Utility.addURLParam(strURL, sField.getSFieldParam(null, false), strData); // Don't need outside frame stuff in a window
}
}
return strURL;
}
|
java
|
public String addScreenParams(BasePanel screen, String strURL)
{
int iNumCols = screen.getSFieldCount();
for (int iIndex = 0; iIndex < iNumCols; iIndex++)
{
ScreenField sField = screen.getSField(iIndex);
boolean bPrintControl = true;
if (sField instanceof BasePanel)
{
strURL = this.addScreenParams((BasePanel)sField, strURL);
bPrintControl = false; // ie., Don't print buttons
}
if (sField.getConverter() == null)
bPrintControl = false;
if (screen == this)
bPrintControl = false; // My children are the report detail (Not params).
if (!sField.isInputField())
bPrintControl = false;
if (!sField.isEnabled())
bPrintControl = false;
if (bPrintControl)
if (sField.getScreenFieldView() != null)
{
String strData = sField.getSFieldValue(false, false); // Match HTML submit (input format/go through converters).
strURL = Utility.addURLParam(strURL, sField.getSFieldParam(null, false), strData); // Don't need outside frame stuff in a window
}
}
return strURL;
}
|
[
"public",
"String",
"addScreenParams",
"(",
"BasePanel",
"screen",
",",
"String",
"strURL",
")",
"{",
"int",
"iNumCols",
"=",
"screen",
".",
"getSFieldCount",
"(",
")",
";",
"for",
"(",
"int",
"iIndex",
"=",
"0",
";",
"iIndex",
"<",
"iNumCols",
";",
"iIndex",
"++",
")",
"{",
"ScreenField",
"sField",
"=",
"screen",
".",
"getSField",
"(",
"iIndex",
")",
";",
"boolean",
"bPrintControl",
"=",
"true",
";",
"if",
"(",
"sField",
"instanceof",
"BasePanel",
")",
"{",
"strURL",
"=",
"this",
".",
"addScreenParams",
"(",
"(",
"BasePanel",
")",
"sField",
",",
"strURL",
")",
";",
"bPrintControl",
"=",
"false",
";",
"// ie., Don't print buttons",
"}",
"if",
"(",
"sField",
".",
"getConverter",
"(",
")",
"==",
"null",
")",
"bPrintControl",
"=",
"false",
";",
"if",
"(",
"screen",
"==",
"this",
")",
"bPrintControl",
"=",
"false",
";",
"// My children are the report detail (Not params).",
"if",
"(",
"!",
"sField",
".",
"isInputField",
"(",
")",
")",
"bPrintControl",
"=",
"false",
";",
"if",
"(",
"!",
"sField",
".",
"isEnabled",
"(",
")",
")",
"bPrintControl",
"=",
"false",
";",
"if",
"(",
"bPrintControl",
")",
"if",
"(",
"sField",
".",
"getScreenFieldView",
"(",
")",
"!=",
"null",
")",
"{",
"String",
"strData",
"=",
"sField",
".",
"getSFieldValue",
"(",
"false",
",",
"false",
")",
";",
"// Match HTML submit (input format/go through converters).",
"strURL",
"=",
"Utility",
".",
"addURLParam",
"(",
"strURL",
",",
"sField",
".",
"getSFieldParam",
"(",
"null",
",",
"false",
")",
",",
"strData",
")",
";",
"// Don't need outside frame stuff in a window",
"}",
"}",
"return",
"strURL",
";",
"}"
] |
Display this screen in html input format.
returns true if default params were found for this form.
@param out The html out stream.
@param iHtmlAttributes The Html attributes.
@return True if fields were found.
@exception DBException File exception.
|
[
"Display",
"this",
"screen",
"in",
"html",
"input",
"format",
".",
"returns",
"true",
"if",
"default",
"params",
"were",
"found",
"for",
"this",
"form",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/report/BaseReportScreen.java#L59-L87
|
153,711
|
kirgor/enklib
|
sql/src/main/java/com/kirgor/enklib/sql/Session.java
|
Session.execute
|
public void execute(String query, Object... params) throws SQLException {
createPreparedStatement(query, 0, params).execute();
}
|
java
|
public void execute(String query, Object... params) throws SQLException {
createPreparedStatement(query, 0, params).execute();
}
|
[
"public",
"void",
"execute",
"(",
"String",
"query",
",",
"Object",
"...",
"params",
")",
"throws",
"SQLException",
"{",
"createPreparedStatement",
"(",
"query",
",",
"0",
",",
"params",
")",
".",
"execute",
"(",
")",
";",
"}"
] |
Executes SQL query, which returns nothing.
@param query SQL query string.
@param params Parameters, which will be placed instead of '?' signs.
@throws SQLException In general SQL error case.
|
[
"Executes",
"SQL",
"query",
"which",
"returns",
"nothing",
"."
] |
8a24db296dc43db5d8fe509cf64ace0a0c7be8f2
|
https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/sql/src/main/java/com/kirgor/enklib/sql/Session.java#L95-L97
|
153,712
|
kirgor/enklib
|
sql/src/main/java/com/kirgor/enklib/sql/Session.java
|
Session.getList
|
public <T> List<T> getList(String query, Class<T> entityClass, Object... params)
throws SQLException, NoSuchFieldException, InstantiationException, IllegalAccessException {
Cursor<T> cursor = getCursor(query, entityClass, params);
return cursor.fetchList();
}
|
java
|
public <T> List<T> getList(String query, Class<T> entityClass, Object... params)
throws SQLException, NoSuchFieldException, InstantiationException, IllegalAccessException {
Cursor<T> cursor = getCursor(query, entityClass, params);
return cursor.fetchList();
}
|
[
"public",
"<",
"T",
">",
"List",
"<",
"T",
">",
"getList",
"(",
"String",
"query",
",",
"Class",
"<",
"T",
">",
"entityClass",
",",
"Object",
"...",
"params",
")",
"throws",
"SQLException",
",",
"NoSuchFieldException",
",",
"InstantiationException",
",",
"IllegalAccessException",
"{",
"Cursor",
"<",
"T",
">",
"cursor",
"=",
"getCursor",
"(",
"query",
",",
"entityClass",
",",
"params",
")",
";",
"return",
"cursor",
".",
"fetchList",
"(",
")",
";",
"}"
] |
Executes SQL query, which returns list of entities.
@param <T> Entity type.
@param query SQL query string.
@param entityClass Entity class.
@param params Parameters, which will be placed instead of '?' signs.
@return List of result entities.
@throws SQLException In general SQL error case.
@throws NoSuchFieldException If result set has field which entity class doesn't.
@throws InstantiationException If entity class hasn't default constructor.
@throws IllegalAccessException If entity class is not accessible.
|
[
"Executes",
"SQL",
"query",
"which",
"returns",
"list",
"of",
"entities",
"."
] |
8a24db296dc43db5d8fe509cf64ace0a0c7be8f2
|
https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/sql/src/main/java/com/kirgor/enklib/sql/Session.java#L112-L116
|
153,713
|
kirgor/enklib
|
sql/src/main/java/com/kirgor/enklib/sql/Session.java
|
Session.getSingle
|
public <T> T getSingle(String query, Class<T> entityClass, Object... params)
throws SQLException, NoSuchFieldException, InstantiationException, IllegalAccessException {
Cursor<T> cursor = getCursor(query, entityClass, params);
return cursor.fetchSingle();
}
|
java
|
public <T> T getSingle(String query, Class<T> entityClass, Object... params)
throws SQLException, NoSuchFieldException, InstantiationException, IllegalAccessException {
Cursor<T> cursor = getCursor(query, entityClass, params);
return cursor.fetchSingle();
}
|
[
"public",
"<",
"T",
">",
"T",
"getSingle",
"(",
"String",
"query",
",",
"Class",
"<",
"T",
">",
"entityClass",
",",
"Object",
"...",
"params",
")",
"throws",
"SQLException",
",",
"NoSuchFieldException",
",",
"InstantiationException",
",",
"IllegalAccessException",
"{",
"Cursor",
"<",
"T",
">",
"cursor",
"=",
"getCursor",
"(",
"query",
",",
"entityClass",
",",
"params",
")",
";",
"return",
"cursor",
".",
"fetchSingle",
"(",
")",
";",
"}"
] |
Executes SQL query, which returns single entity.
@param <T> Entity type.
@param query SQL query string.
@param entityClass Entity class.
@param params Parameters, which will be placed instead of '?' signs.
@return Single result entity.
@throws SQLException In general SQL error case.
@throws NoSuchFieldException If result set has field which entity class doesn't.
@throws InstantiationException If entity class hasn't default constructor.
@throws IllegalAccessException If entity class is not accessible.
|
[
"Executes",
"SQL",
"query",
"which",
"returns",
"single",
"entity",
"."
] |
8a24db296dc43db5d8fe509cf64ace0a0c7be8f2
|
https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/sql/src/main/java/com/kirgor/enklib/sql/Session.java#L131-L135
|
153,714
|
kirgor/enklib
|
sql/src/main/java/com/kirgor/enklib/sql/Session.java
|
Session.getSingleOrNull
|
public <T> T getSingleOrNull(String query, Class<T> entityClass, Object... params)
throws SQLException, NoSuchFieldException, InstantiationException, IllegalAccessException {
Cursor<T> cursor = getCursor(query, entityClass, params);
return cursor.fetchSingleOrNull();
}
|
java
|
public <T> T getSingleOrNull(String query, Class<T> entityClass, Object... params)
throws SQLException, NoSuchFieldException, InstantiationException, IllegalAccessException {
Cursor<T> cursor = getCursor(query, entityClass, params);
return cursor.fetchSingleOrNull();
}
|
[
"public",
"<",
"T",
">",
"T",
"getSingleOrNull",
"(",
"String",
"query",
",",
"Class",
"<",
"T",
">",
"entityClass",
",",
"Object",
"...",
"params",
")",
"throws",
"SQLException",
",",
"NoSuchFieldException",
",",
"InstantiationException",
",",
"IllegalAccessException",
"{",
"Cursor",
"<",
"T",
">",
"cursor",
"=",
"getCursor",
"(",
"query",
",",
"entityClass",
",",
"params",
")",
";",
"return",
"cursor",
".",
"fetchSingleOrNull",
"(",
")",
";",
"}"
] |
Executes SQL query, which returns single entity or null if result is not there.
@param <T> Entity type.
@param query SQL query string.
@param entityClass Entity class.
@param params Parameters, which will be placed instead of '?' signs.
@return Single result entity or null.
@throws SQLException In general SQL error case.
@throws NoSuchFieldException If result set has field which entity class doesn't.
@throws InstantiationException If entity class hasn't default constructor.
@throws IllegalAccessException If entity class is not accessible.
|
[
"Executes",
"SQL",
"query",
"which",
"returns",
"single",
"entity",
"or",
"null",
"if",
"result",
"is",
"not",
"there",
"."
] |
8a24db296dc43db5d8fe509cf64ace0a0c7be8f2
|
https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/sql/src/main/java/com/kirgor/enklib/sql/Session.java#L150-L154
|
153,715
|
kirgor/enklib
|
rest/src/main/java/com/kirgor/enklib/rest/exception/RESTException.java
|
RESTException.getHeaderValue
|
public String getHeaderValue(String name) {
if (headers == null) {
return null;
}
return headers.get(name);
}
|
java
|
public String getHeaderValue(String name) {
if (headers == null) {
return null;
}
return headers.get(name);
}
|
[
"public",
"String",
"getHeaderValue",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"headers",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"headers",
".",
"get",
"(",
"name",
")",
";",
"}"
] |
Gets value of specified HTTP response header.
@param name HTTP header name.
@return Value of the header or null, if header is not present.
|
[
"Gets",
"value",
"of",
"specified",
"HTTP",
"response",
"header",
"."
] |
8a24db296dc43db5d8fe509cf64ace0a0c7be8f2
|
https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/rest/src/main/java/com/kirgor/enklib/rest/exception/RESTException.java#L46-L51
|
153,716
|
microfocus-idol/java-configuration-impl
|
src/main/java/com/hp/autonomy/frontend/configuration/authentication/BCryptUsernameAndPassword.java
|
BCryptUsernameAndPassword.validate
|
public ValidationResult<?> validate(final BCryptUsernameAndPassword existingSingleUser, final UsernameAndPassword defaultLogin) {
if (passwordRedacted) {
return new ValidationResult<>(true);
}
final boolean valid = defaultLogin.getPassword() != null ? currentPassword.equals(defaultLogin.getPassword()) : BCrypt.checkpw(currentPassword, existingSingleUser.hashedPassword);
return valid ? new ValidationResult<>(true) : new ValidationResult<>(false, "The current password is incorrect");
}
|
java
|
public ValidationResult<?> validate(final BCryptUsernameAndPassword existingSingleUser, final UsernameAndPassword defaultLogin) {
if (passwordRedacted) {
return new ValidationResult<>(true);
}
final boolean valid = defaultLogin.getPassword() != null ? currentPassword.equals(defaultLogin.getPassword()) : BCrypt.checkpw(currentPassword, existingSingleUser.hashedPassword);
return valid ? new ValidationResult<>(true) : new ValidationResult<>(false, "The current password is incorrect");
}
|
[
"public",
"ValidationResult",
"<",
"?",
">",
"validate",
"(",
"final",
"BCryptUsernameAndPassword",
"existingSingleUser",
",",
"final",
"UsernameAndPassword",
"defaultLogin",
")",
"{",
"if",
"(",
"passwordRedacted",
")",
"{",
"return",
"new",
"ValidationResult",
"<>",
"(",
"true",
")",
";",
"}",
"final",
"boolean",
"valid",
"=",
"defaultLogin",
".",
"getPassword",
"(",
")",
"!=",
"null",
"?",
"currentPassword",
".",
"equals",
"(",
"defaultLogin",
".",
"getPassword",
"(",
")",
")",
":",
"BCrypt",
".",
"checkpw",
"(",
"currentPassword",
",",
"existingSingleUser",
".",
"hashedPassword",
")",
";",
"return",
"valid",
"?",
"new",
"ValidationResult",
"<>",
"(",
"true",
")",
":",
"new",
"ValidationResult",
"<>",
"(",
"false",
",",
"\"The current password is incorrect\"",
")",
";",
"}"
] |
Validates this component by comparing the current password against either a default login or an existing single
user
@param existingSingleUser The current single user
@param defaultLogin The current default credentials. May be null
@return A true {@link ValidationResult} if valid, or false otherwise. The false result includes a detail message
|
[
"Validates",
"this",
"component",
"by",
"comparing",
"the",
"current",
"password",
"against",
"either",
"a",
"default",
"login",
"or",
"an",
"existing",
"single",
"user"
] |
cd9d744cacfaaae3c76cacc211e65742bbc7b00a
|
https://github.com/microfocus-idol/java-configuration-impl/blob/cd9d744cacfaaae3c76cacc211e65742bbc7b00a/src/main/java/com/hp/autonomy/frontend/configuration/authentication/BCryptUsernameAndPassword.java#L80-L87
|
153,717
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/client/protocol/messages/SnapshotRequestMessage.java
|
SnapshotRequestMessage.getMessageLength
|
public int getMessageLength() {
// Message type, ticket #
int messageLength = 1 + 4;
// Identifier length prefix
messageLength += 4;
if (this.identifierRegex != null) {
try {
messageLength += this.identifierRegex.getBytes("UTF-16BE").length;
} catch (UnsupportedEncodingException e) {
log.error("Unable to encode String into UTF-16.");
e.printStackTrace();
}
}
// Number of query attributes length prefix
messageLength += 4;
// Add length prefix and String length for each attribute
if (this.attributeRegexes != null) {
for (String attrib : this.attributeRegexes) {
messageLength += 4;
try {
messageLength += attrib.getBytes("UTF-16BE").length;
} catch (UnsupportedEncodingException e) {
log.error("Unable to encode String into uTF-16");
e.printStackTrace();
}
}
}
// Begin and end timestamps
messageLength += 16;
return messageLength;
}
|
java
|
public int getMessageLength() {
// Message type, ticket #
int messageLength = 1 + 4;
// Identifier length prefix
messageLength += 4;
if (this.identifierRegex != null) {
try {
messageLength += this.identifierRegex.getBytes("UTF-16BE").length;
} catch (UnsupportedEncodingException e) {
log.error("Unable to encode String into UTF-16.");
e.printStackTrace();
}
}
// Number of query attributes length prefix
messageLength += 4;
// Add length prefix and String length for each attribute
if (this.attributeRegexes != null) {
for (String attrib : this.attributeRegexes) {
messageLength += 4;
try {
messageLength += attrib.getBytes("UTF-16BE").length;
} catch (UnsupportedEncodingException e) {
log.error("Unable to encode String into uTF-16");
e.printStackTrace();
}
}
}
// Begin and end timestamps
messageLength += 16;
return messageLength;
}
|
[
"public",
"int",
"getMessageLength",
"(",
")",
"{",
"// Message type, ticket #",
"int",
"messageLength",
"=",
"1",
"+",
"4",
";",
"// Identifier length prefix",
"messageLength",
"+=",
"4",
";",
"if",
"(",
"this",
".",
"identifierRegex",
"!=",
"null",
")",
"{",
"try",
"{",
"messageLength",
"+=",
"this",
".",
"identifierRegex",
".",
"getBytes",
"(",
"\"UTF-16BE\"",
")",
".",
"length",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Unable to encode String into UTF-16.\"",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"// Number of query attributes length prefix",
"messageLength",
"+=",
"4",
";",
"// Add length prefix and String length for each attribute",
"if",
"(",
"this",
".",
"attributeRegexes",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"attrib",
":",
"this",
".",
"attributeRegexes",
")",
"{",
"messageLength",
"+=",
"4",
";",
"try",
"{",
"messageLength",
"+=",
"attrib",
".",
"getBytes",
"(",
"\"UTF-16BE\"",
")",
".",
"length",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Unable to encode String into uTF-16\"",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}",
"// Begin and end timestamps",
"messageLength",
"+=",
"16",
";",
"return",
"messageLength",
";",
"}"
] |
Returns the length of the message, in bytes, excluding the message length
prefix value.
@return the length of the message, in bytes, excluding the message length
prefix value.
|
[
"Returns",
"the",
"length",
"of",
"the",
"message",
"in",
"bytes",
"excluding",
"the",
"message",
"length",
"prefix",
"value",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/protocol/messages/SnapshotRequestMessage.java#L85-L121
|
153,718
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/convert/MultipleFieldConverter.java
|
MultipleFieldConverter.addComponent
|
public void addComponent(Object screenField)
{ // Set up the dependencies, This will recompute if any change from these three fields
this.setEnableTranslation(false);
super.addComponent(screenField);
this.setEnableTranslation(true);
for (int iIndex = 0; ; iIndex++)
{
Converter converter = this.getConverterToPass(iIndex);
if (converter == null)
break;
converter.addComponent(screenField);
}
}
|
java
|
public void addComponent(Object screenField)
{ // Set up the dependencies, This will recompute if any change from these three fields
this.setEnableTranslation(false);
super.addComponent(screenField);
this.setEnableTranslation(true);
for (int iIndex = 0; ; iIndex++)
{
Converter converter = this.getConverterToPass(iIndex);
if (converter == null)
break;
converter.addComponent(screenField);
}
}
|
[
"public",
"void",
"addComponent",
"(",
"Object",
"screenField",
")",
"{",
"// Set up the dependencies, This will recompute if any change from these three fields",
"this",
".",
"setEnableTranslation",
"(",
"false",
")",
";",
"super",
".",
"addComponent",
"(",
"screenField",
")",
";",
"this",
".",
"setEnableTranslation",
"(",
"true",
")",
";",
"for",
"(",
"int",
"iIndex",
"=",
"0",
";",
";",
"iIndex",
"++",
")",
"{",
"Converter",
"converter",
"=",
"this",
".",
"getConverterToPass",
"(",
"iIndex",
")",
";",
"if",
"(",
"converter",
"==",
"null",
")",
"break",
";",
"converter",
".",
"addComponent",
"(",
"screenField",
")",
";",
"}",
"}"
] |
Add this component to the components displaying this field.
Make sure all the converter have this screenfield on their list.
@param Object sField The screen component.. either a awt.Component or a ScreenField.
|
[
"Add",
"this",
"component",
"to",
"the",
"components",
"displaying",
"this",
"field",
".",
"Make",
"sure",
"all",
"the",
"converter",
"have",
"this",
"screenfield",
"on",
"their",
"list",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/convert/MultipleFieldConverter.java#L92-L104
|
153,719
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/convert/MultipleFieldConverter.java
|
MultipleFieldConverter.getNextConverter
|
public Converter getNextConverter()
{
if ((m_bEnableTranslation == true) && (this.getConverterToPass(m_bSetData) != null))
return this.getConverterToPass(m_bSetData); // Retrieve the dependent field
else
return super.getNextConverter(); // Retrieve this info
}
|
java
|
public Converter getNextConverter()
{
if ((m_bEnableTranslation == true) && (this.getConverterToPass(m_bSetData) != null))
return this.getConverterToPass(m_bSetData); // Retrieve the dependent field
else
return super.getNextConverter(); // Retrieve this info
}
|
[
"public",
"Converter",
"getNextConverter",
"(",
")",
"{",
"if",
"(",
"(",
"m_bEnableTranslation",
"==",
"true",
")",
"&&",
"(",
"this",
".",
"getConverterToPass",
"(",
"m_bSetData",
")",
"!=",
"null",
")",
")",
"return",
"this",
".",
"getConverterToPass",
"(",
"m_bSetData",
")",
";",
"// Retrieve the dependent field",
"else",
"return",
"super",
".",
"getNextConverter",
"(",
")",
";",
"// Retrieve this info",
"}"
] |
Get the next Converter in the chain.
|
[
"Get",
"the",
"next",
"Converter",
"in",
"the",
"chain",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/convert/MultipleFieldConverter.java#L187-L193
|
153,720
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/convert/MultipleFieldConverter.java
|
MultipleFieldConverter.getConverterToPass
|
public Converter getConverterToPass(int iIndex)
{
if (iIndex == -1)
return super.getNextConverter();
if (m_vconvDependent != null)
{
if (iIndex < m_vconvDependent.size())
return (Converter)m_vconvDependent.get(iIndex);
}
return null; // Use the next converter on the chain
}
|
java
|
public Converter getConverterToPass(int iIndex)
{
if (iIndex == -1)
return super.getNextConverter();
if (m_vconvDependent != null)
{
if (iIndex < m_vconvDependent.size())
return (Converter)m_vconvDependent.get(iIndex);
}
return null; // Use the next converter on the chain
}
|
[
"public",
"Converter",
"getConverterToPass",
"(",
"int",
"iIndex",
")",
"{",
"if",
"(",
"iIndex",
"==",
"-",
"1",
")",
"return",
"super",
".",
"getNextConverter",
"(",
")",
";",
"if",
"(",
"m_vconvDependent",
"!=",
"null",
")",
"{",
"if",
"(",
"iIndex",
"<",
"m_vconvDependent",
".",
"size",
"(",
")",
")",
"return",
"(",
"Converter",
")",
"m_vconvDependent",
".",
"get",
"(",
"iIndex",
")",
";",
"}",
"return",
"null",
";",
"// Use the next converter on the chain",
"}"
] |
Get this converter to use at this index.
@param iIndex The converter index.
@return The current converter.
|
[
"Get",
"this",
"converter",
"to",
"use",
"at",
"this",
"index",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/convert/MultipleFieldConverter.java#L219-L229
|
153,721
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/convert/MultipleFieldConverter.java
|
MultipleFieldConverter.addConverterToPass
|
public void addConverterToPass(Converter converter)
{
if (m_vconvDependent == null)
m_vconvDependent = new Vector<Converter>();
m_vconvDependent.add(converter);
this.setEnableTranslation(false);
if ((this.getNextConverter() == null)
|| (this.getNextConverter().getField() == null))
{
this.setEnableTranslation(true);
return;
}
for (int iSeq = 0; ; iSeq++)
{
ScreenComponent sField = (ScreenComponent)this.getNextConverter().getField().getComponent(iSeq);
if (sField == null)
break;
if (!this.isConverterInPath(sField))
continue; // This converter does not belong to this screen field
if (converter != null)
if (converter.getField() != null)
{
boolean bFound = false;
for (int iSeq2 = 0; ; iSeq2++)
{
if (converter.getField().getComponent(iSeq2) == null)
break;
if (converter.getField().getComponent(iSeq2) == sField)
bFound = true;
}
if (!bFound)
converter.addComponent(sField);
}
}
this.setEnableTranslation(true);
}
|
java
|
public void addConverterToPass(Converter converter)
{
if (m_vconvDependent == null)
m_vconvDependent = new Vector<Converter>();
m_vconvDependent.add(converter);
this.setEnableTranslation(false);
if ((this.getNextConverter() == null)
|| (this.getNextConverter().getField() == null))
{
this.setEnableTranslation(true);
return;
}
for (int iSeq = 0; ; iSeq++)
{
ScreenComponent sField = (ScreenComponent)this.getNextConverter().getField().getComponent(iSeq);
if (sField == null)
break;
if (!this.isConverterInPath(sField))
continue; // This converter does not belong to this screen field
if (converter != null)
if (converter.getField() != null)
{
boolean bFound = false;
for (int iSeq2 = 0; ; iSeq2++)
{
if (converter.getField().getComponent(iSeq2) == null)
break;
if (converter.getField().getComponent(iSeq2) == sField)
bFound = true;
}
if (!bFound)
converter.addComponent(sField);
}
}
this.setEnableTranslation(true);
}
|
[
"public",
"void",
"addConverterToPass",
"(",
"Converter",
"converter",
")",
"{",
"if",
"(",
"m_vconvDependent",
"==",
"null",
")",
"m_vconvDependent",
"=",
"new",
"Vector",
"<",
"Converter",
">",
"(",
")",
";",
"m_vconvDependent",
".",
"add",
"(",
"converter",
")",
";",
"this",
".",
"setEnableTranslation",
"(",
"false",
")",
";",
"if",
"(",
"(",
"this",
".",
"getNextConverter",
"(",
")",
"==",
"null",
")",
"||",
"(",
"this",
".",
"getNextConverter",
"(",
")",
".",
"getField",
"(",
")",
"==",
"null",
")",
")",
"{",
"this",
".",
"setEnableTranslation",
"(",
"true",
")",
";",
"return",
";",
"}",
"for",
"(",
"int",
"iSeq",
"=",
"0",
";",
";",
"iSeq",
"++",
")",
"{",
"ScreenComponent",
"sField",
"=",
"(",
"ScreenComponent",
")",
"this",
".",
"getNextConverter",
"(",
")",
".",
"getField",
"(",
")",
".",
"getComponent",
"(",
"iSeq",
")",
";",
"if",
"(",
"sField",
"==",
"null",
")",
"break",
";",
"if",
"(",
"!",
"this",
".",
"isConverterInPath",
"(",
"sField",
")",
")",
"continue",
";",
"// This converter does not belong to this screen field",
"if",
"(",
"converter",
"!=",
"null",
")",
"if",
"(",
"converter",
".",
"getField",
"(",
")",
"!=",
"null",
")",
"{",
"boolean",
"bFound",
"=",
"false",
";",
"for",
"(",
"int",
"iSeq2",
"=",
"0",
";",
";",
"iSeq2",
"++",
")",
"{",
"if",
"(",
"converter",
".",
"getField",
"(",
")",
".",
"getComponent",
"(",
"iSeq2",
")",
"==",
"null",
")",
"break",
";",
"if",
"(",
"converter",
".",
"getField",
"(",
")",
".",
"getComponent",
"(",
"iSeq2",
")",
"==",
"sField",
")",
"bFound",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"bFound",
")",
"converter",
".",
"addComponent",
"(",
"sField",
")",
";",
"}",
"}",
"this",
".",
"setEnableTranslation",
"(",
"true",
")",
";",
"}"
] |
Add this converter to pass.
@param converter Add this converter to the list.
|
[
"Add",
"this",
"converter",
"to",
"pass",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/convert/MultipleFieldConverter.java#L234-L269
|
153,722
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/convert/MultipleFieldConverter.java
|
MultipleFieldConverter.setEnableTranslation
|
public boolean setEnableTranslation(boolean bEnableTranslation)
{
boolean bOldTranslation = m_bEnableTranslation;
m_bEnableTranslation = false;
LinkedConverter converter = this;
while (converter != null)
{
if (converter.getNextConverter() instanceof LinkedConverter)
{
converter = (LinkedConverter)((LinkedConverter)converter).getNextConverter();
if (converter instanceof MultipleFieldConverter)
((MultipleFieldConverter)converter).setEnableTranslation(bEnableTranslation);
}
else
converter = null;
}
m_bEnableTranslation = bEnableTranslation;
return bOldTranslation;
}
|
java
|
public boolean setEnableTranslation(boolean bEnableTranslation)
{
boolean bOldTranslation = m_bEnableTranslation;
m_bEnableTranslation = false;
LinkedConverter converter = this;
while (converter != null)
{
if (converter.getNextConverter() instanceof LinkedConverter)
{
converter = (LinkedConverter)((LinkedConverter)converter).getNextConverter();
if (converter instanceof MultipleFieldConverter)
((MultipleFieldConverter)converter).setEnableTranslation(bEnableTranslation);
}
else
converter = null;
}
m_bEnableTranslation = bEnableTranslation;
return bOldTranslation;
}
|
[
"public",
"boolean",
"setEnableTranslation",
"(",
"boolean",
"bEnableTranslation",
")",
"{",
"boolean",
"bOldTranslation",
"=",
"m_bEnableTranslation",
";",
"m_bEnableTranslation",
"=",
"false",
";",
"LinkedConverter",
"converter",
"=",
"this",
";",
"while",
"(",
"converter",
"!=",
"null",
")",
"{",
"if",
"(",
"converter",
".",
"getNextConverter",
"(",
")",
"instanceof",
"LinkedConverter",
")",
"{",
"converter",
"=",
"(",
"LinkedConverter",
")",
"(",
"(",
"LinkedConverter",
")",
"converter",
")",
".",
"getNextConverter",
"(",
")",
";",
"if",
"(",
"converter",
"instanceof",
"MultipleFieldConverter",
")",
"(",
"(",
"MultipleFieldConverter",
")",
"converter",
")",
".",
"setEnableTranslation",
"(",
"bEnableTranslation",
")",
";",
"}",
"else",
"converter",
"=",
"null",
";",
"}",
"m_bEnableTranslation",
"=",
"bEnableTranslation",
";",
"return",
"bOldTranslation",
";",
"}"
] |
Enable or disable the converter translation.
@param bEnableTranslation If true, enable translation.
@return The old translation value.
|
[
"Enable",
"or",
"disable",
"the",
"converter",
"translation",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/convert/MultipleFieldConverter.java#L275-L293
|
153,723
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/convert/MultipleFieldConverter.java
|
MultipleFieldConverter.isConverterInPath
|
public boolean isConverterInPath(ScreenComponent sField)
{
Convert converter = sField.getConverter();
while (converter != null)
{
if (converter == this)
return true;
if (converter instanceof LinkedConverter)
{
MultipleFieldConverter convMultiple = null;
boolean bOldEnable = false;
if (converter instanceof MultipleFieldConverter)
convMultiple = (MultipleFieldConverter)converter;
if (convMultiple != null)
bOldEnable = convMultiple.setEnableTranslation(false);
converter = ((LinkedConverter)converter).getNextConverter();
if (convMultiple != null)
convMultiple.setEnableTranslation(bOldEnable);
}
else
converter = null;
}
return false; // Not found
}
|
java
|
public boolean isConverterInPath(ScreenComponent sField)
{
Convert converter = sField.getConverter();
while (converter != null)
{
if (converter == this)
return true;
if (converter instanceof LinkedConverter)
{
MultipleFieldConverter convMultiple = null;
boolean bOldEnable = false;
if (converter instanceof MultipleFieldConverter)
convMultiple = (MultipleFieldConverter)converter;
if (convMultiple != null)
bOldEnable = convMultiple.setEnableTranslation(false);
converter = ((LinkedConverter)converter).getNextConverter();
if (convMultiple != null)
convMultiple.setEnableTranslation(bOldEnable);
}
else
converter = null;
}
return false; // Not found
}
|
[
"public",
"boolean",
"isConverterInPath",
"(",
"ScreenComponent",
"sField",
")",
"{",
"Convert",
"converter",
"=",
"sField",
".",
"getConverter",
"(",
")",
";",
"while",
"(",
"converter",
"!=",
"null",
")",
"{",
"if",
"(",
"converter",
"==",
"this",
")",
"return",
"true",
";",
"if",
"(",
"converter",
"instanceof",
"LinkedConverter",
")",
"{",
"MultipleFieldConverter",
"convMultiple",
"=",
"null",
";",
"boolean",
"bOldEnable",
"=",
"false",
";",
"if",
"(",
"converter",
"instanceof",
"MultipleFieldConverter",
")",
"convMultiple",
"=",
"(",
"MultipleFieldConverter",
")",
"converter",
";",
"if",
"(",
"convMultiple",
"!=",
"null",
")",
"bOldEnable",
"=",
"convMultiple",
".",
"setEnableTranslation",
"(",
"false",
")",
";",
"converter",
"=",
"(",
"(",
"LinkedConverter",
")",
"converter",
")",
".",
"getNextConverter",
"(",
")",
";",
"if",
"(",
"convMultiple",
"!=",
"null",
")",
"convMultiple",
".",
"setEnableTranslation",
"(",
"bOldEnable",
")",
";",
"}",
"else",
"converter",
"=",
"null",
";",
"}",
"return",
"false",
";",
"// Not found",
"}"
] |
Is this converter in the converter path of this screen field.
@return true if it is.
|
[
"Is",
"this",
"converter",
"in",
"the",
"converter",
"path",
"of",
"this",
"screen",
"field",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/convert/MultipleFieldConverter.java#L298-L321
|
153,724
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/report/AnalysisScreen.java
|
AnalysisScreen.makeDefaultAnalysisRecord
|
public Record makeDefaultAnalysisRecord(Record recBasis)
{ // Set one up from scratch using the output params
Record recSummary = new AnalysisRecord(this);
KeyArea keyArea = recSummary.makeIndex(DBConstants.UNIQUE, "SummaryKey");
boolean bAddKeyField = true;
for (int i = 0; i < this.getSourceFieldCount(); i++)
{
BaseField field = this.getSourceField(i);
if (field == null)
continue;
try {
BaseField fldSummary = BaseField.cloneField(field);
if (field.getRecord() != recBasis)
{
String strRecord = field.getRecord().getRecordName();
if (field.getRecord() == this.getScreenRecord())
strRecord = "ScreenRecord";
fldSummary.setFieldName(strRecord + '.' + field.getFieldName());
}
if (field == field.getRecord().getCounterField())
{
fldSummary.setFieldName("Count");
fldSummary.setFieldDesc("Count");
}
recSummary.addField(fldSummary);
if (!this.isKeyField(fldSummary, i))
if (i != 0)
bAddKeyField = false;
if (bAddKeyField)
keyArea.addKeyField(fldSummary, DBConstants.ASCENDING);
} catch (CloneNotSupportedException ex) {
ex.printStackTrace(); // Never
}
}
recSummary.setKeyArea(AnalysisRecord.kIDKey + 1);
// Get rid of the current screen controls.
for (int i = this.getSFieldCount() - 1; i >= 0 ; i--)
{
ScreenField sField = this.getSField(i);
if (!(sField instanceof BasePanel))
sField.free();
}
int iToolbars = this.getSFieldCount();
// Add the new screen controls.
for (int i = AnalysisRecord.kID + 1; i < recSummary.getFieldCount(); i++)
{
recSummary.getField(i).setupDefaultView(this.getNextLocation(ScreenConstants.NEXT_LOGICAL, ScreenConstants.ANCHOR_DEFAULT), this, ScreenConstants.DEFAULT_DISPLAY);
}
while (iToolbars > 0)
{ // Move the toolbars up
ScreenField sField = this.getSField(0);
this.removeSField(sField);
this.addSField(sField);
iToolbars--;
}
// New main record!
this.addRecord(recSummary, true);
return recSummary;
}
|
java
|
public Record makeDefaultAnalysisRecord(Record recBasis)
{ // Set one up from scratch using the output params
Record recSummary = new AnalysisRecord(this);
KeyArea keyArea = recSummary.makeIndex(DBConstants.UNIQUE, "SummaryKey");
boolean bAddKeyField = true;
for (int i = 0; i < this.getSourceFieldCount(); i++)
{
BaseField field = this.getSourceField(i);
if (field == null)
continue;
try {
BaseField fldSummary = BaseField.cloneField(field);
if (field.getRecord() != recBasis)
{
String strRecord = field.getRecord().getRecordName();
if (field.getRecord() == this.getScreenRecord())
strRecord = "ScreenRecord";
fldSummary.setFieldName(strRecord + '.' + field.getFieldName());
}
if (field == field.getRecord().getCounterField())
{
fldSummary.setFieldName("Count");
fldSummary.setFieldDesc("Count");
}
recSummary.addField(fldSummary);
if (!this.isKeyField(fldSummary, i))
if (i != 0)
bAddKeyField = false;
if (bAddKeyField)
keyArea.addKeyField(fldSummary, DBConstants.ASCENDING);
} catch (CloneNotSupportedException ex) {
ex.printStackTrace(); // Never
}
}
recSummary.setKeyArea(AnalysisRecord.kIDKey + 1);
// Get rid of the current screen controls.
for (int i = this.getSFieldCount() - 1; i >= 0 ; i--)
{
ScreenField sField = this.getSField(i);
if (!(sField instanceof BasePanel))
sField.free();
}
int iToolbars = this.getSFieldCount();
// Add the new screen controls.
for (int i = AnalysisRecord.kID + 1; i < recSummary.getFieldCount(); i++)
{
recSummary.getField(i).setupDefaultView(this.getNextLocation(ScreenConstants.NEXT_LOGICAL, ScreenConstants.ANCHOR_DEFAULT), this, ScreenConstants.DEFAULT_DISPLAY);
}
while (iToolbars > 0)
{ // Move the toolbars up
ScreenField sField = this.getSField(0);
this.removeSField(sField);
this.addSField(sField);
iToolbars--;
}
// New main record!
this.addRecord(recSummary, true);
return recSummary;
}
|
[
"public",
"Record",
"makeDefaultAnalysisRecord",
"(",
"Record",
"recBasis",
")",
"{",
"// Set one up from scratch using the output params",
"Record",
"recSummary",
"=",
"new",
"AnalysisRecord",
"(",
"this",
")",
";",
"KeyArea",
"keyArea",
"=",
"recSummary",
".",
"makeIndex",
"(",
"DBConstants",
".",
"UNIQUE",
",",
"\"SummaryKey\"",
")",
";",
"boolean",
"bAddKeyField",
"=",
"true",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"getSourceFieldCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"BaseField",
"field",
"=",
"this",
".",
"getSourceField",
"(",
"i",
")",
";",
"if",
"(",
"field",
"==",
"null",
")",
"continue",
";",
"try",
"{",
"BaseField",
"fldSummary",
"=",
"BaseField",
".",
"cloneField",
"(",
"field",
")",
";",
"if",
"(",
"field",
".",
"getRecord",
"(",
")",
"!=",
"recBasis",
")",
"{",
"String",
"strRecord",
"=",
"field",
".",
"getRecord",
"(",
")",
".",
"getRecordName",
"(",
")",
";",
"if",
"(",
"field",
".",
"getRecord",
"(",
")",
"==",
"this",
".",
"getScreenRecord",
"(",
")",
")",
"strRecord",
"=",
"\"ScreenRecord\"",
";",
"fldSummary",
".",
"setFieldName",
"(",
"strRecord",
"+",
"'",
"'",
"+",
"field",
".",
"getFieldName",
"(",
")",
")",
";",
"}",
"if",
"(",
"field",
"==",
"field",
".",
"getRecord",
"(",
")",
".",
"getCounterField",
"(",
")",
")",
"{",
"fldSummary",
".",
"setFieldName",
"(",
"\"Count\"",
")",
";",
"fldSummary",
".",
"setFieldDesc",
"(",
"\"Count\"",
")",
";",
"}",
"recSummary",
".",
"addField",
"(",
"fldSummary",
")",
";",
"if",
"(",
"!",
"this",
".",
"isKeyField",
"(",
"fldSummary",
",",
"i",
")",
")",
"if",
"(",
"i",
"!=",
"0",
")",
"bAddKeyField",
"=",
"false",
";",
"if",
"(",
"bAddKeyField",
")",
"keyArea",
".",
"addKeyField",
"(",
"fldSummary",
",",
"DBConstants",
".",
"ASCENDING",
")",
";",
"}",
"catch",
"(",
"CloneNotSupportedException",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"// Never",
"}",
"}",
"recSummary",
".",
"setKeyArea",
"(",
"AnalysisRecord",
".",
"kIDKey",
"+",
"1",
")",
";",
"// Get rid of the current screen controls.",
"for",
"(",
"int",
"i",
"=",
"this",
".",
"getSFieldCount",
"(",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"ScreenField",
"sField",
"=",
"this",
".",
"getSField",
"(",
"i",
")",
";",
"if",
"(",
"!",
"(",
"sField",
"instanceof",
"BasePanel",
")",
")",
"sField",
".",
"free",
"(",
")",
";",
"}",
"int",
"iToolbars",
"=",
"this",
".",
"getSFieldCount",
"(",
")",
";",
"// Add the new screen controls.",
"for",
"(",
"int",
"i",
"=",
"AnalysisRecord",
".",
"kID",
"+",
"1",
";",
"i",
"<",
"recSummary",
".",
"getFieldCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"recSummary",
".",
"getField",
"(",
"i",
")",
".",
"setupDefaultView",
"(",
"this",
".",
"getNextLocation",
"(",
"ScreenConstants",
".",
"NEXT_LOGICAL",
",",
"ScreenConstants",
".",
"ANCHOR_DEFAULT",
")",
",",
"this",
",",
"ScreenConstants",
".",
"DEFAULT_DISPLAY",
")",
";",
"}",
"while",
"(",
"iToolbars",
">",
"0",
")",
"{",
"// Move the toolbars up",
"ScreenField",
"sField",
"=",
"this",
".",
"getSField",
"(",
"0",
")",
";",
"this",
".",
"removeSField",
"(",
"sField",
")",
";",
"this",
".",
"addSField",
"(",
"sField",
")",
";",
"iToolbars",
"--",
";",
"}",
"// New main record!",
"this",
".",
"addRecord",
"(",
"recSummary",
",",
"true",
")",
";",
"return",
"recSummary",
";",
"}"
] |
Create a record to do the data analysis with.
@param recBasis The record that will be analyzed.
@return The new record that will be used for analysis.
|
[
"Create",
"a",
"record",
"to",
"do",
"the",
"data",
"analysis",
"with",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/report/AnalysisScreen.java#L141-L201
|
153,725
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/report/AnalysisScreen.java
|
AnalysisScreen.getKeyMap
|
public BaseField[][] getKeyMap(Record recSummary, Record recBasis)
{
BaseField[][] mxKeyFields = new BaseField[recSummary.getKeyArea().getKeyFields()][2];
for (int i = 0; i < mxKeyFields.length; i++)
{
mxKeyFields[i][SUMMARY] = recSummary.getKeyArea().getField(i);
mxKeyFields[i][BASIS] = this.getBasisField(mxKeyFields[i][SUMMARY], recBasis, i);
}
return mxKeyFields;
}
|
java
|
public BaseField[][] getKeyMap(Record recSummary, Record recBasis)
{
BaseField[][] mxKeyFields = new BaseField[recSummary.getKeyArea().getKeyFields()][2];
for (int i = 0; i < mxKeyFields.length; i++)
{
mxKeyFields[i][SUMMARY] = recSummary.getKeyArea().getField(i);
mxKeyFields[i][BASIS] = this.getBasisField(mxKeyFields[i][SUMMARY], recBasis, i);
}
return mxKeyFields;
}
|
[
"public",
"BaseField",
"[",
"]",
"[",
"]",
"getKeyMap",
"(",
"Record",
"recSummary",
",",
"Record",
"recBasis",
")",
"{",
"BaseField",
"[",
"]",
"[",
"]",
"mxKeyFields",
"=",
"new",
"BaseField",
"[",
"recSummary",
".",
"getKeyArea",
"(",
")",
".",
"getKeyFields",
"(",
")",
"]",
"[",
"2",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mxKeyFields",
".",
"length",
";",
"i",
"++",
")",
"{",
"mxKeyFields",
"[",
"i",
"]",
"[",
"SUMMARY",
"]",
"=",
"recSummary",
".",
"getKeyArea",
"(",
")",
".",
"getField",
"(",
"i",
")",
";",
"mxKeyFields",
"[",
"i",
"]",
"[",
"BASIS",
"]",
"=",
"this",
".",
"getBasisField",
"(",
"mxKeyFields",
"[",
"i",
"]",
"[",
"SUMMARY",
"]",
",",
"recBasis",
",",
"i",
")",
";",
"}",
"return",
"mxKeyFields",
";",
"}"
] |
Create a map of the source and destination key fields.
@param recSummary The destination (analysis) record.
@param recBasic The source record (to analyze).
@return A mapping of the source and dest key fields.
|
[
"Create",
"a",
"map",
"of",
"the",
"source",
"and",
"destination",
"key",
"fields",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/report/AnalysisScreen.java#L249-L258
|
153,726
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/report/AnalysisScreen.java
|
AnalysisScreen.getDataMap
|
public BaseField[][] getDataMap(Record recSummary, Record recBasis)
{
int iFieldSeq = 0;
if (recSummary.getField(iFieldSeq) == recSummary.getCounterField())
iFieldSeq++;
int iLength = recSummary.getFieldCount();
iLength = iLength - recSummary.getKeyArea().getKeyFields() - iFieldSeq;
BaseField[][] mxDataFields = new BaseField[iLength][2];
for (int i = 0; i < mxDataFields.length; i++)
{
mxDataFields[i][SUMMARY] = recSummary.getField(iFieldSeq);
mxDataFields[i][BASIS] = this.getBasisField(mxDataFields[i][SUMMARY], recBasis, i);
iFieldSeq++;
for (int j = 0; j < recSummary.getKeyArea().getKeyFields(); j++)
{
if (mxDataFields[i][SUMMARY] == recSummary.getKeyArea().getField(j))
{
i--; // Skip this one, it is in the key area.
break;
}
}
}
return mxDataFields;
}
|
java
|
public BaseField[][] getDataMap(Record recSummary, Record recBasis)
{
int iFieldSeq = 0;
if (recSummary.getField(iFieldSeq) == recSummary.getCounterField())
iFieldSeq++;
int iLength = recSummary.getFieldCount();
iLength = iLength - recSummary.getKeyArea().getKeyFields() - iFieldSeq;
BaseField[][] mxDataFields = new BaseField[iLength][2];
for (int i = 0; i < mxDataFields.length; i++)
{
mxDataFields[i][SUMMARY] = recSummary.getField(iFieldSeq);
mxDataFields[i][BASIS] = this.getBasisField(mxDataFields[i][SUMMARY], recBasis, i);
iFieldSeq++;
for (int j = 0; j < recSummary.getKeyArea().getKeyFields(); j++)
{
if (mxDataFields[i][SUMMARY] == recSummary.getKeyArea().getField(j))
{
i--; // Skip this one, it is in the key area.
break;
}
}
}
return mxDataFields;
}
|
[
"public",
"BaseField",
"[",
"]",
"[",
"]",
"getDataMap",
"(",
"Record",
"recSummary",
",",
"Record",
"recBasis",
")",
"{",
"int",
"iFieldSeq",
"=",
"0",
";",
"if",
"(",
"recSummary",
".",
"getField",
"(",
"iFieldSeq",
")",
"==",
"recSummary",
".",
"getCounterField",
"(",
")",
")",
"iFieldSeq",
"++",
";",
"int",
"iLength",
"=",
"recSummary",
".",
"getFieldCount",
"(",
")",
";",
"iLength",
"=",
"iLength",
"-",
"recSummary",
".",
"getKeyArea",
"(",
")",
".",
"getKeyFields",
"(",
")",
"-",
"iFieldSeq",
";",
"BaseField",
"[",
"]",
"[",
"]",
"mxDataFields",
"=",
"new",
"BaseField",
"[",
"iLength",
"]",
"[",
"2",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mxDataFields",
".",
"length",
";",
"i",
"++",
")",
"{",
"mxDataFields",
"[",
"i",
"]",
"[",
"SUMMARY",
"]",
"=",
"recSummary",
".",
"getField",
"(",
"iFieldSeq",
")",
";",
"mxDataFields",
"[",
"i",
"]",
"[",
"BASIS",
"]",
"=",
"this",
".",
"getBasisField",
"(",
"mxDataFields",
"[",
"i",
"]",
"[",
"SUMMARY",
"]",
",",
"recBasis",
",",
"i",
")",
";",
"iFieldSeq",
"++",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"recSummary",
".",
"getKeyArea",
"(",
")",
".",
"getKeyFields",
"(",
")",
";",
"j",
"++",
")",
"{",
"if",
"(",
"mxDataFields",
"[",
"i",
"]",
"[",
"SUMMARY",
"]",
"==",
"recSummary",
".",
"getKeyArea",
"(",
")",
".",
"getField",
"(",
"j",
")",
")",
"{",
"i",
"--",
";",
"// Skip this one, it is in the key area.",
"break",
";",
"}",
"}",
"}",
"return",
"mxDataFields",
";",
"}"
] |
Create a map of the source and destination data fields.
@param recSummary The destination (analysis) record.
@param recBasic The source record (to analyze).
@return A mapping of the source and dest non-key fields.
|
[
"Create",
"a",
"map",
"of",
"the",
"source",
"and",
"destination",
"data",
"fields",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/report/AnalysisScreen.java#L265-L288
|
153,727
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/report/AnalysisScreen.java
|
AnalysisScreen.getBasisField
|
public BaseField getBasisField(BaseField fldSummary, Record recBasis, int iSummarySeq)
{
BaseField fldBasis = null;
String strFieldName = fldSummary.getFieldName();
if ((strFieldName != null) && (strFieldName.indexOf('.') != -1))
{
Record record = this.getRecord(strFieldName.substring(0, strFieldName.indexOf('.')));
if ((strFieldName.indexOf('.') == 0) || ("ScreenRecord".equalsIgnoreCase(strFieldName.substring(0, strFieldName.indexOf('.')))))
record = this.getScreenRecord();
fldBasis = record.getField(strFieldName.substring(strFieldName.indexOf('.') + 1));
}
else
fldBasis = recBasis.getField(strFieldName);
return fldBasis;
}
|
java
|
public BaseField getBasisField(BaseField fldSummary, Record recBasis, int iSummarySeq)
{
BaseField fldBasis = null;
String strFieldName = fldSummary.getFieldName();
if ((strFieldName != null) && (strFieldName.indexOf('.') != -1))
{
Record record = this.getRecord(strFieldName.substring(0, strFieldName.indexOf('.')));
if ((strFieldName.indexOf('.') == 0) || ("ScreenRecord".equalsIgnoreCase(strFieldName.substring(0, strFieldName.indexOf('.')))))
record = this.getScreenRecord();
fldBasis = record.getField(strFieldName.substring(strFieldName.indexOf('.') + 1));
}
else
fldBasis = recBasis.getField(strFieldName);
return fldBasis;
}
|
[
"public",
"BaseField",
"getBasisField",
"(",
"BaseField",
"fldSummary",
",",
"Record",
"recBasis",
",",
"int",
"iSummarySeq",
")",
"{",
"BaseField",
"fldBasis",
"=",
"null",
";",
"String",
"strFieldName",
"=",
"fldSummary",
".",
"getFieldName",
"(",
")",
";",
"if",
"(",
"(",
"strFieldName",
"!=",
"null",
")",
"&&",
"(",
"strFieldName",
".",
"indexOf",
"(",
"'",
"'",
")",
"!=",
"-",
"1",
")",
")",
"{",
"Record",
"record",
"=",
"this",
".",
"getRecord",
"(",
"strFieldName",
".",
"substring",
"(",
"0",
",",
"strFieldName",
".",
"indexOf",
"(",
"'",
"'",
")",
")",
")",
";",
"if",
"(",
"(",
"strFieldName",
".",
"indexOf",
"(",
"'",
"'",
")",
"==",
"0",
")",
"||",
"(",
"\"ScreenRecord\"",
".",
"equalsIgnoreCase",
"(",
"strFieldName",
".",
"substring",
"(",
"0",
",",
"strFieldName",
".",
"indexOf",
"(",
"'",
"'",
")",
")",
")",
")",
")",
"record",
"=",
"this",
".",
"getScreenRecord",
"(",
")",
";",
"fldBasis",
"=",
"record",
".",
"getField",
"(",
"strFieldName",
".",
"substring",
"(",
"strFieldName",
".",
"indexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
")",
";",
"}",
"else",
"fldBasis",
"=",
"recBasis",
".",
"getField",
"(",
"strFieldName",
")",
";",
"return",
"fldBasis",
";",
"}"
] |
Get the matching basis field given the summary field.
Override this if you don't want the defaults.
@param fldSummary The summary field to match.
@param recBasic The basis record.
@param iSummarySeq The position in the summary record.
@return The basis field.
|
[
"Get",
"the",
"matching",
"basis",
"field",
"given",
"the",
"summary",
"field",
".",
"Override",
"this",
"if",
"you",
"don",
"t",
"want",
"the",
"defaults",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/report/AnalysisScreen.java#L297-L311
|
153,728
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/report/AnalysisScreen.java
|
AnalysisScreen.setupSummaryKey
|
public void setupSummaryKey(BaseField[][] mxKeyFields)
{
for (int i = 0; i < mxKeyFields.length; i++)
{
mxKeyFields[i][SUMMARY].moveFieldToThis(mxKeyFields[i][BASIS]);
}
}
|
java
|
public void setupSummaryKey(BaseField[][] mxKeyFields)
{
for (int i = 0; i < mxKeyFields.length; i++)
{
mxKeyFields[i][SUMMARY].moveFieldToThis(mxKeyFields[i][BASIS]);
}
}
|
[
"public",
"void",
"setupSummaryKey",
"(",
"BaseField",
"[",
"]",
"[",
"]",
"mxKeyFields",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mxKeyFields",
".",
"length",
";",
"i",
"++",
")",
"{",
"mxKeyFields",
"[",
"i",
"]",
"[",
"SUMMARY",
"]",
".",
"moveFieldToThis",
"(",
"mxKeyFields",
"[",
"i",
"]",
"[",
"BASIS",
"]",
")",
";",
"}",
"}"
] |
Move the source key fields to the destinataion keys.
@param mxKeyFields The key fields to move.
|
[
"Move",
"the",
"source",
"key",
"fields",
"to",
"the",
"destinataion",
"keys",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/report/AnalysisScreen.java#L316-L322
|
153,729
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/report/AnalysisScreen.java
|
AnalysisScreen.addSummaryData
|
public void addSummaryData(BaseField[][] mxDataFields)
{
for (int i = 0; i < mxDataFields.length; i++)
{
double dAmount = 1;
if (mxDataFields[i][BASIS] != null)
dAmount = mxDataFields[i][BASIS].getValue();
mxDataFields[i][SUMMARY].setValue(mxDataFields[i][SUMMARY].getValue() + dAmount);
}
}
|
java
|
public void addSummaryData(BaseField[][] mxDataFields)
{
for (int i = 0; i < mxDataFields.length; i++)
{
double dAmount = 1;
if (mxDataFields[i][BASIS] != null)
dAmount = mxDataFields[i][BASIS].getValue();
mxDataFields[i][SUMMARY].setValue(mxDataFields[i][SUMMARY].getValue() + dAmount);
}
}
|
[
"public",
"void",
"addSummaryData",
"(",
"BaseField",
"[",
"]",
"[",
"]",
"mxDataFields",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mxDataFields",
".",
"length",
";",
"i",
"++",
")",
"{",
"double",
"dAmount",
"=",
"1",
";",
"if",
"(",
"mxDataFields",
"[",
"i",
"]",
"[",
"BASIS",
"]",
"!=",
"null",
")",
"dAmount",
"=",
"mxDataFields",
"[",
"i",
"]",
"[",
"BASIS",
"]",
".",
"getValue",
"(",
")",
";",
"mxDataFields",
"[",
"i",
"]",
"[",
"SUMMARY",
"]",
".",
"setValue",
"(",
"mxDataFields",
"[",
"i",
"]",
"[",
"SUMMARY",
"]",
".",
"getValue",
"(",
")",
"+",
"dAmount",
")",
";",
"}",
"}"
] |
Move the source data fields to the destinataion data fields.
@param mxDataFields The data fields to move.
|
[
"Move",
"the",
"source",
"data",
"fields",
"to",
"the",
"destinataion",
"data",
"fields",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/report/AnalysisScreen.java#L327-L336
|
153,730
|
myriadmobile/shove
|
library/src/main/java/com/myriadmobile/library/shove/SimpleNotificationDelegate.java
|
SimpleNotificationDelegate.onReceive
|
@Override
public void onReceive(Context context, Intent notification) {
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
String messageType = gcm.getMessageType(notification);
Bundle extras = notification.getExtras();
if (!extras.isEmpty() && GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
showNotification(context, extras);
}
}
|
java
|
@Override
public void onReceive(Context context, Intent notification) {
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
String messageType = gcm.getMessageType(notification);
Bundle extras = notification.getExtras();
if (!extras.isEmpty() && GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
showNotification(context, extras);
}
}
|
[
"@",
"Override",
"public",
"void",
"onReceive",
"(",
"Context",
"context",
",",
"Intent",
"notification",
")",
"{",
"GoogleCloudMessaging",
"gcm",
"=",
"GoogleCloudMessaging",
".",
"getInstance",
"(",
"context",
")",
";",
"String",
"messageType",
"=",
"gcm",
".",
"getMessageType",
"(",
"notification",
")",
";",
"Bundle",
"extras",
"=",
"notification",
".",
"getExtras",
"(",
")",
";",
"if",
"(",
"!",
"extras",
".",
"isEmpty",
"(",
")",
"&&",
"GoogleCloudMessaging",
".",
"MESSAGE_TYPE_MESSAGE",
".",
"equals",
"(",
"messageType",
")",
")",
"{",
"showNotification",
"(",
"context",
",",
"extras",
")",
";",
"}",
"}"
] |
Called when a notification is received
@param context the service context
@param notification the notification intent
|
[
"Called",
"when",
"a",
"notification",
"is",
"received"
] |
71ab329cdbaef5bdc2b75e43af1393308c4c1eed
|
https://github.com/myriadmobile/shove/blob/71ab329cdbaef5bdc2b75e43af1393308c4c1eed/library/src/main/java/com/myriadmobile/library/shove/SimpleNotificationDelegate.java#L79-L88
|
153,731
|
myriadmobile/shove
|
library/src/main/java/com/myriadmobile/library/shove/SimpleNotificationDelegate.java
|
SimpleNotificationDelegate.showNotification
|
public void showNotification(Context context, Bundle extras) {
// parse the title and message from the extras
String title = getTitle(context, extras);
String message = getMessage(context, extras);
// if the message is empty, bail
if (message == null)
return;
// create the notification
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
long when = System.currentTimeMillis();
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setAutoCancel(true)
.setSmallIcon(getIcon(context))
.setContentTitle(title)
.setContentText(message)
.setContentIntent(getContentIntent(context, extras, when))
.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
// display the notification
mNotificationManager.notify((int) when, mBuilder.build());
}
|
java
|
public void showNotification(Context context, Bundle extras) {
// parse the title and message from the extras
String title = getTitle(context, extras);
String message = getMessage(context, extras);
// if the message is empty, bail
if (message == null)
return;
// create the notification
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
long when = System.currentTimeMillis();
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setAutoCancel(true)
.setSmallIcon(getIcon(context))
.setContentTitle(title)
.setContentText(message)
.setContentIntent(getContentIntent(context, extras, when))
.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
// display the notification
mNotificationManager.notify((int) when, mBuilder.build());
}
|
[
"public",
"void",
"showNotification",
"(",
"Context",
"context",
",",
"Bundle",
"extras",
")",
"{",
"// parse the title and message from the extras",
"String",
"title",
"=",
"getTitle",
"(",
"context",
",",
"extras",
")",
";",
"String",
"message",
"=",
"getMessage",
"(",
"context",
",",
"extras",
")",
";",
"// if the message is empty, bail",
"if",
"(",
"message",
"==",
"null",
")",
"return",
";",
"// create the notification",
"NotificationManager",
"mNotificationManager",
"=",
"(",
"NotificationManager",
")",
"context",
".",
"getSystemService",
"(",
"Context",
".",
"NOTIFICATION_SERVICE",
")",
";",
"long",
"when",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"NotificationCompat",
".",
"Builder",
"mBuilder",
"=",
"new",
"NotificationCompat",
".",
"Builder",
"(",
"context",
")",
".",
"setAutoCancel",
"(",
"true",
")",
".",
"setSmallIcon",
"(",
"getIcon",
"(",
"context",
")",
")",
".",
"setContentTitle",
"(",
"title",
")",
".",
"setContentText",
"(",
"message",
")",
".",
"setContentIntent",
"(",
"getContentIntent",
"(",
"context",
",",
"extras",
",",
"when",
")",
")",
".",
"setStyle",
"(",
"new",
"NotificationCompat",
".",
"BigTextStyle",
"(",
")",
".",
"bigText",
"(",
"message",
")",
")",
";",
"// display the notification",
"mNotificationManager",
".",
"notify",
"(",
"(",
"int",
")",
"when",
",",
"mBuilder",
".",
"build",
"(",
")",
")",
";",
"}"
] |
Shows a notification for the given push message
@param extras the message extras
|
[
"Shows",
"a",
"notification",
"for",
"the",
"given",
"push",
"message"
] |
71ab329cdbaef5bdc2b75e43af1393308c4c1eed
|
https://github.com/myriadmobile/shove/blob/71ab329cdbaef5bdc2b75e43af1393308c4c1eed/library/src/main/java/com/myriadmobile/library/shove/SimpleNotificationDelegate.java#L95-L118
|
153,732
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/theme/CustomTheme.java
|
CustomTheme.darken
|
public static ColorUIResource darken(ColorUIResource color)
{
return new ColorUIResource(darkenRGB(color.getRed()), darkenRGB(color.getGreen()), darkenRGB(color.getBlue()));
}
|
java
|
public static ColorUIResource darken(ColorUIResource color)
{
return new ColorUIResource(darkenRGB(color.getRed()), darkenRGB(color.getGreen()), darkenRGB(color.getBlue()));
}
|
[
"public",
"static",
"ColorUIResource",
"darken",
"(",
"ColorUIResource",
"color",
")",
"{",
"return",
"new",
"ColorUIResource",
"(",
"darkenRGB",
"(",
"color",
".",
"getRed",
"(",
")",
")",
",",
"darkenRGB",
"(",
"color",
".",
"getGreen",
"(",
")",
")",
",",
"darkenRGB",
"(",
"color",
".",
"getBlue",
"(",
")",
")",
")",
";",
"}"
] |
Lighten this color.
|
[
"Lighten",
"this",
"color",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/theme/CustomTheme.java#L198-L201
|
153,733
|
the-fascinator/plugin-indexer-solr
|
src/main/java/com/googlecode/fascinator/indexer/SolrWrapperQueueConsumer.java
|
SolrWrapperQueueConsumer.run
|
@Override
public void run() {
try {
MDC.put("name", name);
log.info("Starting {}...", name);
// Get a connection to the broker
String brokerUrl = globalConfig.getString(
ActiveMQConnectionFactory.DEFAULT_BROKER_BIND_URL,
"messaging", "url");
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
brokerUrl);
connection = connectionFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
consumer = session.createConsumer(session.createQueue(QUEUE_ID));
consumer.setMessageListener(this);
connection.start();
// Solr
solr = initCore("solr");
// Timeout 'tick' for buffer (10s)
timer = new Timer("SolrWrapper:" + toString(), true);
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
checkTimeout();
}
}, 0, 10000);
} catch (JMSException ex) {
log.error("Error starting message thread!", ex);
}
}
|
java
|
@Override
public void run() {
try {
MDC.put("name", name);
log.info("Starting {}...", name);
// Get a connection to the broker
String brokerUrl = globalConfig.getString(
ActiveMQConnectionFactory.DEFAULT_BROKER_BIND_URL,
"messaging", "url");
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
brokerUrl);
connection = connectionFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
consumer = session.createConsumer(session.createQueue(QUEUE_ID));
consumer.setMessageListener(this);
connection.start();
// Solr
solr = initCore("solr");
// Timeout 'tick' for buffer (10s)
timer = new Timer("SolrWrapper:" + toString(), true);
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
checkTimeout();
}
}, 0, 10000);
} catch (JMSException ex) {
log.error("Error starting message thread!", ex);
}
}
|
[
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"MDC",
".",
"put",
"(",
"\"name\"",
",",
"name",
")",
";",
"log",
".",
"info",
"(",
"\"Starting {}...\"",
",",
"name",
")",
";",
"// Get a connection to the broker",
"String",
"brokerUrl",
"=",
"globalConfig",
".",
"getString",
"(",
"ActiveMQConnectionFactory",
".",
"DEFAULT_BROKER_BIND_URL",
",",
"\"messaging\"",
",",
"\"url\"",
")",
";",
"ActiveMQConnectionFactory",
"connectionFactory",
"=",
"new",
"ActiveMQConnectionFactory",
"(",
"brokerUrl",
")",
";",
"connection",
"=",
"connectionFactory",
".",
"createConnection",
"(",
")",
";",
"session",
"=",
"connection",
".",
"createSession",
"(",
"false",
",",
"Session",
".",
"AUTO_ACKNOWLEDGE",
")",
";",
"consumer",
"=",
"session",
".",
"createConsumer",
"(",
"session",
".",
"createQueue",
"(",
"QUEUE_ID",
")",
")",
";",
"consumer",
".",
"setMessageListener",
"(",
"this",
")",
";",
"connection",
".",
"start",
"(",
")",
";",
"// Solr",
"solr",
"=",
"initCore",
"(",
"\"solr\"",
")",
";",
"// Timeout 'tick' for buffer (10s)",
"timer",
"=",
"new",
"Timer",
"(",
"\"SolrWrapper:\"",
"+",
"toString",
"(",
")",
",",
"true",
")",
";",
"timer",
".",
"scheduleAtFixedRate",
"(",
"new",
"TimerTask",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"checkTimeout",
"(",
")",
";",
"}",
"}",
",",
"0",
",",
"10000",
")",
";",
"}",
"catch",
"(",
"JMSException",
"ex",
")",
"{",
"log",
".",
"error",
"(",
"\"Error starting message thread!\"",
",",
"ex",
")",
";",
"}",
"}"
] |
Start thread running
|
[
"Start",
"thread",
"running"
] |
001159b18b78a87daa5d8b2a17ced28694bae156
|
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrWrapperQueueConsumer.java#L163-L194
|
153,734
|
the-fascinator/plugin-indexer-solr
|
src/main/java/com/googlecode/fascinator/indexer/SolrWrapperQueueConsumer.java
|
SolrWrapperQueueConsumer.stop
|
@Override
public void stop() throws Exception {
log.info("Stopping {}...", name);
submitBuffer(true);
if (coreContainer != null) {
coreContainer.shutdown();
}
if (consumer != null) {
try {
consumer.close();
} catch (JMSException jmse) {
log.warn("Failed to close consumer: {}", jmse.getMessage());
throw jmse;
}
}
if (session != null) {
try {
session.close();
} catch (JMSException jmse) {
log.warn("Failed to close consumer session: {}", jmse);
}
}
if (connection != null) {
try {
connection.close();
} catch (JMSException jmse) {
log.warn("Failed to close connection: {}", jmse);
}
}
timer.cancel();
}
|
java
|
@Override
public void stop() throws Exception {
log.info("Stopping {}...", name);
submitBuffer(true);
if (coreContainer != null) {
coreContainer.shutdown();
}
if (consumer != null) {
try {
consumer.close();
} catch (JMSException jmse) {
log.warn("Failed to close consumer: {}", jmse.getMessage());
throw jmse;
}
}
if (session != null) {
try {
session.close();
} catch (JMSException jmse) {
log.warn("Failed to close consumer session: {}", jmse);
}
}
if (connection != null) {
try {
connection.close();
} catch (JMSException jmse) {
log.warn("Failed to close connection: {}", jmse);
}
}
timer.cancel();
}
|
[
"@",
"Override",
"public",
"void",
"stop",
"(",
")",
"throws",
"Exception",
"{",
"log",
".",
"info",
"(",
"\"Stopping {}...\"",
",",
"name",
")",
";",
"submitBuffer",
"(",
"true",
")",
";",
"if",
"(",
"coreContainer",
"!=",
"null",
")",
"{",
"coreContainer",
".",
"shutdown",
"(",
")",
";",
"}",
"if",
"(",
"consumer",
"!=",
"null",
")",
"{",
"try",
"{",
"consumer",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"JMSException",
"jmse",
")",
"{",
"log",
".",
"warn",
"(",
"\"Failed to close consumer: {}\"",
",",
"jmse",
".",
"getMessage",
"(",
")",
")",
";",
"throw",
"jmse",
";",
"}",
"}",
"if",
"(",
"session",
"!=",
"null",
")",
"{",
"try",
"{",
"session",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"JMSException",
"jmse",
")",
"{",
"log",
".",
"warn",
"(",
"\"Failed to close consumer session: {}\"",
",",
"jmse",
")",
";",
"}",
"}",
"if",
"(",
"connection",
"!=",
"null",
")",
"{",
"try",
"{",
"connection",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"JMSException",
"jmse",
")",
"{",
"log",
".",
"warn",
"(",
"\"Failed to close connection: {}\"",
",",
"jmse",
")",
";",
"}",
"}",
"timer",
".",
"cancel",
"(",
")",
";",
"}"
] |
Stop the Render Queue Consumer. Including stopping the storage and
indexer
|
[
"Stop",
"the",
"Render",
"Queue",
"Consumer",
".",
"Including",
"stopping",
"the",
"storage",
"and",
"indexer"
] |
001159b18b78a87daa5d8b2a17ced28694bae156
|
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrWrapperQueueConsumer.java#L357-L387
|
153,735
|
the-fascinator/plugin-indexer-solr
|
src/main/java/com/googlecode/fascinator/indexer/SolrWrapperQueueConsumer.java
|
SolrWrapperQueueConsumer.onMessage
|
@Override
public void onMessage(Message message) {
MDC.put("name", name);
try {
// Make sure thread priority is correct
if (!Thread.currentThread().getName().equals(thread.getName())) {
Thread.currentThread().setName(thread.getName());
Thread.currentThread().setPriority(thread.getPriority());
}
// Get the message details
String text = ((TextMessage) message).getText();
JsonSimple config = new JsonSimple(text);
String event = config.getString(null, "event");
if (event == null) {
log.error("Invalid message received: '{}'", text);
return;
}
// Commit on the index
if (event.equals("commit")) {
log.debug("Commit received");
submitBuffer(true);
}
// Index the incoming document
if (event.equals("index")) {
String index = config.getString(null, "index");
String document = config.getString(null, "document");
if (index == null || document == null) {
log.error("Invalid message received: '{}'", text);
return;
}
addToBuffer(index, document);
}
} catch (JMSException jmse) {
log.error("Failed to send/receive message: {}", jmse.getMessage());
} catch (IOException ioe) {
log.error("Failed to parse message: {}", ioe.getMessage());
}
}
|
java
|
@Override
public void onMessage(Message message) {
MDC.put("name", name);
try {
// Make sure thread priority is correct
if (!Thread.currentThread().getName().equals(thread.getName())) {
Thread.currentThread().setName(thread.getName());
Thread.currentThread().setPriority(thread.getPriority());
}
// Get the message details
String text = ((TextMessage) message).getText();
JsonSimple config = new JsonSimple(text);
String event = config.getString(null, "event");
if (event == null) {
log.error("Invalid message received: '{}'", text);
return;
}
// Commit on the index
if (event.equals("commit")) {
log.debug("Commit received");
submitBuffer(true);
}
// Index the incoming document
if (event.equals("index")) {
String index = config.getString(null, "index");
String document = config.getString(null, "document");
if (index == null || document == null) {
log.error("Invalid message received: '{}'", text);
return;
}
addToBuffer(index, document);
}
} catch (JMSException jmse) {
log.error("Failed to send/receive message: {}", jmse.getMessage());
} catch (IOException ioe) {
log.error("Failed to parse message: {}", ioe.getMessage());
}
}
|
[
"@",
"Override",
"public",
"void",
"onMessage",
"(",
"Message",
"message",
")",
"{",
"MDC",
".",
"put",
"(",
"\"name\"",
",",
"name",
")",
";",
"try",
"{",
"// Make sure thread priority is correct",
"if",
"(",
"!",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"thread",
".",
"getName",
"(",
")",
")",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"setName",
"(",
"thread",
".",
"getName",
"(",
")",
")",
";",
"Thread",
".",
"currentThread",
"(",
")",
".",
"setPriority",
"(",
"thread",
".",
"getPriority",
"(",
")",
")",
";",
"}",
"// Get the message details",
"String",
"text",
"=",
"(",
"(",
"TextMessage",
")",
"message",
")",
".",
"getText",
"(",
")",
";",
"JsonSimple",
"config",
"=",
"new",
"JsonSimple",
"(",
"text",
")",
";",
"String",
"event",
"=",
"config",
".",
"getString",
"(",
"null",
",",
"\"event\"",
")",
";",
"if",
"(",
"event",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Invalid message received: '{}'\"",
",",
"text",
")",
";",
"return",
";",
"}",
"// Commit on the index",
"if",
"(",
"event",
".",
"equals",
"(",
"\"commit\"",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"Commit received\"",
")",
";",
"submitBuffer",
"(",
"true",
")",
";",
"}",
"// Index the incoming document",
"if",
"(",
"event",
".",
"equals",
"(",
"\"index\"",
")",
")",
"{",
"String",
"index",
"=",
"config",
".",
"getString",
"(",
"null",
",",
"\"index\"",
")",
";",
"String",
"document",
"=",
"config",
".",
"getString",
"(",
"null",
",",
"\"document\"",
")",
";",
"if",
"(",
"index",
"==",
"null",
"||",
"document",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Invalid message received: '{}'\"",
",",
"text",
")",
";",
"return",
";",
"}",
"addToBuffer",
"(",
"index",
",",
"document",
")",
";",
"}",
"}",
"catch",
"(",
"JMSException",
"jmse",
")",
"{",
"log",
".",
"error",
"(",
"\"Failed to send/receive message: {}\"",
",",
"jmse",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"log",
".",
"error",
"(",
"\"Failed to parse message: {}\"",
",",
"ioe",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Callback function for incoming messages.
@param message The incoming message
|
[
"Callback",
"function",
"for",
"incoming",
"messages",
"."
] |
001159b18b78a87daa5d8b2a17ced28694bae156
|
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrWrapperQueueConsumer.java#L394-L434
|
153,736
|
the-fascinator/plugin-indexer-solr
|
src/main/java/com/googlecode/fascinator/indexer/SolrWrapperQueueConsumer.java
|
SolrWrapperQueueConsumer.submitBuffer
|
private void submitBuffer(boolean forceCommit) {
int size = docBuffer.size();
if (size > 0) {
// Debugging
// String age = String.valueOf(
// ((new Date().getTime()) - bufferOldest) / 1000);
// String length = String.valueOf(bufferSize);
// log.debug("Submitting buffer: " + size + " documents, " + length
// +
// " bytes, " + age + "s");
log.debug("=== Submitting buffer: " + size + " documents");
// Concatenate all documents in the buffer
StringBuffer submissionBuffer = new StringBuffer();
for (String doc : docBuffer.keySet()) {
submissionBuffer.append(docBuffer.get(doc));
// log.debug("DOC: {}", doc);
}
// Submit if the result is valid
if (submissionBuffer.length() > 0) {
// Wrap in the basic Solr 'add' node
String submission = submissionBuffer.insert(0, "<add>")
.append("</add>").toString();
// And submit
try {
solr.request(new DirectXmlRequest("/update", submission));
} catch (Exception ex) {
log.error("Error submitting documents to Solr!", ex);
}
// Commit if required
if (autoCommit || forceCommit) {
log.info("Running forced commit!");
try {
// HTTP commits for embedded
if (commit != null) {
solr.commit();
commit.commit();
// or just HTTP on it's own
} else {
solr.commit();
}
} catch (Exception e) {
log.warn(
"Solr forced commit failed. Document will"
+ " not be visible until Solr autocommit fires."
+ " Error message: {}", e);
}
}
}
}
purgeBuffer();
}
|
java
|
private void submitBuffer(boolean forceCommit) {
int size = docBuffer.size();
if (size > 0) {
// Debugging
// String age = String.valueOf(
// ((new Date().getTime()) - bufferOldest) / 1000);
// String length = String.valueOf(bufferSize);
// log.debug("Submitting buffer: " + size + " documents, " + length
// +
// " bytes, " + age + "s");
log.debug("=== Submitting buffer: " + size + " documents");
// Concatenate all documents in the buffer
StringBuffer submissionBuffer = new StringBuffer();
for (String doc : docBuffer.keySet()) {
submissionBuffer.append(docBuffer.get(doc));
// log.debug("DOC: {}", doc);
}
// Submit if the result is valid
if (submissionBuffer.length() > 0) {
// Wrap in the basic Solr 'add' node
String submission = submissionBuffer.insert(0, "<add>")
.append("</add>").toString();
// And submit
try {
solr.request(new DirectXmlRequest("/update", submission));
} catch (Exception ex) {
log.error("Error submitting documents to Solr!", ex);
}
// Commit if required
if (autoCommit || forceCommit) {
log.info("Running forced commit!");
try {
// HTTP commits for embedded
if (commit != null) {
solr.commit();
commit.commit();
// or just HTTP on it's own
} else {
solr.commit();
}
} catch (Exception e) {
log.warn(
"Solr forced commit failed. Document will"
+ " not be visible until Solr autocommit fires."
+ " Error message: {}", e);
}
}
}
}
purgeBuffer();
}
|
[
"private",
"void",
"submitBuffer",
"(",
"boolean",
"forceCommit",
")",
"{",
"int",
"size",
"=",
"docBuffer",
".",
"size",
"(",
")",
";",
"if",
"(",
"size",
">",
"0",
")",
"{",
"// Debugging",
"// String age = String.valueOf(",
"// ((new Date().getTime()) - bufferOldest) / 1000);",
"// String length = String.valueOf(bufferSize);",
"// log.debug(\"Submitting buffer: \" + size + \" documents, \" + length",
"// +",
"// \" bytes, \" + age + \"s\");",
"log",
".",
"debug",
"(",
"\"=== Submitting buffer: \"",
"+",
"size",
"+",
"\" documents\"",
")",
";",
"// Concatenate all documents in the buffer",
"StringBuffer",
"submissionBuffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"String",
"doc",
":",
"docBuffer",
".",
"keySet",
"(",
")",
")",
"{",
"submissionBuffer",
".",
"append",
"(",
"docBuffer",
".",
"get",
"(",
"doc",
")",
")",
";",
"// log.debug(\"DOC: {}\", doc);",
"}",
"// Submit if the result is valid",
"if",
"(",
"submissionBuffer",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"// Wrap in the basic Solr 'add' node",
"String",
"submission",
"=",
"submissionBuffer",
".",
"insert",
"(",
"0",
",",
"\"<add>\"",
")",
".",
"append",
"(",
"\"</add>\"",
")",
".",
"toString",
"(",
")",
";",
"// And submit",
"try",
"{",
"solr",
".",
"request",
"(",
"new",
"DirectXmlRequest",
"(",
"\"/update\"",
",",
"submission",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"log",
".",
"error",
"(",
"\"Error submitting documents to Solr!\"",
",",
"ex",
")",
";",
"}",
"// Commit if required",
"if",
"(",
"autoCommit",
"||",
"forceCommit",
")",
"{",
"log",
".",
"info",
"(",
"\"Running forced commit!\"",
")",
";",
"try",
"{",
"// HTTP commits for embedded",
"if",
"(",
"commit",
"!=",
"null",
")",
"{",
"solr",
".",
"commit",
"(",
")",
";",
"commit",
".",
"commit",
"(",
")",
";",
"// or just HTTP on it's own",
"}",
"else",
"{",
"solr",
".",
"commit",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"warn",
"(",
"\"Solr forced commit failed. Document will\"",
"+",
"\" not be visible until Solr autocommit fires.\"",
"+",
"\" Error message: {}\"",
",",
"e",
")",
";",
"}",
"}",
"}",
"}",
"purgeBuffer",
"(",
")",
";",
"}"
] |
Submit all documents currently in the buffer to Solr, then purge
|
[
"Submit",
"all",
"documents",
"currently",
"in",
"the",
"buffer",
"to",
"Solr",
"then",
"purge"
] |
001159b18b78a87daa5d8b2a17ced28694bae156
|
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrWrapperQueueConsumer.java#L523-L575
|
153,737
|
the-fascinator/plugin-indexer-solr
|
src/main/java/com/googlecode/fascinator/indexer/SolrWrapperQueueConsumer.java
|
SolrWrapperQueueConsumer.setPriority
|
@Override
public void setPriority(int newPriority) {
if (newPriority >= Thread.MIN_PRIORITY
&& newPriority <= Thread.MAX_PRIORITY) {
thread.setPriority(newPriority);
}
}
|
java
|
@Override
public void setPriority(int newPriority) {
if (newPriority >= Thread.MIN_PRIORITY
&& newPriority <= Thread.MAX_PRIORITY) {
thread.setPriority(newPriority);
}
}
|
[
"@",
"Override",
"public",
"void",
"setPriority",
"(",
"int",
"newPriority",
")",
"{",
"if",
"(",
"newPriority",
">=",
"Thread",
".",
"MIN_PRIORITY",
"&&",
"newPriority",
"<=",
"Thread",
".",
"MAX_PRIORITY",
")",
"{",
"thread",
".",
"setPriority",
"(",
"newPriority",
")",
";",
"}",
"}"
] |
Sets the priority level for the thread. Used by the OS.
@param newPriority The priority level to set the thread at
|
[
"Sets",
"the",
"priority",
"level",
"for",
"the",
"thread",
".",
"Used",
"by",
"the",
"OS",
"."
] |
001159b18b78a87daa5d8b2a17ced28694bae156
|
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrWrapperQueueConsumer.java#L593-L599
|
153,738
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.insert
|
public static String insert(String haystack, String needle, int index) {
StringBuffer val = new StringBuffer(haystack);
val.insert(index, needle);
return val.toString();
}
|
java
|
public static String insert(String haystack, String needle, int index) {
StringBuffer val = new StringBuffer(haystack);
val.insert(index, needle);
return val.toString();
}
|
[
"public",
"static",
"String",
"insert",
"(",
"String",
"haystack",
",",
"String",
"needle",
",",
"int",
"index",
")",
"{",
"StringBuffer",
"val",
"=",
"new",
"StringBuffer",
"(",
"haystack",
")",
";",
"val",
".",
"insert",
"(",
"index",
",",
"needle",
")",
";",
"return",
"val",
".",
"toString",
"(",
")",
";",
"}"
] |
replaces the first occurrence of needle in haystack with newNeedle
@param haystack input string
@param needle string to place
@param index position to place
|
[
"replaces",
"the",
"first",
"occurrence",
"of",
"needle",
"in",
"haystack",
"with",
"newNeedle"
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L40-L44
|
153,739
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.replaceFirst
|
public static void replaceFirst(StringBuffer haystack, String needle, String newNeedle) {
int idx = haystack.indexOf(needle);
if (idx != -1) {
haystack.replace(idx, idx + needle.length(), newNeedle);
}
}
|
java
|
public static void replaceFirst(StringBuffer haystack, String needle, String newNeedle) {
int idx = haystack.indexOf(needle);
if (idx != -1) {
haystack.replace(idx, idx + needle.length(), newNeedle);
}
}
|
[
"public",
"static",
"void",
"replaceFirst",
"(",
"StringBuffer",
"haystack",
",",
"String",
"needle",
",",
"String",
"newNeedle",
")",
"{",
"int",
"idx",
"=",
"haystack",
".",
"indexOf",
"(",
"needle",
")",
";",
"if",
"(",
"idx",
"!=",
"-",
"1",
")",
"{",
"haystack",
".",
"replace",
"(",
"idx",
",",
"idx",
"+",
"needle",
".",
"length",
"(",
")",
",",
"newNeedle",
")",
";",
"}",
"}"
] |
replaces the first occurance of needle in haystack with newNeedle
@param haystack input string
@param needle string to replace
@param newNeedle replacement
|
[
"replaces",
"the",
"first",
"occurance",
"of",
"needle",
"in",
"haystack",
"with",
"newNeedle"
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L61-L66
|
153,740
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.replaceLast
|
public static void replaceLast(StringBuffer haystack, String needle, String newNeedle) {
int idx = haystack.lastIndexOf(needle);
if (idx != -1) {
haystack.replace(idx, idx + needle.length(), newNeedle);
}
}
|
java
|
public static void replaceLast(StringBuffer haystack, String needle, String newNeedle) {
int idx = haystack.lastIndexOf(needle);
if (idx != -1) {
haystack.replace(idx, idx + needle.length(), newNeedle);
}
}
|
[
"public",
"static",
"void",
"replaceLast",
"(",
"StringBuffer",
"haystack",
",",
"String",
"needle",
",",
"String",
"newNeedle",
")",
"{",
"int",
"idx",
"=",
"haystack",
".",
"lastIndexOf",
"(",
"needle",
")",
";",
"if",
"(",
"idx",
"!=",
"-",
"1",
")",
"{",
"haystack",
".",
"replace",
"(",
"idx",
",",
"idx",
"+",
"needle",
".",
"length",
"(",
")",
",",
"newNeedle",
")",
";",
"}",
"}"
] |
replaces the last occurance of needle in haystack with newNeedle
@param haystack input string
@param needle string to replace
@param newNeedle replacement
|
[
"replaces",
"the",
"last",
"occurance",
"of",
"needle",
"in",
"haystack",
"with",
"newNeedle"
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L82-L87
|
153,741
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.replaceAll
|
public static String replaceAll(String haystack, String[] needle, String newNeedle[]) {
if (needle.length != newNeedle.length) {
throw new IllegalArgumentException("length of original and replace values do not match (" + needle.length + " != " + newNeedle.length + " )");
}
StringBuffer buf = new StringBuffer(haystack);
for (int i = 0; i < needle.length; i++) {
//TODO not very elegant
replaceAll(buf, needle[i], newNeedle[i]);
}
return buf.toString();
}
|
java
|
public static String replaceAll(String haystack, String[] needle, String newNeedle[]) {
if (needle.length != newNeedle.length) {
throw new IllegalArgumentException("length of original and replace values do not match (" + needle.length + " != " + newNeedle.length + " )");
}
StringBuffer buf = new StringBuffer(haystack);
for (int i = 0; i < needle.length; i++) {
//TODO not very elegant
replaceAll(buf, needle[i], newNeedle[i]);
}
return buf.toString();
}
|
[
"public",
"static",
"String",
"replaceAll",
"(",
"String",
"haystack",
",",
"String",
"[",
"]",
"needle",
",",
"String",
"newNeedle",
"[",
"]",
")",
"{",
"if",
"(",
"needle",
".",
"length",
"!=",
"newNeedle",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"length of original and replace values do not match (\"",
"+",
"needle",
".",
"length",
"+",
"\" != \"",
"+",
"newNeedle",
".",
"length",
"+",
"\" )\"",
")",
";",
"}",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
"haystack",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"needle",
".",
"length",
";",
"i",
"++",
")",
"{",
"//TODO not very elegant",
"replaceAll",
"(",
"buf",
",",
"needle",
"[",
"i",
"]",
",",
"newNeedle",
"[",
"i",
"]",
")",
";",
"}",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] |
Replaces a series of possible occurrences by a series of substitutes.
@param haystack
@param needle
@param newNeedle
@return
|
[
"Replaces",
"a",
"series",
"of",
"possible",
"occurrences",
"by",
"a",
"series",
"of",
"substitutes",
"."
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L120-L131
|
153,742
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.replaceAll
|
public static void replaceAll(StringBuffer haystack, String needle, String newNeedle) {
/* if(needle == null || "".equals(needle))
{
throw new IllegalArgumentException("string to replace may not be empty");
}
int idx = haystack.indexOf(needle);
int needleLength = needle.length();
int newNeedleLength = newNeedle.length();
while (idx != -1)
{
haystack.replace(idx, idx + needleLength, newNeedle);
idx = haystack.indexOf(needle, idx + newNeedleLength);
}*/
replaceAll(haystack, needle, newNeedle, 0);
}
|
java
|
public static void replaceAll(StringBuffer haystack, String needle, String newNeedle) {
/* if(needle == null || "".equals(needle))
{
throw new IllegalArgumentException("string to replace may not be empty");
}
int idx = haystack.indexOf(needle);
int needleLength = needle.length();
int newNeedleLength = newNeedle.length();
while (idx != -1)
{
haystack.replace(idx, idx + needleLength, newNeedle);
idx = haystack.indexOf(needle, idx + newNeedleLength);
}*/
replaceAll(haystack, needle, newNeedle, 0);
}
|
[
"public",
"static",
"void",
"replaceAll",
"(",
"StringBuffer",
"haystack",
",",
"String",
"needle",
",",
"String",
"newNeedle",
")",
"{",
"/*\t\tif(needle == null || \"\".equals(needle))\n\t\t{\n\t\t\tthrow new IllegalArgumentException(\"string to replace may not be empty\");\n\t\t}\n\t\tint idx = haystack.indexOf(needle);\n\t\tint needleLength = needle.length();\n\t\tint newNeedleLength = newNeedle.length();\n\t\twhile (idx != -1)\n\t\t{\n\t\t\thaystack.replace(idx, idx + needleLength, newNeedle);\n\t\t\tidx = haystack.indexOf(needle, idx + newNeedleLength);\n\t\t}*/",
"replaceAll",
"(",
"haystack",
",",
"needle",
",",
"newNeedle",
",",
"0",
")",
";",
"}"
] |
replaces all occurrences of needle in haystack with newNeedle
the input itself is not modified
@param haystack input string
@param needle string to replace
@param newNeedle replacement
|
[
"replaces",
"all",
"occurrences",
"of",
"needle",
"in",
"haystack",
"with",
"newNeedle",
"the",
"input",
"itself",
"is",
"not",
"modified"
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L141-L155
|
153,743
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.replaceAll
|
public static void replaceAll(StringBuffer haystack, String needle, String newNeedle, int interval) {
if (needle == null) {
throw new IllegalArgumentException("string to replace can not be empty");
}
int idx = haystack.indexOf(needle);
int nextIdx = -1;
int processedChunkSize = idx;
int needleLength = needle.length();
int newNeedleLength = newNeedle.length();
while (idx != -1/* && idx < haystack.length()*/) {
if (processedChunkSize >= interval) {
haystack.replace(idx, idx + needleLength, newNeedle);
nextIdx = haystack.indexOf(needle, idx + newNeedleLength);
processedChunkSize = nextIdx - idx;//length of replacement is not included
idx = nextIdx;
}
else {
nextIdx = haystack.indexOf(needle, idx + newNeedleLength);
processedChunkSize += nextIdx - idx;
idx = nextIdx;
if (newNeedleLength == 0) {
return;
}
}
}
}
|
java
|
public static void replaceAll(StringBuffer haystack, String needle, String newNeedle, int interval) {
if (needle == null) {
throw new IllegalArgumentException("string to replace can not be empty");
}
int idx = haystack.indexOf(needle);
int nextIdx = -1;
int processedChunkSize = idx;
int needleLength = needle.length();
int newNeedleLength = newNeedle.length();
while (idx != -1/* && idx < haystack.length()*/) {
if (processedChunkSize >= interval) {
haystack.replace(idx, idx + needleLength, newNeedle);
nextIdx = haystack.indexOf(needle, idx + newNeedleLength);
processedChunkSize = nextIdx - idx;//length of replacement is not included
idx = nextIdx;
}
else {
nextIdx = haystack.indexOf(needle, idx + newNeedleLength);
processedChunkSize += nextIdx - idx;
idx = nextIdx;
if (newNeedleLength == 0) {
return;
}
}
}
}
|
[
"public",
"static",
"void",
"replaceAll",
"(",
"StringBuffer",
"haystack",
",",
"String",
"needle",
",",
"String",
"newNeedle",
",",
"int",
"interval",
")",
"{",
"if",
"(",
"needle",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"string to replace can not be empty\"",
")",
";",
"}",
"int",
"idx",
"=",
"haystack",
".",
"indexOf",
"(",
"needle",
")",
";",
"int",
"nextIdx",
"=",
"-",
"1",
";",
"int",
"processedChunkSize",
"=",
"idx",
";",
"int",
"needleLength",
"=",
"needle",
".",
"length",
"(",
")",
";",
"int",
"newNeedleLength",
"=",
"newNeedle",
".",
"length",
"(",
")",
";",
"while",
"(",
"idx",
"!=",
"-",
"1",
"/* && idx < haystack.length()*/",
")",
"{",
"if",
"(",
"processedChunkSize",
">=",
"interval",
")",
"{",
"haystack",
".",
"replace",
"(",
"idx",
",",
"idx",
"+",
"needleLength",
",",
"newNeedle",
")",
";",
"nextIdx",
"=",
"haystack",
".",
"indexOf",
"(",
"needle",
",",
"idx",
"+",
"newNeedleLength",
")",
";",
"processedChunkSize",
"=",
"nextIdx",
"-",
"idx",
";",
"//length of replacement is not included",
"idx",
"=",
"nextIdx",
";",
"}",
"else",
"{",
"nextIdx",
"=",
"haystack",
".",
"indexOf",
"(",
"needle",
",",
"idx",
"+",
"newNeedleLength",
")",
";",
"processedChunkSize",
"+=",
"nextIdx",
"-",
"idx",
";",
"idx",
"=",
"nextIdx",
";",
"if",
"(",
"newNeedleLength",
"==",
"0",
")",
"{",
"return",
";",
"}",
"}",
"}",
"}"
] |
default is 0, which means that all found characters must be replaced
|
[
"default",
"is",
"0",
"which",
"means",
"that",
"all",
"found",
"characters",
"must",
"be",
"replaced"
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L159-L184
|
153,744
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.removeAll
|
public static String removeAll(String haystack, String ... needles) {
return replaceAll(haystack, needles, ArraySupport.getFilledArray(new String[needles.length], ""));
}
|
java
|
public static String removeAll(String haystack, String ... needles) {
return replaceAll(haystack, needles, ArraySupport.getFilledArray(new String[needles.length], ""));
}
|
[
"public",
"static",
"String",
"removeAll",
"(",
"String",
"haystack",
",",
"String",
"...",
"needles",
")",
"{",
"return",
"replaceAll",
"(",
"haystack",
",",
"needles",
",",
"ArraySupport",
".",
"getFilledArray",
"(",
"new",
"String",
"[",
"needles",
".",
"length",
"]",
",",
"\"\"",
")",
")",
";",
"}"
] |
removes all occurrences of needle in haystack
@param haystack input string
@param needles strings to remove
|
[
"removes",
"all",
"occurrences",
"of",
"needle",
"in",
"haystack"
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L250-L252
|
153,745
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.esc
|
public static String esc(String in) {
if (in == null) {
return null;
}
StringBuffer val = new StringBuffer(in);
esc(val);
return val.toString();
}
|
java
|
public static String esc(String in) {
if (in == null) {
return null;
}
StringBuffer val = new StringBuffer(in);
esc(val);
return val.toString();
}
|
[
"public",
"static",
"String",
"esc",
"(",
"String",
"in",
")",
"{",
"if",
"(",
"in",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"StringBuffer",
"val",
"=",
"new",
"StringBuffer",
"(",
"in",
")",
";",
"esc",
"(",
"val",
")",
";",
"return",
"val",
".",
"toString",
"(",
")",
";",
"}"
] |
Escapes quotes, double quotes, ecape characters and end-of-line characters in strings.
@param in input string
@return escaped string
|
[
"Escapes",
"quotes",
"double",
"quotes",
"ecape",
"characters",
"and",
"end",
"-",
"of",
"-",
"line",
"characters",
"in",
"strings",
"."
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L315-L322
|
153,746
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.esc
|
public static void esc(StringBuffer in) {
if (in == null) {
return;
}
replaceAll(in, "\\", "\\\\");
replaceAll(in, "'", "\\'");
replaceAll(in, "\"", "\\\"");
replaceAll(in, "\n", "\\n");
replaceAll(in, "\r", "\\r");
}
|
java
|
public static void esc(StringBuffer in) {
if (in == null) {
return;
}
replaceAll(in, "\\", "\\\\");
replaceAll(in, "'", "\\'");
replaceAll(in, "\"", "\\\"");
replaceAll(in, "\n", "\\n");
replaceAll(in, "\r", "\\r");
}
|
[
"public",
"static",
"void",
"esc",
"(",
"StringBuffer",
"in",
")",
"{",
"if",
"(",
"in",
"==",
"null",
")",
"{",
"return",
";",
"}",
"replaceAll",
"(",
"in",
",",
"\"\\\\\"",
",",
"\"\\\\\\\\\"",
")",
";",
"replaceAll",
"(",
"in",
",",
"\"'\"",
",",
"\"\\\\'\"",
")",
";",
"replaceAll",
"(",
"in",
",",
"\"\\\"\"",
",",
"\"\\\\\\\"\"",
")",
";",
"replaceAll",
"(",
"in",
",",
"\"\\n\"",
",",
"\"\\\\n\"",
")",
";",
"replaceAll",
"(",
"in",
",",
"\"\\r\"",
",",
"\"\\\\r\"",
")",
";",
"}"
] |
Escapes quotes, double quotes, ecape characters and end-of-line characters in strings
@param in input string
@return escaped string
|
[
"Escapes",
"quotes",
"double",
"quotes",
"ecape",
"characters",
"and",
"end",
"-",
"of",
"-",
"line",
"characters",
"in",
"strings"
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L330-L339
|
153,747
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.isNumeric
|
public static boolean isNumeric(String in) {
char c = 0;
for (int i = in.length(); i > 0; i--) {
c = in.charAt(i - 1);
if (!Character.isDigit(c)) {
return false;
}
}
return true;
}
|
java
|
public static boolean isNumeric(String in) {
char c = 0;
for (int i = in.length(); i > 0; i--) {
c = in.charAt(i - 1);
if (!Character.isDigit(c)) {
return false;
}
}
return true;
}
|
[
"public",
"static",
"boolean",
"isNumeric",
"(",
"String",
"in",
")",
"{",
"char",
"c",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"in",
".",
"length",
"(",
")",
";",
"i",
">",
"0",
";",
"i",
"--",
")",
"{",
"c",
"=",
"in",
".",
"charAt",
"(",
"i",
"-",
"1",
")",
";",
"if",
"(",
"!",
"Character",
".",
"isDigit",
"(",
"c",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
tells whether all characters in a String are digits
@param in String to evaluate
|
[
"tells",
"whether",
"all",
"characters",
"in",
"a",
"String",
"are",
"digits"
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L347-L356
|
153,748
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.isAlpha
|
public static boolean isAlpha(String in) {
char c = 0;
for (int i = in.length(); i > 0; i--) {
c = in.charAt(i - 1);
if (!Character.isLetter(c)) {
return false;
}
}
return true;
}
|
java
|
public static boolean isAlpha(String in) {
char c = 0;
for (int i = in.length(); i > 0; i--) {
c = in.charAt(i - 1);
if (!Character.isLetter(c)) {
return false;
}
}
return true;
}
|
[
"public",
"static",
"boolean",
"isAlpha",
"(",
"String",
"in",
")",
"{",
"char",
"c",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"in",
".",
"length",
"(",
")",
";",
"i",
">",
"0",
";",
"i",
"--",
")",
"{",
"c",
"=",
"in",
".",
"charAt",
"(",
"i",
"-",
"1",
")",
";",
"if",
"(",
"!",
"Character",
".",
"isLetter",
"(",
"c",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
tells whether all characters in a String are letters
@param in String to evaluate
|
[
"tells",
"whether",
"all",
"characters",
"in",
"a",
"String",
"are",
"letters"
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L363-L372
|
153,749
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.isAlphaNumeric
|
public static boolean isAlphaNumeric(String in) {
char c = 0;
for (int i = in.length(); i > 0; i--) {
c = in.charAt(i - 1);
if (!Character.isLetterOrDigit(c)) {
return false;
}
}
return true;
}
|
java
|
public static boolean isAlphaNumeric(String in) {
char c = 0;
for (int i = in.length(); i > 0; i--) {
c = in.charAt(i - 1);
if (!Character.isLetterOrDigit(c)) {
return false;
}
}
return true;
}
|
[
"public",
"static",
"boolean",
"isAlphaNumeric",
"(",
"String",
"in",
")",
"{",
"char",
"c",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"in",
".",
"length",
"(",
")",
";",
"i",
">",
"0",
";",
"i",
"--",
")",
"{",
"c",
"=",
"in",
".",
"charAt",
"(",
"i",
"-",
"1",
")",
";",
"if",
"(",
"!",
"Character",
".",
"isLetterOrDigit",
"(",
"c",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
tells whether all characters in a String are digits or letters
@param in String to evaluate
|
[
"tells",
"whether",
"all",
"characters",
"in",
"a",
"String",
"are",
"digits",
"or",
"letters"
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L379-L388
|
153,750
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.isAlphaNumericOrContainsOnlyCharacters
|
public static boolean isAlphaNumericOrContainsOnlyCharacters(String in, String chars) {
char c = 0;
for (int i = 0; i < in.length(); i++) {
c = in.charAt(i);
if (Character.isLetterOrDigit(c) == (chars.indexOf(c) != -1)) {
return false;
}
}
return true;
}
|
java
|
public static boolean isAlphaNumericOrContainsOnlyCharacters(String in, String chars) {
char c = 0;
for (int i = 0; i < in.length(); i++) {
c = in.charAt(i);
if (Character.isLetterOrDigit(c) == (chars.indexOf(c) != -1)) {
return false;
}
}
return true;
}
|
[
"public",
"static",
"boolean",
"isAlphaNumericOrContainsOnlyCharacters",
"(",
"String",
"in",
",",
"String",
"chars",
")",
"{",
"char",
"c",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"in",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"c",
"=",
"in",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"Character",
".",
"isLetterOrDigit",
"(",
"c",
")",
"==",
"(",
"chars",
".",
"indexOf",
"(",
"c",
")",
"!=",
"-",
"1",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
tells whether all characters in a String are letters or digits or part of a given String
@param in String to evaluate
@param chars characters which are allowed in the given String
|
[
"tells",
"whether",
"all",
"characters",
"in",
"a",
"String",
"are",
"letters",
"or",
"digits",
"or",
"part",
"of",
"a",
"given",
"String"
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L397-L406
|
153,751
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.containsCharacters
|
public static boolean containsCharacters(String in, String chars) {
for (int i = 0; i < chars.length(); i++) {
if (in.indexOf(chars.charAt(i)) != -1) {
return true;
}
}
return false;
}
|
java
|
public static boolean containsCharacters(String in, String chars) {
for (int i = 0; i < chars.length(); i++) {
if (in.indexOf(chars.charAt(i)) != -1) {
return true;
}
}
return false;
}
|
[
"public",
"static",
"boolean",
"containsCharacters",
"(",
"String",
"in",
",",
"String",
"chars",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"chars",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"in",
".",
"indexOf",
"(",
"chars",
".",
"charAt",
"(",
"i",
")",
")",
"!=",
"-",
"1",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
tells whether one or more characters in a String are part of a given String
@param in String to evaluate
@param chars characters which are to be tested in the given String
|
[
"tells",
"whether",
"one",
"or",
"more",
"characters",
"in",
"a",
"String",
"are",
"part",
"of",
"a",
"given",
"String"
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L415-L422
|
153,752
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.absorbInputStream
|
public static String absorbInputStream(InputStream input) throws IOException {
byte[] bytes = StreamSupport.absorbInputStream(input);
return new String(bytes);
}
|
java
|
public static String absorbInputStream(InputStream input) throws IOException {
byte[] bytes = StreamSupport.absorbInputStream(input);
return new String(bytes);
}
|
[
"public",
"static",
"String",
"absorbInputStream",
"(",
"InputStream",
"input",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"StreamSupport",
".",
"absorbInputStream",
"(",
"input",
")",
";",
"return",
"new",
"String",
"(",
"bytes",
")",
";",
"}"
] |
keep reading until the InputStream is exhausted
@param input
@return a resulting String
|
[
"keep",
"reading",
"until",
"the",
"InputStream",
"is",
"exhausted"
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L447-L450
|
153,753
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.split
|
public static List<String> split(String input, String punctuationChars, boolean sort, boolean convertToLowerCase, boolean distinct) {
return split(input, punctuationChars, "\"", sort, convertToLowerCase, distinct);
}
|
java
|
public static List<String> split(String input, String punctuationChars, boolean sort, boolean convertToLowerCase, boolean distinct) {
return split(input, punctuationChars, "\"", sort, convertToLowerCase, distinct);
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"split",
"(",
"String",
"input",
",",
"String",
"punctuationChars",
",",
"boolean",
"sort",
",",
"boolean",
"convertToLowerCase",
",",
"boolean",
"distinct",
")",
"{",
"return",
"split",
"(",
"input",
",",
"punctuationChars",
",",
"\"\\\"\"",
",",
"sort",
",",
"convertToLowerCase",
",",
"distinct",
")",
";",
"}"
] |
reads all words in a text
@param input
@param punctuationChars characters that can not belong to words and are therefore separators
@param sort whether to sort the result alphabetically. (If the result is sorted, setting the distinct flag to false has no effect)
@param convertToLowerCase whether to convert all found words to lowercase
@param distinct true if a certain word may occur only once in the resulting collection
@return a collection of extracted words
|
[
"reads",
"all",
"words",
"in",
"a",
"text"
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L568-L570
|
153,754
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.trim
|
public static String trim(String input, int maxNrofChars, String end) {
if (end == null) {
end = "";
}
int margin = end.length();
if (input != null && input.length() > maxNrofChars + margin) {
input = input.substring(0, maxNrofChars) + end;
}
return input;
}
|
java
|
public static String trim(String input, int maxNrofChars, String end) {
if (end == null) {
end = "";
}
int margin = end.length();
if (input != null && input.length() > maxNrofChars + margin) {
input = input.substring(0, maxNrofChars) + end;
}
return input;
}
|
[
"public",
"static",
"String",
"trim",
"(",
"String",
"input",
",",
"int",
"maxNrofChars",
",",
"String",
"end",
")",
"{",
"if",
"(",
"end",
"==",
"null",
")",
"{",
"end",
"=",
"\"\"",
";",
"}",
"int",
"margin",
"=",
"end",
".",
"length",
"(",
")",
";",
"if",
"(",
"input",
"!=",
"null",
"&&",
"input",
".",
"length",
"(",
")",
">",
"maxNrofChars",
"+",
"margin",
")",
"{",
"input",
"=",
"input",
".",
"substring",
"(",
"0",
",",
"maxNrofChars",
")",
"+",
"end",
";",
"}",
"return",
"input",
";",
"}"
] |
Trims strings that contain too many characters and adds trailing characters
to indicate that the original string has been trimmed.
@param input
@param maxNrofChars maximum allowed length of input
@param end trailing characters when trimmed
@return original string or trimmed version
|
[
"Trims",
"strings",
"that",
"contain",
"too",
"many",
"characters",
"and",
"adds",
"trailing",
"characters",
"to",
"indicate",
"that",
"the",
"original",
"string",
"has",
"been",
"trimmed",
"."
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L1000-L1009
|
153,755
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java
|
StringSupport.createCharArray
|
public static char[] createCharArray(int size, char defaultVal) {
char[] retval = new char[size];
if (size > 0) {
if (size < 500) {
for (int i = 0; i < size; i++) {
retval[i] = defaultVal;
}
}
else {
initializelLargeCharArray(retval, defaultVal);
}
}
return retval;
}
|
java
|
public static char[] createCharArray(int size, char defaultVal) {
char[] retval = new char[size];
if (size > 0) {
if (size < 500) {
for (int i = 0; i < size; i++) {
retval[i] = defaultVal;
}
}
else {
initializelLargeCharArray(retval, defaultVal);
}
}
return retval;
}
|
[
"public",
"static",
"char",
"[",
"]",
"createCharArray",
"(",
"int",
"size",
",",
"char",
"defaultVal",
")",
"{",
"char",
"[",
"]",
"retval",
"=",
"new",
"char",
"[",
"size",
"]",
";",
"if",
"(",
"size",
">",
"0",
")",
"{",
"if",
"(",
"size",
"<",
"500",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"retval",
"[",
"i",
"]",
"=",
"defaultVal",
";",
"}",
"}",
"else",
"{",
"initializelLargeCharArray",
"(",
"retval",
",",
"defaultVal",
")",
";",
"}",
"}",
"return",
"retval",
";",
"}"
] |
Creates a character array and initializes it with a default value.
@param size
@param defaultVal
@return
|
[
"Creates",
"a",
"character",
"array",
"and",
"initializes",
"it",
"with",
"a",
"default",
"value",
"."
] |
971eb022115247b1e34dc26dd02e7e621e29e910
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L1020-L1033
|
153,756
|
tvesalainen/util
|
security/src/main/java/org/vesalainen/security/cert/X509Generator.java
|
X509Generator.generateSelfSignedCertificate
|
public X509Certificate generateSelfSignedCertificate(String subjectDN, KeyPair pair, int days, String algorithm) throws CertificateException
{
return generateCertificate(subjectDN, null, pair, null, days, algorithm);
}
|
java
|
public X509Certificate generateSelfSignedCertificate(String subjectDN, KeyPair pair, int days, String algorithm) throws CertificateException
{
return generateCertificate(subjectDN, null, pair, null, days, algorithm);
}
|
[
"public",
"X509Certificate",
"generateSelfSignedCertificate",
"(",
"String",
"subjectDN",
",",
"KeyPair",
"pair",
",",
"int",
"days",
",",
"String",
"algorithm",
")",
"throws",
"CertificateException",
"{",
"return",
"generateCertificate",
"(",
"subjectDN",
",",
"null",
",",
"pair",
",",
"null",
",",
"days",
",",
"algorithm",
")",
";",
"}"
] |
Create a self-signed X.509 Certificate
@param subjectDN the X.509 Distinguished Name, eg "CN=Test, L=London, C=GB"
@param pair the KeyPair
@param days how many days from now the Certificate is valid for
@param algorithm the signing algorithm, e.g. "SHA1withRSA"
@return
@throws java.security.cert.CertificateException
|
[
"Create",
"a",
"self",
"-",
"signed",
"X",
".",
"509",
"Certificate"
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/security/src/main/java/org/vesalainen/security/cert/X509Generator.java#L58-L61
|
153,757
|
tvesalainen/util
|
security/src/main/java/org/vesalainen/security/cert/X509Generator.java
|
X509Generator.generateCertificate
|
public X509Certificate generateCertificate(String subjectDN, String issuerDN, KeyPair pair, PrivateKey privkey, int days, String signingAlgorithm) throws CertificateException
{
if (privkey == null)
{
privkey = pair.getPrivate();
}
X500Name issuer;
if (issuerDN == null)
{
issuer = new X500Name(RFC4519Style.INSTANCE, subjectDN);
}
else
{
issuer = new X500Name(RFC4519Style.INSTANCE, issuerDN);
}
long now = System.currentTimeMillis();
BigInteger serial = BigInteger.probablePrime(64, new SecureRandom(Primitives.writeLong(now)));
X500Name subject = new X500Name(RFC4519Style.INSTANCE, subjectDN);
PublicKey publicKey = pair.getPublic();
byte[] encoded = publicKey.getEncoded();
SubjectPublicKeyInfo subjectPublicKeyInfo = SubjectPublicKeyInfo.getInstance(encoded);
X509v3CertificateBuilder builder = new X509v3CertificateBuilder(
issuer,
serial,
new Date(now - 86400000l),
new Date(now + days * 86400000l),
subject,
subjectPublicKeyInfo
);
X509CertificateHolder holder = builder.build(createSigner(privkey, signingAlgorithm));
return new JcaX509CertificateConverter().getCertificate(holder);
}
|
java
|
public X509Certificate generateCertificate(String subjectDN, String issuerDN, KeyPair pair, PrivateKey privkey, int days, String signingAlgorithm) throws CertificateException
{
if (privkey == null)
{
privkey = pair.getPrivate();
}
X500Name issuer;
if (issuerDN == null)
{
issuer = new X500Name(RFC4519Style.INSTANCE, subjectDN);
}
else
{
issuer = new X500Name(RFC4519Style.INSTANCE, issuerDN);
}
long now = System.currentTimeMillis();
BigInteger serial = BigInteger.probablePrime(64, new SecureRandom(Primitives.writeLong(now)));
X500Name subject = new X500Name(RFC4519Style.INSTANCE, subjectDN);
PublicKey publicKey = pair.getPublic();
byte[] encoded = publicKey.getEncoded();
SubjectPublicKeyInfo subjectPublicKeyInfo = SubjectPublicKeyInfo.getInstance(encoded);
X509v3CertificateBuilder builder = new X509v3CertificateBuilder(
issuer,
serial,
new Date(now - 86400000l),
new Date(now + days * 86400000l),
subject,
subjectPublicKeyInfo
);
X509CertificateHolder holder = builder.build(createSigner(privkey, signingAlgorithm));
return new JcaX509CertificateConverter().getCertificate(holder);
}
|
[
"public",
"X509Certificate",
"generateCertificate",
"(",
"String",
"subjectDN",
",",
"String",
"issuerDN",
",",
"KeyPair",
"pair",
",",
"PrivateKey",
"privkey",
",",
"int",
"days",
",",
"String",
"signingAlgorithm",
")",
"throws",
"CertificateException",
"{",
"if",
"(",
"privkey",
"==",
"null",
")",
"{",
"privkey",
"=",
"pair",
".",
"getPrivate",
"(",
")",
";",
"}",
"X500Name",
"issuer",
";",
"if",
"(",
"issuerDN",
"==",
"null",
")",
"{",
"issuer",
"=",
"new",
"X500Name",
"(",
"RFC4519Style",
".",
"INSTANCE",
",",
"subjectDN",
")",
";",
"}",
"else",
"{",
"issuer",
"=",
"new",
"X500Name",
"(",
"RFC4519Style",
".",
"INSTANCE",
",",
"issuerDN",
")",
";",
"}",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"BigInteger",
"serial",
"=",
"BigInteger",
".",
"probablePrime",
"(",
"64",
",",
"new",
"SecureRandom",
"(",
"Primitives",
".",
"writeLong",
"(",
"now",
")",
")",
")",
";",
"X500Name",
"subject",
"=",
"new",
"X500Name",
"(",
"RFC4519Style",
".",
"INSTANCE",
",",
"subjectDN",
")",
";",
"PublicKey",
"publicKey",
"=",
"pair",
".",
"getPublic",
"(",
")",
";",
"byte",
"[",
"]",
"encoded",
"=",
"publicKey",
".",
"getEncoded",
"(",
")",
";",
"SubjectPublicKeyInfo",
"subjectPublicKeyInfo",
"=",
"SubjectPublicKeyInfo",
".",
"getInstance",
"(",
"encoded",
")",
";",
"X509v3CertificateBuilder",
"builder",
"=",
"new",
"X509v3CertificateBuilder",
"(",
"issuer",
",",
"serial",
",",
"new",
"Date",
"(",
"now",
"-",
"86400000l",
")",
",",
"new",
"Date",
"(",
"now",
"+",
"days",
"*",
"86400000l",
")",
",",
"subject",
",",
"subjectPublicKeyInfo",
")",
";",
"X509CertificateHolder",
"holder",
"=",
"builder",
".",
"build",
"(",
"createSigner",
"(",
"privkey",
",",
"signingAlgorithm",
")",
")",
";",
"return",
"new",
"JcaX509CertificateConverter",
"(",
")",
".",
"getCertificate",
"(",
"holder",
")",
";",
"}"
] |
Create a signed X.509 Certificate
@param subjectDN the X.509 Distinguished Name, eg "CN=Test, L=London, C=GB"
@param issuerDN Signers X.509 Distinguished Name, eg "CN=Test, L=London, C=GB"
@param pair the KeyPair
@param privkey Signers private key
@param days how many days from now the Certificate is valid for
@param signingAlgorithm the signing algorithm, e.g. "SHA1withRSA"
@return
@throws java.security.cert.CertificateException
|
[
"Create",
"a",
"signed",
"X",
".",
"509",
"Certificate"
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/security/src/main/java/org/vesalainen/security/cert/X509Generator.java#L73-L104
|
153,758
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/code/TransactionalSetter.java
|
TransactionalSetter.getInstance
|
public static <T extends TransactionalSetter> T getInstance(Class<T> cls, Object intf)
{
Class<?>[] interfaces = cls.getInterfaces();
if (interfaces.length != 1)
{
throw new IllegalArgumentException(cls+" should implement exactly one interface");
}
boolean ok = false;
if (!interfaces[0].isAssignableFrom(intf.getClass()))
{
throw new IllegalArgumentException(cls+" doesn't implement "+intf);
}
try
{
TransactionalSetterClass annotation = cls.getAnnotation(TransactionalSetterClass.class);
if (annotation == null)
{
throw new IllegalArgumentException("@"+TransactionalSetterClass.class.getSimpleName()+" missing in cls");
}
Class<?> c = Class.forName(annotation.value());
T t =(T) c.newInstance();
t.intf = intf;
return t;
}
catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex)
{
throw new IllegalArgumentException(ex);
}
}
|
java
|
public static <T extends TransactionalSetter> T getInstance(Class<T> cls, Object intf)
{
Class<?>[] interfaces = cls.getInterfaces();
if (interfaces.length != 1)
{
throw new IllegalArgumentException(cls+" should implement exactly one interface");
}
boolean ok = false;
if (!interfaces[0].isAssignableFrom(intf.getClass()))
{
throw new IllegalArgumentException(cls+" doesn't implement "+intf);
}
try
{
TransactionalSetterClass annotation = cls.getAnnotation(TransactionalSetterClass.class);
if (annotation == null)
{
throw new IllegalArgumentException("@"+TransactionalSetterClass.class.getSimpleName()+" missing in cls");
}
Class<?> c = Class.forName(annotation.value());
T t =(T) c.newInstance();
t.intf = intf;
return t;
}
catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex)
{
throw new IllegalArgumentException(ex);
}
}
|
[
"public",
"static",
"<",
"T",
"extends",
"TransactionalSetter",
">",
"T",
"getInstance",
"(",
"Class",
"<",
"T",
">",
"cls",
",",
"Object",
"intf",
")",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"interfaces",
"=",
"cls",
".",
"getInterfaces",
"(",
")",
";",
"if",
"(",
"interfaces",
".",
"length",
"!=",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"cls",
"+",
"\" should implement exactly one interface\"",
")",
";",
"}",
"boolean",
"ok",
"=",
"false",
";",
"if",
"(",
"!",
"interfaces",
"[",
"0",
"]",
".",
"isAssignableFrom",
"(",
"intf",
".",
"getClass",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"cls",
"+",
"\" doesn't implement \"",
"+",
"intf",
")",
";",
"}",
"try",
"{",
"TransactionalSetterClass",
"annotation",
"=",
"cls",
".",
"getAnnotation",
"(",
"TransactionalSetterClass",
".",
"class",
")",
";",
"if",
"(",
"annotation",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"@\"",
"+",
"TransactionalSetterClass",
".",
"class",
".",
"getSimpleName",
"(",
")",
"+",
"\" missing in cls\"",
")",
";",
"}",
"Class",
"<",
"?",
">",
"c",
"=",
"Class",
".",
"forName",
"(",
"annotation",
".",
"value",
"(",
")",
")",
";",
"T",
"t",
"=",
"(",
"T",
")",
"c",
".",
"newInstance",
"(",
")",
";",
"t",
".",
"intf",
"=",
"intf",
";",
"return",
"t",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"|",
"InstantiationException",
"|",
"IllegalAccessException",
"ex",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"ex",
")",
";",
"}",
"}"
] |
Creates a instance of a class TransactionalSetter subclass.
@param <T> Type of TransactionalSetter subclass
@param cls TransactionalSetter subclass class
@param intf Interface implemented by TransactionalSetter subclass
@return
|
[
"Creates",
"a",
"instance",
"of",
"a",
"class",
"TransactionalSetter",
"subclass",
"."
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/code/TransactionalSetter.java#L75-L103
|
153,759
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.init
|
public void init(Object env, Map<String,Object> properties, Object applet)
{
if (properties == null)
properties = new Hashtable<String,Object>();
if (m_properties == null)
m_properties = properties;
else
m_properties.putAll(properties);
m_mapTasks = new HashMap<Task,RemoteTask>();
if (applet != null)
m_sApplet = applet;
try {
Class.forName("javax.jnlp.PersistenceService"); // Test if this exists
this.setMuffinManager(new MuffinManager(this));
if (this.getMuffinManager().isServiceAvailable())
if ((this.getProperty(Params.REMOTE_HOST) == null) || (this.getProperty(Params.REMOTE_HOST).length() == 0))
this.setProperty(Params.REMOTE_HOST, this.getAppServerName());
} catch (Exception ex) { // Test for JNLP
}
String strUser = this.getProperty(Params.USER_ID);
if (strUser == null) // if (strUser.length() == 0) then you don't want the current sys username
if (this.getProperty(Params.USER_NAME) == null)
if (this.getMuffinManager() != null)
{
strUser = this.getMuffinManager().getMuffin(Params.USER_ID);
this.setProperty(Params.USER_ID, strUser); // User name is required
}
if (strUser == null) // if (strUser.length() == 0) then you don't want the current sys username
if (this.getProperty(Params.USER_NAME) == null)
{
try {
strUser = System.getProperties().getProperty("user.name");
this.setProperty(Params.USER_NAME, strUser); // User name is required
} catch (java.security.AccessControlException ex) {
// Ignore this, I'm probably running in an Applet
}
}
try { // Since I send this over the wire, make sure I'm using the default dom implementation
System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
} catch (Exception e) { // Ignore this error
}
if (Util.getPortableImageUtil() == null)
{
PortableImageUtil portableImageUtil = null;
try {
Class.forName("javax.swing.ImageIcon"); // Test if swing exists
portableImageUtil = (PortableImageUtil)ClassServiceUtility.getClassService().makeObjectFromClassName(SWING_IMAGE_UTIL);
} catch (Exception ex) { // Android
portableImageUtil = (PortableImageUtil)ClassServiceUtility.getClassService().makeObjectFromClassName(ANDROID_IMAGE_UTIL);
}
if (portableImageUtil == null) // Sometime OSGi has a hard time finding javax
portableImageUtil = (PortableImageUtil)ClassServiceUtility.getClassService().makeObjectFromClassName(SWING_IMAGE_UTIL);
Util.setPortableImageUtil(portableImageUtil);
}
}
|
java
|
public void init(Object env, Map<String,Object> properties, Object applet)
{
if (properties == null)
properties = new Hashtable<String,Object>();
if (m_properties == null)
m_properties = properties;
else
m_properties.putAll(properties);
m_mapTasks = new HashMap<Task,RemoteTask>();
if (applet != null)
m_sApplet = applet;
try {
Class.forName("javax.jnlp.PersistenceService"); // Test if this exists
this.setMuffinManager(new MuffinManager(this));
if (this.getMuffinManager().isServiceAvailable())
if ((this.getProperty(Params.REMOTE_HOST) == null) || (this.getProperty(Params.REMOTE_HOST).length() == 0))
this.setProperty(Params.REMOTE_HOST, this.getAppServerName());
} catch (Exception ex) { // Test for JNLP
}
String strUser = this.getProperty(Params.USER_ID);
if (strUser == null) // if (strUser.length() == 0) then you don't want the current sys username
if (this.getProperty(Params.USER_NAME) == null)
if (this.getMuffinManager() != null)
{
strUser = this.getMuffinManager().getMuffin(Params.USER_ID);
this.setProperty(Params.USER_ID, strUser); // User name is required
}
if (strUser == null) // if (strUser.length() == 0) then you don't want the current sys username
if (this.getProperty(Params.USER_NAME) == null)
{
try {
strUser = System.getProperties().getProperty("user.name");
this.setProperty(Params.USER_NAME, strUser); // User name is required
} catch (java.security.AccessControlException ex) {
// Ignore this, I'm probably running in an Applet
}
}
try { // Since I send this over the wire, make sure I'm using the default dom implementation
System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
} catch (Exception e) { // Ignore this error
}
if (Util.getPortableImageUtil() == null)
{
PortableImageUtil portableImageUtil = null;
try {
Class.forName("javax.swing.ImageIcon"); // Test if swing exists
portableImageUtil = (PortableImageUtil)ClassServiceUtility.getClassService().makeObjectFromClassName(SWING_IMAGE_UTIL);
} catch (Exception ex) { // Android
portableImageUtil = (PortableImageUtil)ClassServiceUtility.getClassService().makeObjectFromClassName(ANDROID_IMAGE_UTIL);
}
if (portableImageUtil == null) // Sometime OSGi has a hard time finding javax
portableImageUtil = (PortableImageUtil)ClassServiceUtility.getClassService().makeObjectFromClassName(SWING_IMAGE_UTIL);
Util.setPortableImageUtil(portableImageUtil);
}
}
|
[
"public",
"void",
"init",
"(",
"Object",
"env",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
",",
"Object",
"applet",
")",
"{",
"if",
"(",
"properties",
"==",
"null",
")",
"properties",
"=",
"new",
"Hashtable",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"if",
"(",
"m_properties",
"==",
"null",
")",
"m_properties",
"=",
"properties",
";",
"else",
"m_properties",
".",
"putAll",
"(",
"properties",
")",
";",
"m_mapTasks",
"=",
"new",
"HashMap",
"<",
"Task",
",",
"RemoteTask",
">",
"(",
")",
";",
"if",
"(",
"applet",
"!=",
"null",
")",
"m_sApplet",
"=",
"applet",
";",
"try",
"{",
"Class",
".",
"forName",
"(",
"\"javax.jnlp.PersistenceService\"",
")",
";",
"// Test if this exists",
"this",
".",
"setMuffinManager",
"(",
"new",
"MuffinManager",
"(",
"this",
")",
")",
";",
"if",
"(",
"this",
".",
"getMuffinManager",
"(",
")",
".",
"isServiceAvailable",
"(",
")",
")",
"if",
"(",
"(",
"this",
".",
"getProperty",
"(",
"Params",
".",
"REMOTE_HOST",
")",
"==",
"null",
")",
"||",
"(",
"this",
".",
"getProperty",
"(",
"Params",
".",
"REMOTE_HOST",
")",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"this",
".",
"setProperty",
"(",
"Params",
".",
"REMOTE_HOST",
",",
"this",
".",
"getAppServerName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"// Test for JNLP",
"}",
"String",
"strUser",
"=",
"this",
".",
"getProperty",
"(",
"Params",
".",
"USER_ID",
")",
";",
"if",
"(",
"strUser",
"==",
"null",
")",
"// if (strUser.length() == 0) then you don't want the current sys username",
"if",
"(",
"this",
".",
"getProperty",
"(",
"Params",
".",
"USER_NAME",
")",
"==",
"null",
")",
"if",
"(",
"this",
".",
"getMuffinManager",
"(",
")",
"!=",
"null",
")",
"{",
"strUser",
"=",
"this",
".",
"getMuffinManager",
"(",
")",
".",
"getMuffin",
"(",
"Params",
".",
"USER_ID",
")",
";",
"this",
".",
"setProperty",
"(",
"Params",
".",
"USER_ID",
",",
"strUser",
")",
";",
"// User name is required",
"}",
"if",
"(",
"strUser",
"==",
"null",
")",
"// if (strUser.length() == 0) then you don't want the current sys username",
"if",
"(",
"this",
".",
"getProperty",
"(",
"Params",
".",
"USER_NAME",
")",
"==",
"null",
")",
"{",
"try",
"{",
"strUser",
"=",
"System",
".",
"getProperties",
"(",
")",
".",
"getProperty",
"(",
"\"user.name\"",
")",
";",
"this",
".",
"setProperty",
"(",
"Params",
".",
"USER_NAME",
",",
"strUser",
")",
";",
"// User name is required",
"}",
"catch",
"(",
"java",
".",
"security",
".",
"AccessControlException",
"ex",
")",
"{",
"// Ignore this, I'm probably running in an Applet",
"}",
"}",
"try",
"{",
"// Since I send this over the wire, make sure I'm using the default dom implementation",
"System",
".",
"setProperty",
"(",
"\"javax.xml.parsers.DocumentBuilderFactory\"",
",",
"\"com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl\"",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Ignore this error",
"}",
"if",
"(",
"Util",
".",
"getPortableImageUtil",
"(",
")",
"==",
"null",
")",
"{",
"PortableImageUtil",
"portableImageUtil",
"=",
"null",
";",
"try",
"{",
"Class",
".",
"forName",
"(",
"\"javax.swing.ImageIcon\"",
")",
";",
"// Test if swing exists",
"portableImageUtil",
"=",
"(",
"PortableImageUtil",
")",
"ClassServiceUtility",
".",
"getClassService",
"(",
")",
".",
"makeObjectFromClassName",
"(",
"SWING_IMAGE_UTIL",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"// Android",
"portableImageUtil",
"=",
"(",
"PortableImageUtil",
")",
"ClassServiceUtility",
".",
"getClassService",
"(",
")",
".",
"makeObjectFromClassName",
"(",
"ANDROID_IMAGE_UTIL",
")",
";",
"}",
"if",
"(",
"portableImageUtil",
"==",
"null",
")",
"// Sometime OSGi has a hard time finding javax",
"portableImageUtil",
"=",
"(",
"PortableImageUtil",
")",
"ClassServiceUtility",
".",
"getClassService",
"(",
")",
".",
"makeObjectFromClassName",
"(",
"SWING_IMAGE_UTIL",
")",
";",
"Util",
".",
"setPortableImageUtil",
"(",
"portableImageUtil",
")",
";",
"}",
"}"
] |
Initialize the Application.
@param env Environment is ignored in the thin context.
@param strURL The application parameters as a URL.
@param args The application parameters as an initial arg list.
@param applet The application parameters coming from an applet.
|
[
"Initialize",
"the",
"Application",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L145-L199
|
153,760
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.free
|
public void free()
{
if (m_mapTasks != null)
{
while (m_mapTasks.size() > 0)
{
for (Task task : m_mapTasks.keySet())
{
if (task != null)
{
int iCount = 0;
while (task.isRunning()) // This will also remove this from the list
{
if (iCount++ == 10)
{
Util.getLogger().warning("Shutting down a running task"); // Ignore and continue
break;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
this.removeTask(task); // Make sure this doesn't free me (if all tasks are freed, app will be freed)
task.setApplication(null);
task.stopTask();
}
else
{
try {
RemoteTask remoteTask = m_mapTasks.remove(task);
if (remoteTask != null)
remoteTask.freeRemoteSession();
} catch (RemoteException ex) {
ex.printStackTrace();
}
}
break; // YES, This only loops through the FIRST one, because it is removed and I would get a concurrent mod error
}
}
}
m_mapTasks = null;
if (m_PhysicalDatabaseParent instanceof Freeable)
{
((Freeable)m_PhysicalDatabaseParent).free();
m_PhysicalDatabaseParent = null;
}
}
|
java
|
public void free()
{
if (m_mapTasks != null)
{
while (m_mapTasks.size() > 0)
{
for (Task task : m_mapTasks.keySet())
{
if (task != null)
{
int iCount = 0;
while (task.isRunning()) // This will also remove this from the list
{
if (iCount++ == 10)
{
Util.getLogger().warning("Shutting down a running task"); // Ignore and continue
break;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
this.removeTask(task); // Make sure this doesn't free me (if all tasks are freed, app will be freed)
task.setApplication(null);
task.stopTask();
}
else
{
try {
RemoteTask remoteTask = m_mapTasks.remove(task);
if (remoteTask != null)
remoteTask.freeRemoteSession();
} catch (RemoteException ex) {
ex.printStackTrace();
}
}
break; // YES, This only loops through the FIRST one, because it is removed and I would get a concurrent mod error
}
}
}
m_mapTasks = null;
if (m_PhysicalDatabaseParent instanceof Freeable)
{
((Freeable)m_PhysicalDatabaseParent).free();
m_PhysicalDatabaseParent = null;
}
}
|
[
"public",
"void",
"free",
"(",
")",
"{",
"if",
"(",
"m_mapTasks",
"!=",
"null",
")",
"{",
"while",
"(",
"m_mapTasks",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"for",
"(",
"Task",
"task",
":",
"m_mapTasks",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"task",
"!=",
"null",
")",
"{",
"int",
"iCount",
"=",
"0",
";",
"while",
"(",
"task",
".",
"isRunning",
"(",
")",
")",
"// This will also remove this from the list",
"{",
"if",
"(",
"iCount",
"++",
"==",
"10",
")",
"{",
"Util",
".",
"getLogger",
"(",
")",
".",
"warning",
"(",
"\"Shutting down a running task\"",
")",
";",
"// Ignore and continue",
"break",
";",
"}",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"100",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"this",
".",
"removeTask",
"(",
"task",
")",
";",
"// Make sure this doesn't free me (if all tasks are freed, app will be freed)",
"task",
".",
"setApplication",
"(",
"null",
")",
";",
"task",
".",
"stopTask",
"(",
")",
";",
"}",
"else",
"{",
"try",
"{",
"RemoteTask",
"remoteTask",
"=",
"m_mapTasks",
".",
"remove",
"(",
"task",
")",
";",
"if",
"(",
"remoteTask",
"!=",
"null",
")",
"remoteTask",
".",
"freeRemoteSession",
"(",
")",
";",
"}",
"catch",
"(",
"RemoteException",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"break",
";",
"// YES, This only loops through the FIRST one, because it is removed and I would get a concurrent mod error",
"}",
"}",
"}",
"m_mapTasks",
"=",
"null",
";",
"if",
"(",
"m_PhysicalDatabaseParent",
"instanceof",
"Freeable",
")",
"{",
"(",
"(",
"Freeable",
")",
"m_PhysicalDatabaseParent",
")",
".",
"free",
"(",
")",
";",
"m_PhysicalDatabaseParent",
"=",
"null",
";",
"}",
"}"
] |
Free all the resources belonging to this application.
|
[
"Free",
"all",
"the",
"resources",
"belonging",
"to",
"this",
"application",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L205-L253
|
153,761
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.addTask
|
public int addTask(Task task, Object remoteTask)
{
if (m_taskMain == null)
{
if (task != null)
if (task.isMainTaskCandidate())
m_taskMain = task;
}
m_mapTasks.put(task, (RemoteTask)remoteTask);
return m_mapTasks.size();
}
|
java
|
public int addTask(Task task, Object remoteTask)
{
if (m_taskMain == null)
{
if (task != null)
if (task.isMainTaskCandidate())
m_taskMain = task;
}
m_mapTasks.put(task, (RemoteTask)remoteTask);
return m_mapTasks.size();
}
|
[
"public",
"int",
"addTask",
"(",
"Task",
"task",
",",
"Object",
"remoteTask",
")",
"{",
"if",
"(",
"m_taskMain",
"==",
"null",
")",
"{",
"if",
"(",
"task",
"!=",
"null",
")",
"if",
"(",
"task",
".",
"isMainTaskCandidate",
"(",
")",
")",
"m_taskMain",
"=",
"task",
";",
"}",
"m_mapTasks",
".",
"put",
"(",
"task",
",",
"(",
"RemoteTask",
")",
"remoteTask",
")",
";",
"return",
"m_mapTasks",
".",
"size",
"(",
")",
";",
"}"
] |
Add this session, screen, or task that belongs to this application.
@param objSession Session to remove.
@return Number of remaining sessions still active.
|
[
"Add",
"this",
"session",
"screen",
"or",
"task",
"that",
"belongs",
"to",
"this",
"application",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L284-L294
|
153,762
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.removeTask
|
public boolean removeTask(Task task)
{
if (task != null)
if (!m_mapTasks.containsKey(task))
Util.getLogger().warning("Attempt to remove non-existent task");
RemoteTask remoteTask = m_mapTasks.remove(task);
if (remoteTask != null)
{
try {
remoteTask.freeRemoteSession();
} catch (RemoteException ex) {
ex.printStackTrace();
}
}
synchronized (this)
{
boolean bEndOfTasks = true;
if (m_taskMain == task)
{
if (m_mapTasks.size() == 0)
m_taskMain = null;
else
{
m_taskMain = null;
for (Task task2 : m_mapTasks.keySet())
{
if (task2.isMainTaskCandidate())
{
m_taskMain = task2; // Main task can only be an applet
break; // Preferred
}
if (task2.isRunning())
{
bEndOfTasks = false; // There are more main tasks to go!
continue;
}
}
}
}
if (m_taskMain != null)
return false; // There are more main tasks to go!
return bEndOfTasks; // All Main task candidates are GONE!
}
}
|
java
|
public boolean removeTask(Task task)
{
if (task != null)
if (!m_mapTasks.containsKey(task))
Util.getLogger().warning("Attempt to remove non-existent task");
RemoteTask remoteTask = m_mapTasks.remove(task);
if (remoteTask != null)
{
try {
remoteTask.freeRemoteSession();
} catch (RemoteException ex) {
ex.printStackTrace();
}
}
synchronized (this)
{
boolean bEndOfTasks = true;
if (m_taskMain == task)
{
if (m_mapTasks.size() == 0)
m_taskMain = null;
else
{
m_taskMain = null;
for (Task task2 : m_mapTasks.keySet())
{
if (task2.isMainTaskCandidate())
{
m_taskMain = task2; // Main task can only be an applet
break; // Preferred
}
if (task2.isRunning())
{
bEndOfTasks = false; // There are more main tasks to go!
continue;
}
}
}
}
if (m_taskMain != null)
return false; // There are more main tasks to go!
return bEndOfTasks; // All Main task candidates are GONE!
}
}
|
[
"public",
"boolean",
"removeTask",
"(",
"Task",
"task",
")",
"{",
"if",
"(",
"task",
"!=",
"null",
")",
"if",
"(",
"!",
"m_mapTasks",
".",
"containsKey",
"(",
"task",
")",
")",
"Util",
".",
"getLogger",
"(",
")",
".",
"warning",
"(",
"\"Attempt to remove non-existent task\"",
")",
";",
"RemoteTask",
"remoteTask",
"=",
"m_mapTasks",
".",
"remove",
"(",
"task",
")",
";",
"if",
"(",
"remoteTask",
"!=",
"null",
")",
"{",
"try",
"{",
"remoteTask",
".",
"freeRemoteSession",
"(",
")",
";",
"}",
"catch",
"(",
"RemoteException",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"synchronized",
"(",
"this",
")",
"{",
"boolean",
"bEndOfTasks",
"=",
"true",
";",
"if",
"(",
"m_taskMain",
"==",
"task",
")",
"{",
"if",
"(",
"m_mapTasks",
".",
"size",
"(",
")",
"==",
"0",
")",
"m_taskMain",
"=",
"null",
";",
"else",
"{",
"m_taskMain",
"=",
"null",
";",
"for",
"(",
"Task",
"task2",
":",
"m_mapTasks",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"task2",
".",
"isMainTaskCandidate",
"(",
")",
")",
"{",
"m_taskMain",
"=",
"task2",
";",
"// Main task can only be an applet",
"break",
";",
"// Preferred",
"}",
"if",
"(",
"task2",
".",
"isRunning",
"(",
")",
")",
"{",
"bEndOfTasks",
"=",
"false",
";",
"// There are more main tasks to go!",
"continue",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"m_taskMain",
"!=",
"null",
")",
"return",
"false",
";",
"// There are more main tasks to go!",
"return",
"bEndOfTasks",
";",
"// All Main task candidates are GONE!",
"}",
"}"
] |
Remove this session, screen, or task that belongs to this application.
@param objSession Session to remove.
@return True if all the potential main tasks have been removed.
|
[
"Remove",
"this",
"session",
"screen",
"or",
"task",
"that",
"belongs",
"to",
"this",
"application",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L300-L343
|
153,763
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.getConnectionType
|
public int getConnectionType()
{
int iConnectionType = DEFAULT_CONNECTION_TYPE;
if (this.getMuffinManager() != null)
if (this.getMuffinManager().isServiceAvailable())
iConnectionType = PROXY; // HACK - Webstart gives a warning when using RMI
String strConnectionType = this.getProperty(Params.CONNECTION_TYPE);
if (strConnectionType != null)
{
if ("proxy".equalsIgnoreCase(strConnectionType))
iConnectionType = PROXY;
//x if ("rmi".equalsIgnoreCase(strConnectionType))
//x iConnectionType = RMI;
if (Util.isNumeric(strConnectionType))
iConnectionType = Integer.parseInt(strConnectionType);
}
if (ClassServiceUtility.getClassService().getClassFinder(null) == null)
iConnectionType = PROXY; // No OSGi
/* if (iConnectionType == RMI)
{
try {
Hashtable<String,String> env = new Hashtable<String,String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
env.put(Context.PROVIDER_URL, "rmi://" + strServer); // + ":1099"); // The RMI server port
Context initial = new InitialContext(env);
Object objref = initial.lookup(strRemoteApp);
if (objref == null)
return null; // Ahhhhh, The app is not registered.
appServer = (ApplicationServer)PortableRemoteObject.narrow(objref, org.jbundle.thin.base.remote.ApplicationServer.class);
} catch (NameNotFoundException ex) {
return null; // Error - not found
} catch (ServiceUnavailableException ex) {
return null; // Error - not found
} catch (Exception ex) {
ex.printStackTrace();
// } catch (java.net.ConnectException ex) {
// Try tunneling through http
iConnectionType = PROXY;
}
} */
return iConnectionType;
}
|
java
|
public int getConnectionType()
{
int iConnectionType = DEFAULT_CONNECTION_TYPE;
if (this.getMuffinManager() != null)
if (this.getMuffinManager().isServiceAvailable())
iConnectionType = PROXY; // HACK - Webstart gives a warning when using RMI
String strConnectionType = this.getProperty(Params.CONNECTION_TYPE);
if (strConnectionType != null)
{
if ("proxy".equalsIgnoreCase(strConnectionType))
iConnectionType = PROXY;
//x if ("rmi".equalsIgnoreCase(strConnectionType))
//x iConnectionType = RMI;
if (Util.isNumeric(strConnectionType))
iConnectionType = Integer.parseInt(strConnectionType);
}
if (ClassServiceUtility.getClassService().getClassFinder(null) == null)
iConnectionType = PROXY; // No OSGi
/* if (iConnectionType == RMI)
{
try {
Hashtable<String,String> env = new Hashtable<String,String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
env.put(Context.PROVIDER_URL, "rmi://" + strServer); // + ":1099"); // The RMI server port
Context initial = new InitialContext(env);
Object objref = initial.lookup(strRemoteApp);
if (objref == null)
return null; // Ahhhhh, The app is not registered.
appServer = (ApplicationServer)PortableRemoteObject.narrow(objref, org.jbundle.thin.base.remote.ApplicationServer.class);
} catch (NameNotFoundException ex) {
return null; // Error - not found
} catch (ServiceUnavailableException ex) {
return null; // Error - not found
} catch (Exception ex) {
ex.printStackTrace();
// } catch (java.net.ConnectException ex) {
// Try tunneling through http
iConnectionType = PROXY;
}
} */
return iConnectionType;
}
|
[
"public",
"int",
"getConnectionType",
"(",
")",
"{",
"int",
"iConnectionType",
"=",
"DEFAULT_CONNECTION_TYPE",
";",
"if",
"(",
"this",
".",
"getMuffinManager",
"(",
")",
"!=",
"null",
")",
"if",
"(",
"this",
".",
"getMuffinManager",
"(",
")",
".",
"isServiceAvailable",
"(",
")",
")",
"iConnectionType",
"=",
"PROXY",
";",
"// HACK - Webstart gives a warning when using RMI",
"String",
"strConnectionType",
"=",
"this",
".",
"getProperty",
"(",
"Params",
".",
"CONNECTION_TYPE",
")",
";",
"if",
"(",
"strConnectionType",
"!=",
"null",
")",
"{",
"if",
"(",
"\"proxy\"",
".",
"equalsIgnoreCase",
"(",
"strConnectionType",
")",
")",
"iConnectionType",
"=",
"PROXY",
";",
"//x if (\"rmi\".equalsIgnoreCase(strConnectionType))",
"//x iConnectionType = RMI;",
"if",
"(",
"Util",
".",
"isNumeric",
"(",
"strConnectionType",
")",
")",
"iConnectionType",
"=",
"Integer",
".",
"parseInt",
"(",
"strConnectionType",
")",
";",
"}",
"if",
"(",
"ClassServiceUtility",
".",
"getClassService",
"(",
")",
".",
"getClassFinder",
"(",
"null",
")",
"==",
"null",
")",
"iConnectionType",
"=",
"PROXY",
";",
"// No OSGi",
"/* if (iConnectionType == RMI)\n {\n try {\n Hashtable<String,String> env = new Hashtable<String,String>();\n env.put(Context.INITIAL_CONTEXT_FACTORY, \"com.sun.jndi.rmi.registry.RegistryContextFactory\");\n env.put(Context.PROVIDER_URL, \"rmi://\" + strServer); // + \":1099\"); // The RMI server port\n Context initial = new InitialContext(env);\n Object objref = initial.lookup(strRemoteApp);\n if (objref == null)\n return null; // Ahhhhh, The app is not registered.\n \n appServer = (ApplicationServer)PortableRemoteObject.narrow(objref, org.jbundle.thin.base.remote.ApplicationServer.class);\n } catch (NameNotFoundException ex) {\n return null; // Error - not found\n } catch (ServiceUnavailableException ex) {\n return null; // Error - not found\n } catch (Exception ex) {\n ex.printStackTrace();\n // } catch (java.net.ConnectException ex) {\n // Try tunneling through http\n iConnectionType = PROXY;\n }\n } */",
"return",
"iConnectionType",
";",
"}"
] |
Get the connection type.
@return
|
[
"Get",
"the",
"connection",
"type",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L489-L531
|
153,764
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.getAppServerName
|
public String getAppServerName()
{
String strServer = this.getProperty(Params.REMOTE_HOST);
if ((strServer == null) || (strServer.length() == 0))
{
URL urlCodeBase = this.getCodeBase();
if (urlCodeBase != null)
{
strServer = urlCodeBase.getHost();
int port = urlCodeBase.getPort();
if ((port != -1) && (port != 80))
if (!strServer.contains(":"))
strServer = strServer + ':' + port;
}
}
return strServer;
}
|
java
|
public String getAppServerName()
{
String strServer = this.getProperty(Params.REMOTE_HOST);
if ((strServer == null) || (strServer.length() == 0))
{
URL urlCodeBase = this.getCodeBase();
if (urlCodeBase != null)
{
strServer = urlCodeBase.getHost();
int port = urlCodeBase.getPort();
if ((port != -1) && (port != 80))
if (!strServer.contains(":"))
strServer = strServer + ':' + port;
}
}
return strServer;
}
|
[
"public",
"String",
"getAppServerName",
"(",
")",
"{",
"String",
"strServer",
"=",
"this",
".",
"getProperty",
"(",
"Params",
".",
"REMOTE_HOST",
")",
";",
"if",
"(",
"(",
"strServer",
"==",
"null",
")",
"||",
"(",
"strServer",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"URL",
"urlCodeBase",
"=",
"this",
".",
"getCodeBase",
"(",
")",
";",
"if",
"(",
"urlCodeBase",
"!=",
"null",
")",
"{",
"strServer",
"=",
"urlCodeBase",
".",
"getHost",
"(",
")",
";",
"int",
"port",
"=",
"urlCodeBase",
".",
"getPort",
"(",
")",
";",
"if",
"(",
"(",
"port",
"!=",
"-",
"1",
")",
"&&",
"(",
"port",
"!=",
"80",
")",
")",
"if",
"(",
"!",
"strServer",
".",
"contains",
"(",
"\":\"",
")",
")",
"strServer",
"=",
"strServer",
"+",
"'",
"'",
"+",
"port",
";",
"}",
"}",
"return",
"strServer",
";",
"}"
] |
Get the URL of the server.
@return The remote server name.
|
[
"Get",
"the",
"URL",
"of",
"the",
"server",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L560-L576
|
153,765
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.getResourcePath
|
public String getResourcePath(String strResourceName)
{
if (strResourceName == null)
strResourceName = THIN_RES_PATH + "Menu"; // ResourceConstants.MENU_RESOURCE;
if ((!strResourceName.endsWith(RESOURCES))
&& (!strResourceName.endsWith(BUNDLE))
&& (!strResourceName.endsWith(PROPERTIES)))
strResourceName = strResourceName + "Resources";
if (strResourceName.indexOf('.') == -1)
strResourceName = getResPackage() + strResourceName;
if (strResourceName.indexOf('.') == 0)
strResourceName = Constants.ROOT_PACKAGE + strResourceName.substring(1);
return strResourceName;
}
|
java
|
public String getResourcePath(String strResourceName)
{
if (strResourceName == null)
strResourceName = THIN_RES_PATH + "Menu"; // ResourceConstants.MENU_RESOURCE;
if ((!strResourceName.endsWith(RESOURCES))
&& (!strResourceName.endsWith(BUNDLE))
&& (!strResourceName.endsWith(PROPERTIES)))
strResourceName = strResourceName + "Resources";
if (strResourceName.indexOf('.') == -1)
strResourceName = getResPackage() + strResourceName;
if (strResourceName.indexOf('.') == 0)
strResourceName = Constants.ROOT_PACKAGE + strResourceName.substring(1);
return strResourceName;
}
|
[
"public",
"String",
"getResourcePath",
"(",
"String",
"strResourceName",
")",
"{",
"if",
"(",
"strResourceName",
"==",
"null",
")",
"strResourceName",
"=",
"THIN_RES_PATH",
"+",
"\"Menu\"",
";",
"// ResourceConstants.MENU_RESOURCE;",
"if",
"(",
"(",
"!",
"strResourceName",
".",
"endsWith",
"(",
"RESOURCES",
")",
")",
"&&",
"(",
"!",
"strResourceName",
".",
"endsWith",
"(",
"BUNDLE",
")",
")",
"&&",
"(",
"!",
"strResourceName",
".",
"endsWith",
"(",
"PROPERTIES",
")",
")",
")",
"strResourceName",
"=",
"strResourceName",
"+",
"\"Resources\"",
";",
"if",
"(",
"strResourceName",
".",
"indexOf",
"(",
"'",
"'",
")",
"==",
"-",
"1",
")",
"strResourceName",
"=",
"getResPackage",
"(",
")",
"+",
"strResourceName",
";",
"if",
"(",
"strResourceName",
".",
"indexOf",
"(",
"'",
"'",
")",
"==",
"0",
")",
"strResourceName",
"=",
"Constants",
".",
"ROOT_PACKAGE",
"+",
"strResourceName",
".",
"substring",
"(",
"1",
")",
";",
"return",
"strResourceName",
";",
"}"
] |
Fix this resource name to point to the resources.
@param strResourceName The name to fix.
@return The full class name of the resource to get.
|
[
"Fix",
"this",
"resource",
"name",
"to",
"point",
"to",
"the",
"resources",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L740-L753
|
153,766
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.getString
|
public String getString(String string)
{
String strReturn = null;
try {
if (m_resources == null)
this.setLanguage(null); // If the resource file is not here, add the default file.
if (m_resources != null)
if (string != null)
strReturn = m_resources.getString(string);
} catch (MissingResourceException ex) {
strReturn = null;
}
if ((strReturn != null) && (strReturn.length() > 0))
return strReturn;
else
return string;
}
|
java
|
public String getString(String string)
{
String strReturn = null;
try {
if (m_resources == null)
this.setLanguage(null); // If the resource file is not here, add the default file.
if (m_resources != null)
if (string != null)
strReturn = m_resources.getString(string);
} catch (MissingResourceException ex) {
strReturn = null;
}
if ((strReturn != null) && (strReturn.length() > 0))
return strReturn;
else
return string;
}
|
[
"public",
"String",
"getString",
"(",
"String",
"string",
")",
"{",
"String",
"strReturn",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"m_resources",
"==",
"null",
")",
"this",
".",
"setLanguage",
"(",
"null",
")",
";",
"// If the resource file is not here, add the default file.",
"if",
"(",
"m_resources",
"!=",
"null",
")",
"if",
"(",
"string",
"!=",
"null",
")",
"strReturn",
"=",
"m_resources",
".",
"getString",
"(",
"string",
")",
";",
"}",
"catch",
"(",
"MissingResourceException",
"ex",
")",
"{",
"strReturn",
"=",
"null",
";",
"}",
"if",
"(",
"(",
"strReturn",
"!=",
"null",
")",
"&&",
"(",
"strReturn",
".",
"length",
"(",
")",
">",
"0",
")",
")",
"return",
"strReturn",
";",
"else",
"return",
"string",
";",
"}"
] |
Look this key up in the current resource file and return the string in the local language.
If no resource file is active, return the string.
@param string The key to lookup.
@return The local string.
|
[
"Look",
"this",
"key",
"up",
"in",
"the",
"current",
"resource",
"file",
"and",
"return",
"the",
"string",
"in",
"the",
"local",
"language",
".",
"If",
"no",
"resource",
"file",
"is",
"active",
"return",
"the",
"string",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L788-L804
|
153,767
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.getLanguage
|
public String getLanguage(boolean bCheckLocaleAlso)
{
String strLanguage = this.getProperty(Params.LANGUAGE);
if ((strLanguage == null) || (strLanguage.length() == 0))
if (bCheckLocaleAlso)
return Locale.getDefault().getLanguage();
return strLanguage;
}
|
java
|
public String getLanguage(boolean bCheckLocaleAlso)
{
String strLanguage = this.getProperty(Params.LANGUAGE);
if ((strLanguage == null) || (strLanguage.length() == 0))
if (bCheckLocaleAlso)
return Locale.getDefault().getLanguage();
return strLanguage;
}
|
[
"public",
"String",
"getLanguage",
"(",
"boolean",
"bCheckLocaleAlso",
")",
"{",
"String",
"strLanguage",
"=",
"this",
".",
"getProperty",
"(",
"Params",
".",
"LANGUAGE",
")",
";",
"if",
"(",
"(",
"strLanguage",
"==",
"null",
")",
"||",
"(",
"strLanguage",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"if",
"(",
"bCheckLocaleAlso",
")",
"return",
"Locale",
".",
"getDefault",
"(",
")",
".",
"getLanguage",
"(",
")",
";",
"return",
"strLanguage",
";",
"}"
] |
Get the current language.
@param bCheckLocaleAlso If true, and language has not been set, return the system's language
@return The current language code.
|
[
"Get",
"the",
"current",
"language",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L840-L847
|
153,768
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.getProperty
|
public String getProperty(String strProperty)
{
String strValue = null;
if (m_properties != null)
if (m_properties.get(strProperty) != null)
strValue = m_properties.get(strProperty).toString();
if (strValue == null)
if (m_sApplet != null) // Try applet properties if an Applet
strValue = this.getParameterByReflection(m_sApplet, strProperty); // Passed in as an applet param?
return strValue;
}
|
java
|
public String getProperty(String strProperty)
{
String strValue = null;
if (m_properties != null)
if (m_properties.get(strProperty) != null)
strValue = m_properties.get(strProperty).toString();
if (strValue == null)
if (m_sApplet != null) // Try applet properties if an Applet
strValue = this.getParameterByReflection(m_sApplet, strProperty); // Passed in as an applet param?
return strValue;
}
|
[
"public",
"String",
"getProperty",
"(",
"String",
"strProperty",
")",
"{",
"String",
"strValue",
"=",
"null",
";",
"if",
"(",
"m_properties",
"!=",
"null",
")",
"if",
"(",
"m_properties",
".",
"get",
"(",
"strProperty",
")",
"!=",
"null",
")",
"strValue",
"=",
"m_properties",
".",
"get",
"(",
"strProperty",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"strValue",
"==",
"null",
")",
"if",
"(",
"m_sApplet",
"!=",
"null",
")",
"// Try applet properties if an Applet",
"strValue",
"=",
"this",
".",
"getParameterByReflection",
"(",
"m_sApplet",
",",
"strProperty",
")",
";",
"// Passed in as an applet param?",
"return",
"strValue",
";",
"}"
] |
Get the value of this property key.
@param strParam The key to lookup.
@return The value for this key.
|
[
"Get",
"the",
"value",
"of",
"this",
"property",
"key",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L893-L903
|
153,769
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.changePassword
|
public int changePassword(Task task, String strUserName, String strCurrentPassword, String strNewPassword)
{
int iErrorCode = Constants.NORMAL_RETURN;
org.jbundle.thin.base.remote.RemoteTask remoteTask = (org.jbundle.thin.base.remote.RemoteTask)this.getRemoteTask(null, strUserName, false);
Map<String,Object> properties = new HashMap<String,Object>();
properties.put(Params.USER_NAME, strUserName);
properties.put(Params.PASSWORD, strCurrentPassword);
properties.put("newPassword", strNewPassword);
try {
Object objReturn = remoteTask.doRemoteAction(ThinMenuConstants.CHANGE_PASSWORD, properties);
if (objReturn instanceof Integer)
iErrorCode = ((Integer)objReturn).intValue();
} catch (Exception ex) {
return task.setLastError(ex.getMessage());
}
return iErrorCode;
}
|
java
|
public int changePassword(Task task, String strUserName, String strCurrentPassword, String strNewPassword)
{
int iErrorCode = Constants.NORMAL_RETURN;
org.jbundle.thin.base.remote.RemoteTask remoteTask = (org.jbundle.thin.base.remote.RemoteTask)this.getRemoteTask(null, strUserName, false);
Map<String,Object> properties = new HashMap<String,Object>();
properties.put(Params.USER_NAME, strUserName);
properties.put(Params.PASSWORD, strCurrentPassword);
properties.put("newPassword", strNewPassword);
try {
Object objReturn = remoteTask.doRemoteAction(ThinMenuConstants.CHANGE_PASSWORD, properties);
if (objReturn instanceof Integer)
iErrorCode = ((Integer)objReturn).intValue();
} catch (Exception ex) {
return task.setLastError(ex.getMessage());
}
return iErrorCode;
}
|
[
"public",
"int",
"changePassword",
"(",
"Task",
"task",
",",
"String",
"strUserName",
",",
"String",
"strCurrentPassword",
",",
"String",
"strNewPassword",
")",
"{",
"int",
"iErrorCode",
"=",
"Constants",
".",
"NORMAL_RETURN",
";",
"org",
".",
"jbundle",
".",
"thin",
".",
"base",
".",
"remote",
".",
"RemoteTask",
"remoteTask",
"=",
"(",
"org",
".",
"jbundle",
".",
"thin",
".",
"base",
".",
"remote",
".",
"RemoteTask",
")",
"this",
".",
"getRemoteTask",
"(",
"null",
",",
"strUserName",
",",
"false",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"properties",
".",
"put",
"(",
"Params",
".",
"USER_NAME",
",",
"strUserName",
")",
";",
"properties",
".",
"put",
"(",
"Params",
".",
"PASSWORD",
",",
"strCurrentPassword",
")",
";",
"properties",
".",
"put",
"(",
"\"newPassword\"",
",",
"strNewPassword",
")",
";",
"try",
"{",
"Object",
"objReturn",
"=",
"remoteTask",
".",
"doRemoteAction",
"(",
"ThinMenuConstants",
".",
"CHANGE_PASSWORD",
",",
"properties",
")",
";",
"if",
"(",
"objReturn",
"instanceof",
"Integer",
")",
"iErrorCode",
"=",
"(",
"(",
"Integer",
")",
"objReturn",
")",
".",
"intValue",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"return",
"task",
".",
"setLastError",
"(",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"iErrorCode",
";",
"}"
] |
Change the password.
|
[
"Change",
"the",
"password",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L1002-L1018
|
153,770
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.getSecurityErrorText
|
public String getSecurityErrorText(int iErrorCode)
{
String key = "Error " + Integer.toString(iErrorCode);
if (iErrorCode == Constants.ACCESS_DENIED)
key = "Access Denied";
if (iErrorCode == Constants.LOGIN_REQUIRED)
key = "Login required";
if (iErrorCode == Constants.AUTHENTICATION_REQUIRED)
key = "Authentication required";
if (iErrorCode == Constants.CREATE_USER_REQUIRED)
key = "Create user required";
key = this.getResources(ThinResourceConstants.ERROR_RESOURCE, true).getString(key);
return key;
}
|
java
|
public String getSecurityErrorText(int iErrorCode)
{
String key = "Error " + Integer.toString(iErrorCode);
if (iErrorCode == Constants.ACCESS_DENIED)
key = "Access Denied";
if (iErrorCode == Constants.LOGIN_REQUIRED)
key = "Login required";
if (iErrorCode == Constants.AUTHENTICATION_REQUIRED)
key = "Authentication required";
if (iErrorCode == Constants.CREATE_USER_REQUIRED)
key = "Create user required";
key = this.getResources(ThinResourceConstants.ERROR_RESOURCE, true).getString(key);
return key;
}
|
[
"public",
"String",
"getSecurityErrorText",
"(",
"int",
"iErrorCode",
")",
"{",
"String",
"key",
"=",
"\"Error \"",
"+",
"Integer",
".",
"toString",
"(",
"iErrorCode",
")",
";",
"if",
"(",
"iErrorCode",
"==",
"Constants",
".",
"ACCESS_DENIED",
")",
"key",
"=",
"\"Access Denied\"",
";",
"if",
"(",
"iErrorCode",
"==",
"Constants",
".",
"LOGIN_REQUIRED",
")",
"key",
"=",
"\"Login required\"",
";",
"if",
"(",
"iErrorCode",
"==",
"Constants",
".",
"AUTHENTICATION_REQUIRED",
")",
"key",
"=",
"\"Authentication required\"",
";",
"if",
"(",
"iErrorCode",
"==",
"Constants",
".",
"CREATE_USER_REQUIRED",
")",
"key",
"=",
"\"Create user required\"",
";",
"key",
"=",
"this",
".",
"getResources",
"(",
"ThinResourceConstants",
".",
"ERROR_RESOURCE",
",",
"true",
")",
".",
"getString",
"(",
"key",
")",
";",
"return",
"key",
";",
"}"
] |
Get the error text for this security error.
|
[
"Get",
"the",
"error",
"text",
"for",
"this",
"security",
"error",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L1095-L1108
|
153,771
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.classMatch
|
public boolean classMatch(String targetClass, String templateClass)
{
//x if (targetClass.startsWith(Constants.ROOT_PACKAGE)) // Always
//x targetClass = targetClass.substring(Constants.ROOT_PACKAGE.length() - 1);
//x if (templateClass.startsWith(Constants.ROOT_PACKAGE)) // Never
//x templateClass = templateClass.substring(Constants.ROOT_PACKAGE.length() - 1);
//x if (targetClass.startsWith(Constants.THIN_SUBPACKAGE))
//x if (!templateClass.startsWith(THIN_CLASS))
//x targetClass = targetClass.substring(THIN_CLASS.length()); // Include thin classes
if (targetClass.startsWith(BASE_CLASS))
return true; // Allow access to all base classes
if (templateClass.endsWith("*"))
{
if (templateClass.startsWith("*"))
return targetClass.indexOf(templateClass.substring(1, templateClass.length() - 1)) != -1;
return targetClass.startsWith(templateClass.substring(0, templateClass.length() - 1));
}
else
{ // Exact match
return templateClass.equalsIgnoreCase(targetClass);
}
}
|
java
|
public boolean classMatch(String targetClass, String templateClass)
{
//x if (targetClass.startsWith(Constants.ROOT_PACKAGE)) // Always
//x targetClass = targetClass.substring(Constants.ROOT_PACKAGE.length() - 1);
//x if (templateClass.startsWith(Constants.ROOT_PACKAGE)) // Never
//x templateClass = templateClass.substring(Constants.ROOT_PACKAGE.length() - 1);
//x if (targetClass.startsWith(Constants.THIN_SUBPACKAGE))
//x if (!templateClass.startsWith(THIN_CLASS))
//x targetClass = targetClass.substring(THIN_CLASS.length()); // Include thin classes
if (targetClass.startsWith(BASE_CLASS))
return true; // Allow access to all base classes
if (templateClass.endsWith("*"))
{
if (templateClass.startsWith("*"))
return targetClass.indexOf(templateClass.substring(1, templateClass.length() - 1)) != -1;
return targetClass.startsWith(templateClass.substring(0, templateClass.length() - 1));
}
else
{ // Exact match
return templateClass.equalsIgnoreCase(targetClass);
}
}
|
[
"public",
"boolean",
"classMatch",
"(",
"String",
"targetClass",
",",
"String",
"templateClass",
")",
"{",
"//x if (targetClass.startsWith(Constants.ROOT_PACKAGE)) // Always",
"//x targetClass = targetClass.substring(Constants.ROOT_PACKAGE.length() - 1);",
"//x if (templateClass.startsWith(Constants.ROOT_PACKAGE)) // Never",
"//x templateClass = templateClass.substring(Constants.ROOT_PACKAGE.length() - 1);",
"//x if (targetClass.startsWith(Constants.THIN_SUBPACKAGE))",
"//x if (!templateClass.startsWith(THIN_CLASS))",
"//x targetClass = targetClass.substring(THIN_CLASS.length()); // Include thin classes",
"if",
"(",
"targetClass",
".",
"startsWith",
"(",
"BASE_CLASS",
")",
")",
"return",
"true",
";",
"// Allow access to all base classes",
"if",
"(",
"templateClass",
".",
"endsWith",
"(",
"\"*\"",
")",
")",
"{",
"if",
"(",
"templateClass",
".",
"startsWith",
"(",
"\"*\"",
")",
")",
"return",
"targetClass",
".",
"indexOf",
"(",
"templateClass",
".",
"substring",
"(",
"1",
",",
"templateClass",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
"!=",
"-",
"1",
";",
"return",
"targetClass",
".",
"startsWith",
"(",
"templateClass",
".",
"substring",
"(",
"0",
",",
"templateClass",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
";",
"}",
"else",
"{",
"// Exact match",
"return",
"templateClass",
".",
"equalsIgnoreCase",
"(",
"targetClass",
")",
";",
"}",
"}"
] |
Is this target class in the template class pattern?
@param targetClass
@param templateClass
@return true If it matches.
|
[
"Is",
"this",
"target",
"class",
"in",
"the",
"template",
"class",
"pattern?"
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L1171-L1192
|
153,772
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.registerUniqueApplication
|
public int registerUniqueApplication(String strQueueName, String strQueueType)
{
// HACK - This works if you are careful about starting the server... DONT TRUST THIS CODE!
// todo(don) - THIS DOES NOT WORK CORRECTLY (need to register this app with jini or write an entry in a table or use the lock server or something)
Map<String,Object> properties = new HashMap<String,Object>();
properties.put("removeListener", Boolean.TRUE);
BaseMessage message = new MapMessage(new BaseMessageHeader(strQueueName, strQueueType, this, properties), properties);
this.getMessageManager().sendMessage(message); // Make sure there is no listener that will start this server up.
return Constants.NORMAL_RETURN;
}
|
java
|
public int registerUniqueApplication(String strQueueName, String strQueueType)
{
// HACK - This works if you are careful about starting the server... DONT TRUST THIS CODE!
// todo(don) - THIS DOES NOT WORK CORRECTLY (need to register this app with jini or write an entry in a table or use the lock server or something)
Map<String,Object> properties = new HashMap<String,Object>();
properties.put("removeListener", Boolean.TRUE);
BaseMessage message = new MapMessage(new BaseMessageHeader(strQueueName, strQueueType, this, properties), properties);
this.getMessageManager().sendMessage(message); // Make sure there is no listener that will start this server up.
return Constants.NORMAL_RETURN;
}
|
[
"public",
"int",
"registerUniqueApplication",
"(",
"String",
"strQueueName",
",",
"String",
"strQueueType",
")",
"{",
"// HACK - This works if you are careful about starting the server... DONT TRUST THIS CODE!",
"// todo(don) - THIS DOES NOT WORK CORRECTLY (need to register this app with jini or write an entry in a table or use the lock server or something)",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"properties",
".",
"put",
"(",
"\"removeListener\"",
",",
"Boolean",
".",
"TRUE",
")",
";",
"BaseMessage",
"message",
"=",
"new",
"MapMessage",
"(",
"new",
"BaseMessageHeader",
"(",
"strQueueName",
",",
"strQueueType",
",",
"this",
",",
"properties",
")",
",",
"properties",
")",
";",
"this",
".",
"getMessageManager",
"(",
")",
".",
"sendMessage",
"(",
"message",
")",
";",
"// Make sure there is no listener that will start this server up.",
"return",
"Constants",
".",
"NORMAL_RETURN",
";",
"}"
] |
Register this unique application so there will be only one running.
@param strQueueName The (optional) Queue that this app services.
@param strQueueType The (optional) QueueType for this queue.
@return NORMAL_RETURN If I registered the app okay, ERROR_RETURN if not (The app is already running)
|
[
"Register",
"this",
"unique",
"application",
"so",
"there",
"will",
"be",
"only",
"one",
"running",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L1233-L1242
|
153,773
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java
|
Application.addUserParamsToURL
|
public String addUserParamsToURL(String strURL)
{
strURL = Util.addURLParam(strURL, Constants.SYSTEM_NAME, this.getProperty(Constants.SYSTEM_NAME), false);
strURL = Util.addURLParam(strURL, Params.USER_ID, this.getProperty(Params.USER_ID));
if (this.getProperty(Params.AUTH_TOKEN) != null)
strURL = Util.addURLParam(strURL, Params.AUTH_TOKEN, this.getProperty(Params.AUTH_TOKEN));
return strURL;
}
|
java
|
public String addUserParamsToURL(String strURL)
{
strURL = Util.addURLParam(strURL, Constants.SYSTEM_NAME, this.getProperty(Constants.SYSTEM_NAME), false);
strURL = Util.addURLParam(strURL, Params.USER_ID, this.getProperty(Params.USER_ID));
if (this.getProperty(Params.AUTH_TOKEN) != null)
strURL = Util.addURLParam(strURL, Params.AUTH_TOKEN, this.getProperty(Params.AUTH_TOKEN));
return strURL;
}
|
[
"public",
"String",
"addUserParamsToURL",
"(",
"String",
"strURL",
")",
"{",
"strURL",
"=",
"Util",
".",
"addURLParam",
"(",
"strURL",
",",
"Constants",
".",
"SYSTEM_NAME",
",",
"this",
".",
"getProperty",
"(",
"Constants",
".",
"SYSTEM_NAME",
")",
",",
"false",
")",
";",
"strURL",
"=",
"Util",
".",
"addURLParam",
"(",
"strURL",
",",
"Params",
".",
"USER_ID",
",",
"this",
".",
"getProperty",
"(",
"Params",
".",
"USER_ID",
")",
")",
";",
"if",
"(",
"this",
".",
"getProperty",
"(",
"Params",
".",
"AUTH_TOKEN",
")",
"!=",
"null",
")",
"strURL",
"=",
"Util",
".",
"addURLParam",
"(",
"strURL",
",",
"Params",
".",
"AUTH_TOKEN",
",",
"this",
".",
"getProperty",
"(",
"Params",
".",
"AUTH_TOKEN",
")",
")",
";",
"return",
"strURL",
";",
"}"
] |
Add this user's params to the URL, so when I submit this to the server it can authenticate me.
@param strURL
@return
|
[
"Add",
"this",
"user",
"s",
"params",
"to",
"the",
"URL",
"so",
"when",
"I",
"submit",
"this",
"to",
"the",
"server",
"it",
"can",
"authenticate",
"me",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/Application.java#L1264-L1271
|
153,774
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/client/StepResponse.java
|
StepResponse.setComplete
|
void setComplete() {
this.complete = true;
try {
// If we haven't gotten any results back, make sure to create an
// empty one
if (this.states.size() == 0) {
this.states.put(new WorldState());
}
// Special WorldState to indicate that the request has completed and
// interrupt
// any blocking threads
else {
this.states.put(RESPONSE_COMPLETE);
}
} catch (InterruptedException e) {
log.error("Interrupted trying to indicate a completed condition.", e);
}
}
|
java
|
void setComplete() {
this.complete = true;
try {
// If we haven't gotten any results back, make sure to create an
// empty one
if (this.states.size() == 0) {
this.states.put(new WorldState());
}
// Special WorldState to indicate that the request has completed and
// interrupt
// any blocking threads
else {
this.states.put(RESPONSE_COMPLETE);
}
} catch (InterruptedException e) {
log.error("Interrupted trying to indicate a completed condition.", e);
}
}
|
[
"void",
"setComplete",
"(",
")",
"{",
"this",
".",
"complete",
"=",
"true",
";",
"try",
"{",
"// If we haven't gotten any results back, make sure to create an",
"// empty one",
"if",
"(",
"this",
".",
"states",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"this",
".",
"states",
".",
"put",
"(",
"new",
"WorldState",
"(",
")",
")",
";",
"}",
"// Special WorldState to indicate that the request has completed and",
"// interrupt",
"// any blocking threads",
"else",
"{",
"this",
".",
"states",
".",
"put",
"(",
"RESPONSE_COMPLETE",
")",
";",
"}",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Interrupted trying to indicate a completed condition.\"",
",",
"e",
")",
";",
"}",
"}"
] |
Marks this StepResponse as completed. A StepResponse is completed when all
WorldStates have been added to it, and no others will be returned by the
World Model.
|
[
"Marks",
"this",
"StepResponse",
"as",
"completed",
".",
"A",
"StepResponse",
"is",
"completed",
"when",
"all",
"WorldStates",
"have",
"been",
"added",
"to",
"it",
"and",
"no",
"others",
"will",
"be",
"returned",
"by",
"the",
"World",
"Model",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/StepResponse.java#L148-L165
|
153,775
|
jbundle/jbundle
|
thin/base/screen/cal/sample/remote/src/main/java/org/jbundle/thin/base/screen/cal/sample/remote/AppointmentCalendarApplet.java
|
AppointmentCalendarApplet.main
|
public static void main(String[] args)
{
BaseApplet.main(args);
BaseApplet applet = AppointmentCalendarApplet.getSharedInstance();
if (applet == null)
applet = new AppointmentCalendarApplet(args);
new JBaseFrame("Calendar", applet);
}
|
java
|
public static void main(String[] args)
{
BaseApplet.main(args);
BaseApplet applet = AppointmentCalendarApplet.getSharedInstance();
if (applet == null)
applet = new AppointmentCalendarApplet(args);
new JBaseFrame("Calendar", applet);
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"BaseApplet",
".",
"main",
"(",
"args",
")",
";",
"BaseApplet",
"applet",
"=",
"AppointmentCalendarApplet",
".",
"getSharedInstance",
"(",
")",
";",
"if",
"(",
"applet",
"==",
"null",
")",
"applet",
"=",
"new",
"AppointmentCalendarApplet",
"(",
"args",
")",
";",
"new",
"JBaseFrame",
"(",
"\"Calendar\"",
",",
"applet",
")",
";",
"}"
] |
For Stand-alone.
|
[
"For",
"Stand",
"-",
"alone",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/cal/sample/remote/src/main/java/org/jbundle/thin/base/screen/cal/sample/remote/AppointmentCalendarApplet.java#L101-L108
|
153,776
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/SButtonBox.java
|
SButtonBox.setSFieldValue
|
public int setSFieldValue(String strParamValue, boolean bDisplayOption, int iMoveMode)
{
String strButtonDesc = this.getButtonDesc();
String strButtonCommand = this.getButtonCommand();
if (strButtonCommand != null)
if (strButtonDesc != null)
if (strButtonDesc.equals(strParamValue))
{ // Button was pressed, do command
this.handleCommand(strButtonCommand, this, ScreenConstants.USE_NEW_WINDOW);
return DBConstants.NORMAL_RETURN;
}
// Often this is called in a report needing a value set, so set it:
return super.setSFieldValue(strParamValue, bDisplayOption, iMoveMode);
}
|
java
|
public int setSFieldValue(String strParamValue, boolean bDisplayOption, int iMoveMode)
{
String strButtonDesc = this.getButtonDesc();
String strButtonCommand = this.getButtonCommand();
if (strButtonCommand != null)
if (strButtonDesc != null)
if (strButtonDesc.equals(strParamValue))
{ // Button was pressed, do command
this.handleCommand(strButtonCommand, this, ScreenConstants.USE_NEW_WINDOW);
return DBConstants.NORMAL_RETURN;
}
// Often this is called in a report needing a value set, so set it:
return super.setSFieldValue(strParamValue, bDisplayOption, iMoveMode);
}
|
[
"public",
"int",
"setSFieldValue",
"(",
"String",
"strParamValue",
",",
"boolean",
"bDisplayOption",
",",
"int",
"iMoveMode",
")",
"{",
"String",
"strButtonDesc",
"=",
"this",
".",
"getButtonDesc",
"(",
")",
";",
"String",
"strButtonCommand",
"=",
"this",
".",
"getButtonCommand",
"(",
")",
";",
"if",
"(",
"strButtonCommand",
"!=",
"null",
")",
"if",
"(",
"strButtonDesc",
"!=",
"null",
")",
"if",
"(",
"strButtonDesc",
".",
"equals",
"(",
"strParamValue",
")",
")",
"{",
"// Button was pressed, do command",
"this",
".",
"handleCommand",
"(",
"strButtonCommand",
",",
"this",
",",
"ScreenConstants",
".",
"USE_NEW_WINDOW",
")",
";",
"return",
"DBConstants",
".",
"NORMAL_RETURN",
";",
"}",
"// Often this is called in a report needing a value set, so set it:",
"return",
"super",
".",
"setSFieldValue",
"(",
"strParamValue",
",",
"bDisplayOption",
",",
"iMoveMode",
")",
";",
"}"
] |
Set this control's converter to this HTML param.
ie., Check to see if this button was pressed.
|
[
"Set",
"this",
"control",
"s",
"converter",
"to",
"this",
"HTML",
"param",
".",
"ie",
".",
"Check",
"to",
"see",
"if",
"this",
"button",
"was",
"pressed",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/SButtonBox.java#L177-L190
|
153,777
|
Joe0/Feather
|
src/main/java/com/joepritzel/feather/PSBroker.java
|
PSBroker.subscribe
|
public <T> void subscribe(Subscriber<?> subscriber, Class<T> messageType) {
subscribeStrategy.subscribe(mapping, subscriber, messageType);
}
|
java
|
public <T> void subscribe(Subscriber<?> subscriber, Class<T> messageType) {
subscribeStrategy.subscribe(mapping, subscriber, messageType);
}
|
[
"public",
"<",
"T",
">",
"void",
"subscribe",
"(",
"Subscriber",
"<",
"?",
">",
"subscriber",
",",
"Class",
"<",
"T",
">",
"messageType",
")",
"{",
"subscribeStrategy",
".",
"subscribe",
"(",
"mapping",
",",
"subscriber",
",",
"messageType",
")",
";",
"}"
] |
Subscribes the subscriber to the given type of message.
@param <T>
- The class to subscribe to.
@param subscriber
- The subscriber.
@param messageType
- The type of message to subscribe to.
@exception SubscriberTypeMismatchException
the type the subscriber was bound to is incompatible with
the type that is being received.
|
[
"Subscribes",
"the",
"subscriber",
"to",
"the",
"given",
"type",
"of",
"message",
"."
] |
d17b1bc38326b8b86f1068898a59c8a34678d499
|
https://github.com/Joe0/Feather/blob/d17b1bc38326b8b86f1068898a59c8a34678d499/src/main/java/com/joepritzel/feather/PSBroker.java#L75-L77
|
153,778
|
Joe0/Feather
|
src/main/java/com/joepritzel/feather/PSBroker.java
|
PSBroker.unsubscribeAll
|
public <T> List<Subscriber<T>> unsubscribeAll(Class<T> messageType) {
return subscribeStrategy.unsubscribeAll(mapping, messageType);
}
|
java
|
public <T> List<Subscriber<T>> unsubscribeAll(Class<T> messageType) {
return subscribeStrategy.unsubscribeAll(mapping, messageType);
}
|
[
"public",
"<",
"T",
">",
"List",
"<",
"Subscriber",
"<",
"T",
">",
">",
"unsubscribeAll",
"(",
"Class",
"<",
"T",
">",
"messageType",
")",
"{",
"return",
"subscribeStrategy",
".",
"unsubscribeAll",
"(",
"mapping",
",",
"messageType",
")",
";",
"}"
] |
Unsubscribes all subscribers listening to the given message type.
@param <T>
- The type to unsubscribe from.
@param messageType
- The type to unsubscribe all subscribers from.
@return Returns the list of subscribers that were forced to unsubscribe.
|
[
"Unsubscribes",
"all",
"subscribers",
"listening",
"to",
"the",
"given",
"message",
"type",
"."
] |
d17b1bc38326b8b86f1068898a59c8a34678d499
|
https://github.com/Joe0/Feather/blob/d17b1bc38326b8b86f1068898a59c8a34678d499/src/main/java/com/joepritzel/feather/PSBroker.java#L88-L90
|
153,779
|
Joe0/Feather
|
src/main/java/com/joepritzel/feather/PSBroker.java
|
PSBroker.unsubscribeByTypes
|
public <S extends Subscriber<T>, T> boolean unsubscribeByTypes(
S subscriberType, Class<T> messageType) {
return subscribeStrategy.unsubscribeByTypes(mapping, subscriberType,
messageType);
}
|
java
|
public <S extends Subscriber<T>, T> boolean unsubscribeByTypes(
S subscriberType, Class<T> messageType) {
return subscribeStrategy.unsubscribeByTypes(mapping, subscriberType,
messageType);
}
|
[
"public",
"<",
"S",
"extends",
"Subscriber",
"<",
"T",
">",
",",
"T",
">",
"boolean",
"unsubscribeByTypes",
"(",
"S",
"subscriberType",
",",
"Class",
"<",
"T",
">",
"messageType",
")",
"{",
"return",
"subscribeStrategy",
".",
"unsubscribeByTypes",
"(",
"mapping",
",",
"subscriberType",
",",
"messageType",
")",
";",
"}"
] |
Forces subscribers to unsubscribe based on the given subscriber type and
message type.
@param <S>
- The type of subscriber to unsubscribe from.
@param <T>
- The type of the subscriber.
@param subscriberType
- The type of subscriber that will be forced to unsubscribe.
@param messageType
- The type of message that the subscibers will unsubscribe
from.
@return Returns true if at least one subscriber was forced to
unsubscribe. Otherwise, it returns false.
|
[
"Forces",
"subscribers",
"to",
"unsubscribe",
"based",
"on",
"the",
"given",
"subscriber",
"type",
"and",
"message",
"type",
"."
] |
d17b1bc38326b8b86f1068898a59c8a34678d499
|
https://github.com/Joe0/Feather/blob/d17b1bc38326b8b86f1068898a59c8a34678d499/src/main/java/com/joepritzel/feather/PSBroker.java#L108-L112
|
153,780
|
Joe0/Feather
|
src/main/java/com/joepritzel/feather/PSBroker.java
|
PSBroker.unsubscribe
|
public <T> boolean unsubscribe(Subscriber<T> s, Class<T> messageType) {
return subscribeStrategy.unsubscribe(mapping, s, messageType);
}
|
java
|
public <T> boolean unsubscribe(Subscriber<T> s, Class<T> messageType) {
return subscribeStrategy.unsubscribe(mapping, s, messageType);
}
|
[
"public",
"<",
"T",
">",
"boolean",
"unsubscribe",
"(",
"Subscriber",
"<",
"T",
">",
"s",
",",
"Class",
"<",
"T",
">",
"messageType",
")",
"{",
"return",
"subscribeStrategy",
".",
"unsubscribe",
"(",
"mapping",
",",
"s",
",",
"messageType",
")",
";",
"}"
] |
Forces the given subscriber to unsubscribe from the given type of
messages.
@param <T>
- The type to unsubscribe from.
@param s
- The subscriber that will be forced to unsubscribe.
@param messageType
- The type of message.
@return Returns true if the subscriber was forced to unsubscribe from the
given type pf messages.
|
[
"Forces",
"the",
"given",
"subscriber",
"to",
"unsubscribe",
"from",
"the",
"given",
"type",
"of",
"messages",
"."
] |
d17b1bc38326b8b86f1068898a59c8a34678d499
|
https://github.com/Joe0/Feather/blob/d17b1bc38326b8b86f1068898a59c8a34678d499/src/main/java/com/joepritzel/feather/PSBroker.java#L127-L129
|
153,781
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/db/event/SequenceHandler.java
|
SequenceHandler.init
|
public void init(Record record, BaseField fldDest, BaseField fldSource)
{
super.init(record, fldDest, fldSource, null, true, false, false, false, false, null, false);
}
|
java
|
public void init(Record record, BaseField fldDest, BaseField fldSource)
{
super.init(record, fldDest, fldSource, null, true, false, false, false, false, null, false);
}
|
[
"public",
"void",
"init",
"(",
"Record",
"record",
",",
"BaseField",
"fldDest",
",",
"BaseField",
"fldSource",
")",
"{",
"super",
".",
"init",
"(",
"record",
",",
"fldDest",
",",
"fldSource",
",",
"null",
",",
"true",
",",
"false",
",",
"false",
",",
"false",
",",
"false",
",",
"null",
",",
"false",
")",
";",
"}"
] |
This Constructor moves the source field to the dest field on valid.
@param record My owner (usually passed as null, and set on addListener in setOwner()).
@param pfldDest tour.field.BaseField The destination field.
@param fldSource The source field.
|
[
"This",
"Constructor",
"moves",
"the",
"source",
"field",
"to",
"the",
"dest",
"field",
"on",
"valid",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/event/SequenceHandler.java#L55-L58
|
153,782
|
NessComputing/components-ness-lifecycle
|
src/main/java/com/nesscomputing/lifecycle/guice/AbstractLifecycleProvider.java
|
AbstractLifecycleProvider.addAction
|
@Override
public void addAction(final LifecycleStage stage, final LifecycleAction<T> action)
{
stageEvents.add(new StageEvent(stage, action));
}
|
java
|
@Override
public void addAction(final LifecycleStage stage, final LifecycleAction<T> action)
{
stageEvents.add(new StageEvent(stage, action));
}
|
[
"@",
"Override",
"public",
"void",
"addAction",
"(",
"final",
"LifecycleStage",
"stage",
",",
"final",
"LifecycleAction",
"<",
"T",
">",
"action",
")",
"{",
"stageEvents",
".",
"add",
"(",
"new",
"StageEvent",
"(",
"stage",
",",
"action",
")",
")",
";",
"}"
] |
Add a lifecycle Action to this provider. The action will called back when the lifecycle stage is
hit and contain an object that was created by the provider.
|
[
"Add",
"a",
"lifecycle",
"Action",
"to",
"this",
"provider",
".",
"The",
"action",
"will",
"called",
"back",
"when",
"the",
"lifecycle",
"stage",
"is",
"hit",
"and",
"contain",
"an",
"object",
"that",
"was",
"created",
"by",
"the",
"provider",
"."
] |
6c8ae8ec8fdcd16b30383092ce9e70424a6760f1
|
https://github.com/NessComputing/components-ness-lifecycle/blob/6c8ae8ec8fdcd16b30383092ce9e70424a6760f1/src/main/java/com/nesscomputing/lifecycle/guice/AbstractLifecycleProvider.java#L46-L50
|
153,783
|
eliwan/ew-profiling
|
profiling-core/src/main/java/be/eliwan/profiling/jdbc/ProfilingDriver.java
|
ProfilingDriver.register
|
static void register(String group, long durationMillis) {
for (ProfilingListener listener : LISTENERS) {
listener.register(group, durationMillis);
}
}
|
java
|
static void register(String group, long durationMillis) {
for (ProfilingListener listener : LISTENERS) {
listener.register(group, durationMillis);
}
}
|
[
"static",
"void",
"register",
"(",
"String",
"group",
",",
"long",
"durationMillis",
")",
"{",
"for",
"(",
"ProfilingListener",
"listener",
":",
"LISTENERS",
")",
"{",
"listener",
".",
"register",
"(",
"group",
",",
"durationMillis",
")",
";",
"}",
"}"
] |
Register a duration in milliseconds for running a JDBC method.
@param group indication of type of command.
@param durationMillis duration in milliseconds
|
[
"Register",
"a",
"duration",
"in",
"milliseconds",
"for",
"running",
"a",
"JDBC",
"method",
"."
] |
3315a0038de967fceb2f4be3c29393857d7b15a2
|
https://github.com/eliwan/ew-profiling/blob/3315a0038de967fceb2f4be3c29393857d7b15a2/profiling-core/src/main/java/be/eliwan/profiling/jdbc/ProfilingDriver.java#L56-L60
|
153,784
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/client/ClientWorldModelInterface.java
|
ClientWorldModelInterface.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().setIdleTime(IdleStatus.WRITER_IDLE,
ClientWorldModelInterface.TIMEOUT_PERIOD / 2);
// this.connector.getSessionConfig().setIdleTime(IdleStatus.READER_IDLE,
// (int) (ClientWorldModelInterface.TIMEOUT_PERIOD * 1.1f));
if (!this.connector.getFilterChain().contains(
WorldModelClientProtocolCodecFactory.CODEC_NAME)) {
this.connector.getFilterChain().addLast(
WorldModelClientProtocolCodecFactory.CODEC_NAME,
new ProtocolCodecFilter(
new WorldModelClientProtocolCodecFactory(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().setIdleTime(IdleStatus.WRITER_IDLE,
ClientWorldModelInterface.TIMEOUT_PERIOD / 2);
// this.connector.getSessionConfig().setIdleTime(IdleStatus.READER_IDLE,
// (int) (ClientWorldModelInterface.TIMEOUT_PERIOD * 1.1f));
if (!this.connector.getFilterChain().contains(
WorldModelClientProtocolCodecFactory.CODEC_NAME)) {
this.connector.getFilterChain().addLast(
WorldModelClientProtocolCodecFactory.CODEC_NAME,
new ProtocolCodecFilter(
new WorldModelClientProtocolCodecFactory(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",
"(",
")",
".",
"setIdleTime",
"(",
"IdleStatus",
".",
"WRITER_IDLE",
",",
"ClientWorldModelInterface",
".",
"TIMEOUT_PERIOD",
"/",
"2",
")",
";",
"// this.connector.getSessionConfig().setIdleTime(IdleStatus.READER_IDLE,",
"// (int) (ClientWorldModelInterface.TIMEOUT_PERIOD * 1.1f));",
"if",
"(",
"!",
"this",
".",
"connector",
".",
"getFilterChain",
"(",
")",
".",
"contains",
"(",
"WorldModelClientProtocolCodecFactory",
".",
"CODEC_NAME",
")",
")",
"{",
"this",
".",
"connector",
".",
"getFilterChain",
"(",
")",
".",
"addLast",
"(",
"WorldModelClientProtocolCodecFactory",
".",
"CODEC_NAME",
",",
"new",
"ProtocolCodecFilter",
"(",
"new",
"WorldModelClientProtocolCodecFactory",
"(",
"true",
")",
")",
")",
";",
"}",
"this",
".",
"connector",
".",
"getFilterChain",
"(",
")",
".",
"addLast",
"(",
"\"ExecutorPool\"",
",",
"this",
".",
"executors",
")",
";",
"this",
".",
"connector",
".",
"setHandler",
"(",
"this",
".",
"ioHandler",
")",
";",
"log",
".",
"debug",
"(",
"\"Connector set up successful.\"",
")",
";",
"return",
"true",
";",
"}"
] |
Sets-up the connector for this MINA session.
@return {@code true} if the setup succeeds, else {@code false}.
|
[
"Sets",
"-",
"up",
"the",
"connector",
"for",
"this",
"MINA",
"session",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/ClientWorldModelInterface.java#L229-L258
|
153,785
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/client/ClientWorldModelInterface.java
|
ClientWorldModelInterface.finishConnection
|
void finishConnection() {
NioSocketConnector conn = this.connector;
if (conn != null) {
this.connector = null;
conn.dispose();
for (ConnectionListener listener : this.connectionListeners) {
listener.connectionEnded(this);
}
}
ExecutorFilter execs = this.executors;
if (execs != null) {
this.executors = null;
execs.destroy();
}
}
|
java
|
void finishConnection() {
NioSocketConnector conn = this.connector;
if (conn != null) {
this.connector = null;
conn.dispose();
for (ConnectionListener listener : this.connectionListeners) {
listener.connectionEnded(this);
}
}
ExecutorFilter execs = this.executors;
if (execs != null) {
this.executors = null;
execs.destroy();
}
}
|
[
"void",
"finishConnection",
"(",
")",
"{",
"NioSocketConnector",
"conn",
"=",
"this",
".",
"connector",
";",
"if",
"(",
"conn",
"!=",
"null",
")",
"{",
"this",
".",
"connector",
"=",
"null",
";",
"conn",
".",
"dispose",
"(",
")",
";",
"for",
"(",
"ConnectionListener",
"listener",
":",
"this",
".",
"connectionListeners",
")",
"{",
"listener",
".",
"connectionEnded",
"(",
"this",
")",
";",
"}",
"}",
"ExecutorFilter",
"execs",
"=",
"this",
".",
"executors",
";",
"if",
"(",
"execs",
"!=",
"null",
")",
"{",
"this",
".",
"executors",
"=",
"null",
";",
"execs",
".",
"destroy",
"(",
")",
";",
"}",
"}"
] |
Cleans-up any resources after a connection has terminated. Should be called
when the connection is disconnected and reconnect is not desired.
|
[
"Cleans",
"-",
"up",
"any",
"resources",
"after",
"a",
"connection",
"has",
"terminated",
".",
"Should",
"be",
"called",
"when",
"the",
"connection",
"is",
"disconnected",
"and",
"reconnect",
"is",
"not",
"desired",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/ClientWorldModelInterface.java#L328-L343
|
153,786
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/client/ClientWorldModelInterface.java
|
ClientWorldModelInterface._connect
|
protected boolean _connect(long timeout) {
log.debug("Attempting connection...");
ConnectFuture connFuture = this.connector.connect(new InetSocketAddress(
this.host, this.port));
if (!connFuture.awaitUninterruptibly(timeout)) {
log.warn("Unable to connect to world model after {}ms.",
Long.valueOf(this.connectionTimeout));
return false;
}
if (!connFuture.isConnected()) {
log.debug("Failed to connect.");
return false;
}
try {
log.debug("Attempting connection to {}:{}.", this.host,
Integer.valueOf(this.port));
this.session = connFuture.getSession();
} catch (RuntimeIoException ioe) {
log.error(String.format(
"Could not create session to World Model (C) %s:%d.", this.host,
Integer.valueOf(this.port)), ioe);
return false;
}
return true;
}
|
java
|
protected boolean _connect(long timeout) {
log.debug("Attempting connection...");
ConnectFuture connFuture = this.connector.connect(new InetSocketAddress(
this.host, this.port));
if (!connFuture.awaitUninterruptibly(timeout)) {
log.warn("Unable to connect to world model after {}ms.",
Long.valueOf(this.connectionTimeout));
return false;
}
if (!connFuture.isConnected()) {
log.debug("Failed to connect.");
return false;
}
try {
log.debug("Attempting connection to {}:{}.", this.host,
Integer.valueOf(this.port));
this.session = connFuture.getSession();
} catch (RuntimeIoException ioe) {
log.error(String.format(
"Could not create session to World Model (C) %s:%d.", this.host,
Integer.valueOf(this.port)), ioe);
return false;
}
return true;
}
|
[
"protected",
"boolean",
"_connect",
"(",
"long",
"timeout",
")",
"{",
"log",
".",
"debug",
"(",
"\"Attempting connection...\"",
")",
";",
"ConnectFuture",
"connFuture",
"=",
"this",
".",
"connector",
".",
"connect",
"(",
"new",
"InetSocketAddress",
"(",
"this",
".",
"host",
",",
"this",
".",
"port",
")",
")",
";",
"if",
"(",
"!",
"connFuture",
".",
"awaitUninterruptibly",
"(",
"timeout",
")",
")",
"{",
"log",
".",
"warn",
"(",
"\"Unable to connect to world model after {}ms.\"",
",",
"Long",
".",
"valueOf",
"(",
"this",
".",
"connectionTimeout",
")",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"connFuture",
".",
"isConnected",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"Failed to connect.\"",
")",
";",
"return",
"false",
";",
"}",
"try",
"{",
"log",
".",
"debug",
"(",
"\"Attempting connection to {}:{}.\"",
",",
"this",
".",
"host",
",",
"Integer",
".",
"valueOf",
"(",
"this",
".",
"port",
")",
")",
";",
"this",
".",
"session",
"=",
"connFuture",
".",
"getSession",
"(",
")",
";",
"}",
"catch",
"(",
"RuntimeIoException",
"ioe",
")",
"{",
"log",
".",
"error",
"(",
"String",
".",
"format",
"(",
"\"Could not create session to World Model (C) %s:%d.\"",
",",
"this",
".",
"host",
",",
"Integer",
".",
"valueOf",
"(",
"this",
".",
"port",
")",
")",
",",
"ioe",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Attempts a connection to the world model.
@param timeout
the connection timeout value in milliseconds.
@return {@code true} if the attempt succeeds, else {@code false}.
|
[
"Attempts",
"a",
"connection",
"to",
"the",
"world",
"model",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/ClientWorldModelInterface.java#L362-L387
|
153,787
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/client/ClientWorldModelInterface.java
|
ClientWorldModelInterface._disconnect
|
protected void _disconnect() {
IoSession currentSession = this.session;
this.session = null;
this.sentHandshake = null;
this.receivedHandshake = null;
this.attributeAliasValues.clear();
this.originAliasValues.clear();
if (currentSession != null && !currentSession.isClosing()) {
log.info(
"Closing connection to World Model (client) at {} (waiting {}ms).",
currentSession.getRemoteAddress(),
Long.valueOf(this.connectionTimeout));
while (!currentSession.close(false).awaitUninterruptibly(
this.connectionTimeout)) {
log.error("Connection didn't close after {}ms.",
Long.valueOf(this.connectionTimeout));
}
}
if (currentSession != null) {
for (ConnectionListener listener : this.connectionListeners) {
listener.connectionInterrupted(this);
}
}
}
|
java
|
protected void _disconnect() {
IoSession currentSession = this.session;
this.session = null;
this.sentHandshake = null;
this.receivedHandshake = null;
this.attributeAliasValues.clear();
this.originAliasValues.clear();
if (currentSession != null && !currentSession.isClosing()) {
log.info(
"Closing connection to World Model (client) at {} (waiting {}ms).",
currentSession.getRemoteAddress(),
Long.valueOf(this.connectionTimeout));
while (!currentSession.close(false).awaitUninterruptibly(
this.connectionTimeout)) {
log.error("Connection didn't close after {}ms.",
Long.valueOf(this.connectionTimeout));
}
}
if (currentSession != null) {
for (ConnectionListener listener : this.connectionListeners) {
listener.connectionInterrupted(this);
}
}
}
|
[
"protected",
"void",
"_disconnect",
"(",
")",
"{",
"IoSession",
"currentSession",
"=",
"this",
".",
"session",
";",
"this",
".",
"session",
"=",
"null",
";",
"this",
".",
"sentHandshake",
"=",
"null",
";",
"this",
".",
"receivedHandshake",
"=",
"null",
";",
"this",
".",
"attributeAliasValues",
".",
"clear",
"(",
")",
";",
"this",
".",
"originAliasValues",
".",
"clear",
"(",
")",
";",
"if",
"(",
"currentSession",
"!=",
"null",
"&&",
"!",
"currentSession",
".",
"isClosing",
"(",
")",
")",
"{",
"log",
".",
"info",
"(",
"\"Closing connection to World Model (client) at {} (waiting {}ms).\"",
",",
"currentSession",
".",
"getRemoteAddress",
"(",
")",
",",
"Long",
".",
"valueOf",
"(",
"this",
".",
"connectionTimeout",
")",
")",
";",
"while",
"(",
"!",
"currentSession",
".",
"close",
"(",
"false",
")",
".",
"awaitUninterruptibly",
"(",
"this",
".",
"connectionTimeout",
")",
")",
"{",
"log",
".",
"error",
"(",
"\"Connection didn't close after {}ms.\"",
",",
"Long",
".",
"valueOf",
"(",
"this",
".",
"connectionTimeout",
")",
")",
";",
"}",
"}",
"if",
"(",
"currentSession",
"!=",
"null",
")",
"{",
"for",
"(",
"ConnectionListener",
"listener",
":",
"this",
".",
"connectionListeners",
")",
"{",
"listener",
".",
"connectionInterrupted",
"(",
"this",
")",
";",
"}",
"}",
"}"
] |
Disconnects from the world model.
|
[
"Disconnects",
"from",
"the",
"world",
"model",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/ClientWorldModelInterface.java#L392-L418
|
153,788
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/client/ClientWorldModelInterface.java
|
ClientWorldModelInterface.sendMessage
|
public synchronized long sendMessage(AbstractRequestMessage message) {
log.debug("Sending {} to {}", message, this);
message.setTicketNumber(this.nextTicketNumber.getAndIncrement());
this.outstandingRequests.put(Long.valueOf(message.getTicketNumber()),
message);
this.session.write(message);
return message.getTicketNumber();
}
|
java
|
public synchronized long sendMessage(AbstractRequestMessage message) {
log.debug("Sending {} to {}", message, this);
message.setTicketNumber(this.nextTicketNumber.getAndIncrement());
this.outstandingRequests.put(Long.valueOf(message.getTicketNumber()),
message);
this.session.write(message);
return message.getTicketNumber();
}
|
[
"public",
"synchronized",
"long",
"sendMessage",
"(",
"AbstractRequestMessage",
"message",
")",
"{",
"log",
".",
"debug",
"(",
"\"Sending {} to {}\"",
",",
"message",
",",
"this",
")",
";",
"message",
".",
"setTicketNumber",
"(",
"this",
".",
"nextTicketNumber",
".",
"getAndIncrement",
"(",
")",
")",
";",
"this",
".",
"outstandingRequests",
".",
"put",
"(",
"Long",
".",
"valueOf",
"(",
"message",
".",
"getTicketNumber",
"(",
")",
")",
",",
"message",
")",
";",
"this",
".",
"session",
".",
"write",
"(",
"message",
")",
";",
"return",
"message",
".",
"getTicketNumber",
"(",
")",
";",
"}"
] |
Sends a request message to the world model.
@param message
the message to send.
@return the ticket number of the request.
|
[
"Sends",
"a",
"request",
"message",
"to",
"the",
"world",
"model",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/ClientWorldModelInterface.java#L670-L677
|
153,789
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/client/ClientWorldModelInterface.java
|
ClientWorldModelInterface.cancelRequest
|
public void cancelRequest(long ticketNumber) {
if (this.session != null
&& this.outstandingRequests.containsKey(Long.valueOf(ticketNumber))) {
CancelRequestMessage message = new CancelRequestMessage();
message.setTicketNumber(ticketNumber);
this.session.write(message);
} else {
log.warn("Tried to cancel unknown request for ticket number {}.",
Long.valueOf(ticketNumber));
}
}
|
java
|
public void cancelRequest(long ticketNumber) {
if (this.session != null
&& this.outstandingRequests.containsKey(Long.valueOf(ticketNumber))) {
CancelRequestMessage message = new CancelRequestMessage();
message.setTicketNumber(ticketNumber);
this.session.write(message);
} else {
log.warn("Tried to cancel unknown request for ticket number {}.",
Long.valueOf(ticketNumber));
}
}
|
[
"public",
"void",
"cancelRequest",
"(",
"long",
"ticketNumber",
")",
"{",
"if",
"(",
"this",
".",
"session",
"!=",
"null",
"&&",
"this",
".",
"outstandingRequests",
".",
"containsKey",
"(",
"Long",
".",
"valueOf",
"(",
"ticketNumber",
")",
")",
")",
"{",
"CancelRequestMessage",
"message",
"=",
"new",
"CancelRequestMessage",
"(",
")",
";",
"message",
".",
"setTicketNumber",
"(",
"ticketNumber",
")",
";",
"this",
".",
"session",
".",
"write",
"(",
"message",
")",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"\"Tried to cancel unknown request for ticket number {}.\"",
",",
"Long",
".",
"valueOf",
"(",
"ticketNumber",
")",
")",
";",
"}",
"}"
] |
Cancels the request with the specified ticket number. Does nothing if the
ticket is already complete or the ticket number doesn't match an existing
request.
@param ticketNumber
the ticket number of the request to cancel.
|
[
"Cancels",
"the",
"request",
"with",
"the",
"specified",
"ticket",
"number",
".",
"Does",
"nothing",
"if",
"the",
"ticket",
"is",
"already",
"complete",
"or",
"the",
"ticket",
"number",
"doesn",
"t",
"match",
"an",
"existing",
"request",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/ClientWorldModelInterface.java#L687-L697
|
153,790
|
OwlPlatform/java-owl-worldmodel
|
src/main/java/com/owlplatform/worldmodel/client/ClientWorldModelInterface.java
|
ClientWorldModelInterface.searchIdRegex
|
public boolean searchIdRegex(final String idRegex) {
if (idRegex == null) {
log.error("Unable to search for a null Identifier regex.");
return false;
}
IdSearchMessage message = new IdSearchMessage();
message.setIdRegex(idRegex);
this.session.write(message);
log.debug("Sent {}", message);
return true;
}
|
java
|
public boolean searchIdRegex(final String idRegex) {
if (idRegex == null) {
log.error("Unable to search for a null Identifier regex.");
return false;
}
IdSearchMessage message = new IdSearchMessage();
message.setIdRegex(idRegex);
this.session.write(message);
log.debug("Sent {}", message);
return true;
}
|
[
"public",
"boolean",
"searchIdRegex",
"(",
"final",
"String",
"idRegex",
")",
"{",
"if",
"(",
"idRegex",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Unable to search for a null Identifier regex.\"",
")",
";",
"return",
"false",
";",
"}",
"IdSearchMessage",
"message",
"=",
"new",
"IdSearchMessage",
"(",
")",
";",
"message",
".",
"setIdRegex",
"(",
"idRegex",
")",
";",
"this",
".",
"session",
".",
"write",
"(",
"message",
")",
";",
"log",
".",
"debug",
"(",
"\"Sent {}\"",
",",
"message",
")",
";",
"return",
"true",
";",
"}"
] |
Search for an Identifier regular expression.
@param idRegex
the regular expression to search.
@return {@code true} if the request was sent, else {@code false}.
|
[
"Search",
"for",
"an",
"Identifier",
"regular",
"expression",
"."
] |
a850e8b930c6e9787c7cad30c0de887858ca563d
|
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/ClientWorldModelInterface.java#L807-L818
|
153,791
|
wigforss/Ka-Commons-Reflection
|
src/main/java/org/kasource/commons/reflection/util/ClassUtils.java
|
ClassUtils.getInterface
|
public static Class<?> getInterface(Class<?> target, ClassFilter filter) {
Set<Class<?>> interfaces = getInterfaces(target, filter);
if (!interfaces.isEmpty()) {
return interfaces.iterator().next();
}
return null;
}
|
java
|
public static Class<?> getInterface(Class<?> target, ClassFilter filter) {
Set<Class<?>> interfaces = getInterfaces(target, filter);
if (!interfaces.isEmpty()) {
return interfaces.iterator().next();
}
return null;
}
|
[
"public",
"static",
"Class",
"<",
"?",
">",
"getInterface",
"(",
"Class",
"<",
"?",
">",
"target",
",",
"ClassFilter",
"filter",
")",
"{",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"interfaces",
"=",
"getInterfaces",
"(",
"target",
",",
"filter",
")",
";",
"if",
"(",
"!",
"interfaces",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"interfaces",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the interface from target class that passes the supplied filter.
This method also inspects any interfaces implemented by super classes.
If no interface is found null is returned.
@param filter The class filter to use.
@return the interface from target class that passes the supplied filter, may
be null if no match is found.
|
[
"Returns",
"the",
"interface",
"from",
"target",
"class",
"that",
"passes",
"the",
"supplied",
"filter",
".",
"This",
"method",
"also",
"inspects",
"any",
"interfaces",
"implemented",
"by",
"super",
"classes",
"."
] |
a80f7a164cd800089e4f4dd948ca6f0e7badcf33
|
https://github.com/wigforss/Ka-Commons-Reflection/blob/a80f7a164cd800089e4f4dd948ca6f0e7badcf33/src/main/java/org/kasource/commons/reflection/util/ClassUtils.java#L82-L88
|
153,792
|
wigforss/Ka-Commons-Reflection
|
src/main/java/org/kasource/commons/reflection/util/ClassUtils.java
|
ClassUtils.getDeclaredInterfaces
|
public static Set<Class<?>> getDeclaredInterfaces(Class<?> clazz, ClassFilter filter) {
Set<Class<?>> interfacesFound = new HashSet<Class<?>>();
Class<?>[] interfaces = clazz.getInterfaces();
for(Class<?> interfaceClass : interfaces) {
if(filter.passFilter(interfaceClass)) {
interfacesFound.add(interfaceClass);
}
}
return interfacesFound;
}
|
java
|
public static Set<Class<?>> getDeclaredInterfaces(Class<?> clazz, ClassFilter filter) {
Set<Class<?>> interfacesFound = new HashSet<Class<?>>();
Class<?>[] interfaces = clazz.getInterfaces();
for(Class<?> interfaceClass : interfaces) {
if(filter.passFilter(interfaceClass)) {
interfacesFound.add(interfaceClass);
}
}
return interfacesFound;
}
|
[
"public",
"static",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"getDeclaredInterfaces",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"ClassFilter",
"filter",
")",
"{",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"interfacesFound",
"=",
"new",
"HashSet",
"<",
"Class",
"<",
"?",
">",
">",
"(",
")",
";",
"Class",
"<",
"?",
">",
"[",
"]",
"interfaces",
"=",
"clazz",
".",
"getInterfaces",
"(",
")",
";",
"for",
"(",
"Class",
"<",
"?",
">",
"interfaceClass",
":",
"interfaces",
")",
"{",
"if",
"(",
"filter",
".",
"passFilter",
"(",
"interfaceClass",
")",
")",
"{",
"interfacesFound",
".",
"add",
"(",
"interfaceClass",
")",
";",
"}",
"}",
"return",
"interfacesFound",
";",
"}"
] |
Returns a set of interfaces that the from clazz that passes the supplied filter.
@param clazz The class to inspect
@param filter The class filter to use.
@return all Interface classes from clazz that passes the filter.
|
[
"Returns",
"a",
"set",
"of",
"interfaces",
"that",
"the",
"from",
"clazz",
"that",
"passes",
"the",
"supplied",
"filter",
"."
] |
a80f7a164cd800089e4f4dd948ca6f0e7badcf33
|
https://github.com/wigforss/Ka-Commons-Reflection/blob/a80f7a164cd800089e4f4dd948ca6f0e7badcf33/src/main/java/org/kasource/commons/reflection/util/ClassUtils.java#L99-L109
|
153,793
|
wigforss/Ka-Commons-Reflection
|
src/main/java/org/kasource/commons/reflection/util/ClassUtils.java
|
ClassUtils.loadClass
|
@SuppressWarnings("unchecked")
public static <T> Class<? extends T> loadClass(String className, Class<T> ofType) {
try {
Class<?> clazz = Class.forName(className);
if(ofType == null || ! ofType.isAssignableFrom(clazz)) {
throw new IllegalArgumentException("Class " + className + " must extend or implement " + ofType + "!");
}
return (Class<? extends T>) clazz;
}catch (ClassNotFoundException cnfe) {
throw new IllegalArgumentException("Class " + className + " could not be found!", cnfe);
}
}
|
java
|
@SuppressWarnings("unchecked")
public static <T> Class<? extends T> loadClass(String className, Class<T> ofType) {
try {
Class<?> clazz = Class.forName(className);
if(ofType == null || ! ofType.isAssignableFrom(clazz)) {
throw new IllegalArgumentException("Class " + className + " must extend or implement " + ofType + "!");
}
return (Class<? extends T>) clazz;
}catch (ClassNotFoundException cnfe) {
throw new IllegalArgumentException("Class " + className + " could not be found!", cnfe);
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"Class",
"<",
"?",
"extends",
"T",
">",
"loadClass",
"(",
"String",
"className",
",",
"Class",
"<",
"T",
">",
"ofType",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"className",
")",
";",
"if",
"(",
"ofType",
"==",
"null",
"||",
"!",
"ofType",
".",
"isAssignableFrom",
"(",
"clazz",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Class \"",
"+",
"className",
"+",
"\" must extend or implement \"",
"+",
"ofType",
"+",
"\"!\"",
")",
";",
"}",
"return",
"(",
"Class",
"<",
"?",
"extends",
"T",
">",
")",
"clazz",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"cnfe",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Class \"",
"+",
"className",
"+",
"\" could not be found!\"",
",",
"cnfe",
")",
";",
"}",
"}"
] |
Loads and returns the class named className of type superClass.
@param <T> Type of the class
@param className Name of the class to load
@param superClass Type of the class to load
@return The loaded class of type superClass.
@throws IllegalArgumentException if the class with className could not be loaded or
if the that class does not extend the class supplied in the superClass parameter.
|
[
"Loads",
"and",
"returns",
"the",
"class",
"named",
"className",
"of",
"type",
"superClass",
"."
] |
a80f7a164cd800089e4f4dd948ca6f0e7badcf33
|
https://github.com/wigforss/Ka-Commons-Reflection/blob/a80f7a164cd800089e4f4dd948ca6f0e7badcf33/src/main/java/org/kasource/commons/reflection/util/ClassUtils.java#L123-L135
|
153,794
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.search
|
public static <E> int search(E[] array, E value) {
return LinearSearch.search(array, value, 1);
}
|
java
|
public static <E> int search(E[] array, E value) {
return LinearSearch.search(array, value, 1);
}
|
[
"public",
"static",
"<",
"E",
">",
"int",
"search",
"(",
"E",
"[",
"]",
"array",
",",
"E",
"value",
")",
"{",
"return",
"LinearSearch",
".",
"search",
"(",
"array",
",",
"value",
",",
"1",
")",
";",
"}"
] |
Search for the value in the array and return the index of the first occurrence from the
beginning of the array.
@param <E> the type of elements in this array.
@param array array that we are searching in.
@param value value that is being searched in the array.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"beginning",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L37-L39
|
153,795
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.searchLast
|
public static <E> int searchLast(E[] array, E value) {
return LinearSearch.searchLast(array, value, 1);
}
|
java
|
public static <E> int searchLast(E[] array, E value) {
return LinearSearch.searchLast(array, value, 1);
}
|
[
"public",
"static",
"<",
"E",
">",
"int",
"searchLast",
"(",
"E",
"[",
"]",
"array",
",",
"E",
"value",
")",
"{",
"return",
"LinearSearch",
".",
"searchLast",
"(",
"array",
",",
"value",
",",
"1",
")",
";",
"}"
] |
Search for the value in the array and return the index of the first occurrence from the
end of the array
@param <E> the type of elements in this array.
@param array array that we are searching in.
@param value value that is being searched in the array.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"end",
"of",
"the",
"array"
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L160-L162
|
153,796
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.search
|
public static <E> int search(E[] array, E value, int occurrence) {
if(occurrence <= 0) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < array.length; i++) {
if(array[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static <E> int search(E[] array, E value, int occurrence) {
if(occurrence <= 0) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < array.length; i++) {
if(array[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"<",
"E",
">",
"int",
"search",
"(",
"E",
"[",
"]",
"array",
",",
"E",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"array",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the array and return the index of the specified occurrence from the
beginning of the array.
@param <E> the type of elements in this array.
@param array array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"specified",
"occurrence",
"from",
"the",
"beginning",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L284-L303
|
153,797
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.searchMin
|
public static <E extends Comparable<E>> E searchMin(List<E> list) {
if(list.size() == 0) {
throw new IllegalArgumentException("The list you provided does not have any elements");
}
E min = list.get(0);
for(int i = 1; i < list.size(); i++) {
if(list.get(i).compareTo(min) < 0) {
min = list.get(i);
}
}
return min;
}
|
java
|
public static <E extends Comparable<E>> E searchMin(List<E> list) {
if(list.size() == 0) {
throw new IllegalArgumentException("The list you provided does not have any elements");
}
E min = list.get(0);
for(int i = 1; i < list.size(); i++) {
if(list.get(i).compareTo(min) < 0) {
min = list.get(i);
}
}
return min;
}
|
[
"public",
"static",
"<",
"E",
"extends",
"Comparable",
"<",
"E",
">",
">",
"E",
"searchMin",
"(",
"List",
"<",
"E",
">",
"list",
")",
"{",
"if",
"(",
"list",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The list you provided does not have any elements\"",
")",
";",
"}",
"E",
"min",
"=",
"list",
".",
"get",
"(",
"0",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"list",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"list",
".",
"get",
"(",
"i",
")",
".",
"compareTo",
"(",
"min",
")",
"<",
"0",
")",
"{",
"min",
"=",
"list",
".",
"get",
"(",
"i",
")",
";",
"}",
"}",
"return",
"min",
";",
"}"
] |
Search for the minimum element in the list.
@param <E> the type of elements in this list.
@param list list that we are searching in.
@return the minimum element in the list.
|
[
"Search",
"for",
"the",
"minimum",
"element",
"in",
"the",
"list",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L450-L461
|
153,798
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.searchMax
|
public static <E extends Comparable<E>> E searchMax(List<E> list) {
if(list.size() == 0) {
throw new IllegalArgumentException("The list you provided does not have any elements");
}
E max = list.get(0);
for(int i = 1; i < list.size(); i++) {
if(list.get(i).compareTo(max) > 0 ) {
max = list.get(i);
}
}
return max;
}
|
java
|
public static <E extends Comparable<E>> E searchMax(List<E> list) {
if(list.size() == 0) {
throw new IllegalArgumentException("The list you provided does not have any elements");
}
E max = list.get(0);
for(int i = 1; i < list.size(); i++) {
if(list.get(i).compareTo(max) > 0 ) {
max = list.get(i);
}
}
return max;
}
|
[
"public",
"static",
"<",
"E",
"extends",
"Comparable",
"<",
"E",
">",
">",
"E",
"searchMax",
"(",
"List",
"<",
"E",
">",
"list",
")",
"{",
"if",
"(",
"list",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The list you provided does not have any elements\"",
")",
";",
"}",
"E",
"max",
"=",
"list",
".",
"get",
"(",
"0",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"list",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"list",
".",
"get",
"(",
"i",
")",
".",
"compareTo",
"(",
"max",
")",
">",
"0",
")",
"{",
"max",
"=",
"list",
".",
"get",
"(",
"i",
")",
";",
"}",
"}",
"return",
"max",
";",
"}"
] |
Search for the maximum element in the list.
@param <E> the type of elements in this list.
@param list list that we are searching in.
@return the maximum element in the list.
|
[
"Search",
"for",
"the",
"maximum",
"element",
"in",
"the",
"list",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L501-L513
|
153,799
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.search
|
public static int search(int[] intArray, int value, int occurrence) {
if(occurrence <= 0 || occurrence > intArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < intArray.length; i++) {
if(intArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static int search(int[] intArray, int value, int occurrence) {
if(occurrence <= 0 || occurrence > intArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < intArray.length; i++) {
if(intArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"int",
"search",
"(",
"int",
"[",
"]",
"intArray",
",",
"int",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"intArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"intArray",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"intArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the int array and return the index of the specified occurrence from the
beginning of the array.
@param intArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"int",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"specified",
"occurrence",
"from",
"the",
"beginning",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L554-L573
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.