repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
JetBrains/xodus | entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java | PersistentEntityStoreImpl.getEntityTypeId | @Deprecated
public int getEntityTypeId(@NotNull final String entityType, final boolean allowCreate) {
return getEntityTypeId(txnProvider, entityType, allowCreate);
} | java | @Deprecated
public int getEntityTypeId(@NotNull final String entityType, final boolean allowCreate) {
return getEntityTypeId(txnProvider, entityType, allowCreate);
} | [
"@",
"Deprecated",
"public",
"int",
"getEntityTypeId",
"(",
"@",
"NotNull",
"final",
"String",
"entityType",
",",
"final",
"boolean",
"allowCreate",
")",
"{",
"return",
"getEntityTypeId",
"(",
"txnProvider",
",",
"entityType",
",",
"allowCreate",
")",
";",
"}"
] | Gets or creates id of the entity type.
@param entityType entity type name.
@param allowCreate if set to true and if there is no entity type like entityType,
create the new id for the entityType.
@return entity type id. | [
"Gets",
"or",
"creates",
"id",
"of",
"the",
"entity",
"type",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java#L1587-L1590 | train |
JetBrains/xodus | entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java | PersistentEntityStoreImpl.getPropertyId | public int getPropertyId(@NotNull final PersistentStoreTransaction txn, @NotNull final String propertyName, final boolean allowCreate) {
return allowCreate ? propertyIds.getOrAllocateId(txn, propertyName) : propertyIds.getId(txn, propertyName);
} | java | public int getPropertyId(@NotNull final PersistentStoreTransaction txn, @NotNull final String propertyName, final boolean allowCreate) {
return allowCreate ? propertyIds.getOrAllocateId(txn, propertyName) : propertyIds.getId(txn, propertyName);
} | [
"public",
"int",
"getPropertyId",
"(",
"@",
"NotNull",
"final",
"PersistentStoreTransaction",
"txn",
",",
"@",
"NotNull",
"final",
"String",
"propertyName",
",",
"final",
"boolean",
"allowCreate",
")",
"{",
"return",
"allowCreate",
"?",
"propertyIds",
".",
"getOrA... | Gets id of a property and creates the new one if necessary.
@param txn transaction
@param propertyName name of the property.
@param allowCreate if set to true and if there is no property named as propertyName,
create the new id for the propertyName.
@return < 0 if there is no such property and create=false, else id of the property | [
"Gets",
"id",
"of",
"a",
"property",
"and",
"creates",
"the",
"new",
"one",
"if",
"necessary",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java#L1725-L1727 | train |
JetBrains/xodus | entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java | PersistentEntityStoreImpl.getLinkId | public int getLinkId(@NotNull final PersistentStoreTransaction txn, @NotNull final String linkName, final boolean allowCreate) {
return allowCreate ? linkIds.getOrAllocateId(txn, linkName) : linkIds.getId(txn, linkName);
} | java | public int getLinkId(@NotNull final PersistentStoreTransaction txn, @NotNull final String linkName, final boolean allowCreate) {
return allowCreate ? linkIds.getOrAllocateId(txn, linkName) : linkIds.getId(txn, linkName);
} | [
"public",
"int",
"getLinkId",
"(",
"@",
"NotNull",
"final",
"PersistentStoreTransaction",
"txn",
",",
"@",
"NotNull",
"final",
"String",
"linkName",
",",
"final",
"boolean",
"allowCreate",
")",
"{",
"return",
"allowCreate",
"?",
"linkIds",
".",
"getOrAllocateId",
... | Gets id of a link and creates the new one if necessary.
@param linkName name of the link.
@param allowCreate if set to true and if there is no link named as linkName,
create the new id for the linkName.
@return < 0 if there is no such link and create=false, else id of the link | [
"Gets",
"id",
"of",
"a",
"link",
"and",
"creates",
"the",
"new",
"one",
"if",
"necessary",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java#L1751-L1753 | train |
JetBrains/xodus | utils/src/main/java/jetbrains/exodus/core/execution/ThreadJobProcessor.java | ThreadJobProcessor.start | @Override
public synchronized void start() {
if (!started.getAndSet(true)) {
finished.set(false);
thread.start();
}
} | java | @Override
public synchronized void start() {
if (!started.getAndSet(true)) {
finished.set(false);
thread.start();
}
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"start",
"(",
")",
"{",
"if",
"(",
"!",
"started",
".",
"getAndSet",
"(",
"true",
")",
")",
"{",
"finished",
".",
"set",
"(",
"false",
")",
";",
"thread",
".",
"start",
"(",
")",
";",
"}",
"}"
] | Starts processor thread. | [
"Starts",
"processor",
"thread",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/core/execution/ThreadJobProcessor.java#L53-L59 | train |
JetBrains/xodus | utils/src/main/java/jetbrains/exodus/core/execution/ThreadJobProcessor.java | ThreadJobProcessor.finish | @Override
public void finish() {
if (started.get() && !finished.getAndSet(true)) {
waitUntilFinished();
super.finish();
// recreate thread (don't start) for processor reuse
createProcessorThread();
clearQueues();
started.set(false);
}
} | java | @Override
public void finish() {
if (started.get() && !finished.getAndSet(true)) {
waitUntilFinished();
super.finish();
// recreate thread (don't start) for processor reuse
createProcessorThread();
clearQueues();
started.set(false);
}
} | [
"@",
"Override",
"public",
"void",
"finish",
"(",
")",
"{",
"if",
"(",
"started",
".",
"get",
"(",
")",
"&&",
"!",
"finished",
".",
"getAndSet",
"(",
"true",
")",
")",
"{",
"waitUntilFinished",
"(",
")",
";",
"super",
".",
"finish",
"(",
")",
";",
... | Signals that the processor to finish and waits until it finishes. | [
"Signals",
"that",
"the",
"processor",
"to",
"finish",
"and",
"waits",
"until",
"it",
"finishes",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/core/execution/ThreadJobProcessor.java#L64-L74 | train |
JetBrains/xodus | environment/src/main/java/jetbrains/exodus/env/ReentrantTransactionDispatcher.java | ReentrantTransactionDispatcher.acquireTransaction | int acquireTransaction(@NotNull final Thread thread) {
try (CriticalSection ignored = criticalSection.enter()) {
final int currentThreadPermits = getThreadPermitsToAcquire(thread);
waitForPermits(thread, currentThreadPermits > 0 ? nestedQueue : regularQueue, 1, currentThreadPermits);
}
return 1;
} | java | int acquireTransaction(@NotNull final Thread thread) {
try (CriticalSection ignored = criticalSection.enter()) {
final int currentThreadPermits = getThreadPermitsToAcquire(thread);
waitForPermits(thread, currentThreadPermits > 0 ? nestedQueue : regularQueue, 1, currentThreadPermits);
}
return 1;
} | [
"int",
"acquireTransaction",
"(",
"@",
"NotNull",
"final",
"Thread",
"thread",
")",
"{",
"try",
"(",
"CriticalSection",
"ignored",
"=",
"criticalSection",
".",
"enter",
"(",
")",
")",
"{",
"final",
"int",
"currentThreadPermits",
"=",
"getThreadPermitsToAcquire",
... | Acquire transaction with a single permit in a thread. Transactions are acquired reentrantly, i.e.
with respect to transactions already acquired in the thread.
@return the number of acquired permits, identically equal to 1. | [
"Acquire",
"transaction",
"with",
"a",
"single",
"permit",
"in",
"a",
"thread",
".",
"Transactions",
"are",
"acquired",
"reentrantly",
"i",
".",
"e",
".",
"with",
"respect",
"to",
"transactions",
"already",
"acquired",
"in",
"the",
"thread",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/environment/src/main/java/jetbrains/exodus/env/ReentrantTransactionDispatcher.java#L68-L74 | train |
JetBrains/xodus | environment/src/main/java/jetbrains/exodus/env/ReentrantTransactionDispatcher.java | ReentrantTransactionDispatcher.releaseTransaction | void releaseTransaction(@NotNull final Thread thread, final int permits) {
try (CriticalSection ignored = criticalSection.enter()) {
int currentThreadPermits = getThreadPermits(thread);
if (permits > currentThreadPermits) {
throw new ExodusException("Can't release more permits than it was acquired");
}
acquiredPermits -= permits;
currentThreadPermits -= permits;
if (currentThreadPermits == 0) {
threadPermits.remove(thread);
} else {
threadPermits.put(thread, currentThreadPermits);
}
notifyNextWaiters();
}
} | java | void releaseTransaction(@NotNull final Thread thread, final int permits) {
try (CriticalSection ignored = criticalSection.enter()) {
int currentThreadPermits = getThreadPermits(thread);
if (permits > currentThreadPermits) {
throw new ExodusException("Can't release more permits than it was acquired");
}
acquiredPermits -= permits;
currentThreadPermits -= permits;
if (currentThreadPermits == 0) {
threadPermits.remove(thread);
} else {
threadPermits.put(thread, currentThreadPermits);
}
notifyNextWaiters();
}
} | [
"void",
"releaseTransaction",
"(",
"@",
"NotNull",
"final",
"Thread",
"thread",
",",
"final",
"int",
"permits",
")",
"{",
"try",
"(",
"CriticalSection",
"ignored",
"=",
"criticalSection",
".",
"enter",
"(",
")",
")",
"{",
"int",
"currentThreadPermits",
"=",
... | Release transaction that was acquired in a thread with specified permits. | [
"Release",
"transaction",
"that",
"was",
"acquired",
"in",
"a",
"thread",
"with",
"specified",
"permits",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/environment/src/main/java/jetbrains/exodus/env/ReentrantTransactionDispatcher.java#L121-L136 | train |
JetBrains/xodus | environment/src/main/java/jetbrains/exodus/env/ReentrantTransactionDispatcher.java | ReentrantTransactionDispatcher.tryAcquireExclusiveTransaction | private int tryAcquireExclusiveTransaction(@NotNull final Thread thread, final int timeout) {
long nanos = TimeUnit.MILLISECONDS.toNanos(timeout);
try (CriticalSection ignored = criticalSection.enter()) {
if (getThreadPermits(thread) > 0) {
throw new ExodusException("Exclusive transaction can't be nested");
}
final Condition condition = criticalSection.newCondition();
final long currentOrder = acquireOrder++;
regularQueue.put(currentOrder, condition);
while (acquiredPermits > 0 || regularQueue.firstKey() != currentOrder) {
try {
nanos = condition.awaitNanos(nanos);
if (nanos < 0) {
break;
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
}
if (acquiredPermits == 0 && regularQueue.firstKey() == currentOrder) {
regularQueue.pollFirstEntry();
acquiredPermits = availablePermits;
threadPermits.put(thread, availablePermits);
return availablePermits;
}
regularQueue.remove(currentOrder);
notifyNextWaiters();
}
return 0;
} | java | private int tryAcquireExclusiveTransaction(@NotNull final Thread thread, final int timeout) {
long nanos = TimeUnit.MILLISECONDS.toNanos(timeout);
try (CriticalSection ignored = criticalSection.enter()) {
if (getThreadPermits(thread) > 0) {
throw new ExodusException("Exclusive transaction can't be nested");
}
final Condition condition = criticalSection.newCondition();
final long currentOrder = acquireOrder++;
regularQueue.put(currentOrder, condition);
while (acquiredPermits > 0 || regularQueue.firstKey() != currentOrder) {
try {
nanos = condition.awaitNanos(nanos);
if (nanos < 0) {
break;
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
}
if (acquiredPermits == 0 && regularQueue.firstKey() == currentOrder) {
regularQueue.pollFirstEntry();
acquiredPermits = availablePermits;
threadPermits.put(thread, availablePermits);
return availablePermits;
}
regularQueue.remove(currentOrder);
notifyNextWaiters();
}
return 0;
} | [
"private",
"int",
"tryAcquireExclusiveTransaction",
"(",
"@",
"NotNull",
"final",
"Thread",
"thread",
",",
"final",
"int",
"timeout",
")",
"{",
"long",
"nanos",
"=",
"TimeUnit",
".",
"MILLISECONDS",
".",
"toNanos",
"(",
"timeout",
")",
";",
"try",
"(",
"Crit... | Wait for exclusive permit during a timeout in milliseconds.
@return number of acquired permits if > 0 | [
"Wait",
"for",
"exclusive",
"permit",
"during",
"a",
"timeout",
"in",
"milliseconds",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/environment/src/main/java/jetbrains/exodus/env/ReentrantTransactionDispatcher.java#L193-L223 | train |
JetBrains/xodus | utils/src/main/java/jetbrains/exodus/core/execution/JobProcessorQueueAdapter.java | JobProcessorQueueAdapter.waitForJobs | protected boolean waitForJobs() throws InterruptedException {
final Pair<Long, Job> peekPair;
try (Guard ignored = timeQueue.lock()) {
peekPair = timeQueue.peekPair();
}
if (peekPair == null) {
awake.acquire();
return true;
}
final long timeout = Long.MAX_VALUE - peekPair.getFirst() - System.currentTimeMillis();
if (timeout < 0) {
return false;
}
return awake.tryAcquire(timeout, TimeUnit.MILLISECONDS);
} | java | protected boolean waitForJobs() throws InterruptedException {
final Pair<Long, Job> peekPair;
try (Guard ignored = timeQueue.lock()) {
peekPair = timeQueue.peekPair();
}
if (peekPair == null) {
awake.acquire();
return true;
}
final long timeout = Long.MAX_VALUE - peekPair.getFirst() - System.currentTimeMillis();
if (timeout < 0) {
return false;
}
return awake.tryAcquire(timeout, TimeUnit.MILLISECONDS);
} | [
"protected",
"boolean",
"waitForJobs",
"(",
")",
"throws",
"InterruptedException",
"{",
"final",
"Pair",
"<",
"Long",
",",
"Job",
">",
"peekPair",
";",
"try",
"(",
"Guard",
"ignored",
"=",
"timeQueue",
".",
"lock",
"(",
")",
")",
"{",
"peekPair",
"=",
"t... | returns true if a job was queued within a timeout | [
"returns",
"true",
"if",
"a",
"job",
"was",
"queued",
"within",
"a",
"timeout"
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/core/execution/JobProcessorQueueAdapter.java#L229-L243 | train |
JetBrains/xodus | entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentStoreTransaction.java | PersistentStoreTransaction.apply | void apply() {
final FlushLog log = new FlushLog();
store.logOperations(txn, log);
final BlobVault blobVault = store.getBlobVault();
if (blobVault.requiresTxn()) {
try {
blobVault.flushBlobs(blobStreams, blobFiles, deferredBlobsToDelete, txn);
} catch (Exception e) {
// out of disk space not expected there
throw ExodusException.toEntityStoreException(e);
}
}
txn.setCommitHook(new Runnable() {
@Override
public void run() {
log.flushed();
final EntityIterableCacheAdapterMutable cache = PersistentStoreTransaction.this.mutableCache;
if (cache != null) { // mutableCache can be null if only blobs are modified
applyAtomicCaches(cache);
}
}
});
} | java | void apply() {
final FlushLog log = new FlushLog();
store.logOperations(txn, log);
final BlobVault blobVault = store.getBlobVault();
if (blobVault.requiresTxn()) {
try {
blobVault.flushBlobs(blobStreams, blobFiles, deferredBlobsToDelete, txn);
} catch (Exception e) {
// out of disk space not expected there
throw ExodusException.toEntityStoreException(e);
}
}
txn.setCommitHook(new Runnable() {
@Override
public void run() {
log.flushed();
final EntityIterableCacheAdapterMutable cache = PersistentStoreTransaction.this.mutableCache;
if (cache != null) { // mutableCache can be null if only blobs are modified
applyAtomicCaches(cache);
}
}
});
} | [
"void",
"apply",
"(",
")",
"{",
"final",
"FlushLog",
"log",
"=",
"new",
"FlushLog",
"(",
")",
";",
"store",
".",
"logOperations",
"(",
"txn",
",",
"log",
")",
";",
"final",
"BlobVault",
"blobVault",
"=",
"store",
".",
"getBlobVault",
"(",
")",
";",
"... | exposed only for tests | [
"exposed",
"only",
"for",
"tests"
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentStoreTransaction.java#L851-L873 | train |
JetBrains/xodus | entity-store/src/main/java/jetbrains/exodus/entitystore/StoreNamingRules.java | StoreNamingRules.getFQName | @NotNull
private String getFQName(@NotNull final String localName, Object... params) {
final StringBuilder builder = new StringBuilder();
builder.append(storeName);
builder.append('.');
builder.append(localName);
for (final Object param : params) {
builder.append('#');
builder.append(param);
}
//noinspection ConstantConditions
return StringInterner.intern(builder.toString());
} | java | @NotNull
private String getFQName(@NotNull final String localName, Object... params) {
final StringBuilder builder = new StringBuilder();
builder.append(storeName);
builder.append('.');
builder.append(localName);
for (final Object param : params) {
builder.append('#');
builder.append(param);
}
//noinspection ConstantConditions
return StringInterner.intern(builder.toString());
} | [
"@",
"NotNull",
"private",
"String",
"getFQName",
"(",
"@",
"NotNull",
"final",
"String",
"localName",
",",
"Object",
"...",
"params",
")",
"{",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
... | Gets fully-qualified name of a table or sequence.
@param localName local table name.
@param params params.
@return fully-qualified table name. | [
"Gets",
"fully",
"-",
"qualified",
"name",
"of",
"a",
"table",
"or",
"sequence",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/StoreNamingRules.java#L144-L156 | train |
JetBrains/xodus | utils/src/main/java/jetbrains/exodus/util/UTFUtil.java | UTFUtil.writeUTF | public static void writeUTF(@NotNull final OutputStream stream, @NotNull final String str) throws IOException {
try (DataOutputStream dataStream = new DataOutputStream(stream)) {
int len = str.length();
if (len < SINGLE_UTF_CHUNK_SIZE) {
dataStream.writeUTF(str);
} else {
int startIndex = 0;
int endIndex;
do {
endIndex = startIndex + SINGLE_UTF_CHUNK_SIZE;
if (endIndex > len) {
endIndex = len;
}
dataStream.writeUTF(str.substring(startIndex, endIndex));
startIndex += SINGLE_UTF_CHUNK_SIZE;
} while (endIndex < len);
}
}
} | java | public static void writeUTF(@NotNull final OutputStream stream, @NotNull final String str) throws IOException {
try (DataOutputStream dataStream = new DataOutputStream(stream)) {
int len = str.length();
if (len < SINGLE_UTF_CHUNK_SIZE) {
dataStream.writeUTF(str);
} else {
int startIndex = 0;
int endIndex;
do {
endIndex = startIndex + SINGLE_UTF_CHUNK_SIZE;
if (endIndex > len) {
endIndex = len;
}
dataStream.writeUTF(str.substring(startIndex, endIndex));
startIndex += SINGLE_UTF_CHUNK_SIZE;
} while (endIndex < len);
}
}
} | [
"public",
"static",
"void",
"writeUTF",
"(",
"@",
"NotNull",
"final",
"OutputStream",
"stream",
",",
"@",
"NotNull",
"final",
"String",
"str",
")",
"throws",
"IOException",
"{",
"try",
"(",
"DataOutputStream",
"dataStream",
"=",
"new",
"DataOutputStream",
"(",
... | Writes long strings to output stream as several chunks.
@param stream stream to write to.
@param str string to be written.
@throws IOException if something went wrong | [
"Writes",
"long",
"strings",
"to",
"output",
"stream",
"as",
"several",
"chunks",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/util/UTFUtil.java#L39-L57 | train |
JetBrains/xodus | utils/src/main/java/jetbrains/exodus/util/UTFUtil.java | UTFUtil.readUTF | @Nullable
public static String readUTF(@NotNull final InputStream stream) throws IOException {
final DataInputStream dataInput = new DataInputStream(stream);
if (stream instanceof ByteArraySizedInputStream) {
final ByteArraySizedInputStream sizedStream = (ByteArraySizedInputStream) stream;
final int streamSize = sizedStream.size();
if (streamSize >= 2) {
sizedStream.mark(Integer.MAX_VALUE);
final int utfLen = dataInput.readUnsignedShort();
if (utfLen == streamSize - 2) {
boolean isAscii = true;
final byte[] bytes = sizedStream.toByteArray();
for (int i = 0; i < utfLen; ++i) {
if ((bytes[i + 2] & 0xff) > 127) {
isAscii = false;
break;
}
}
if (isAscii) {
return fromAsciiByteArray(bytes, 2, utfLen);
}
}
sizedStream.reset();
}
}
try {
String result = null;
StringBuilder builder = null;
for (; ; ) {
final String temp;
try {
temp = dataInput.readUTF();
if (result != null && result.length() == 0 &&
builder != null && builder.length() == 0 && temp.length() == 0) {
break;
}
} catch (EOFException e) {
break;
}
if (result == null) {
result = temp;
} else {
if (builder == null) {
builder = new StringBuilder();
builder.append(result);
}
builder.append(temp);
}
}
return (builder != null) ? builder.toString() : result;
} finally {
dataInput.close();
}
} | java | @Nullable
public static String readUTF(@NotNull final InputStream stream) throws IOException {
final DataInputStream dataInput = new DataInputStream(stream);
if (stream instanceof ByteArraySizedInputStream) {
final ByteArraySizedInputStream sizedStream = (ByteArraySizedInputStream) stream;
final int streamSize = sizedStream.size();
if (streamSize >= 2) {
sizedStream.mark(Integer.MAX_VALUE);
final int utfLen = dataInput.readUnsignedShort();
if (utfLen == streamSize - 2) {
boolean isAscii = true;
final byte[] bytes = sizedStream.toByteArray();
for (int i = 0; i < utfLen; ++i) {
if ((bytes[i + 2] & 0xff) > 127) {
isAscii = false;
break;
}
}
if (isAscii) {
return fromAsciiByteArray(bytes, 2, utfLen);
}
}
sizedStream.reset();
}
}
try {
String result = null;
StringBuilder builder = null;
for (; ; ) {
final String temp;
try {
temp = dataInput.readUTF();
if (result != null && result.length() == 0 &&
builder != null && builder.length() == 0 && temp.length() == 0) {
break;
}
} catch (EOFException e) {
break;
}
if (result == null) {
result = temp;
} else {
if (builder == null) {
builder = new StringBuilder();
builder.append(result);
}
builder.append(temp);
}
}
return (builder != null) ? builder.toString() : result;
} finally {
dataInput.close();
}
} | [
"@",
"Nullable",
"public",
"static",
"String",
"readUTF",
"(",
"@",
"NotNull",
"final",
"InputStream",
"stream",
")",
"throws",
"IOException",
"{",
"final",
"DataInputStream",
"dataInput",
"=",
"new",
"DataInputStream",
"(",
"stream",
")",
";",
"if",
"(",
"str... | Reads a string from input stream saved as a sequence of UTF chunks.
@param stream stream to read from.
@return output string
@throws IOException if something went wrong | [
"Reads",
"a",
"string",
"from",
"input",
"stream",
"saved",
"as",
"a",
"sequence",
"of",
"UTF",
"chunks",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/util/UTFUtil.java#L66-L119 | train |
JetBrains/xodus | environment/src/main/java/jetbrains/exodus/tree/btree/BasePageMutable.java | BasePageMutable.save | protected long save() {
// save leaf nodes
ReclaimFlag flag = saveChildren();
// save self. complementary to {@link load()}
final byte type = getType();
final BTreeBase tree = getTree();
final int structureId = tree.structureId;
final Log log = tree.log;
if (flag == ReclaimFlag.PRESERVE) {
// there is a chance to update the flag to RECLAIM
if (log.getWrittenHighAddress() % log.getFileLengthBound() == 0) {
// page will be exactly on file border
flag = ReclaimFlag.RECLAIM;
} else {
final ByteIterable[] iterables = getByteIterables(flag);
long result = log.tryWrite(type, structureId, new CompoundByteIterable(iterables));
if (result < 0) {
iterables[0] = CompressedUnsignedLongByteIterable.getIterable(
(size << 1) + ReclaimFlag.RECLAIM.value
);
result = log.writeContinuously(type, structureId, new CompoundByteIterable(iterables));
if (result < 0) {
throw new TooBigLoggableException();
}
}
return result;
}
}
return log.write(type, structureId, new CompoundByteIterable(getByteIterables(flag)));
} | java | protected long save() {
// save leaf nodes
ReclaimFlag flag = saveChildren();
// save self. complementary to {@link load()}
final byte type = getType();
final BTreeBase tree = getTree();
final int structureId = tree.structureId;
final Log log = tree.log;
if (flag == ReclaimFlag.PRESERVE) {
// there is a chance to update the flag to RECLAIM
if (log.getWrittenHighAddress() % log.getFileLengthBound() == 0) {
// page will be exactly on file border
flag = ReclaimFlag.RECLAIM;
} else {
final ByteIterable[] iterables = getByteIterables(flag);
long result = log.tryWrite(type, structureId, new CompoundByteIterable(iterables));
if (result < 0) {
iterables[0] = CompressedUnsignedLongByteIterable.getIterable(
(size << 1) + ReclaimFlag.RECLAIM.value
);
result = log.writeContinuously(type, structureId, new CompoundByteIterable(iterables));
if (result < 0) {
throw new TooBigLoggableException();
}
}
return result;
}
}
return log.write(type, structureId, new CompoundByteIterable(getByteIterables(flag)));
} | [
"protected",
"long",
"save",
"(",
")",
"{",
"// save leaf nodes",
"ReclaimFlag",
"flag",
"=",
"saveChildren",
"(",
")",
";",
"// save self. complementary to {@link load()}",
"final",
"byte",
"type",
"=",
"getType",
"(",
")",
";",
"final",
"BTreeBase",
"tree",
"=",... | Save page to log
@return address of this page after save | [
"Save",
"page",
"to",
"log"
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/environment/src/main/java/jetbrains/exodus/tree/btree/BasePageMutable.java#L113-L143 | train |
JetBrains/xodus | openAPI/src/main/java/jetbrains/exodus/env/EnvironmentConfig.java | EnvironmentConfig.setSetting | @Override
public EnvironmentConfig setSetting(@NotNull final String key, @NotNull final Object value) {
return (EnvironmentConfig) super.setSetting(key, value);
} | java | @Override
public EnvironmentConfig setSetting(@NotNull final String key, @NotNull final Object value) {
return (EnvironmentConfig) super.setSetting(key, value);
} | [
"@",
"Override",
"public",
"EnvironmentConfig",
"setSetting",
"(",
"@",
"NotNull",
"final",
"String",
"key",
",",
"@",
"NotNull",
"final",
"Object",
"value",
")",
"{",
"return",
"(",
"EnvironmentConfig",
")",
"super",
".",
"setSetting",
"(",
"key",
",",
"val... | Sets the value of the setting with the specified key.
@param key name of the setting
@param value the setting value
@return this {@code EnvironmentConfig} instance | [
"Sets",
"the",
"value",
"of",
"the",
"setting",
"with",
"the",
"specified",
"key",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/openAPI/src/main/java/jetbrains/exodus/env/EnvironmentConfig.java#L674-L677 | train |
JetBrains/xodus | openAPI/src/main/java/jetbrains/exodus/entitystore/BlobVault.java | BlobVault.getStringContent | @Nullable
public final String getStringContent(final long blobHandle, @NotNull final Transaction txn) throws IOException {
String result;
result = stringContentCache.tryKey(this, blobHandle);
if (result == null) {
final InputStream content = getContent(blobHandle, txn);
if (content == null) {
logger.error("Blob string not found: " + getBlobLocation(blobHandle), new FileNotFoundException());
}
result = content == null ? null : UTFUtil.readUTF(content);
if (result != null && result.length() <= config.getBlobStringsCacheMaxValueSize()) {
if (stringContentCache.getObject(this, blobHandle) == null) {
stringContentCache.cacheObject(this, blobHandle, result);
}
}
}
return result;
} | java | @Nullable
public final String getStringContent(final long blobHandle, @NotNull final Transaction txn) throws IOException {
String result;
result = stringContentCache.tryKey(this, blobHandle);
if (result == null) {
final InputStream content = getContent(blobHandle, txn);
if (content == null) {
logger.error("Blob string not found: " + getBlobLocation(blobHandle), new FileNotFoundException());
}
result = content == null ? null : UTFUtil.readUTF(content);
if (result != null && result.length() <= config.getBlobStringsCacheMaxValueSize()) {
if (stringContentCache.getObject(this, blobHandle) == null) {
stringContentCache.cacheObject(this, blobHandle, result);
}
}
}
return result;
} | [
"@",
"Nullable",
"public",
"final",
"String",
"getStringContent",
"(",
"final",
"long",
"blobHandle",
",",
"@",
"NotNull",
"final",
"Transaction",
"txn",
")",
"throws",
"IOException",
"{",
"String",
"result",
";",
"result",
"=",
"stringContentCache",
".",
"tryKe... | Returns string content of blob identified by specified blob handle. String contents cache is used.
@param blobHandle blob handle
@param txn {@linkplain Transaction} instance
@return string content of blob identified by specified blob handle
@throws IOException if something went wrong | [
"Returns",
"string",
"content",
"of",
"blob",
"identified",
"by",
"specified",
"blob",
"handle",
".",
"String",
"contents",
"cache",
"is",
"used",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/openAPI/src/main/java/jetbrains/exodus/entitystore/BlobVault.java#L199-L216 | train |
JetBrains/xodus | utils/src/main/java/jetbrains/exodus/core/execution/JobProcessorAdapter.java | JobProcessorAdapter.queueIn | @Override
public final Job queueIn(final Job job, final long millis) {
return pushAt(job, System.currentTimeMillis() + millis);
} | java | @Override
public final Job queueIn(final Job job, final long millis) {
return pushAt(job, System.currentTimeMillis() + millis);
} | [
"@",
"Override",
"public",
"final",
"Job",
"queueIn",
"(",
"final",
"Job",
"job",
",",
"final",
"long",
"millis",
")",
"{",
"return",
"pushAt",
"(",
"job",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"millis",
")",
";",
"}"
] | Queues a job for execution in specified time.
@param job the job.
@param millis execute the job in this time. | [
"Queues",
"a",
"job",
"for",
"execution",
"in",
"specified",
"time",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/core/execution/JobProcessorAdapter.java#L116-L119 | train |
JetBrains/xodus | entity-store/src/main/java/jetbrains/exodus/entitystore/tables/BlobsTable.java | BlobsTable.put | public void put(@NotNull final Transaction txn, final long localId,
final int blobId, @NotNull final ByteIterable value) {
primaryStore.put(txn, PropertyKey.propertyKeyToEntry(new PropertyKey(localId, blobId)), value);
allBlobsIndex.put(txn, IntegerBinding.intToCompressedEntry(blobId), LongBinding.longToCompressedEntry(localId));
} | java | public void put(@NotNull final Transaction txn, final long localId,
final int blobId, @NotNull final ByteIterable value) {
primaryStore.put(txn, PropertyKey.propertyKeyToEntry(new PropertyKey(localId, blobId)), value);
allBlobsIndex.put(txn, IntegerBinding.intToCompressedEntry(blobId), LongBinding.longToCompressedEntry(localId));
} | [
"public",
"void",
"put",
"(",
"@",
"NotNull",
"final",
"Transaction",
"txn",
",",
"final",
"long",
"localId",
",",
"final",
"int",
"blobId",
",",
"@",
"NotNull",
"final",
"ByteIterable",
"value",
")",
"{",
"primaryStore",
".",
"put",
"(",
"txn",
",",
"Pr... | Setter for blob handle value.
@param txn enclosing transaction
@param localId entity local id.
@param blobId blob id
@param value property value. | [
"Setter",
"for",
"blob",
"handle",
"value",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/tables/BlobsTable.java#L62-L66 | train |
JetBrains/xodus | entity-store/src/main/java/jetbrains/exodus/entitystore/tables/PropertiesTable.java | PropertiesTable.put | public void put(@NotNull final PersistentStoreTransaction txn,
final long localId,
@NotNull final ByteIterable value,
@Nullable final ByteIterable oldValue,
final int propertyId,
@NotNull final ComparableValueType type) {
final Store valueIdx = getOrCreateValueIndex(txn, propertyId);
final ByteIterable key = PropertyKey.propertyKeyToEntry(new PropertyKey(localId, propertyId));
final Transaction envTxn = txn.getEnvironmentTransaction();
primaryStore.put(envTxn, key, value);
final ByteIterable secondaryValue = LongBinding.longToCompressedEntry(localId);
boolean success;
if (oldValue == null) {
success = allPropsIndex.put(envTxn, IntegerBinding.intToCompressedEntry(propertyId), secondaryValue);
} else {
success = deleteFromStore(envTxn, valueIdx, secondaryValue, createSecondaryKeys(store.getPropertyTypes(), oldValue, type));
}
if (success) {
for (final ByteIterable secondaryKey : createSecondaryKeys(store.getPropertyTypes(), value, type)) {
valueIdx.put(envTxn, secondaryKey, secondaryValue);
}
}
checkStatus(success, "Failed to put");
} | java | public void put(@NotNull final PersistentStoreTransaction txn,
final long localId,
@NotNull final ByteIterable value,
@Nullable final ByteIterable oldValue,
final int propertyId,
@NotNull final ComparableValueType type) {
final Store valueIdx = getOrCreateValueIndex(txn, propertyId);
final ByteIterable key = PropertyKey.propertyKeyToEntry(new PropertyKey(localId, propertyId));
final Transaction envTxn = txn.getEnvironmentTransaction();
primaryStore.put(envTxn, key, value);
final ByteIterable secondaryValue = LongBinding.longToCompressedEntry(localId);
boolean success;
if (oldValue == null) {
success = allPropsIndex.put(envTxn, IntegerBinding.intToCompressedEntry(propertyId), secondaryValue);
} else {
success = deleteFromStore(envTxn, valueIdx, secondaryValue, createSecondaryKeys(store.getPropertyTypes(), oldValue, type));
}
if (success) {
for (final ByteIterable secondaryKey : createSecondaryKeys(store.getPropertyTypes(), value, type)) {
valueIdx.put(envTxn, secondaryKey, secondaryValue);
}
}
checkStatus(success, "Failed to put");
} | [
"public",
"void",
"put",
"(",
"@",
"NotNull",
"final",
"PersistentStoreTransaction",
"txn",
",",
"final",
"long",
"localId",
",",
"@",
"NotNull",
"final",
"ByteIterable",
"value",
",",
"@",
"Nullable",
"final",
"ByteIterable",
"oldValue",
",",
"final",
"int",
... | Setter for property value. Doesn't affect entity version and doesn't
invalidate any of the cached entity iterables.
@param localId entity local id.
@param value property value.
@param oldValue property old value
@param propertyId property id | [
"Setter",
"for",
"property",
"value",
".",
"Doesn",
"t",
"affect",
"entity",
"version",
"and",
"doesn",
"t",
"invalidate",
"any",
"of",
"the",
"cached",
"entity",
"iterables",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/tables/PropertiesTable.java#L74-L97 | train |
JetBrains/xodus | utils/src/main/java/jetbrains/exodus/core/dataStructures/persistent/AbstractPersistent23Tree.java | AbstractPersistent23Tree.tailIterator | public Iterator<K> tailIterator(@NotNull final K key) {
return new Iterator<K>() {
private Stack<TreePos<K>> stack;
private boolean hasNext;
private boolean hasNextValid;
@Override
public boolean hasNext() {
if (hasNextValid) {
return hasNext;
}
hasNextValid = true;
if (stack == null) {
Node<K> root = getRoot();
if (root == null) {
hasNext = false;
return hasNext;
}
stack = new Stack<>();
if (!root.getLess(key, stack)) {
stack.push(new TreePos<>(root));
}
}
TreePos<K> treePos = stack.peek();
if (treePos.node.isLeaf()) {
while (treePos.pos >= (treePos.node.isTernary() ? 2 : 1)) {
stack.pop();
if (stack.isEmpty()) {
hasNext = false;
return hasNext;
}
treePos = stack.peek();
}
} else {
if (treePos.pos == 0) {
treePos = new TreePos<>(treePos.node.getFirstChild());
} else if (treePos.pos == 1) {
treePos = new TreePos<>(treePos.node.getSecondChild());
} else {
treePos = new TreePos<>(treePos.node.getThirdChild());
}
stack.push(treePos);
while (!treePos.node.isLeaf()) {
treePos = new TreePos<>(treePos.node.getFirstChild());
stack.push(treePos);
}
}
treePos.pos++;
hasNext = true;
return hasNext;
}
@Override
public K next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
hasNextValid = false;
TreePos<K> treePos = stack.peek();
// treePos.pos must be 1 or 2 here
return treePos.pos == 1 ? treePos.node.getFirstKey() : treePos.node.getSecondKey();
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
} | java | public Iterator<K> tailIterator(@NotNull final K key) {
return new Iterator<K>() {
private Stack<TreePos<K>> stack;
private boolean hasNext;
private boolean hasNextValid;
@Override
public boolean hasNext() {
if (hasNextValid) {
return hasNext;
}
hasNextValid = true;
if (stack == null) {
Node<K> root = getRoot();
if (root == null) {
hasNext = false;
return hasNext;
}
stack = new Stack<>();
if (!root.getLess(key, stack)) {
stack.push(new TreePos<>(root));
}
}
TreePos<K> treePos = stack.peek();
if (treePos.node.isLeaf()) {
while (treePos.pos >= (treePos.node.isTernary() ? 2 : 1)) {
stack.pop();
if (stack.isEmpty()) {
hasNext = false;
return hasNext;
}
treePos = stack.peek();
}
} else {
if (treePos.pos == 0) {
treePos = new TreePos<>(treePos.node.getFirstChild());
} else if (treePos.pos == 1) {
treePos = new TreePos<>(treePos.node.getSecondChild());
} else {
treePos = new TreePos<>(treePos.node.getThirdChild());
}
stack.push(treePos);
while (!treePos.node.isLeaf()) {
treePos = new TreePos<>(treePos.node.getFirstChild());
stack.push(treePos);
}
}
treePos.pos++;
hasNext = true;
return hasNext;
}
@Override
public K next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
hasNextValid = false;
TreePos<K> treePos = stack.peek();
// treePos.pos must be 1 or 2 here
return treePos.pos == 1 ? treePos.node.getFirstKey() : treePos.node.getSecondKey();
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
} | [
"public",
"Iterator",
"<",
"K",
">",
"tailIterator",
"(",
"@",
"NotNull",
"final",
"K",
"key",
")",
"{",
"return",
"new",
"Iterator",
"<",
"K",
">",
"(",
")",
"{",
"private",
"Stack",
"<",
"TreePos",
"<",
"K",
">",
">",
"stack",
";",
"private",
"bo... | Returns an iterator that iterates over all elements greater or equal to key in ascending order
@param key key
@return iterator | [
"Returns",
"an",
"iterator",
"that",
"iterates",
"over",
"all",
"elements",
"greater",
"or",
"equal",
"to",
"key",
"in",
"ascending",
"order"
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/core/dataStructures/persistent/AbstractPersistent23Tree.java#L146-L215 | train |
JetBrains/xodus | entity-store/src/main/java/jetbrains/exodus/entitystore/tables/TwoColumnTable.java | TwoColumnTable.get | @Nullable
public ByteIterable get(@NotNull final Transaction txn, @NotNull final ByteIterable first) {
return this.first.get(txn, first);
} | java | @Nullable
public ByteIterable get(@NotNull final Transaction txn, @NotNull final ByteIterable first) {
return this.first.get(txn, first);
} | [
"@",
"Nullable",
"public",
"ByteIterable",
"get",
"(",
"@",
"NotNull",
"final",
"Transaction",
"txn",
",",
"@",
"NotNull",
"final",
"ByteIterable",
"first",
")",
"{",
"return",
"this",
".",
"first",
".",
"get",
"(",
"txn",
",",
"first",
")",
";",
"}"
] | Search for the first entry in the first database. Use this method for databases configured with no duplicates.
@param txn enclosing transaction
@param first first key.
@return null if no entry found, otherwise the value. | [
"Search",
"for",
"the",
"first",
"entry",
"in",
"the",
"first",
"database",
".",
"Use",
"this",
"method",
"for",
"databases",
"configured",
"with",
"no",
"duplicates",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/tables/TwoColumnTable.java#L54-L57 | train |
JetBrains/xodus | entity-store/src/main/java/jetbrains/exodus/entitystore/tables/TwoColumnTable.java | TwoColumnTable.get2 | @Nullable
public ByteIterable get2(@NotNull final Transaction txn, @NotNull final ByteIterable second) {
return this.second.get(txn, second);
} | java | @Nullable
public ByteIterable get2(@NotNull final Transaction txn, @NotNull final ByteIterable second) {
return this.second.get(txn, second);
} | [
"@",
"Nullable",
"public",
"ByteIterable",
"get2",
"(",
"@",
"NotNull",
"final",
"Transaction",
"txn",
",",
"@",
"NotNull",
"final",
"ByteIterable",
"second",
")",
"{",
"return",
"this",
".",
"second",
".",
"get",
"(",
"txn",
",",
"second",
")",
";",
"}"... | Search for the second entry in the second database. Use this method for databases configured with no duplicates.
@param second second key (value for first).
@return null if no entry found, otherwise the value. | [
"Search",
"for",
"the",
"second",
"entry",
"in",
"the",
"second",
"database",
".",
"Use",
"this",
"method",
"for",
"databases",
"configured",
"with",
"no",
"duplicates",
"."
] | 7b3476c4e81db66f9c7529148c761605cc8eea6d | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/tables/TwoColumnTable.java#L65-L68 | train |
OpenHFT/Chronicle-Network | src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java | TcpChannelHub.close | @Override
public void close() {
if (closed)
return;
closed = true;
tcpSocketConsumer.prepareToShutdown();
if (shouldSendCloseMessage)
eventLoop.addHandler(new EventHandler() {
@Override
public boolean action() throws InvalidEventHandlerException {
try {
TcpChannelHub.this.sendCloseMessage();
tcpSocketConsumer.stop();
closed = true;
if (LOG.isDebugEnabled())
Jvm.debug().on(getClass(), "closing connection to " + socketAddressSupplier);
while (clientChannel != null) {
if (LOG.isDebugEnabled())
Jvm.debug().on(getClass(), "waiting for disconnect to " + socketAddressSupplier);
}
} catch (ConnectionDroppedException e) {
throw new InvalidEventHandlerException(e);
}
// we just want this to run once
throw new InvalidEventHandlerException();
}
@NotNull
@Override
public String toString() {
return TcpChannelHub.class.getSimpleName() + "..close()";
}
});
} | java | @Override
public void close() {
if (closed)
return;
closed = true;
tcpSocketConsumer.prepareToShutdown();
if (shouldSendCloseMessage)
eventLoop.addHandler(new EventHandler() {
@Override
public boolean action() throws InvalidEventHandlerException {
try {
TcpChannelHub.this.sendCloseMessage();
tcpSocketConsumer.stop();
closed = true;
if (LOG.isDebugEnabled())
Jvm.debug().on(getClass(), "closing connection to " + socketAddressSupplier);
while (clientChannel != null) {
if (LOG.isDebugEnabled())
Jvm.debug().on(getClass(), "waiting for disconnect to " + socketAddressSupplier);
}
} catch (ConnectionDroppedException e) {
throw new InvalidEventHandlerException(e);
}
// we just want this to run once
throw new InvalidEventHandlerException();
}
@NotNull
@Override
public String toString() {
return TcpChannelHub.class.getSimpleName() + "..close()";
}
});
} | [
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"closed",
")",
"return",
";",
"closed",
"=",
"true",
";",
"tcpSocketConsumer",
".",
"prepareToShutdown",
"(",
")",
";",
"if",
"(",
"shouldSendCloseMessage",
")",
"eventLoop",
".",
"addHa... | called when we are completed finished with using the TcpChannelHub | [
"called",
"when",
"we",
"are",
"completed",
"finished",
"with",
"using",
"the",
"TcpChannelHub"
] | b50d232a1763b1400d5438c7925dce845e5c387a | https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java#L490-L529 | train |
OpenHFT/Chronicle-Network | src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java | TcpChannelHub.sendCloseMessage | private void sendCloseMessage() {
this.lock(() -> {
TcpChannelHub.this.writeMetaDataForKnownTID(0, outWire, null, 0);
TcpChannelHub.this.outWire.writeDocument(false, w ->
w.writeEventName(EventId.onClientClosing).text(""));
}, TryLock.LOCK);
// wait up to 1 seconds to receive an close request acknowledgment from the server
try {
final boolean await = receivedClosedAcknowledgement.await(1, TimeUnit.SECONDS);
if (!await)
if (Jvm.isDebugEnabled(getClass()))
Jvm.debug().on(getClass(), "SERVER IGNORED CLOSE REQUEST: shutting down the client anyway as the " +
"server did not respond to the close() request.");
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
}
} | java | private void sendCloseMessage() {
this.lock(() -> {
TcpChannelHub.this.writeMetaDataForKnownTID(0, outWire, null, 0);
TcpChannelHub.this.outWire.writeDocument(false, w ->
w.writeEventName(EventId.onClientClosing).text(""));
}, TryLock.LOCK);
// wait up to 1 seconds to receive an close request acknowledgment from the server
try {
final boolean await = receivedClosedAcknowledgement.await(1, TimeUnit.SECONDS);
if (!await)
if (Jvm.isDebugEnabled(getClass()))
Jvm.debug().on(getClass(), "SERVER IGNORED CLOSE REQUEST: shutting down the client anyway as the " +
"server did not respond to the close() request.");
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
}
} | [
"private",
"void",
"sendCloseMessage",
"(",
")",
"{",
"this",
".",
"lock",
"(",
"(",
")",
"->",
"{",
"TcpChannelHub",
".",
"this",
".",
"writeMetaDataForKnownTID",
"(",
"0",
",",
"outWire",
",",
"null",
",",
"0",
")",
";",
"TcpChannelHub",
".",
"this",
... | used to signal to the server that the client is going to drop the connection, and waits up to
one second for the server to acknowledge the receipt of this message | [
"used",
"to",
"signal",
"to",
"the",
"server",
"that",
"the",
"client",
"is",
"going",
"to",
"drop",
"the",
"connection",
"and",
"waits",
"up",
"to",
"one",
"second",
"for",
"the",
"server",
"to",
"acknowledge",
"the",
"receipt",
"of",
"this",
"message"
] | b50d232a1763b1400d5438c7925dce845e5c387a | https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java#L535-L556 | train |
OpenHFT/Chronicle-Network | src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java | TcpChannelHub.nextUniqueTransaction | public long nextUniqueTransaction(long timeMs) {
long id = timeMs;
for (; ; ) {
long old = transactionID.get();
if (old >= id)
id = old + 1;
if (transactionID.compareAndSet(old, id))
break;
}
return id;
} | java | public long nextUniqueTransaction(long timeMs) {
long id = timeMs;
for (; ; ) {
long old = transactionID.get();
if (old >= id)
id = old + 1;
if (transactionID.compareAndSet(old, id))
break;
}
return id;
} | [
"public",
"long",
"nextUniqueTransaction",
"(",
"long",
"timeMs",
")",
"{",
"long",
"id",
"=",
"timeMs",
";",
"for",
"(",
";",
";",
")",
"{",
"long",
"old",
"=",
"transactionID",
".",
"get",
"(",
")",
";",
"if",
"(",
"old",
">=",
"id",
")",
"id",
... | the transaction id are generated as unique timestamps
@param timeMs in milliseconds
@return a unique transactionId | [
"the",
"transaction",
"id",
"are",
"generated",
"as",
"unique",
"timestamps"
] | b50d232a1763b1400d5438c7925dce845e5c387a | https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java#L564-L574 | train |
OpenHFT/Chronicle-Network | src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java | TcpChannelHub.checkConnection | public void checkConnection() {
long start = Time.currentTimeMillis();
while (clientChannel == null) {
tcpSocketConsumer.checkNotShutdown();
if (start + timeoutMs > Time.currentTimeMillis())
try {
condition.await(1, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new IORuntimeException("Interrupted");
}
else
throw new IORuntimeException("Not connected to " + socketAddressSupplier);
}
if (clientChannel == null)
throw new IORuntimeException("Not connected to " + socketAddressSupplier);
} | java | public void checkConnection() {
long start = Time.currentTimeMillis();
while (clientChannel == null) {
tcpSocketConsumer.checkNotShutdown();
if (start + timeoutMs > Time.currentTimeMillis())
try {
condition.await(1, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new IORuntimeException("Interrupted");
}
else
throw new IORuntimeException("Not connected to " + socketAddressSupplier);
}
if (clientChannel == null)
throw new IORuntimeException("Not connected to " + socketAddressSupplier);
} | [
"public",
"void",
"checkConnection",
"(",
")",
"{",
"long",
"start",
"=",
"Time",
".",
"currentTimeMillis",
"(",
")",
";",
"while",
"(",
"clientChannel",
"==",
"null",
")",
"{",
"tcpSocketConsumer",
".",
"checkNotShutdown",
"(",
")",
";",
"if",
"(",
"start... | blocks until there is a connection | [
"blocks",
"until",
"there",
"is",
"a",
"connection"
] | b50d232a1763b1400d5438c7925dce845e5c387a | https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java#L944-L964 | train |
OpenHFT/Chronicle-Network | src/main/java/net/openhft/chronicle/network/VanillaNetworkContext.java | VanillaNetworkContext.closeAtomically | protected boolean closeAtomically() {
if (isClosed.compareAndSet(false, true)) {
Closeable.closeQuietly(networkStatsListener);
return true;
} else {
//was already closed.
return false;
}
} | java | protected boolean closeAtomically() {
if (isClosed.compareAndSet(false, true)) {
Closeable.closeQuietly(networkStatsListener);
return true;
} else {
//was already closed.
return false;
}
} | [
"protected",
"boolean",
"closeAtomically",
"(",
")",
"{",
"if",
"(",
"isClosed",
".",
"compareAndSet",
"(",
"false",
",",
"true",
")",
")",
"{",
"Closeable",
".",
"closeQuietly",
"(",
"networkStatsListener",
")",
";",
"return",
"true",
";",
"}",
"else",
"{... | Close the connection atomically.
@return true if state changed to closed; false if nothing changed. | [
"Close",
"the",
"connection",
"atomically",
"."
] | b50d232a1763b1400d5438c7925dce845e5c387a | https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/VanillaNetworkContext.java#L183-L191 | train |
OpenHFT/Chronicle-Network | src/main/java/net/openhft/chronicle/network/WireTcpHandler.java | WireTcpHandler.onRead0 | private void onRead0() {
assert inWire.startUse();
ensureCapacity();
try {
while (!inWire.bytes().isEmpty()) {
try (DocumentContext dc = inWire.readingDocument()) {
if (!dc.isPresent())
return;
try {
if (YamlLogging.showServerReads())
logYaml(dc);
onRead(dc, outWire);
onWrite(outWire);
} catch (Exception e) {
Jvm.warn().on(getClass(), "inWire=" + inWire.getClass() + ",yaml=" + Wires.fromSizePrefixedBlobs(dc), e);
}
}
}
} finally {
assert inWire.endUse();
}
} | java | private void onRead0() {
assert inWire.startUse();
ensureCapacity();
try {
while (!inWire.bytes().isEmpty()) {
try (DocumentContext dc = inWire.readingDocument()) {
if (!dc.isPresent())
return;
try {
if (YamlLogging.showServerReads())
logYaml(dc);
onRead(dc, outWire);
onWrite(outWire);
} catch (Exception e) {
Jvm.warn().on(getClass(), "inWire=" + inWire.getClass() + ",yaml=" + Wires.fromSizePrefixedBlobs(dc), e);
}
}
}
} finally {
assert inWire.endUse();
}
} | [
"private",
"void",
"onRead0",
"(",
")",
"{",
"assert",
"inWire",
".",
"startUse",
"(",
")",
";",
"ensureCapacity",
"(",
")",
";",
"try",
"{",
"while",
"(",
"!",
"inWire",
".",
"bytes",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"try",
"(",
"Do... | process all messages in this batch, provided there is plenty of output space. | [
"process",
"all",
"messages",
"in",
"this",
"batch",
"provided",
"there",
"is",
"plenty",
"of",
"output",
"space",
"."
] | b50d232a1763b1400d5438c7925dce845e5c387a | https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/WireTcpHandler.java#L188-L215 | train |
OpenHFT/Chronicle-Network | src/main/java/net/openhft/chronicle/network/cluster/handlers/HeartbeatHandler.java | HeartbeatHandler.hasReceivedHeartbeat | private boolean hasReceivedHeartbeat() {
long currentTimeMillis = System.currentTimeMillis();
boolean result = lastTimeMessageReceived + heartbeatTimeoutMs >= currentTimeMillis;
if (!result)
Jvm.warn().on(getClass(), Integer.toHexString(hashCode()) + " missed heartbeat, lastTimeMessageReceived=" + lastTimeMessageReceived
+ ", currentTimeMillis=" + currentTimeMillis);
return result;
} | java | private boolean hasReceivedHeartbeat() {
long currentTimeMillis = System.currentTimeMillis();
boolean result = lastTimeMessageReceived + heartbeatTimeoutMs >= currentTimeMillis;
if (!result)
Jvm.warn().on(getClass(), Integer.toHexString(hashCode()) + " missed heartbeat, lastTimeMessageReceived=" + lastTimeMessageReceived
+ ", currentTimeMillis=" + currentTimeMillis);
return result;
} | [
"private",
"boolean",
"hasReceivedHeartbeat",
"(",
")",
"{",
"long",
"currentTimeMillis",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"boolean",
"result",
"=",
"lastTimeMessageReceived",
"+",
"heartbeatTimeoutMs",
">=",
"currentTimeMillis",
";",
"if",
"(... | called periodically to check that the heartbeat has been received
@return {@code true} if we have received a heartbeat recently | [
"called",
"periodically",
"to",
"check",
"that",
"the",
"heartbeat",
"has",
"been",
"received"
] | b50d232a1763b1400d5438c7925dce845e5c387a | https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/cluster/handlers/HeartbeatHandler.java#L185-L193 | train |
Stratio/cassandra-lucene-index | plugin/src/main/java/com/stratio/cassandra/lucene/schema/mapping/Mapper.java | Mapper.mapsCell | public boolean mapsCell(String cell) {
return mappedCells.stream().anyMatch(x -> x.equals(cell));
} | java | public boolean mapsCell(String cell) {
return mappedCells.stream().anyMatch(x -> x.equals(cell));
} | [
"public",
"boolean",
"mapsCell",
"(",
"String",
"cell",
")",
"{",
"return",
"mappedCells",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"x",
"->",
"x",
".",
"equals",
"(",
"cell",
")",
")",
";",
"}"
] | Returns if this maps the specified cell.
@param cell the cell name
@return {@code true} if this maps the column, {@code false} otherwise | [
"Returns",
"if",
"this",
"maps",
"the",
"specified",
"cell",
"."
] | a94a4d9af6c25d40e1108729974c35c27c54441c | https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/schema/mapping/Mapper.java#L192-L194 | train |
Stratio/cassandra-lucene-index | plugin/src/main/java/com/stratio/cassandra/lucene/common/GeoDistance.java | GeoDistance.getDegrees | public double getDegrees() {
double kms = getValue(GeoDistanceUnit.KILOMETRES);
return DistanceUtils.dist2Degrees(kms, DistanceUtils.EARTH_MEAN_RADIUS_KM);
} | java | public double getDegrees() {
double kms = getValue(GeoDistanceUnit.KILOMETRES);
return DistanceUtils.dist2Degrees(kms, DistanceUtils.EARTH_MEAN_RADIUS_KM);
} | [
"public",
"double",
"getDegrees",
"(",
")",
"{",
"double",
"kms",
"=",
"getValue",
"(",
"GeoDistanceUnit",
".",
"KILOMETRES",
")",
";",
"return",
"DistanceUtils",
".",
"dist2Degrees",
"(",
"kms",
",",
"DistanceUtils",
".",
"EARTH_MEAN_RADIUS_KM",
")",
";",
"}"... | Return the numeric distance value in degrees.
@return the degrees | [
"Return",
"the",
"numeric",
"distance",
"value",
"in",
"degrees",
"."
] | a94a4d9af6c25d40e1108729974c35c27c54441c | https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/common/GeoDistance.java#L62-L65 | train |
Stratio/cassandra-lucene-index | plugin/src/main/java/com/stratio/cassandra/lucene/schema/mapping/DateRangeMapper.java | DateRangeMapper.makeShape | public NRShape makeShape(Date from, Date to) {
UnitNRShape fromShape = tree.toUnitShape(from);
UnitNRShape toShape = tree.toUnitShape(to);
return tree.toRangeShape(fromShape, toShape);
} | java | public NRShape makeShape(Date from, Date to) {
UnitNRShape fromShape = tree.toUnitShape(from);
UnitNRShape toShape = tree.toUnitShape(to);
return tree.toRangeShape(fromShape, toShape);
} | [
"public",
"NRShape",
"makeShape",
"(",
"Date",
"from",
",",
"Date",
"to",
")",
"{",
"UnitNRShape",
"fromShape",
"=",
"tree",
".",
"toUnitShape",
"(",
"from",
")",
";",
"UnitNRShape",
"toShape",
"=",
"tree",
".",
"toUnitShape",
"(",
"to",
")",
";",
"retur... | Makes an spatial shape representing the time range defined by the two specified dates.
@param from the start {@link Date}
@param to the end {@link Date}
@return a shape | [
"Makes",
"an",
"spatial",
"shape",
"representing",
"the",
"time",
"range",
"defined",
"by",
"the",
"two",
"specified",
"dates",
"."
] | a94a4d9af6c25d40e1108729974c35c27c54441c | https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/schema/mapping/DateRangeMapper.java#L123-L127 | train |
Stratio/cassandra-lucene-index | plugin/src/main/java/com/stratio/cassandra/lucene/common/GeospatialUtils.java | GeospatialUtils.validateGeohashMaxLevels | public static int validateGeohashMaxLevels(Integer userMaxLevels, int defaultMaxLevels) {
int maxLevels = userMaxLevels == null ? defaultMaxLevels : userMaxLevels;
if (maxLevels < 1 || maxLevels > GeohashPrefixTree.getMaxLevelsPossible()) {
throw new IndexException("max_levels must be in range [1, {}], but found {}",
GeohashPrefixTree.getMaxLevelsPossible(),
maxLevels);
}
return maxLevels;
} | java | public static int validateGeohashMaxLevels(Integer userMaxLevels, int defaultMaxLevels) {
int maxLevels = userMaxLevels == null ? defaultMaxLevels : userMaxLevels;
if (maxLevels < 1 || maxLevels > GeohashPrefixTree.getMaxLevelsPossible()) {
throw new IndexException("max_levels must be in range [1, {}], but found {}",
GeohashPrefixTree.getMaxLevelsPossible(),
maxLevels);
}
return maxLevels;
} | [
"public",
"static",
"int",
"validateGeohashMaxLevels",
"(",
"Integer",
"userMaxLevels",
",",
"int",
"defaultMaxLevels",
")",
"{",
"int",
"maxLevels",
"=",
"userMaxLevels",
"==",
"null",
"?",
"defaultMaxLevels",
":",
"userMaxLevels",
";",
"if",
"(",
"maxLevels",
"<... | Checks if the specified max levels is correct.
@param userMaxLevels the maximum number of levels in the tree
@param defaultMaxLevels the default max number of levels
@return the validated max levels | [
"Checks",
"if",
"the",
"specified",
"max",
"levels",
"is",
"correct",
"."
] | a94a4d9af6c25d40e1108729974c35c27c54441c | https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/common/GeospatialUtils.java#L51-L59 | train |
Stratio/cassandra-lucene-index | plugin/src/main/java/com/stratio/cassandra/lucene/common/GeospatialUtils.java | GeospatialUtils.checkLatitude | public static Double checkLatitude(String name, Double latitude) {
if (latitude == null) {
throw new IndexException("{} required", name);
} else if (latitude < MIN_LATITUDE || latitude > MAX_LATITUDE) {
throw new IndexException("{} must be in range [{}, {}], but found {}",
name,
MIN_LATITUDE,
MAX_LATITUDE,
latitude);
}
return latitude;
} | java | public static Double checkLatitude(String name, Double latitude) {
if (latitude == null) {
throw new IndexException("{} required", name);
} else if (latitude < MIN_LATITUDE || latitude > MAX_LATITUDE) {
throw new IndexException("{} must be in range [{}, {}], but found {}",
name,
MIN_LATITUDE,
MAX_LATITUDE,
latitude);
}
return latitude;
} | [
"public",
"static",
"Double",
"checkLatitude",
"(",
"String",
"name",
",",
"Double",
"latitude",
")",
"{",
"if",
"(",
"latitude",
"==",
"null",
")",
"{",
"throw",
"new",
"IndexException",
"(",
"\"{} required\"",
",",
"name",
")",
";",
"}",
"else",
"if",
... | Checks if the specified latitude is correct.
@param name the name of the latitude field
@param latitude the value of the latitude field
@return the latitude | [
"Checks",
"if",
"the",
"specified",
"latitude",
"is",
"correct",
"."
] | a94a4d9af6c25d40e1108729974c35c27c54441c | https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/common/GeospatialUtils.java#L68-L79 | train |
Stratio/cassandra-lucene-index | plugin/src/main/java/com/stratio/cassandra/lucene/common/GeospatialUtils.java | GeospatialUtils.checkLongitude | public static Double checkLongitude(String name, Double longitude) {
if (longitude == null) {
throw new IndexException("{} required", name);
} else if (longitude < MIN_LONGITUDE || longitude > MAX_LONGITUDE) {
throw new IndexException("{} must be in range [{}, {}], but found {}",
name,
MIN_LONGITUDE,
MAX_LONGITUDE,
longitude);
}
return longitude;
} | java | public static Double checkLongitude(String name, Double longitude) {
if (longitude == null) {
throw new IndexException("{} required", name);
} else if (longitude < MIN_LONGITUDE || longitude > MAX_LONGITUDE) {
throw new IndexException("{} must be in range [{}, {}], but found {}",
name,
MIN_LONGITUDE,
MAX_LONGITUDE,
longitude);
}
return longitude;
} | [
"public",
"static",
"Double",
"checkLongitude",
"(",
"String",
"name",
",",
"Double",
"longitude",
")",
"{",
"if",
"(",
"longitude",
"==",
"null",
")",
"{",
"throw",
"new",
"IndexException",
"(",
"\"{} required\"",
",",
"name",
")",
";",
"}",
"else",
"if",... | Checks if the specified longitude is correct.
@param name the name of the longitude field
@param longitude the value of the longitude field
@return the longitude | [
"Checks",
"if",
"the",
"specified",
"longitude",
"is",
"correct",
"."
] | a94a4d9af6c25d40e1108729974c35c27c54441c | https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/common/GeospatialUtils.java#L88-L99 | train |
Stratio/cassandra-lucene-index | plugin/src/main/java/com/stratio/cassandra/lucene/search/Search.java | Search.postProcessingFields | public Set<String> postProcessingFields() {
Set<String> fields = new LinkedHashSet<>();
query.forEach(condition -> fields.addAll(condition.postProcessingFields()));
sort.forEach(condition -> fields.addAll(condition.postProcessingFields()));
return fields;
} | java | public Set<String> postProcessingFields() {
Set<String> fields = new LinkedHashSet<>();
query.forEach(condition -> fields.addAll(condition.postProcessingFields()));
sort.forEach(condition -> fields.addAll(condition.postProcessingFields()));
return fields;
} | [
"public",
"Set",
"<",
"String",
">",
"postProcessingFields",
"(",
")",
"{",
"Set",
"<",
"String",
">",
"fields",
"=",
"new",
"LinkedHashSet",
"<>",
"(",
")",
";",
"query",
".",
"forEach",
"(",
"condition",
"->",
"fields",
".",
"addAll",
"(",
"condition",... | Returns the names of the involved fields when post processing.
@return the names of the involved fields | [
"Returns",
"the",
"names",
"of",
"the",
"involved",
"fields",
"when",
"post",
"processing",
"."
] | a94a4d9af6c25d40e1108729974c35c27c54441c | https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/search/Search.java#L189-L194 | train |
Stratio/cassandra-lucene-index | builder/src/main/java/com/stratio/cassandra/lucene/builder/Builder.java | Builder.index | public static Index index(String keyspace, String table, String name) {
return new Index(table, name).keyspace(keyspace);
} | java | public static Index index(String keyspace, String table, String name) {
return new Index(table, name).keyspace(keyspace);
} | [
"public",
"static",
"Index",
"index",
"(",
"String",
"keyspace",
",",
"String",
"table",
",",
"String",
"name",
")",
"{",
"return",
"new",
"Index",
"(",
"table",
",",
"name",
")",
".",
"keyspace",
"(",
"keyspace",
")",
";",
"}"
] | Returns a new index creation statement using the session's keyspace.
@param keyspace the keyspace name
@param table the table name
@param name the index name
@return a new index creation statement | [
"Returns",
"a",
"new",
"index",
"creation",
"statement",
"using",
"the",
"session",
"s",
"keyspace",
"."
] | a94a4d9af6c25d40e1108729974c35c27c54441c | https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/builder/src/main/java/com/stratio/cassandra/lucene/builder/Builder.java#L61-L63 | train |
Stratio/cassandra-lucene-index | builder/src/main/java/com/stratio/cassandra/lucene/builder/index/schema/mapping/GeoShapeMapper.java | GeoShapeMapper.transform | public GeoShapeMapper transform(GeoTransformation... transformations) {
if (this.transformations == null) {
this.transformations = Arrays.asList(transformations);
} else {
this.transformations.addAll(Arrays.asList(transformations));
}
return this;
} | java | public GeoShapeMapper transform(GeoTransformation... transformations) {
if (this.transformations == null) {
this.transformations = Arrays.asList(transformations);
} else {
this.transformations.addAll(Arrays.asList(transformations));
}
return this;
} | [
"public",
"GeoShapeMapper",
"transform",
"(",
"GeoTransformation",
"...",
"transformations",
")",
"{",
"if",
"(",
"this",
".",
"transformations",
"==",
"null",
")",
"{",
"this",
".",
"transformations",
"=",
"Arrays",
".",
"asList",
"(",
"transformations",
")",
... | Sets the transformations to be applied to the shape before indexing it.
@param transformations the sequence of transformations
@return this with the specified sequence of transformations | [
"Sets",
"the",
"transformations",
"to",
"be",
"applied",
"to",
"the",
"shape",
"before",
"indexing",
"it",
"."
] | a94a4d9af6c25d40e1108729974c35c27c54441c | https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/builder/src/main/java/com/stratio/cassandra/lucene/builder/index/schema/mapping/GeoShapeMapper.java#L74-L81 | train |
Stratio/cassandra-lucene-index | plugin/src/main/java/com/stratio/cassandra/lucene/search/SearchBuilderLegacy.java | SearchBuilderLegacy.paging | @JsonProperty("paging")
void paging(String paging) {
builder.paging(IndexPagingState.fromByteBuffer(ByteBufferUtils.byteBuffer(paging)));
} | java | @JsonProperty("paging")
void paging(String paging) {
builder.paging(IndexPagingState.fromByteBuffer(ByteBufferUtils.byteBuffer(paging)));
} | [
"@",
"JsonProperty",
"(",
"\"paging\"",
")",
"void",
"paging",
"(",
"String",
"paging",
")",
"{",
"builder",
".",
"paging",
"(",
"IndexPagingState",
".",
"fromByteBuffer",
"(",
"ByteBufferUtils",
".",
"byteBuffer",
"(",
"paging",
")",
")",
")",
";",
"}"
] | Sets the specified starting partition key.
@param paging a paging state | [
"Sets",
"the",
"specified",
"starting",
"partition",
"key",
"."
] | a94a4d9af6c25d40e1108729974c35c27c54441c | https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/search/SearchBuilderLegacy.java#L86-L89 | train |
Stratio/cassandra-lucene-index | plugin/src/main/java/com/stratio/cassandra/lucene/schema/Schema.java | Schema.mapsCell | public boolean mapsCell(String cell) {
return mappers.values().stream().anyMatch(mapper -> mapper.mapsCell(cell));
} | java | public boolean mapsCell(String cell) {
return mappers.values().stream().anyMatch(mapper -> mapper.mapsCell(cell));
} | [
"public",
"boolean",
"mapsCell",
"(",
"String",
"cell",
")",
"{",
"return",
"mappers",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"mapper",
"->",
"mapper",
".",
"mapsCell",
"(",
"cell",
")",
")",
";",
"}"
] | Returns if this has any mapping for the specified cell.
@param cell the cell name
@return {@code true} if there is any mapping for the cell, {@code false} otherwise | [
"Returns",
"if",
"this",
"has",
"any",
"mapping",
"for",
"the",
"specified",
"cell",
"."
] | a94a4d9af6c25d40e1108729974c35c27c54441c | https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/schema/Schema.java#L150-L152 | train |
dlew/joda-time-android | library/src/main/java/net/danlew/android/joda/ResUtils.java | ResUtils.convertPathToResource | private static String convertPathToResource(String path) {
File file = new File(path);
List<String> parts = new ArrayList<String>();
do {
parts.add(file.getName());
file = file.getParentFile();
}
while (file != null);
StringBuffer sb = new StringBuffer();
int size = parts.size();
for (int a = size - 1; a >= 0; a--) {
if (sb.length() > 0) {
sb.append("_");
}
sb.append(parts.get(a));
}
// TODO: Better regex replacement
return sb.toString().replace('-', '_').replace("+", "plus").toLowerCase(Locale.US);
} | java | private static String convertPathToResource(String path) {
File file = new File(path);
List<String> parts = new ArrayList<String>();
do {
parts.add(file.getName());
file = file.getParentFile();
}
while (file != null);
StringBuffer sb = new StringBuffer();
int size = parts.size();
for (int a = size - 1; a >= 0; a--) {
if (sb.length() > 0) {
sb.append("_");
}
sb.append(parts.get(a));
}
// TODO: Better regex replacement
return sb.toString().replace('-', '_').replace("+", "plus").toLowerCase(Locale.US);
} | [
"private",
"static",
"String",
"convertPathToResource",
"(",
"String",
"path",
")",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"path",
")",
";",
"List",
"<",
"String",
">",
"parts",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"do",
... | Converts any path into something that can be placed in an Android directory.
Traverses any subdirectories and flattens it all into a single filename. Also
gets rid of commonly seen illegal characters in tz identifiers, and lower cases
the entire thing.
@param path the path to convert
@return a flat path with no directories (and lower-cased) | [
"Converts",
"any",
"path",
"into",
"something",
"that",
"can",
"be",
"placed",
"in",
"an",
"Android",
"directory",
"."
] | 5bf96f6ef4ea63ee91e73e1e528896fa00108dec | https://github.com/dlew/joda-time-android/blob/5bf96f6ef4ea63ee91e73e1e528896fa00108dec/library/src/main/java/net/danlew/android/joda/ResUtils.java#L31-L51 | train |
dlew/joda-time-android | library/src/main/java/net/danlew/android/joda/DateUtils.java | DateUtils.formatDateTime | public static String formatDateTime(Context context, ReadablePartial time, int flags) {
return android.text.format.DateUtils.formatDateTime(context, toMillis(time), flags | FORMAT_UTC);
} | java | public static String formatDateTime(Context context, ReadablePartial time, int flags) {
return android.text.format.DateUtils.formatDateTime(context, toMillis(time), flags | FORMAT_UTC);
} | [
"public",
"static",
"String",
"formatDateTime",
"(",
"Context",
"context",
",",
"ReadablePartial",
"time",
",",
"int",
"flags",
")",
"{",
"return",
"android",
".",
"text",
".",
"format",
".",
"DateUtils",
".",
"formatDateTime",
"(",
"context",
",",
"toMillis",... | Formats a date or a time according to the local conventions.
Since ReadablePartials don't support all fields, we fill in any blanks
needed for formatting by using the epoch (1970-01-01T00:00:00Z).
See {@link android.text.format.DateUtils#formatDateTime} for full docs.
@param context the context is required only if the time is shown
@param time a point in time
@param flags a bit mask of formatting options
@return a string containing the formatted date/time. | [
"Formats",
"a",
"date",
"or",
"a",
"time",
"according",
"to",
"the",
"local",
"conventions",
"."
] | 5bf96f6ef4ea63ee91e73e1e528896fa00108dec | https://github.com/dlew/joda-time-android/blob/5bf96f6ef4ea63ee91e73e1e528896fa00108dec/library/src/main/java/net/danlew/android/joda/DateUtils.java#L79-L81 | train |
dlew/joda-time-android | library/src/main/java/net/danlew/android/joda/DateUtils.java | DateUtils.formatDateRange | public static String formatDateRange(Context context, ReadablePartial start, ReadablePartial end, int flags) {
return formatDateRange(context, toMillis(start), toMillis(end), flags);
} | java | public static String formatDateRange(Context context, ReadablePartial start, ReadablePartial end, int flags) {
return formatDateRange(context, toMillis(start), toMillis(end), flags);
} | [
"public",
"static",
"String",
"formatDateRange",
"(",
"Context",
"context",
",",
"ReadablePartial",
"start",
",",
"ReadablePartial",
"end",
",",
"int",
"flags",
")",
"{",
"return",
"formatDateRange",
"(",
"context",
",",
"toMillis",
"(",
"start",
")",
",",
"to... | Formats a date or a time range according to the local conventions.
You should ensure that start/end are in the same timezone; formatDateRange()
doesn't handle start/end in different timezones well.
See {@link android.text.format.DateUtils#formatDateRange} for full docs.
@param context the context is required only if the time is shown
@param start the start time
@param end the end time
@param flags a bit mask of options
@return a string containing the formatted date/time range | [
"Formats",
"a",
"date",
"or",
"a",
"time",
"range",
"according",
"to",
"the",
"local",
"conventions",
"."
] | 5bf96f6ef4ea63ee91e73e1e528896fa00108dec | https://github.com/dlew/joda-time-android/blob/5bf96f6ef4ea63ee91e73e1e528896fa00108dec/library/src/main/java/net/danlew/android/joda/DateUtils.java#L111-L113 | train |
dlew/joda-time-android | library/src/main/java/net/danlew/android/joda/DateUtils.java | DateUtils.getRelativeTimeSpanString | public static CharSequence getRelativeTimeSpanString(Context context, ReadableInstant time, int flags) {
boolean abbrevRelative = (flags & (FORMAT_ABBREV_RELATIVE | FORMAT_ABBREV_ALL)) != 0;
// We set the millis to 0 so we aren't off by a fraction of a second when counting intervals
DateTime now = DateTime.now(time.getZone()).withMillisOfSecond(0);
DateTime timeDt = new DateTime(time).withMillisOfSecond(0);
boolean past = !now.isBefore(timeDt);
Interval interval = past ? new Interval(timeDt, now) : new Interval(now, timeDt);
int resId;
long count;
if (Minutes.minutesIn(interval).isLessThan(Minutes.ONE)) {
count = Seconds.secondsIn(interval).getSeconds();
if (past) {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_num_seconds_ago;
}
else {
resId = R.plurals.joda_time_android_num_seconds_ago;
}
}
else {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_in_num_seconds;
}
else {
resId = R.plurals.joda_time_android_in_num_seconds;
}
}
}
else if (Hours.hoursIn(interval).isLessThan(Hours.ONE)) {
count = Minutes.minutesIn(interval).getMinutes();
if (past) {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_num_minutes_ago;
}
else {
resId = R.plurals.joda_time_android_num_minutes_ago;
}
}
else {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_in_num_minutes;
}
else {
resId = R.plurals.joda_time_android_in_num_minutes;
}
}
}
else if (Days.daysIn(interval).isLessThan(Days.ONE)) {
count = Hours.hoursIn(interval).getHours();
if (past) {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_num_hours_ago;
}
else {
resId = R.plurals.joda_time_android_num_hours_ago;
}
}
else {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_in_num_hours;
}
else {
resId = R.plurals.joda_time_android_in_num_hours;
}
}
}
else if (Weeks.weeksIn(interval).isLessThan(Weeks.ONE)) {
count = Days.daysIn(interval).getDays();
if (past) {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_num_days_ago;
}
else {
resId = R.plurals.joda_time_android_num_days_ago;
}
}
else {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_in_num_days;
}
else {
resId = R.plurals.joda_time_android_in_num_days;
}
}
}
else {
return formatDateRange(context, time, time, flags);
}
String format = context.getResources().getQuantityString(resId, (int) count);
return String.format(format, count);
} | java | public static CharSequence getRelativeTimeSpanString(Context context, ReadableInstant time, int flags) {
boolean abbrevRelative = (flags & (FORMAT_ABBREV_RELATIVE | FORMAT_ABBREV_ALL)) != 0;
// We set the millis to 0 so we aren't off by a fraction of a second when counting intervals
DateTime now = DateTime.now(time.getZone()).withMillisOfSecond(0);
DateTime timeDt = new DateTime(time).withMillisOfSecond(0);
boolean past = !now.isBefore(timeDt);
Interval interval = past ? new Interval(timeDt, now) : new Interval(now, timeDt);
int resId;
long count;
if (Minutes.minutesIn(interval).isLessThan(Minutes.ONE)) {
count = Seconds.secondsIn(interval).getSeconds();
if (past) {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_num_seconds_ago;
}
else {
resId = R.plurals.joda_time_android_num_seconds_ago;
}
}
else {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_in_num_seconds;
}
else {
resId = R.plurals.joda_time_android_in_num_seconds;
}
}
}
else if (Hours.hoursIn(interval).isLessThan(Hours.ONE)) {
count = Minutes.minutesIn(interval).getMinutes();
if (past) {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_num_minutes_ago;
}
else {
resId = R.plurals.joda_time_android_num_minutes_ago;
}
}
else {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_in_num_minutes;
}
else {
resId = R.plurals.joda_time_android_in_num_minutes;
}
}
}
else if (Days.daysIn(interval).isLessThan(Days.ONE)) {
count = Hours.hoursIn(interval).getHours();
if (past) {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_num_hours_ago;
}
else {
resId = R.plurals.joda_time_android_num_hours_ago;
}
}
else {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_in_num_hours;
}
else {
resId = R.plurals.joda_time_android_in_num_hours;
}
}
}
else if (Weeks.weeksIn(interval).isLessThan(Weeks.ONE)) {
count = Days.daysIn(interval).getDays();
if (past) {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_num_days_ago;
}
else {
resId = R.plurals.joda_time_android_num_days_ago;
}
}
else {
if (abbrevRelative) {
resId = R.plurals.joda_time_android_abbrev_in_num_days;
}
else {
resId = R.plurals.joda_time_android_in_num_days;
}
}
}
else {
return formatDateRange(context, time, time, flags);
}
String format = context.getResources().getQuantityString(resId, (int) count);
return String.format(format, count);
} | [
"public",
"static",
"CharSequence",
"getRelativeTimeSpanString",
"(",
"Context",
"context",
",",
"ReadableInstant",
"time",
",",
"int",
"flags",
")",
"{",
"boolean",
"abbrevRelative",
"=",
"(",
"flags",
"&",
"(",
"FORMAT_ABBREV_RELATIVE",
"|",
"FORMAT_ABBREV_ALL",
"... | Returns a string describing 'time' as a time relative to 'now'.
See {@link android.text.format.DateUtils#getRelativeTimeSpanString} for full docs.
@param context the context
@param time the time to describe
@param flags a bit mask for formatting options, usually FORMAT_ABBREV_RELATIVE
@return a string describing 'time' as a time relative to 'now'. | [
"Returns",
"a",
"string",
"describing",
"time",
"as",
"a",
"time",
"relative",
"to",
"now",
"."
] | 5bf96f6ef4ea63ee91e73e1e528896fa00108dec | https://github.com/dlew/joda-time-android/blob/5bf96f6ef4ea63ee91e73e1e528896fa00108dec/library/src/main/java/net/danlew/android/joda/DateUtils.java#L246-L339 | train |
dlew/joda-time-android | library/src/main/java/net/danlew/android/joda/DateUtils.java | DateUtils.formatDuration | public static CharSequence formatDuration(Context context, ReadableDuration readableDuration) {
Resources res = context.getResources();
Duration duration = readableDuration.toDuration();
final int hours = (int) duration.getStandardHours();
if (hours != 0) {
return res.getQuantityString(R.plurals.joda_time_android_duration_hours, hours, hours);
}
final int minutes = (int) duration.getStandardMinutes();
if (minutes != 0) {
return res.getQuantityString(R.plurals.joda_time_android_duration_minutes, minutes, minutes);
}
final int seconds = (int) duration.getStandardSeconds();
return res.getQuantityString(R.plurals.joda_time_android_duration_seconds, seconds, seconds);
} | java | public static CharSequence formatDuration(Context context, ReadableDuration readableDuration) {
Resources res = context.getResources();
Duration duration = readableDuration.toDuration();
final int hours = (int) duration.getStandardHours();
if (hours != 0) {
return res.getQuantityString(R.plurals.joda_time_android_duration_hours, hours, hours);
}
final int minutes = (int) duration.getStandardMinutes();
if (minutes != 0) {
return res.getQuantityString(R.plurals.joda_time_android_duration_minutes, minutes, minutes);
}
final int seconds = (int) duration.getStandardSeconds();
return res.getQuantityString(R.plurals.joda_time_android_duration_seconds, seconds, seconds);
} | [
"public",
"static",
"CharSequence",
"formatDuration",
"(",
"Context",
"context",
",",
"ReadableDuration",
"readableDuration",
")",
"{",
"Resources",
"res",
"=",
"context",
".",
"getResources",
"(",
")",
";",
"Duration",
"duration",
"=",
"readableDuration",
".",
"t... | Return given duration in a human-friendly format. For example, "4
minutes" or "1 second". Returns only largest meaningful unit of time,
from seconds up to hours.
The longest duration it supports is hours.
This method assumes that there are 60 minutes in an hour,
60 seconds in a minute and 1000 milliseconds in a second.
All currently supplied chronologies use this definition. | [
"Return",
"given",
"duration",
"in",
"a",
"human",
"-",
"friendly",
"format",
".",
"For",
"example",
"4",
"minutes",
"or",
"1",
"second",
".",
"Returns",
"only",
"largest",
"meaningful",
"unit",
"of",
"time",
"from",
"seconds",
"up",
"to",
"hours",
"."
] | 5bf96f6ef4ea63ee91e73e1e528896fa00108dec | https://github.com/dlew/joda-time-android/blob/5bf96f6ef4ea63ee91e73e1e528896fa00108dec/library/src/main/java/net/danlew/android/joda/DateUtils.java#L489-L505 | train |
dlew/joda-time-android | library/src/main/java/net/danlew/android/joda/ResourceZoneInfoProvider.java | ResourceZoneInfoProvider.getZone | public DateTimeZone getZone(String id) {
if (id == null) {
return null;
}
Object obj = iZoneInfoMap.get(id);
if (obj == null) {
return null;
}
if (id.equals(obj)) {
// Load zone data for the first time.
return loadZoneData(id);
}
if (obj instanceof SoftReference<?>) {
@SuppressWarnings("unchecked")
SoftReference<DateTimeZone> ref = (SoftReference<DateTimeZone>) obj;
DateTimeZone tz = ref.get();
if (tz != null) {
return tz;
}
// Reference cleared; load data again.
return loadZoneData(id);
}
// If this point is reached, mapping must link to another.
return getZone((String) obj);
} | java | public DateTimeZone getZone(String id) {
if (id == null) {
return null;
}
Object obj = iZoneInfoMap.get(id);
if (obj == null) {
return null;
}
if (id.equals(obj)) {
// Load zone data for the first time.
return loadZoneData(id);
}
if (obj instanceof SoftReference<?>) {
@SuppressWarnings("unchecked")
SoftReference<DateTimeZone> ref = (SoftReference<DateTimeZone>) obj;
DateTimeZone tz = ref.get();
if (tz != null) {
return tz;
}
// Reference cleared; load data again.
return loadZoneData(id);
}
// If this point is reached, mapping must link to another.
return getZone((String) obj);
} | [
"public",
"DateTimeZone",
"getZone",
"(",
"String",
"id",
")",
"{",
"if",
"(",
"id",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Object",
"obj",
"=",
"iZoneInfoMap",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"obj",
"==",
"null",
")",
"... | If an error is thrown while loading zone data, the exception is logged
to system error and null is returned for this and all future requests.
@param id the id to load
@return the loaded zone | [
"If",
"an",
"error",
"is",
"thrown",
"while",
"loading",
"zone",
"data",
"the",
"exception",
"is",
"logged",
"to",
"system",
"error",
"and",
"null",
"is",
"returned",
"for",
"this",
"and",
"all",
"future",
"requests",
"."
] | 5bf96f6ef4ea63ee91e73e1e528896fa00108dec | https://github.com/dlew/joda-time-android/blob/5bf96f6ef4ea63ee91e73e1e528896fa00108dec/library/src/main/java/net/danlew/android/joda/ResourceZoneInfoProvider.java#L49-L77 | train |
kiegroup/jbpm-designer | jbpm-designer-client/src/main/java/org/jbpm/designer/client/notification/DesignerNotificationPopupsManager.java | DesignerNotificationPopupsManager.addNotification | public void addNotification(@Observes final DesignerNotificationEvent event) {
if (user.getIdentifier().equals(event.getUserId())) {
if (event.getNotification() != null && !event.getNotification().equals("openinxmleditor")) {
final NotificationPopupView view = new NotificationPopupView();
activeNotifications.add(view);
view.setPopupPosition(getMargin(),
activeNotifications.size() * SPACING);
view.setNotification(event.getNotification());
view.setType(event.getType());
view.setNotificationWidth(getWidth() + "px");
view.show(new Command() {
@Override
public void execute() {
//The notification has been shown and can now be removed
deactiveNotifications.add(view);
remove();
}
});
}
}
} | java | public void addNotification(@Observes final DesignerNotificationEvent event) {
if (user.getIdentifier().equals(event.getUserId())) {
if (event.getNotification() != null && !event.getNotification().equals("openinxmleditor")) {
final NotificationPopupView view = new NotificationPopupView();
activeNotifications.add(view);
view.setPopupPosition(getMargin(),
activeNotifications.size() * SPACING);
view.setNotification(event.getNotification());
view.setType(event.getType());
view.setNotificationWidth(getWidth() + "px");
view.show(new Command() {
@Override
public void execute() {
//The notification has been shown and can now be removed
deactiveNotifications.add(view);
remove();
}
});
}
}
} | [
"public",
"void",
"addNotification",
"(",
"@",
"Observes",
"final",
"DesignerNotificationEvent",
"event",
")",
"{",
"if",
"(",
"user",
".",
"getIdentifier",
"(",
")",
".",
"equals",
"(",
"event",
".",
"getUserId",
"(",
")",
")",
")",
"{",
"if",
"(",
"eve... | Display a Notification message
@param event | [
"Display",
"a",
"Notification",
"message"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/notification/DesignerNotificationPopupsManager.java#L51-L74 | train |
kiegroup/jbpm-designer | jbpm-designer-client/src/main/java/org/jbpm/designer/client/notification/DesignerNotificationPopupsManager.java | DesignerNotificationPopupsManager.remove | private void remove() {
if (removing) {
return;
}
if (deactiveNotifications.size() == 0) {
return;
}
removing = true;
final NotificationPopupView view = deactiveNotifications.get(0);
final LinearFadeOutAnimation fadeOutAnimation = new LinearFadeOutAnimation(view) {
@Override
public void onUpdate(double progress) {
super.onUpdate(progress);
for (int i = 0; i < activeNotifications.size(); i++) {
NotificationPopupView v = activeNotifications.get(i);
final int left = v.getPopupLeft();
final int top = (int) (((i + 1) * SPACING) - (progress * SPACING));
v.setPopupPosition(left,
top);
}
}
@Override
public void onComplete() {
super.onComplete();
view.hide();
deactiveNotifications.remove(view);
activeNotifications.remove(view);
removing = false;
remove();
}
};
fadeOutAnimation.run(500);
} | java | private void remove() {
if (removing) {
return;
}
if (deactiveNotifications.size() == 0) {
return;
}
removing = true;
final NotificationPopupView view = deactiveNotifications.get(0);
final LinearFadeOutAnimation fadeOutAnimation = new LinearFadeOutAnimation(view) {
@Override
public void onUpdate(double progress) {
super.onUpdate(progress);
for (int i = 0; i < activeNotifications.size(); i++) {
NotificationPopupView v = activeNotifications.get(i);
final int left = v.getPopupLeft();
final int top = (int) (((i + 1) * SPACING) - (progress * SPACING));
v.setPopupPosition(left,
top);
}
}
@Override
public void onComplete() {
super.onComplete();
view.hide();
deactiveNotifications.remove(view);
activeNotifications.remove(view);
removing = false;
remove();
}
};
fadeOutAnimation.run(500);
} | [
"private",
"void",
"remove",
"(",
")",
"{",
"if",
"(",
"removing",
")",
"{",
"return",
";",
"}",
"if",
"(",
"deactiveNotifications",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"removing",
"=",
"true",
";",
"final",
"NotificationP... | Remove a notification message. Recursive until all pending removals have been completed. | [
"Remove",
"a",
"notification",
"message",
".",
"Recursive",
"until",
"all",
"pending",
"removals",
"have",
"been",
"completed",
"."
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/notification/DesignerNotificationPopupsManager.java#L87-L121 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/EditorHandler.java | EditorHandler.readDesignerVersion | public static String readDesignerVersion(ServletContext context) {
String retStr = "";
BufferedReader br = null;
try {
InputStream inputStream = context.getResourceAsStream("/META-INF/MANIFEST.MF");
br = new BufferedReader(new InputStreamReader(inputStream,
"UTF-8"));
String line;
while ((line = br.readLine()) != null) {
if (line.startsWith(BUNDLE_VERSION)) {
retStr = line.substring(BUNDLE_VERSION.length() + 1);
retStr = retStr.trim();
}
}
inputStream.close();
} catch (Exception e) {
logger.error(e.getMessage(),
e);
} finally {
if (br != null) {
IOUtils.closeQuietly(br);
}
}
return retStr;
} | java | public static String readDesignerVersion(ServletContext context) {
String retStr = "";
BufferedReader br = null;
try {
InputStream inputStream = context.getResourceAsStream("/META-INF/MANIFEST.MF");
br = new BufferedReader(new InputStreamReader(inputStream,
"UTF-8"));
String line;
while ((line = br.readLine()) != null) {
if (line.startsWith(BUNDLE_VERSION)) {
retStr = line.substring(BUNDLE_VERSION.length() + 1);
retStr = retStr.trim();
}
}
inputStream.close();
} catch (Exception e) {
logger.error(e.getMessage(),
e);
} finally {
if (br != null) {
IOUtils.closeQuietly(br);
}
}
return retStr;
} | [
"public",
"static",
"String",
"readDesignerVersion",
"(",
"ServletContext",
"context",
")",
"{",
"String",
"retStr",
"=",
"\"\"",
";",
"BufferedReader",
"br",
"=",
"null",
";",
"try",
"{",
"InputStream",
"inputStream",
"=",
"context",
".",
"getResourceAsStream",
... | Returns the designer version from the manifest.
@param context
@return version | [
"Returns",
"the",
"designer",
"version",
"from",
"the",
"manifest",
"."
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/EditorHandler.java#L476-L500 | train |
kiegroup/jbpm-designer | jbpm-designer-client/src/main/java/org/jbpm/designer/client/popup/ActivityDataIOEditorWidget.java | ActivityDataIOEditorWidget.isDuplicateName | public boolean isDuplicateName(String name) {
if (name == null || name.trim().isEmpty()) {
return false;
}
List<AssignmentRow> as = view.getAssignmentRows();
if (as != null && !as.isEmpty()) {
int nameCount = 0;
for (AssignmentRow row : as) {
if (name.trim().compareTo(row.getName()) == 0) {
nameCount++;
if (nameCount > 1) {
return true;
}
}
}
}
return false;
} | java | public boolean isDuplicateName(String name) {
if (name == null || name.trim().isEmpty()) {
return false;
}
List<AssignmentRow> as = view.getAssignmentRows();
if (as != null && !as.isEmpty()) {
int nameCount = 0;
for (AssignmentRow row : as) {
if (name.trim().compareTo(row.getName()) == 0) {
nameCount++;
if (nameCount > 1) {
return true;
}
}
}
}
return false;
} | [
"public",
"boolean",
"isDuplicateName",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"List",
"<",
"AssignmentRow",
">",
"as",
... | Tests whether a Row name occurs more than once in the list of rows
@param name
@return | [
"Tests",
"whether",
"a",
"Row",
"name",
"occurs",
"more",
"than",
"once",
"in",
"the",
"list",
"of",
"rows"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/popup/ActivityDataIOEditorWidget.java#L221-L238 | train |
kiegroup/jbpm-designer | jbpm-designer-client/src/main/java/org/jbpm/designer/client/util/ListBoxValues.java | ListBoxValues.getValueForDisplayValue | public String getValueForDisplayValue(final String key) {
if (mapDisplayValuesToValues.containsKey(key)) {
return mapDisplayValuesToValues.get(key);
}
return key;
} | java | public String getValueForDisplayValue(final String key) {
if (mapDisplayValuesToValues.containsKey(key)) {
return mapDisplayValuesToValues.get(key);
}
return key;
} | [
"public",
"String",
"getValueForDisplayValue",
"(",
"final",
"String",
"key",
")",
"{",
"if",
"(",
"mapDisplayValuesToValues",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"return",
"mapDisplayValuesToValues",
".",
"get",
"(",
"key",
")",
";",
"}",
"return",... | Returns real unquoted value for a DisplayValue
@param key
@return | [
"Returns",
"real",
"unquoted",
"value",
"for",
"a",
"DisplayValue"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/util/ListBoxValues.java#L275-L280 | train |
kiegroup/jbpm-designer | jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/AssignmentData.java | AssignmentData.getAssignmentRows | public List<AssignmentRow> getAssignmentRows(VariableType varType) {
List<AssignmentRow> rows = new ArrayList<AssignmentRow>();
List<Variable> handledVariables = new ArrayList<Variable>();
// Create an AssignmentRow for each Assignment
for (Assignment assignment : assignments) {
if (assignment.getVariableType() == varType) {
String dataType = getDisplayNameFromDataType(assignment.getDataType());
AssignmentRow row = new AssignmentRow(assignment.getName(),
assignment.getVariableType(),
dataType,
assignment.getCustomDataType(),
assignment.getProcessVarName(),
assignment.getConstant());
rows.add(row);
handledVariables.add(assignment.getVariable());
}
}
List<Variable> vars = null;
if (varType == VariableType.INPUT) {
vars = inputVariables;
} else {
vars = outputVariables;
}
// Create an AssignmentRow for each Variable that doesn't have an Assignment
for (Variable var : vars) {
if (!handledVariables.contains(var)) {
AssignmentRow row = new AssignmentRow(var.getName(),
var.getVariableType(),
var.getDataType(),
var.getCustomDataType(),
null,
null);
rows.add(row);
}
}
return rows;
} | java | public List<AssignmentRow> getAssignmentRows(VariableType varType) {
List<AssignmentRow> rows = new ArrayList<AssignmentRow>();
List<Variable> handledVariables = new ArrayList<Variable>();
// Create an AssignmentRow for each Assignment
for (Assignment assignment : assignments) {
if (assignment.getVariableType() == varType) {
String dataType = getDisplayNameFromDataType(assignment.getDataType());
AssignmentRow row = new AssignmentRow(assignment.getName(),
assignment.getVariableType(),
dataType,
assignment.getCustomDataType(),
assignment.getProcessVarName(),
assignment.getConstant());
rows.add(row);
handledVariables.add(assignment.getVariable());
}
}
List<Variable> vars = null;
if (varType == VariableType.INPUT) {
vars = inputVariables;
} else {
vars = outputVariables;
}
// Create an AssignmentRow for each Variable that doesn't have an Assignment
for (Variable var : vars) {
if (!handledVariables.contains(var)) {
AssignmentRow row = new AssignmentRow(var.getName(),
var.getVariableType(),
var.getDataType(),
var.getCustomDataType(),
null,
null);
rows.add(row);
}
}
return rows;
} | [
"public",
"List",
"<",
"AssignmentRow",
">",
"getAssignmentRows",
"(",
"VariableType",
"varType",
")",
"{",
"List",
"<",
"AssignmentRow",
">",
"rows",
"=",
"new",
"ArrayList",
"<",
"AssignmentRow",
">",
"(",
")",
";",
"List",
"<",
"Variable",
">",
"handledVa... | Gets a list of AssignmentRows based on the current Assignments
@return | [
"Gets",
"a",
"list",
"of",
"AssignmentRows",
"based",
"on",
"the",
"current",
"Assignments"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/AssignmentData.java#L530-L567 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java | DiagramBuilder.parseJson | public static Diagram parseJson(String json,
Boolean keepGlossaryLink) throws JSONException {
JSONObject modelJSON = new JSONObject(json);
return parseJson(modelJSON,
keepGlossaryLink);
} | java | public static Diagram parseJson(String json,
Boolean keepGlossaryLink) throws JSONException {
JSONObject modelJSON = new JSONObject(json);
return parseJson(modelJSON,
keepGlossaryLink);
} | [
"public",
"static",
"Diagram",
"parseJson",
"(",
"String",
"json",
",",
"Boolean",
"keepGlossaryLink",
")",
"throws",
"JSONException",
"{",
"JSONObject",
"modelJSON",
"=",
"new",
"JSONObject",
"(",
"json",
")",
";",
"return",
"parseJson",
"(",
"modelJSON",
",",
... | Parse the json string to the diagram model, assumes that the json is
hierarchical ordered
@param json
@return Model with all shapes defined in JSON
@throws org.json.JSONException | [
"Parse",
"the",
"json",
"string",
"to",
"the",
"diagram",
"model",
"assumes",
"that",
"the",
"json",
"is",
"hierarchical",
"ordered"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L49-L54 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java | DiagramBuilder.parseJson | public static Diagram parseJson(JSONObject json,
Boolean keepGlossaryLink) throws JSONException {
ArrayList<Shape> shapes = new ArrayList<Shape>();
HashMap<String, JSONObject> flatJSON = flatRessources(json);
for (String resourceId : flatJSON.keySet()) {
parseRessource(shapes,
flatJSON,
resourceId,
keepGlossaryLink);
}
String id = "canvas";
if (json.has("resourceId")) {
id = json.getString("resourceId");
shapes.remove(new Shape(id));
}
;
Diagram diagram = new Diagram(id);
// remove Diagram
// (Diagram)getShapeWithId(json.getString("resourceId"), shapes);
parseStencilSet(json,
diagram);
parseSsextensions(json,
diagram);
parseStencil(json,
diagram);
parseProperties(json,
diagram,
keepGlossaryLink);
parseChildShapes(shapes,
json,
diagram);
parseBounds(json,
diagram);
diagram.setShapes(shapes);
return diagram;
} | java | public static Diagram parseJson(JSONObject json,
Boolean keepGlossaryLink) throws JSONException {
ArrayList<Shape> shapes = new ArrayList<Shape>();
HashMap<String, JSONObject> flatJSON = flatRessources(json);
for (String resourceId : flatJSON.keySet()) {
parseRessource(shapes,
flatJSON,
resourceId,
keepGlossaryLink);
}
String id = "canvas";
if (json.has("resourceId")) {
id = json.getString("resourceId");
shapes.remove(new Shape(id));
}
;
Diagram diagram = new Diagram(id);
// remove Diagram
// (Diagram)getShapeWithId(json.getString("resourceId"), shapes);
parseStencilSet(json,
diagram);
parseSsextensions(json,
diagram);
parseStencil(json,
diagram);
parseProperties(json,
diagram,
keepGlossaryLink);
parseChildShapes(shapes,
json,
diagram);
parseBounds(json,
diagram);
diagram.setShapes(shapes);
return diagram;
} | [
"public",
"static",
"Diagram",
"parseJson",
"(",
"JSONObject",
"json",
",",
"Boolean",
"keepGlossaryLink",
")",
"throws",
"JSONException",
"{",
"ArrayList",
"<",
"Shape",
">",
"shapes",
"=",
"new",
"ArrayList",
"<",
"Shape",
">",
"(",
")",
";",
"HashMap",
"<... | do the parsing on an JSONObject, assumes that the json is hierarchical
ordered, so all shapes are reachable over child relations
@param json hierarchical JSON object
@return Model with all shapes defined in JSON
@throws org.json.JSONException | [
"do",
"the",
"parsing",
"on",
"an",
"JSONObject",
"assumes",
"that",
"the",
"json",
"is",
"hierarchical",
"ordered",
"so",
"all",
"shapes",
"are",
"reachable",
"over",
"child",
"relations"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L68-L105 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java | DiagramBuilder.parseRessource | private static void parseRessource(ArrayList<Shape> shapes,
HashMap<String, JSONObject> flatJSON,
String resourceId,
Boolean keepGlossaryLink)
throws JSONException {
JSONObject modelJSON = flatJSON.get(resourceId);
Shape current = getShapeWithId(modelJSON.getString("resourceId"),
shapes);
parseStencil(modelJSON,
current);
parseProperties(modelJSON,
current,
keepGlossaryLink);
parseOutgoings(shapes,
modelJSON,
current);
parseChildShapes(shapes,
modelJSON,
current);
parseDockers(modelJSON,
current);
parseBounds(modelJSON,
current);
parseTarget(shapes,
modelJSON,
current);
} | java | private static void parseRessource(ArrayList<Shape> shapes,
HashMap<String, JSONObject> flatJSON,
String resourceId,
Boolean keepGlossaryLink)
throws JSONException {
JSONObject modelJSON = flatJSON.get(resourceId);
Shape current = getShapeWithId(modelJSON.getString("resourceId"),
shapes);
parseStencil(modelJSON,
current);
parseProperties(modelJSON,
current,
keepGlossaryLink);
parseOutgoings(shapes,
modelJSON,
current);
parseChildShapes(shapes,
modelJSON,
current);
parseDockers(modelJSON,
current);
parseBounds(modelJSON,
current);
parseTarget(shapes,
modelJSON,
current);
} | [
"private",
"static",
"void",
"parseRessource",
"(",
"ArrayList",
"<",
"Shape",
">",
"shapes",
",",
"HashMap",
"<",
"String",
",",
"JSONObject",
">",
"flatJSON",
",",
"String",
"resourceId",
",",
"Boolean",
"keepGlossaryLink",
")",
"throws",
"JSONException",
"{",... | Parse one resource to a shape object and add it to the shapes array
@param shapes
@param flatJSON
@param resourceId
@throws org.json.JSONException | [
"Parse",
"one",
"resource",
"to",
"a",
"shape",
"object",
"and",
"add",
"it",
"to",
"the",
"shapes",
"array"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L114-L142 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java | DiagramBuilder.parseStencil | private static void parseStencil(JSONObject modelJSON,
Shape current) throws JSONException {
// get stencil type
if (modelJSON.has("stencil")) {
JSONObject stencil = modelJSON.getJSONObject("stencil");
// TODO other attributes of stencil
String stencilString = "";
if (stencil.has("id")) {
stencilString = stencil.getString("id");
}
current.setStencil(new StencilType(stencilString));
}
} | java | private static void parseStencil(JSONObject modelJSON,
Shape current) throws JSONException {
// get stencil type
if (modelJSON.has("stencil")) {
JSONObject stencil = modelJSON.getJSONObject("stencil");
// TODO other attributes of stencil
String stencilString = "";
if (stencil.has("id")) {
stencilString = stencil.getString("id");
}
current.setStencil(new StencilType(stencilString));
}
} | [
"private",
"static",
"void",
"parseStencil",
"(",
"JSONObject",
"modelJSON",
",",
"Shape",
"current",
")",
"throws",
"JSONException",
"{",
"// get stencil type",
"if",
"(",
"modelJSON",
".",
"has",
"(",
"\"stencil\"",
")",
")",
"{",
"JSONObject",
"stencil",
"=",... | parse the stencil out of a JSONObject and set it to the current shape
@param modelJSON
@param current
@throws org.json.JSONException | [
"parse",
"the",
"stencil",
"out",
"of",
"a",
"JSONObject",
"and",
"set",
"it",
"to",
"the",
"current",
"shape"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L150-L162 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java | DiagramBuilder.parseStencilSet | private static void parseStencilSet(JSONObject modelJSON,
Diagram current) throws JSONException {
// get stencil type
if (modelJSON.has("stencilset")) {
JSONObject object = modelJSON.getJSONObject("stencilset");
String url = null;
String namespace = null;
if (object.has("url")) {
url = object.getString("url");
}
if (object.has("namespace")) {
namespace = object.getString("namespace");
}
current.setStencilset(new StencilSet(url,
namespace));
}
} | java | private static void parseStencilSet(JSONObject modelJSON,
Diagram current) throws JSONException {
// get stencil type
if (modelJSON.has("stencilset")) {
JSONObject object = modelJSON.getJSONObject("stencilset");
String url = null;
String namespace = null;
if (object.has("url")) {
url = object.getString("url");
}
if (object.has("namespace")) {
namespace = object.getString("namespace");
}
current.setStencilset(new StencilSet(url,
namespace));
}
} | [
"private",
"static",
"void",
"parseStencilSet",
"(",
"JSONObject",
"modelJSON",
",",
"Diagram",
"current",
")",
"throws",
"JSONException",
"{",
"// get stencil type",
"if",
"(",
"modelJSON",
".",
"has",
"(",
"\"stencilset\"",
")",
")",
"{",
"JSONObject",
"object",... | crates a StencilSet object and add it to the current diagram
@param modelJSON
@param current
@throws org.json.JSONException | [
"crates",
"a",
"StencilSet",
"object",
"and",
"add",
"it",
"to",
"the",
"current",
"diagram"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L170-L189 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java | DiagramBuilder.parseProperties | @SuppressWarnings("unchecked")
private static void parseProperties(JSONObject modelJSON,
Shape current,
Boolean keepGlossaryLink) throws JSONException {
if (modelJSON.has("properties")) {
JSONObject propsObject = modelJSON.getJSONObject("properties");
Iterator<String> keys = propsObject.keys();
Pattern pattern = Pattern.compile(jsonPattern);
while (keys.hasNext()) {
StringBuilder result = new StringBuilder();
int lastIndex = 0;
String key = keys.next();
String value = propsObject.getString(key);
if (!keepGlossaryLink) {
Matcher matcher = pattern.matcher(value);
while (matcher.find()) {
String id = matcher.group(1);
current.addGlossaryIds(id);
String text = matcher.group(2);
result.append(text);
lastIndex = matcher.end();
}
result.append(value.substring(lastIndex));
value = result.toString();
}
current.putProperty(key,
value);
}
}
} | java | @SuppressWarnings("unchecked")
private static void parseProperties(JSONObject modelJSON,
Shape current,
Boolean keepGlossaryLink) throws JSONException {
if (modelJSON.has("properties")) {
JSONObject propsObject = modelJSON.getJSONObject("properties");
Iterator<String> keys = propsObject.keys();
Pattern pattern = Pattern.compile(jsonPattern);
while (keys.hasNext()) {
StringBuilder result = new StringBuilder();
int lastIndex = 0;
String key = keys.next();
String value = propsObject.getString(key);
if (!keepGlossaryLink) {
Matcher matcher = pattern.matcher(value);
while (matcher.find()) {
String id = matcher.group(1);
current.addGlossaryIds(id);
String text = matcher.group(2);
result.append(text);
lastIndex = matcher.end();
}
result.append(value.substring(lastIndex));
value = result.toString();
}
current.putProperty(key,
value);
}
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"static",
"void",
"parseProperties",
"(",
"JSONObject",
"modelJSON",
",",
"Shape",
"current",
",",
"Boolean",
"keepGlossaryLink",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"modelJSON",
".",
"has"... | create a HashMap form the json properties and add it to the shape
@param modelJSON
@param current
@throws org.json.JSONException | [
"create",
"a",
"HashMap",
"form",
"the",
"json",
"properties",
"and",
"add",
"it",
"to",
"the",
"shape"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L197-L229 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java | DiagramBuilder.parseSsextensions | private static void parseSsextensions(JSONObject modelJSON,
Diagram current) throws JSONException {
if (modelJSON.has("ssextensions")) {
JSONArray array = modelJSON.getJSONArray("ssextensions");
for (int i = 0; i < array.length(); i++) {
current.addSsextension(array.getString(i));
}
}
} | java | private static void parseSsextensions(JSONObject modelJSON,
Diagram current) throws JSONException {
if (modelJSON.has("ssextensions")) {
JSONArray array = modelJSON.getJSONArray("ssextensions");
for (int i = 0; i < array.length(); i++) {
current.addSsextension(array.getString(i));
}
}
} | [
"private",
"static",
"void",
"parseSsextensions",
"(",
"JSONObject",
"modelJSON",
",",
"Diagram",
"current",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"modelJSON",
".",
"has",
"(",
"\"ssextensions\"",
")",
")",
"{",
"JSONArray",
"array",
"=",
"modelJSON",
... | adds all json extension to an diagram
@param modelJSON
@param current
@throws org.json.JSONException | [
"adds",
"all",
"json",
"extension",
"to",
"an",
"diagram"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L237-L245 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java | DiagramBuilder.parseOutgoings | private static void parseOutgoings(ArrayList<Shape> shapes,
JSONObject modelJSON,
Shape current) throws JSONException {
if (modelJSON.has("outgoing")) {
ArrayList<Shape> outgoings = new ArrayList<Shape>();
JSONArray outgoingObject = modelJSON.getJSONArray("outgoing");
for (int i = 0; i < outgoingObject.length(); i++) {
Shape out = getShapeWithId(outgoingObject.getJSONObject(i).getString("resourceId"),
shapes);
outgoings.add(out);
out.addIncoming(current);
}
if (outgoings.size() > 0) {
current.setOutgoings(outgoings);
}
}
} | java | private static void parseOutgoings(ArrayList<Shape> shapes,
JSONObject modelJSON,
Shape current) throws JSONException {
if (modelJSON.has("outgoing")) {
ArrayList<Shape> outgoings = new ArrayList<Shape>();
JSONArray outgoingObject = modelJSON.getJSONArray("outgoing");
for (int i = 0; i < outgoingObject.length(); i++) {
Shape out = getShapeWithId(outgoingObject.getJSONObject(i).getString("resourceId"),
shapes);
outgoings.add(out);
out.addIncoming(current);
}
if (outgoings.size() > 0) {
current.setOutgoings(outgoings);
}
}
} | [
"private",
"static",
"void",
"parseOutgoings",
"(",
"ArrayList",
"<",
"Shape",
">",
"shapes",
",",
"JSONObject",
"modelJSON",
",",
"Shape",
"current",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"modelJSON",
".",
"has",
"(",
"\"outgoing\"",
")",
")",
"{"... | parse the outgoings form an json object and add all shape references to
the current shapes, add new shapes to the shape array
@param shapes
@param modelJSON
@param current
@throws org.json.JSONException | [
"parse",
"the",
"outgoings",
"form",
"an",
"json",
"object",
"and",
"add",
"all",
"shape",
"references",
"to",
"the",
"current",
"shapes",
"add",
"new",
"shapes",
"to",
"the",
"shape",
"array"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L255-L271 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java | DiagramBuilder.parseChildShapes | private static void parseChildShapes(ArrayList<Shape> shapes,
JSONObject modelJSON,
Shape current) throws JSONException {
if (modelJSON.has("childShapes")) {
ArrayList<Shape> childShapes = new ArrayList<Shape>();
JSONArray childShapeObject = modelJSON.getJSONArray("childShapes");
for (int i = 0; i < childShapeObject.length(); i++) {
childShapes.add(getShapeWithId(childShapeObject.getJSONObject(i).getString("resourceId"),
shapes));
}
if (childShapes.size() > 0) {
for (Shape each : childShapes) {
each.setParent(current);
}
current.setChildShapes(childShapes);
}
;
}
} | java | private static void parseChildShapes(ArrayList<Shape> shapes,
JSONObject modelJSON,
Shape current) throws JSONException {
if (modelJSON.has("childShapes")) {
ArrayList<Shape> childShapes = new ArrayList<Shape>();
JSONArray childShapeObject = modelJSON.getJSONArray("childShapes");
for (int i = 0; i < childShapeObject.length(); i++) {
childShapes.add(getShapeWithId(childShapeObject.getJSONObject(i).getString("resourceId"),
shapes));
}
if (childShapes.size() > 0) {
for (Shape each : childShapes) {
each.setParent(current);
}
current.setChildShapes(childShapes);
}
;
}
} | [
"private",
"static",
"void",
"parseChildShapes",
"(",
"ArrayList",
"<",
"Shape",
">",
"shapes",
",",
"JSONObject",
"modelJSON",
",",
"Shape",
"current",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"modelJSON",
".",
"has",
"(",
"\"childShapes\"",
")",
")",
... | creates a shape list containing all child shapes and set it to the
current shape new shape get added to the shape array
@param shapes
@param modelJSON
@param current
@throws org.json.JSONException | [
"creates",
"a",
"shape",
"list",
"containing",
"all",
"child",
"shapes",
"and",
"set",
"it",
"to",
"the",
"current",
"shape",
"new",
"shape",
"get",
"added",
"to",
"the",
"shape",
"array"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L281-L300 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java | DiagramBuilder.parseDockers | private static void parseDockers(JSONObject modelJSON,
Shape current) throws JSONException {
if (modelJSON.has("dockers")) {
ArrayList<Point> dockers = new ArrayList<Point>();
JSONArray dockersObject = modelJSON.getJSONArray("dockers");
for (int i = 0; i < dockersObject.length(); i++) {
Double x = dockersObject.getJSONObject(i).getDouble("x");
Double y = dockersObject.getJSONObject(i).getDouble("y");
dockers.add(new Point(x,
y));
}
if (dockers.size() > 0) {
current.setDockers(dockers);
}
}
} | java | private static void parseDockers(JSONObject modelJSON,
Shape current) throws JSONException {
if (modelJSON.has("dockers")) {
ArrayList<Point> dockers = new ArrayList<Point>();
JSONArray dockersObject = modelJSON.getJSONArray("dockers");
for (int i = 0; i < dockersObject.length(); i++) {
Double x = dockersObject.getJSONObject(i).getDouble("x");
Double y = dockersObject.getJSONObject(i).getDouble("y");
dockers.add(new Point(x,
y));
}
if (dockers.size() > 0) {
current.setDockers(dockers);
}
}
} | [
"private",
"static",
"void",
"parseDockers",
"(",
"JSONObject",
"modelJSON",
",",
"Shape",
"current",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"modelJSON",
".",
"has",
"(",
"\"dockers\"",
")",
")",
"{",
"ArrayList",
"<",
"Point",
">",
"dockers",
"=",
... | creates a point array of all dockers and add it to the current shape
@param modelJSON
@param current
@throws org.json.JSONException | [
"creates",
"a",
"point",
"array",
"of",
"all",
"dockers",
"and",
"add",
"it",
"to",
"the",
"current",
"shape"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L308-L324 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java | DiagramBuilder.parseBounds | private static void parseBounds(JSONObject modelJSON,
Shape current) throws JSONException {
if (modelJSON.has("bounds")) {
JSONObject boundsObject = modelJSON.getJSONObject("bounds");
current.setBounds(new Bounds(new Point(boundsObject.getJSONObject("lowerRight").getDouble("x"),
boundsObject.getJSONObject("lowerRight").getDouble(
"y")),
new Point(boundsObject.getJSONObject("upperLeft").getDouble("x"),
boundsObject.getJSONObject("upperLeft").getDouble("y"))));
}
} | java | private static void parseBounds(JSONObject modelJSON,
Shape current) throws JSONException {
if (modelJSON.has("bounds")) {
JSONObject boundsObject = modelJSON.getJSONObject("bounds");
current.setBounds(new Bounds(new Point(boundsObject.getJSONObject("lowerRight").getDouble("x"),
boundsObject.getJSONObject("lowerRight").getDouble(
"y")),
new Point(boundsObject.getJSONObject("upperLeft").getDouble("x"),
boundsObject.getJSONObject("upperLeft").getDouble("y"))));
}
} | [
"private",
"static",
"void",
"parseBounds",
"(",
"JSONObject",
"modelJSON",
",",
"Shape",
"current",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"modelJSON",
".",
"has",
"(",
"\"bounds\"",
")",
")",
"{",
"JSONObject",
"boundsObject",
"=",
"modelJSON",
".",... | creates a bounds object with both point parsed from the json and set it
to the current shape
@param modelJSON
@param current
@throws org.json.JSONException | [
"creates",
"a",
"bounds",
"object",
"with",
"both",
"point",
"parsed",
"from",
"the",
"json",
"and",
"set",
"it",
"to",
"the",
"current",
"shape"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L333-L343 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java | DiagramBuilder.parseTarget | private static void parseTarget(ArrayList<Shape> shapes,
JSONObject modelJSON,
Shape current) throws JSONException {
if (modelJSON.has("target")) {
JSONObject targetObject = modelJSON.getJSONObject("target");
if (targetObject.has("resourceId")) {
current.setTarget(getShapeWithId(targetObject.getString("resourceId"),
shapes));
}
}
} | java | private static void parseTarget(ArrayList<Shape> shapes,
JSONObject modelJSON,
Shape current) throws JSONException {
if (modelJSON.has("target")) {
JSONObject targetObject = modelJSON.getJSONObject("target");
if (targetObject.has("resourceId")) {
current.setTarget(getShapeWithId(targetObject.getString("resourceId"),
shapes));
}
}
} | [
"private",
"static",
"void",
"parseTarget",
"(",
"ArrayList",
"<",
"Shape",
">",
"shapes",
",",
"JSONObject",
"modelJSON",
",",
"Shape",
"current",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"modelJSON",
".",
"has",
"(",
"\"target\"",
")",
")",
"{",
"... | parse the target resource and add it to the current shape
@param shapes
@param modelJSON
@param current
@throws org.json.JSONException | [
"parse",
"the",
"target",
"resource",
"and",
"add",
"it",
"to",
"the",
"current",
"shape"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L352-L362 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java | DiagramBuilder.flatRessources | public static HashMap<String, JSONObject> flatRessources(JSONObject object) throws JSONException {
HashMap<String, JSONObject> result = new HashMap<String, JSONObject>();
// no cycle in hierarchies!!
if (object.has("resourceId") && object.has("childShapes")) {
result.put(object.getString("resourceId"),
object);
JSONArray childShapes = object.getJSONArray("childShapes");
for (int i = 0; i < childShapes.length(); i++) {
result.putAll(flatRessources(childShapes.getJSONObject(i)));
}
}
;
return result;
} | java | public static HashMap<String, JSONObject> flatRessources(JSONObject object) throws JSONException {
HashMap<String, JSONObject> result = new HashMap<String, JSONObject>();
// no cycle in hierarchies!!
if (object.has("resourceId") && object.has("childShapes")) {
result.put(object.getString("resourceId"),
object);
JSONArray childShapes = object.getJSONArray("childShapes");
for (int i = 0; i < childShapes.length(); i++) {
result.putAll(flatRessources(childShapes.getJSONObject(i)));
}
}
;
return result;
} | [
"public",
"static",
"HashMap",
"<",
"String",
",",
"JSONObject",
">",
"flatRessources",
"(",
"JSONObject",
"object",
")",
"throws",
"JSONException",
"{",
"HashMap",
"<",
"String",
",",
"JSONObject",
">",
"result",
"=",
"new",
"HashMap",
"<",
"String",
",",
"... | Prepare a model JSON for analyze, resolves the hierarchical structure
creates a HashMap which contains all resourceIds as keys and for each key
the JSONObject, all id are keys of this map
@param object
@return a HashMap keys: all ressourceIds values: all child JSONObjects
@throws org.json.JSONException | [
"Prepare",
"a",
"model",
"JSON",
"for",
"analyze",
"resolves",
"the",
"hierarchical",
"structure",
"creates",
"a",
"HashMap",
"which",
"contains",
"all",
"resourceIds",
"as",
"keys",
"and",
"for",
"each",
"key",
"the",
"JSONObject",
"all",
"id",
"are",
"keys",... | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L388-L403 | train |
kiegroup/jbpm-designer | jbpm-designer-client/src/main/java/org/jbpm/designer/client/util/DataIOEditorNameTextBox.java | DataIOEditorNameTextBox.setInvalidValues | public void setInvalidValues(final Set<String> invalidValues,
final boolean isCaseSensitive,
final String invalidValueErrorMessage) {
if (isCaseSensitive) {
this.invalidValues = invalidValues;
} else {
this.invalidValues = new HashSet<String>();
for (String value : invalidValues) {
this.invalidValues.add(value.toLowerCase());
}
}
this.isCaseSensitive = isCaseSensitive;
this.invalidValueErrorMessage = invalidValueErrorMessage;
} | java | public void setInvalidValues(final Set<String> invalidValues,
final boolean isCaseSensitive,
final String invalidValueErrorMessage) {
if (isCaseSensitive) {
this.invalidValues = invalidValues;
} else {
this.invalidValues = new HashSet<String>();
for (String value : invalidValues) {
this.invalidValues.add(value.toLowerCase());
}
}
this.isCaseSensitive = isCaseSensitive;
this.invalidValueErrorMessage = invalidValueErrorMessage;
} | [
"public",
"void",
"setInvalidValues",
"(",
"final",
"Set",
"<",
"String",
">",
"invalidValues",
",",
"final",
"boolean",
"isCaseSensitive",
",",
"final",
"String",
"invalidValueErrorMessage",
")",
"{",
"if",
"(",
"isCaseSensitive",
")",
"{",
"this",
".",
"invali... | Sets the invalid values for the TextBox
@param invalidValues
@param isCaseSensitive
@param invalidValueErrorMessage | [
"Sets",
"the",
"invalid",
"values",
"for",
"the",
"TextBox"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/util/DataIOEditorNameTextBox.java#L47-L60 | train |
kiegroup/jbpm-designer | jbpm-designer-client/src/main/java/org/jbpm/designer/client/util/DataIOEditorNameTextBox.java | DataIOEditorNameTextBox.setRegExp | public void setRegExp(final String pattern,
final String invalidCharactersInNameErrorMessage,
final String invalidCharacterTypedMessage) {
regExp = RegExp.compile(pattern);
this.invalidCharactersInNameErrorMessage = invalidCharactersInNameErrorMessage;
this.invalidCharacterTypedMessage = invalidCharacterTypedMessage;
} | java | public void setRegExp(final String pattern,
final String invalidCharactersInNameErrorMessage,
final String invalidCharacterTypedMessage) {
regExp = RegExp.compile(pattern);
this.invalidCharactersInNameErrorMessage = invalidCharactersInNameErrorMessage;
this.invalidCharacterTypedMessage = invalidCharacterTypedMessage;
} | [
"public",
"void",
"setRegExp",
"(",
"final",
"String",
"pattern",
",",
"final",
"String",
"invalidCharactersInNameErrorMessage",
",",
"final",
"String",
"invalidCharacterTypedMessage",
")",
"{",
"regExp",
"=",
"RegExp",
".",
"compile",
"(",
"pattern",
")",
";",
"t... | Sets the RegExp pattern for the TextBox
@param pattern
@param invalidCharactersInNameErrorMessage | [
"Sets",
"the",
"RegExp",
"pattern",
"for",
"the",
"TextBox"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/util/DataIOEditorNameTextBox.java#L67-L73 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/Shape.java | Shape.getProperties | public HashMap<String, String> getProperties() {
if (this.properties == null) {
this.properties = new HashMap<String, String>();
}
return properties;
} | java | public HashMap<String, String> getProperties() {
if (this.properties == null) {
this.properties = new HashMap<String, String>();
}
return properties;
} | [
"public",
"HashMap",
"<",
"String",
",",
"String",
">",
"getProperties",
"(",
")",
"{",
"if",
"(",
"this",
".",
"properties",
"==",
"null",
")",
"{",
"this",
".",
"properties",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
... | return a HashMap with all properties, name as key, value as value
@return the properties | [
"return",
"a",
"HashMap",
"with",
"all",
"properties",
"name",
"as",
"key",
"value",
"as",
"value"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/Shape.java#L153-L158 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/Shape.java | Shape.putProperty | public String putProperty(String key,
String value) {
return this.getProperties().put(key,
value);
} | java | public String putProperty(String key,
String value) {
return this.getProperties().put(key,
value);
} | [
"public",
"String",
"putProperty",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"return",
"this",
".",
"getProperties",
"(",
")",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}"
] | changes an existing property with the same name, or adds a new one
@param key property name with which the specified value is to be
associated
@param value value to be associated with the specified property name
@return the previous value associated with property name, or null if
there was no mapping for property name. (A null return can also
indicate that the map previously associated null with key.) | [
"changes",
"an",
"existing",
"property",
"with",
"the",
"same",
"name",
"or",
"adds",
"a",
"new",
"one"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/Shape.java#L177-L181 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/web/server/CalledElementServlet.java | CalledElementServlet.getRuleFlowNames | List<String> getRuleFlowNames(HttpServletRequest req) {
final String[] projectAndBranch = getProjectAndBranchNames(req);
// Query RuleFlowGroups for asset project and branch
List<RefactoringPageRow> results = queryService.query(
DesignerFindRuleFlowNamesQuery.NAME,
new HashSet<ValueIndexTerm>() {{
add(new ValueSharedPartIndexTerm("*",
PartType.RULEFLOW_GROUP,
TermSearchType.WILDCARD));
add(new ValueModuleNameIndexTerm(projectAndBranch[0]));
if (projectAndBranch[1] != null) {
add(new ValueBranchNameIndexTerm(projectAndBranch[1]));
}
}});
final List<String> ruleFlowGroupNames = new ArrayList<String>();
for (RefactoringPageRow row : results) {
ruleFlowGroupNames.add((String) row.getValue());
}
Collections.sort(ruleFlowGroupNames);
// Query RuleFlowGroups for all projects and branches
results = queryService.query(
DesignerFindRuleFlowNamesQuery.NAME,
new HashSet<ValueIndexTerm>() {{
add(new ValueSharedPartIndexTerm("*",
PartType.RULEFLOW_GROUP,
TermSearchType.WILDCARD));
}});
final List<String> otherRuleFlowGroupNames = new LinkedList<String>();
for (RefactoringPageRow row : results) {
String ruleFlowGroupName = (String) row.getValue();
if (!ruleFlowGroupNames.contains(ruleFlowGroupName)) {
// but only add the new ones
otherRuleFlowGroupNames.add(ruleFlowGroupName);
}
}
Collections.sort(otherRuleFlowGroupNames);
ruleFlowGroupNames.addAll(otherRuleFlowGroupNames);
return ruleFlowGroupNames;
} | java | List<String> getRuleFlowNames(HttpServletRequest req) {
final String[] projectAndBranch = getProjectAndBranchNames(req);
// Query RuleFlowGroups for asset project and branch
List<RefactoringPageRow> results = queryService.query(
DesignerFindRuleFlowNamesQuery.NAME,
new HashSet<ValueIndexTerm>() {{
add(new ValueSharedPartIndexTerm("*",
PartType.RULEFLOW_GROUP,
TermSearchType.WILDCARD));
add(new ValueModuleNameIndexTerm(projectAndBranch[0]));
if (projectAndBranch[1] != null) {
add(new ValueBranchNameIndexTerm(projectAndBranch[1]));
}
}});
final List<String> ruleFlowGroupNames = new ArrayList<String>();
for (RefactoringPageRow row : results) {
ruleFlowGroupNames.add((String) row.getValue());
}
Collections.sort(ruleFlowGroupNames);
// Query RuleFlowGroups for all projects and branches
results = queryService.query(
DesignerFindRuleFlowNamesQuery.NAME,
new HashSet<ValueIndexTerm>() {{
add(new ValueSharedPartIndexTerm("*",
PartType.RULEFLOW_GROUP,
TermSearchType.WILDCARD));
}});
final List<String> otherRuleFlowGroupNames = new LinkedList<String>();
for (RefactoringPageRow row : results) {
String ruleFlowGroupName = (String) row.getValue();
if (!ruleFlowGroupNames.contains(ruleFlowGroupName)) {
// but only add the new ones
otherRuleFlowGroupNames.add(ruleFlowGroupName);
}
}
Collections.sort(otherRuleFlowGroupNames);
ruleFlowGroupNames.addAll(otherRuleFlowGroupNames);
return ruleFlowGroupNames;
} | [
"List",
"<",
"String",
">",
"getRuleFlowNames",
"(",
"HttpServletRequest",
"req",
")",
"{",
"final",
"String",
"[",
"]",
"projectAndBranch",
"=",
"getProjectAndBranchNames",
"(",
"req",
")",
";",
"// Query RuleFlowGroups for asset project and branch",
"List",
"<",
"Re... | package scope in order to test the method | [
"package",
"scope",
"in",
"order",
"to",
"test",
"the",
"method"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/web/server/CalledElementServlet.java#L206-L249 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/web/plugin/impl/PluginServiceImpl.java | PluginServiceImpl.getLocalPluginsRegistry | public static Map<String, IDiagramPlugin>
getLocalPluginsRegistry(ServletContext context) {
if (LOCAL == null) {
LOCAL = initializeLocalPlugins(context);
}
return LOCAL;
} | java | public static Map<String, IDiagramPlugin>
getLocalPluginsRegistry(ServletContext context) {
if (LOCAL == null) {
LOCAL = initializeLocalPlugins(context);
}
return LOCAL;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"IDiagramPlugin",
">",
"getLocalPluginsRegistry",
"(",
"ServletContext",
"context",
")",
"{",
"if",
"(",
"LOCAL",
"==",
"null",
")",
"{",
"LOCAL",
"=",
"initializeLocalPlugins",
"(",
"context",
")",
";",
"}",
"r... | Initialize the local plugins registry
@param context the servlet context necessary to grab
the files inside the servlet.
@return the set of local plugins organized by name | [
"Initialize",
"the",
"local",
"plugins",
"registry"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/web/plugin/impl/PluginServiceImpl.java#L81-L87 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/Diagram.java | Diagram.addSsextension | public boolean addSsextension(String ssExt) {
if (this.ssextensions == null) {
this.ssextensions = new ArrayList<String>();
}
return this.ssextensions.add(ssExt);
} | java | public boolean addSsextension(String ssExt) {
if (this.ssextensions == null) {
this.ssextensions = new ArrayList<String>();
}
return this.ssextensions.add(ssExt);
} | [
"public",
"boolean",
"addSsextension",
"(",
"String",
"ssExt",
")",
"{",
"if",
"(",
"this",
".",
"ssextensions",
"==",
"null",
")",
"{",
"this",
".",
"ssextensions",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"}",
"return",
"this",
"."... | Add an additional SSExtension
@param ssExt the ssextension to set | [
"Add",
"an",
"additional",
"SSExtension"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/Diagram.java#L101-L106 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java | JSONBuilder.parseStencil | private static JSONObject parseStencil(String stencilId) throws JSONException {
JSONObject stencilObject = new JSONObject();
stencilObject.put("id",
stencilId.toString());
return stencilObject;
} | java | private static JSONObject parseStencil(String stencilId) throws JSONException {
JSONObject stencilObject = new JSONObject();
stencilObject.put("id",
stencilId.toString());
return stencilObject;
} | [
"private",
"static",
"JSONObject",
"parseStencil",
"(",
"String",
"stencilId",
")",
"throws",
"JSONException",
"{",
"JSONObject",
"stencilObject",
"=",
"new",
"JSONObject",
"(",
")",
";",
"stencilObject",
".",
"put",
"(",
"\"id\"",
",",
"stencilId",
".",
"toStri... | Delivers the correct JSON Object for the stencilId
@param stencilId
@throws org.json.JSONException | [
"Delivers",
"the",
"correct",
"JSON",
"Object",
"for",
"the",
"stencilId"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L66-L73 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java | JSONBuilder.parseChildShapesRecursive | private static JSONArray parseChildShapesRecursive(ArrayList<Shape> childShapes) throws JSONException {
if (childShapes != null) {
JSONArray childShapesArray = new JSONArray();
for (Shape childShape : childShapes) {
JSONObject childShapeObject = new JSONObject();
childShapeObject.put("resourceId",
childShape.getResourceId().toString());
childShapeObject.put("properties",
parseProperties(childShape.getProperties()));
childShapeObject.put("stencil",
parseStencil(childShape.getStencilId()));
childShapeObject.put("childShapes",
parseChildShapesRecursive(childShape.getChildShapes()));
childShapeObject.put("outgoing",
parseOutgoings(childShape.getOutgoings()));
childShapeObject.put("bounds",
parseBounds(childShape.getBounds()));
childShapeObject.put("dockers",
parseDockers(childShape.getDockers()));
if (childShape.getTarget() != null) {
childShapeObject.put("target",
parseTarget(childShape.getTarget()));
}
childShapesArray.put(childShapeObject);
}
return childShapesArray;
}
return new JSONArray();
} | java | private static JSONArray parseChildShapesRecursive(ArrayList<Shape> childShapes) throws JSONException {
if (childShapes != null) {
JSONArray childShapesArray = new JSONArray();
for (Shape childShape : childShapes) {
JSONObject childShapeObject = new JSONObject();
childShapeObject.put("resourceId",
childShape.getResourceId().toString());
childShapeObject.put("properties",
parseProperties(childShape.getProperties()));
childShapeObject.put("stencil",
parseStencil(childShape.getStencilId()));
childShapeObject.put("childShapes",
parseChildShapesRecursive(childShape.getChildShapes()));
childShapeObject.put("outgoing",
parseOutgoings(childShape.getOutgoings()));
childShapeObject.put("bounds",
parseBounds(childShape.getBounds()));
childShapeObject.put("dockers",
parseDockers(childShape.getDockers()));
if (childShape.getTarget() != null) {
childShapeObject.put("target",
parseTarget(childShape.getTarget()));
}
childShapesArray.put(childShapeObject);
}
return childShapesArray;
}
return new JSONArray();
} | [
"private",
"static",
"JSONArray",
"parseChildShapesRecursive",
"(",
"ArrayList",
"<",
"Shape",
">",
"childShapes",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"childShapes",
"!=",
"null",
")",
"{",
"JSONArray",
"childShapesArray",
"=",
"new",
"JSONArray",
"(",... | Parses all child Shapes recursively and adds them to the correct JSON
Object
@param childShapes
@throws org.json.JSONException | [
"Parses",
"all",
"child",
"Shapes",
"recursively",
"and",
"adds",
"them",
"to",
"the",
"correct",
"JSON",
"Object"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L82-L116 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java | JSONBuilder.parseTarget | private static JSONObject parseTarget(Shape target) throws JSONException {
JSONObject targetObject = new JSONObject();
targetObject.put("resourceId",
target.getResourceId().toString());
return targetObject;
} | java | private static JSONObject parseTarget(Shape target) throws JSONException {
JSONObject targetObject = new JSONObject();
targetObject.put("resourceId",
target.getResourceId().toString());
return targetObject;
} | [
"private",
"static",
"JSONObject",
"parseTarget",
"(",
"Shape",
"target",
")",
"throws",
"JSONException",
"{",
"JSONObject",
"targetObject",
"=",
"new",
"JSONObject",
"(",
")",
";",
"targetObject",
".",
"put",
"(",
"\"resourceId\"",
",",
"target",
".",
"getResou... | Delivers the correct JSON Object for the target
@param target
@throws org.json.JSONException | [
"Delivers",
"the",
"correct",
"JSON",
"Object",
"for",
"the",
"target"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L124-L131 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java | JSONBuilder.parseDockers | private static JSONArray parseDockers(ArrayList<Point> dockers) throws JSONException {
if (dockers != null) {
JSONArray dockersArray = new JSONArray();
for (Point docker : dockers) {
JSONObject dockerObject = new JSONObject();
dockerObject.put("x",
docker.getX().doubleValue());
dockerObject.put("y",
docker.getY().doubleValue());
dockersArray.put(dockerObject);
}
return dockersArray;
}
return new JSONArray();
} | java | private static JSONArray parseDockers(ArrayList<Point> dockers) throws JSONException {
if (dockers != null) {
JSONArray dockersArray = new JSONArray();
for (Point docker : dockers) {
JSONObject dockerObject = new JSONObject();
dockerObject.put("x",
docker.getX().doubleValue());
dockerObject.put("y",
docker.getY().doubleValue());
dockersArray.put(dockerObject);
}
return dockersArray;
}
return new JSONArray();
} | [
"private",
"static",
"JSONArray",
"parseDockers",
"(",
"ArrayList",
"<",
"Point",
">",
"dockers",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"dockers",
"!=",
"null",
")",
"{",
"JSONArray",
"dockersArray",
"=",
"new",
"JSONArray",
"(",
")",
";",
"for",
... | Delivers the correct JSON Object for the dockers
@param dockers
@throws org.json.JSONException | [
"Delivers",
"the",
"correct",
"JSON",
"Object",
"for",
"the",
"dockers"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L139-L158 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java | JSONBuilder.parseOutgoings | private static JSONArray parseOutgoings(ArrayList<Shape> outgoings) throws JSONException {
if (outgoings != null) {
JSONArray outgoingsArray = new JSONArray();
for (Shape outgoing : outgoings) {
JSONObject outgoingObject = new JSONObject();
outgoingObject.put("resourceId",
outgoing.getResourceId().toString());
outgoingsArray.put(outgoingObject);
}
return outgoingsArray;
}
return new JSONArray();
} | java | private static JSONArray parseOutgoings(ArrayList<Shape> outgoings) throws JSONException {
if (outgoings != null) {
JSONArray outgoingsArray = new JSONArray();
for (Shape outgoing : outgoings) {
JSONObject outgoingObject = new JSONObject();
outgoingObject.put("resourceId",
outgoing.getResourceId().toString());
outgoingsArray.put(outgoingObject);
}
return outgoingsArray;
}
return new JSONArray();
} | [
"private",
"static",
"JSONArray",
"parseOutgoings",
"(",
"ArrayList",
"<",
"Shape",
">",
"outgoings",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"outgoings",
"!=",
"null",
")",
"{",
"JSONArray",
"outgoingsArray",
"=",
"new",
"JSONArray",
"(",
")",
";",
... | Delivers the correct JSON Object for outgoings
@param outgoings
@throws org.json.JSONException | [
"Delivers",
"the",
"correct",
"JSON",
"Object",
"for",
"outgoings"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L166-L182 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java | JSONBuilder.parseProperties | private static JSONObject parseProperties(HashMap<String, String> properties) throws JSONException {
if (properties != null) {
JSONObject propertiesObject = new JSONObject();
for (String key : properties.keySet()) {
String propertyValue = properties.get(key);
/*
* if(propertyValue.matches("true|false")) {
*
* propertiesObject.put(key, propertyValue.equals("true"));
*
* } else if(propertyValue.matches("[0-9]+")) {
*
* Integer value = Integer.parseInt(propertyValue);
* propertiesObject.put(key, value);
*
* } else
*/
if (propertyValue.startsWith("{") && propertyValue.endsWith("}")) {
propertiesObject.put(key,
new JSONObject(propertyValue));
} else {
propertiesObject.put(key,
propertyValue.toString());
}
}
return propertiesObject;
}
return new JSONObject();
} | java | private static JSONObject parseProperties(HashMap<String, String> properties) throws JSONException {
if (properties != null) {
JSONObject propertiesObject = new JSONObject();
for (String key : properties.keySet()) {
String propertyValue = properties.get(key);
/*
* if(propertyValue.matches("true|false")) {
*
* propertiesObject.put(key, propertyValue.equals("true"));
*
* } else if(propertyValue.matches("[0-9]+")) {
*
* Integer value = Integer.parseInt(propertyValue);
* propertiesObject.put(key, value);
*
* } else
*/
if (propertyValue.startsWith("{") && propertyValue.endsWith("}")) {
propertiesObject.put(key,
new JSONObject(propertyValue));
} else {
propertiesObject.put(key,
propertyValue.toString());
}
}
return propertiesObject;
}
return new JSONObject();
} | [
"private",
"static",
"JSONObject",
"parseProperties",
"(",
"HashMap",
"<",
"String",
",",
"String",
">",
"properties",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"properties",
"!=",
"null",
")",
"{",
"JSONObject",
"propertiesObject",
"=",
"new",
"JSONObject... | Delivers the correct JSON Object for properties
@param properties
@throws org.json.JSONException | [
"Delivers",
"the",
"correct",
"JSON",
"Object",
"for",
"properties"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L190-L222 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java | JSONBuilder.parseStencilSetExtensions | private static JSONArray parseStencilSetExtensions(ArrayList<String> extensions) {
if (extensions != null) {
JSONArray extensionsArray = new JSONArray();
for (String extension : extensions) {
extensionsArray.put(extension.toString());
}
return extensionsArray;
}
return new JSONArray();
} | java | private static JSONArray parseStencilSetExtensions(ArrayList<String> extensions) {
if (extensions != null) {
JSONArray extensionsArray = new JSONArray();
for (String extension : extensions) {
extensionsArray.put(extension.toString());
}
return extensionsArray;
}
return new JSONArray();
} | [
"private",
"static",
"JSONArray",
"parseStencilSetExtensions",
"(",
"ArrayList",
"<",
"String",
">",
"extensions",
")",
"{",
"if",
"(",
"extensions",
"!=",
"null",
")",
"{",
"JSONArray",
"extensionsArray",
"=",
"new",
"JSONArray",
"(",
")",
";",
"for",
"(",
... | Delivers the correct JSON Object for the Stencilset Extensions
@param extensions | [
"Delivers",
"the",
"correct",
"JSON",
"Object",
"for",
"the",
"Stencilset",
"Extensions"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L229-L241 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java | JSONBuilder.parseStencilSet | private static JSONObject parseStencilSet(StencilSet stencilSet) throws JSONException {
if (stencilSet != null) {
JSONObject stencilSetObject = new JSONObject();
stencilSetObject.put("url",
stencilSet.getUrl().toString());
stencilSetObject.put("namespace",
stencilSet.getNamespace().toString());
return stencilSetObject;
}
return new JSONObject();
} | java | private static JSONObject parseStencilSet(StencilSet stencilSet) throws JSONException {
if (stencilSet != null) {
JSONObject stencilSetObject = new JSONObject();
stencilSetObject.put("url",
stencilSet.getUrl().toString());
stencilSetObject.put("namespace",
stencilSet.getNamespace().toString());
return stencilSetObject;
}
return new JSONObject();
} | [
"private",
"static",
"JSONObject",
"parseStencilSet",
"(",
"StencilSet",
"stencilSet",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"stencilSet",
"!=",
"null",
")",
"{",
"JSONObject",
"stencilSetObject",
"=",
"new",
"JSONObject",
"(",
")",
";",
"stencilSetObjec... | Delivers the correct JSON Object for the Stencilset
@param stencilSet
@throws org.json.JSONException | [
"Delivers",
"the",
"correct",
"JSON",
"Object",
"for",
"the",
"Stencilset"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L249-L262 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java | JSONBuilder.parseBounds | private static JSONObject parseBounds(Bounds bounds) throws JSONException {
if (bounds != null) {
JSONObject boundsObject = new JSONObject();
JSONObject lowerRight = new JSONObject();
JSONObject upperLeft = new JSONObject();
lowerRight.put("x",
bounds.getLowerRight().getX().doubleValue());
lowerRight.put("y",
bounds.getLowerRight().getY().doubleValue());
upperLeft.put("x",
bounds.getUpperLeft().getX().doubleValue());
upperLeft.put("y",
bounds.getUpperLeft().getY().doubleValue());
boundsObject.put("lowerRight",
lowerRight);
boundsObject.put("upperLeft",
upperLeft);
return boundsObject;
}
return new JSONObject();
} | java | private static JSONObject parseBounds(Bounds bounds) throws JSONException {
if (bounds != null) {
JSONObject boundsObject = new JSONObject();
JSONObject lowerRight = new JSONObject();
JSONObject upperLeft = new JSONObject();
lowerRight.put("x",
bounds.getLowerRight().getX().doubleValue());
lowerRight.put("y",
bounds.getLowerRight().getY().doubleValue());
upperLeft.put("x",
bounds.getUpperLeft().getX().doubleValue());
upperLeft.put("y",
bounds.getUpperLeft().getY().doubleValue());
boundsObject.put("lowerRight",
lowerRight);
boundsObject.put("upperLeft",
upperLeft);
return boundsObject;
}
return new JSONObject();
} | [
"private",
"static",
"JSONObject",
"parseBounds",
"(",
"Bounds",
"bounds",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"bounds",
"!=",
"null",
")",
"{",
"JSONObject",
"boundsObject",
"=",
"new",
"JSONObject",
"(",
")",
";",
"JSONObject",
"lowerRight",
"=",... | Delivers the correct JSON Object for the Bounds
@param bounds
@throws org.json.JSONException | [
"Delivers",
"the",
"correct",
"JSON",
"Object",
"for",
"the",
"Bounds"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L270-L295 | train |
kiegroup/jbpm-designer | jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java | StringUtils.createQuotedConstant | public static String createQuotedConstant(String str) {
if (str == null || str.isEmpty()) {
return str;
}
try {
Double.parseDouble(str);
} catch (NumberFormatException nfe) {
return "\"" + str + "\"";
}
return str;
} | java | public static String createQuotedConstant(String str) {
if (str == null || str.isEmpty()) {
return str;
}
try {
Double.parseDouble(str);
} catch (NumberFormatException nfe) {
return "\"" + str + "\"";
}
return str;
} | [
"public",
"static",
"String",
"createQuotedConstant",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"==",
"null",
"||",
"str",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"str",
";",
"}",
"try",
"{",
"Double",
".",
"parseDouble",
"(",
"str",
")... | Puts strings inside quotes and numerics are left as they are.
@param str
@return | [
"Puts",
"strings",
"inside",
"quotes",
"and",
"numerics",
"are",
"left",
"as",
"they",
"are",
"."
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java#L31-L41 | train |
kiegroup/jbpm-designer | jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java | StringUtils.createUnquotedConstant | public static String createUnquotedConstant(String str) {
if (str == null || str.isEmpty()) {
return str;
}
if (str.startsWith("\"")) {
str = str.substring(1);
}
if (str.endsWith("\"")) {
str = str.substring(0,
str.length() - 1);
}
return str;
} | java | public static String createUnquotedConstant(String str) {
if (str == null || str.isEmpty()) {
return str;
}
if (str.startsWith("\"")) {
str = str.substring(1);
}
if (str.endsWith("\"")) {
str = str.substring(0,
str.length() - 1);
}
return str;
} | [
"public",
"static",
"String",
"createUnquotedConstant",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"==",
"null",
"||",
"str",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"str",
";",
"}",
"if",
"(",
"str",
".",
"startsWith",
"(",
"\"\\\"\"",
... | Removes double-quotes from around a string
@param str
@return | [
"Removes",
"double",
"-",
"quotes",
"from",
"around",
"a",
"string"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java#L48-L60 | train |
kiegroup/jbpm-designer | jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java | StringUtils.isQuotedConstant | public static boolean isQuotedConstant(String str) {
if (str == null || str.isEmpty()) {
return false;
}
return (str.startsWith("\"") && str.endsWith("\""));
} | java | public static boolean isQuotedConstant(String str) {
if (str == null || str.isEmpty()) {
return false;
}
return (str.startsWith("\"") && str.endsWith("\""));
} | [
"public",
"static",
"boolean",
"isQuotedConstant",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"==",
"null",
"||",
"str",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"str",
".",
"startsWith",
"(",
"\"\\\"\"",
... | Returns true if string starts and ends with double-quote
@param str
@return | [
"Returns",
"true",
"if",
"string",
"starts",
"and",
"ends",
"with",
"double",
"-",
"quote"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java#L67-L72 | train |
kiegroup/jbpm-designer | jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java | StringUtils.urlEncode | public String urlEncode(String s) {
if (s == null || s.isEmpty()) {
return s;
}
return URL.encodeQueryString(s);
} | java | public String urlEncode(String s) {
if (s == null || s.isEmpty()) {
return s;
}
return URL.encodeQueryString(s);
} | [
"public",
"String",
"urlEncode",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"s",
"==",
"null",
"||",
"s",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"s",
";",
"}",
"return",
"URL",
".",
"encodeQueryString",
"(",
"s",
")",
";",
"}"
] | URLEncode a string
@param s
@return | [
"URLEncode",
"a",
"string"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java#L79-L85 | train |
kiegroup/jbpm-designer | jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java | StringUtils.urlDecode | public String urlDecode(String s) {
if (s == null || s.isEmpty()) {
return s;
}
return URL.decodeQueryString(s);
} | java | public String urlDecode(String s) {
if (s == null || s.isEmpty()) {
return s;
}
return URL.decodeQueryString(s);
} | [
"public",
"String",
"urlDecode",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"s",
"==",
"null",
"||",
"s",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"s",
";",
"}",
"return",
"URL",
".",
"decodeQueryString",
"(",
"s",
")",
";",
"}"
] | URLDecode a string
@param s
@return | [
"URLDecode",
"a",
"string"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java#L92-L97 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java | Bpmn2JsonUnmarshaller.unmarshall | private Bpmn2Resource unmarshall(JsonParser parser,
String preProcessingData) throws IOException {
try {
parser.nextToken(); // open the object
ResourceSet rSet = new ResourceSetImpl();
rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2",
new JBPMBpmn2ResourceFactoryImpl());
Bpmn2Resource bpmn2 = (Bpmn2Resource) rSet.createResource(URI.createURI("virtual.bpmn2"));
rSet.getResources().add(bpmn2);
_currentResource = bpmn2;
if (preProcessingData == null || preProcessingData.length() < 1) {
preProcessingData = "ReadOnlyService";
}
// do the unmarshalling now:
Definitions def = (Definitions) unmarshallItem(parser,
preProcessingData);
def.setExporter(exporterName);
def.setExporterVersion(exporterVersion);
revisitUserTasks(def);
revisitServiceTasks(def);
revisitMessages(def);
revisitCatchEvents(def);
revisitThrowEvents(def);
revisitLanes(def);
revisitSubProcessItemDefs(def);
revisitArtifacts(def);
revisitGroups(def);
revisitTaskAssociations(def);
revisitTaskIoSpecification(def);
revisitSendReceiveTasks(def);
reconnectFlows();
revisitGateways(def);
revisitCatchEventsConvertToBoundary(def);
revisitBoundaryEventsPositions(def);
createDiagram(def);
updateIDs(def);
revisitDataObjects(def);
revisitAssociationsIoSpec(def);
revisitWsdlImports(def);
revisitMultiInstanceTasks(def);
addSimulation(def);
revisitItemDefinitions(def);
revisitProcessDoc(def);
revisitDI(def);
revisitSignalRef(def);
orderDiagramElements(def);
// return def;
_currentResource.getContents().add(def);
return _currentResource;
} catch (Exception e) {
_logger.error(e.getMessage());
return _currentResource;
} finally {
parser.close();
_objMap.clear();
_idMap.clear();
_outgoingFlows.clear();
_sequenceFlowTargets.clear();
_bounds.clear();
_currentResource = null;
}
} | java | private Bpmn2Resource unmarshall(JsonParser parser,
String preProcessingData) throws IOException {
try {
parser.nextToken(); // open the object
ResourceSet rSet = new ResourceSetImpl();
rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2",
new JBPMBpmn2ResourceFactoryImpl());
Bpmn2Resource bpmn2 = (Bpmn2Resource) rSet.createResource(URI.createURI("virtual.bpmn2"));
rSet.getResources().add(bpmn2);
_currentResource = bpmn2;
if (preProcessingData == null || preProcessingData.length() < 1) {
preProcessingData = "ReadOnlyService";
}
// do the unmarshalling now:
Definitions def = (Definitions) unmarshallItem(parser,
preProcessingData);
def.setExporter(exporterName);
def.setExporterVersion(exporterVersion);
revisitUserTasks(def);
revisitServiceTasks(def);
revisitMessages(def);
revisitCatchEvents(def);
revisitThrowEvents(def);
revisitLanes(def);
revisitSubProcessItemDefs(def);
revisitArtifacts(def);
revisitGroups(def);
revisitTaskAssociations(def);
revisitTaskIoSpecification(def);
revisitSendReceiveTasks(def);
reconnectFlows();
revisitGateways(def);
revisitCatchEventsConvertToBoundary(def);
revisitBoundaryEventsPositions(def);
createDiagram(def);
updateIDs(def);
revisitDataObjects(def);
revisitAssociationsIoSpec(def);
revisitWsdlImports(def);
revisitMultiInstanceTasks(def);
addSimulation(def);
revisitItemDefinitions(def);
revisitProcessDoc(def);
revisitDI(def);
revisitSignalRef(def);
orderDiagramElements(def);
// return def;
_currentResource.getContents().add(def);
return _currentResource;
} catch (Exception e) {
_logger.error(e.getMessage());
return _currentResource;
} finally {
parser.close();
_objMap.clear();
_idMap.clear();
_outgoingFlows.clear();
_sequenceFlowTargets.clear();
_bounds.clear();
_currentResource = null;
}
} | [
"private",
"Bpmn2Resource",
"unmarshall",
"(",
"JsonParser",
"parser",
",",
"String",
"preProcessingData",
")",
"throws",
"IOException",
"{",
"try",
"{",
"parser",
".",
"nextToken",
"(",
")",
";",
"// open the object",
"ResourceSet",
"rSet",
"=",
"new",
"ResourceS... | Start unmarshalling using the parser.
@param parser
@param preProcessingData
@return the root element of a bpmn2 document.
@throws java.io.IOException | [
"Start",
"unmarshalling",
"using",
"the",
"parser",
"."
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java#L274-L338 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java | Bpmn2JsonUnmarshaller.revisitThrowEvents | public void revisitThrowEvents(Definitions def) {
List<RootElement> rootElements = def.getRootElements();
List<Signal> toAddSignals = new ArrayList<Signal>();
Set<Error> toAddErrors = new HashSet<Error>();
Set<Escalation> toAddEscalations = new HashSet<Escalation>();
Set<Message> toAddMessages = new HashSet<Message>();
Set<ItemDefinition> toAddItemDefinitions = new HashSet<ItemDefinition>();
for (RootElement root : rootElements) {
if (root instanceof Process) {
setThrowEventsInfo((Process) root,
def,
rootElements,
toAddSignals,
toAddErrors,
toAddEscalations,
toAddMessages,
toAddItemDefinitions);
}
}
for (Lane lane : _lanes) {
setThrowEventsInfoForLanes(lane,
def,
rootElements,
toAddSignals,
toAddErrors,
toAddEscalations,
toAddMessages,
toAddItemDefinitions);
}
for (Signal s : toAddSignals) {
def.getRootElements().add(s);
}
for (Error er : toAddErrors) {
def.getRootElements().add(er);
}
for (Escalation es : toAddEscalations) {
def.getRootElements().add(es);
}
for (ItemDefinition idef : toAddItemDefinitions) {
def.getRootElements().add(idef);
}
for (Message msg : toAddMessages) {
def.getRootElements().add(msg);
}
} | java | public void revisitThrowEvents(Definitions def) {
List<RootElement> rootElements = def.getRootElements();
List<Signal> toAddSignals = new ArrayList<Signal>();
Set<Error> toAddErrors = new HashSet<Error>();
Set<Escalation> toAddEscalations = new HashSet<Escalation>();
Set<Message> toAddMessages = new HashSet<Message>();
Set<ItemDefinition> toAddItemDefinitions = new HashSet<ItemDefinition>();
for (RootElement root : rootElements) {
if (root instanceof Process) {
setThrowEventsInfo((Process) root,
def,
rootElements,
toAddSignals,
toAddErrors,
toAddEscalations,
toAddMessages,
toAddItemDefinitions);
}
}
for (Lane lane : _lanes) {
setThrowEventsInfoForLanes(lane,
def,
rootElements,
toAddSignals,
toAddErrors,
toAddEscalations,
toAddMessages,
toAddItemDefinitions);
}
for (Signal s : toAddSignals) {
def.getRootElements().add(s);
}
for (Error er : toAddErrors) {
def.getRootElements().add(er);
}
for (Escalation es : toAddEscalations) {
def.getRootElements().add(es);
}
for (ItemDefinition idef : toAddItemDefinitions) {
def.getRootElements().add(idef);
}
for (Message msg : toAddMessages) {
def.getRootElements().add(msg);
}
} | [
"public",
"void",
"revisitThrowEvents",
"(",
"Definitions",
"def",
")",
"{",
"List",
"<",
"RootElement",
">",
"rootElements",
"=",
"def",
".",
"getRootElements",
"(",
")",
";",
"List",
"<",
"Signal",
">",
"toAddSignals",
"=",
"new",
"ArrayList",
"<",
"Signal... | Updates event definitions for all throwing events.
@param def Definitions | [
"Updates",
"event",
"definitions",
"for",
"all",
"throwing",
"events",
"."
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java#L1704-L1748 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java | Bpmn2JsonUnmarshaller.revisitGateways | private void revisitGateways(Definitions def) {
List<RootElement> rootElements = def.getRootElements();
for (RootElement root : rootElements) {
if (root instanceof Process) {
setGatewayInfo((Process) root);
}
}
} | java | private void revisitGateways(Definitions def) {
List<RootElement> rootElements = def.getRootElements();
for (RootElement root : rootElements) {
if (root instanceof Process) {
setGatewayInfo((Process) root);
}
}
} | [
"private",
"void",
"revisitGateways",
"(",
"Definitions",
"def",
")",
"{",
"List",
"<",
"RootElement",
">",
"rootElements",
"=",
"def",
".",
"getRootElements",
"(",
")",
";",
"for",
"(",
"RootElement",
"root",
":",
"rootElements",
")",
"{",
"if",
"(",
"roo... | Updates the gatewayDirection attributes of all gateways.
@param def | [
"Updates",
"the",
"gatewayDirection",
"attributes",
"of",
"all",
"gateways",
"."
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java#L2613-L2620 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java | Bpmn2JsonUnmarshaller.revisitMessages | private void revisitMessages(Definitions def) {
List<RootElement> rootElements = def.getRootElements();
List<ItemDefinition> toAddDefinitions = new ArrayList<ItemDefinition>();
for (RootElement root : rootElements) {
if (root instanceof Message) {
if (!existsMessageItemDefinition(rootElements,
root.getId())) {
ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition();
itemdef.setId(root.getId() + "Type");
toAddDefinitions.add(itemdef);
((Message) root).setItemRef(itemdef);
}
}
}
for (ItemDefinition id : toAddDefinitions) {
def.getRootElements().add(id);
}
} | java | private void revisitMessages(Definitions def) {
List<RootElement> rootElements = def.getRootElements();
List<ItemDefinition> toAddDefinitions = new ArrayList<ItemDefinition>();
for (RootElement root : rootElements) {
if (root instanceof Message) {
if (!existsMessageItemDefinition(rootElements,
root.getId())) {
ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition();
itemdef.setId(root.getId() + "Type");
toAddDefinitions.add(itemdef);
((Message) root).setItemRef(itemdef);
}
}
}
for (ItemDefinition id : toAddDefinitions) {
def.getRootElements().add(id);
}
} | [
"private",
"void",
"revisitMessages",
"(",
"Definitions",
"def",
")",
"{",
"List",
"<",
"RootElement",
">",
"rootElements",
"=",
"def",
".",
"getRootElements",
"(",
")",
";",
"List",
"<",
"ItemDefinition",
">",
"toAddDefinitions",
"=",
"new",
"ArrayList",
"<",... | Revisit message to set their item ref to a item definition
@param def Definitions | [
"Revisit",
"message",
"to",
"set",
"their",
"item",
"ref",
"to",
"a",
"item",
"definition"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java#L3032-L3049 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java | Bpmn2JsonUnmarshaller.reconnectFlows | private void reconnectFlows() {
// create the reverse id map:
for (Entry<Object, List<String>> entry : _outgoingFlows.entrySet()) {
for (String flowId : entry.getValue()) {
if (entry.getKey() instanceof SequenceFlow) { // if it is a sequence flow, we can tell its targets
if (_idMap.get(flowId) instanceof FlowNode) {
((SequenceFlow) entry.getKey()).setTargetRef((FlowNode) _idMap.get(flowId));
}
if (_idMap.get(flowId) instanceof Association) {
((Association) _idMap.get(flowId)).setTargetRef((SequenceFlow) entry.getKey());
}
} else if (entry.getKey() instanceof Association) {
((Association) entry.getKey()).setTargetRef((BaseElement) _idMap.get(flowId));
} else { // if it is a node, we can map it to its outgoing sequence flows
if (_idMap.get(flowId) instanceof SequenceFlow) {
((FlowNode) entry.getKey()).getOutgoing().add((SequenceFlow) _idMap.get(flowId));
} else if (_idMap.get(flowId) instanceof Association) {
((Association) _idMap.get(flowId)).setSourceRef((BaseElement) entry.getKey());
}
}
}
}
} | java | private void reconnectFlows() {
// create the reverse id map:
for (Entry<Object, List<String>> entry : _outgoingFlows.entrySet()) {
for (String flowId : entry.getValue()) {
if (entry.getKey() instanceof SequenceFlow) { // if it is a sequence flow, we can tell its targets
if (_idMap.get(flowId) instanceof FlowNode) {
((SequenceFlow) entry.getKey()).setTargetRef((FlowNode) _idMap.get(flowId));
}
if (_idMap.get(flowId) instanceof Association) {
((Association) _idMap.get(flowId)).setTargetRef((SequenceFlow) entry.getKey());
}
} else if (entry.getKey() instanceof Association) {
((Association) entry.getKey()).setTargetRef((BaseElement) _idMap.get(flowId));
} else { // if it is a node, we can map it to its outgoing sequence flows
if (_idMap.get(flowId) instanceof SequenceFlow) {
((FlowNode) entry.getKey()).getOutgoing().add((SequenceFlow) _idMap.get(flowId));
} else if (_idMap.get(flowId) instanceof Association) {
((Association) _idMap.get(flowId)).setSourceRef((BaseElement) entry.getKey());
}
}
}
}
} | [
"private",
"void",
"reconnectFlows",
"(",
")",
"{",
"// create the reverse id map:",
"for",
"(",
"Entry",
"<",
"Object",
",",
"List",
"<",
"String",
">",
">",
"entry",
":",
"_outgoingFlows",
".",
"entrySet",
"(",
")",
")",
"{",
"for",
"(",
"String",
"flowI... | Reconnect the sequence flows and the flow nodes.
Done after the initial pass so that we have all the target information. | [
"Reconnect",
"the",
"sequence",
"flows",
"and",
"the",
"flow",
"nodes",
".",
"Done",
"after",
"the",
"initial",
"pass",
"so",
"that",
"we",
"have",
"all",
"the",
"target",
"information",
"."
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java#L3076-L3098 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/web/server/menu/connector/AbstractConnectorServlet.java | AbstractConnectorServlet.parseRequest | protected void parseRequest(HttpServletRequest request,
HttpServletResponse response) {
requestParams = new HashMap<String, Object>();
listFiles = new ArrayList<FileItemStream>();
listFileStreams = new ArrayList<ByteArrayOutputStream>();
// Parse the request
if (ServletFileUpload.isMultipartContent(request)) {
// multipart request
try {
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator iter = upload.getItemIterator(request);
while (iter.hasNext()) {
FileItemStream item = iter.next();
String name = item.getFieldName();
InputStream stream = item.openStream();
if (item.isFormField()) {
requestParams.put(name,
Streams.asString(stream));
} else {
String fileName = item.getName();
if (fileName != null && !"".equals(fileName.trim())) {
listFiles.add(item);
ByteArrayOutputStream os = new ByteArrayOutputStream();
IOUtils.copy(stream,
os);
listFileStreams.add(os);
}
}
}
} catch (Exception e) {
logger.error("Unexpected error parsing multipart content",
e);
}
} else {
// not a multipart
for (Object mapKey : request.getParameterMap().keySet()) {
String mapKeyString = (String) mapKey;
if (mapKeyString.endsWith("[]")) {
// multiple values
String values[] = request.getParameterValues(mapKeyString);
List<String> listeValues = new ArrayList<String>();
for (String value : values) {
listeValues.add(value);
}
requestParams.put(mapKeyString,
listeValues);
} else {
// single value
String value = request.getParameter(mapKeyString);
requestParams.put(mapKeyString,
value);
}
}
}
} | java | protected void parseRequest(HttpServletRequest request,
HttpServletResponse response) {
requestParams = new HashMap<String, Object>();
listFiles = new ArrayList<FileItemStream>();
listFileStreams = new ArrayList<ByteArrayOutputStream>();
// Parse the request
if (ServletFileUpload.isMultipartContent(request)) {
// multipart request
try {
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator iter = upload.getItemIterator(request);
while (iter.hasNext()) {
FileItemStream item = iter.next();
String name = item.getFieldName();
InputStream stream = item.openStream();
if (item.isFormField()) {
requestParams.put(name,
Streams.asString(stream));
} else {
String fileName = item.getName();
if (fileName != null && !"".equals(fileName.trim())) {
listFiles.add(item);
ByteArrayOutputStream os = new ByteArrayOutputStream();
IOUtils.copy(stream,
os);
listFileStreams.add(os);
}
}
}
} catch (Exception e) {
logger.error("Unexpected error parsing multipart content",
e);
}
} else {
// not a multipart
for (Object mapKey : request.getParameterMap().keySet()) {
String mapKeyString = (String) mapKey;
if (mapKeyString.endsWith("[]")) {
// multiple values
String values[] = request.getParameterValues(mapKeyString);
List<String> listeValues = new ArrayList<String>();
for (String value : values) {
listeValues.add(value);
}
requestParams.put(mapKeyString,
listeValues);
} else {
// single value
String value = request.getParameter(mapKeyString);
requestParams.put(mapKeyString,
value);
}
}
}
} | [
"protected",
"void",
"parseRequest",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"{",
"requestParams",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"listFiles",
"=",
"new",
"ArrayList",
"<",
"F... | Parse request parameters and files.
@param request
@param response | [
"Parse",
"request",
"parameters",
"and",
"files",
"."
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/web/server/menu/connector/AbstractConnectorServlet.java#L295-L352 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/web/server/menu/connector/AbstractConnectorServlet.java | AbstractConnectorServlet.putResponse | protected void putResponse(JSONObject json,
String param,
Object value) {
try {
json.put(param,
value);
} catch (JSONException e) {
logger.error("json write error",
e);
}
} | java | protected void putResponse(JSONObject json,
String param,
Object value) {
try {
json.put(param,
value);
} catch (JSONException e) {
logger.error("json write error",
e);
}
} | [
"protected",
"void",
"putResponse",
"(",
"JSONObject",
"json",
",",
"String",
"param",
",",
"Object",
"value",
")",
"{",
"try",
"{",
"json",
".",
"put",
"(",
"param",
",",
"value",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"logger",
... | Append data to JSON response.
@param param
@param value | [
"Append",
"data",
"to",
"JSON",
"response",
"."
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/web/server/menu/connector/AbstractConnectorServlet.java#L359-L369 | train |
kiegroup/jbpm-designer | jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/Variable.java | Variable.deserialize | public static Variable deserialize(String s,
VariableType variableType,
List<String> dataTypes) {
Variable var = new Variable(variableType);
String[] varParts = s.split(":");
if (varParts.length > 0) {
String name = varParts[0];
if (!name.isEmpty()) {
var.setName(name);
if (varParts.length == 2) {
String dataType = varParts[1];
if (!dataType.isEmpty()) {
if (dataTypes != null && dataTypes.contains(dataType)) {
var.setDataType(dataType);
} else {
var.setCustomDataType(dataType);
}
}
}
}
}
return var;
} | java | public static Variable deserialize(String s,
VariableType variableType,
List<String> dataTypes) {
Variable var = new Variable(variableType);
String[] varParts = s.split(":");
if (varParts.length > 0) {
String name = varParts[0];
if (!name.isEmpty()) {
var.setName(name);
if (varParts.length == 2) {
String dataType = varParts[1];
if (!dataType.isEmpty()) {
if (dataTypes != null && dataTypes.contains(dataType)) {
var.setDataType(dataType);
} else {
var.setCustomDataType(dataType);
}
}
}
}
}
return var;
} | [
"public",
"static",
"Variable",
"deserialize",
"(",
"String",
"s",
",",
"VariableType",
"variableType",
",",
"List",
"<",
"String",
">",
"dataTypes",
")",
"{",
"Variable",
"var",
"=",
"new",
"Variable",
"(",
"variableType",
")",
";",
"String",
"[",
"]",
"v... | Deserializes a variable, checking whether the datatype is custom or not
@param s
@param variableType
@param dataTypes
@return | [
"Deserializes",
"a",
"variable",
"checking",
"whether",
"the",
"datatype",
"is",
"custom",
"or",
"not"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/Variable.java#L109-L131 | train |
kiegroup/jbpm-designer | jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/Variable.java | Variable.deserialize | public static Variable deserialize(String s,
VariableType variableType) {
return deserialize(s,
variableType,
null);
} | java | public static Variable deserialize(String s,
VariableType variableType) {
return deserialize(s,
variableType,
null);
} | [
"public",
"static",
"Variable",
"deserialize",
"(",
"String",
"s",
",",
"VariableType",
"variableType",
")",
"{",
"return",
"deserialize",
"(",
"s",
",",
"variableType",
",",
"null",
")",
";",
"}"
] | Deserializes a variable, NOT checking whether the datatype is custom
@param s
@param variableType
@return | [
"Deserializes",
"a",
"variable",
"NOT",
"checking",
"whether",
"the",
"datatype",
"is",
"custom"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/Variable.java#L139-L144 | train |
kiegroup/jbpm-designer | jbpm-designer-utilities/src/main/java/org/jbpm/designer/utilities/svginline/SvgInline.java | SvgInline.processStencilSet | public void processStencilSet() throws IOException {
StringBuilder stencilSetFileContents = new StringBuilder();
Scanner scanner = null;
try {
scanner = new Scanner(new File(ssInFile),
"UTF-8");
String currentLine = "";
String prevLine = "";
while (scanner.hasNextLine()) {
prevLine = currentLine;
currentLine = scanner.nextLine();
String trimmedPrevLine = prevLine.trim();
String trimmedCurrentLine = currentLine.trim();
// First time processing - replace view="<file>.svg" with _view_file="<file>.svg" + view="<svg_xml>"
if (trimmedCurrentLine.matches(VIEW_PROPERTY_NAME_PATTERN) && trimmedCurrentLine.endsWith(VIEW_PROPERTY_VALUE_SUFFIX)) {
String newLines = processViewPropertySvgReference(currentLine);
stencilSetFileContents.append(newLines);
}
// Second time processing - replace view="<svg_xml>" with refreshed contents of file referenced by previous line
else if (trimmedPrevLine.matches(VIEW_FILE_PROPERTY_NAME_PATTERN) && trimmedPrevLine.endsWith(VIEW_PROPERTY_VALUE_SUFFIX)
&& trimmedCurrentLine.matches(VIEW_PROPERTY_NAME_PATTERN)) {
String newLines = processViewFilePropertySvgReference(prevLine,
currentLine);
stencilSetFileContents.append(newLines);
} else {
stencilSetFileContents.append(currentLine + LINE_SEPARATOR);
}
}
} finally {
if (scanner != null) {
scanner.close();
}
}
Writer out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(ssOutFile),
"UTF-8"));
out.write(stencilSetFileContents.toString());
} catch (FileNotFoundException e) {
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
}
}
}
System.out.println("SVG files referenced more than once:");
for (Map.Entry<String, Integer> stringIntegerEntry : mapSVGCounts.entrySet()) {
if (stringIntegerEntry.getValue() > 1) {
System.out.println("\t" + stringIntegerEntry.getKey() + "\t = " + stringIntegerEntry.getValue());
}
}
} | java | public void processStencilSet() throws IOException {
StringBuilder stencilSetFileContents = new StringBuilder();
Scanner scanner = null;
try {
scanner = new Scanner(new File(ssInFile),
"UTF-8");
String currentLine = "";
String prevLine = "";
while (scanner.hasNextLine()) {
prevLine = currentLine;
currentLine = scanner.nextLine();
String trimmedPrevLine = prevLine.trim();
String trimmedCurrentLine = currentLine.trim();
// First time processing - replace view="<file>.svg" with _view_file="<file>.svg" + view="<svg_xml>"
if (trimmedCurrentLine.matches(VIEW_PROPERTY_NAME_PATTERN) && trimmedCurrentLine.endsWith(VIEW_PROPERTY_VALUE_SUFFIX)) {
String newLines = processViewPropertySvgReference(currentLine);
stencilSetFileContents.append(newLines);
}
// Second time processing - replace view="<svg_xml>" with refreshed contents of file referenced by previous line
else if (trimmedPrevLine.matches(VIEW_FILE_PROPERTY_NAME_PATTERN) && trimmedPrevLine.endsWith(VIEW_PROPERTY_VALUE_SUFFIX)
&& trimmedCurrentLine.matches(VIEW_PROPERTY_NAME_PATTERN)) {
String newLines = processViewFilePropertySvgReference(prevLine,
currentLine);
stencilSetFileContents.append(newLines);
} else {
stencilSetFileContents.append(currentLine + LINE_SEPARATOR);
}
}
} finally {
if (scanner != null) {
scanner.close();
}
}
Writer out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(ssOutFile),
"UTF-8"));
out.write(stencilSetFileContents.toString());
} catch (FileNotFoundException e) {
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
}
}
}
System.out.println("SVG files referenced more than once:");
for (Map.Entry<String, Integer> stringIntegerEntry : mapSVGCounts.entrySet()) {
if (stringIntegerEntry.getValue() > 1) {
System.out.println("\t" + stringIntegerEntry.getKey() + "\t = " + stringIntegerEntry.getValue());
}
}
} | [
"public",
"void",
"processStencilSet",
"(",
")",
"throws",
"IOException",
"{",
"StringBuilder",
"stencilSetFileContents",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Scanner",
"scanner",
"=",
"null",
";",
"try",
"{",
"scanner",
"=",
"new",
"Scanner",
"(",
"ne... | Processes a stencilset template file
@throws IOException | [
"Processes",
"a",
"stencilset",
"template",
"file"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-utilities/src/main/java/org/jbpm/designer/utilities/svginline/SvgInline.java#L77-L138 | train |
kiegroup/jbpm-designer | jbpm-designer-backend/src/main/java/org/jbpm/designer/web/profile/impl/ProfileServiceImpl.java | ProfileServiceImpl.init | public void init(ServletContext context) {
if (profiles != null) {
for (IDiagramProfile profile : profiles) {
profile.init(context);
_registry.put(profile.getName(),
profile);
}
}
} | java | public void init(ServletContext context) {
if (profiles != null) {
for (IDiagramProfile profile : profiles) {
profile.init(context);
_registry.put(profile.getName(),
profile);
}
}
} | [
"public",
"void",
"init",
"(",
"ServletContext",
"context",
")",
"{",
"if",
"(",
"profiles",
"!=",
"null",
")",
"{",
"for",
"(",
"IDiagramProfile",
"profile",
":",
"profiles",
")",
"{",
"profile",
".",
"init",
"(",
"context",
")",
";",
"_registry",
".",
... | Initialize the service with a context
@param context the servlet context to initialize the profile. | [
"Initialize",
"the",
"service",
"with",
"a",
"context"
] | 97b048d06f083a1f831c971c2e9fdfd0952d2b0b | https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/web/profile/impl/ProfileServiceImpl.java#L66-L74 | train |
voldemort/voldemort | src/java/voldemort/utils/ReflectUtils.java | ReflectUtils.getPropertyName | public static String getPropertyName(String name) {
if(name != null && (name.startsWith("get") || name.startsWith("set"))) {
StringBuilder b = new StringBuilder(name);
b.delete(0, 3);
b.setCharAt(0, Character.toLowerCase(b.charAt(0)));
return b.toString();
} else {
return name;
}
} | java | public static String getPropertyName(String name) {
if(name != null && (name.startsWith("get") || name.startsWith("set"))) {
StringBuilder b = new StringBuilder(name);
b.delete(0, 3);
b.setCharAt(0, Character.toLowerCase(b.charAt(0)));
return b.toString();
} else {
return name;
}
} | [
"public",
"static",
"String",
"getPropertyName",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"!=",
"null",
"&&",
"(",
"name",
".",
"startsWith",
"(",
"\"get\"",
")",
"||",
"name",
".",
"startsWith",
"(",
"\"set\"",
")",
")",
")",
"{",
"StringBu... | Get the property name of a method name. For example the property name of
setSomeValue would be someValue. Names not beginning with set or get are
not changed.
@param name The name to process
@return The property name | [
"Get",
"the",
"property",
"name",
"of",
"a",
"method",
"name",
".",
"For",
"example",
"the",
"property",
"name",
"of",
"setSomeValue",
"would",
"be",
"someValue",
".",
"Names",
"not",
"beginning",
"with",
"set",
"or",
"get",
"are",
"not",
"changed",
"."
] | a7dbdea58032021361680faacf2782cf981c5332 | https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/ReflectUtils.java#L38-L47 | train |
voldemort/voldemort | src/java/voldemort/utils/ReflectUtils.java | ReflectUtils.loadClass | public static Class<?> loadClass(String className) {
try {
return Class.forName(className);
} catch(ClassNotFoundException e) {
throw new IllegalArgumentException(e);
}
} | java | public static Class<?> loadClass(String className) {
try {
return Class.forName(className);
} catch(ClassNotFoundException e) {
throw new IllegalArgumentException(e);
}
} | [
"public",
"static",
"Class",
"<",
"?",
">",
"loadClass",
"(",
"String",
"className",
")",
"{",
"try",
"{",
"return",
"Class",
".",
"forName",
"(",
"className",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"Illegal... | Load the given class using the default constructor
@param className The name of the class
@return The class object | [
"Load",
"the",
"given",
"class",
"using",
"the",
"default",
"constructor"
] | a7dbdea58032021361680faacf2782cf981c5332 | https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/ReflectUtils.java#L55-L61 | train |
voldemort/voldemort | src/java/voldemort/utils/ReflectUtils.java | ReflectUtils.loadClass | public static Class<?> loadClass(String className, ClassLoader cl) {
try {
return Class.forName(className, false, cl);
} catch(ClassNotFoundException e) {
throw new IllegalArgumentException(e);
}
} | java | public static Class<?> loadClass(String className, ClassLoader cl) {
try {
return Class.forName(className, false, cl);
} catch(ClassNotFoundException e) {
throw new IllegalArgumentException(e);
}
} | [
"public",
"static",
"Class",
"<",
"?",
">",
"loadClass",
"(",
"String",
"className",
",",
"ClassLoader",
"cl",
")",
"{",
"try",
"{",
"return",
"Class",
".",
"forName",
"(",
"className",
",",
"false",
",",
"cl",
")",
";",
"}",
"catch",
"(",
"ClassNotFou... | Load the given class using a specific class loader.
@param className The name of the class
@param cl The Class Loader to be used for finding the class.
@return The class object | [
"Load",
"the",
"given",
"class",
"using",
"a",
"specific",
"class",
"loader",
"."
] | a7dbdea58032021361680faacf2782cf981c5332 | https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/ReflectUtils.java#L70-L76 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.