code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
@Deprecated
public int getEntityTypeId(@NotNull final String entityType, final boolean allowCreate) {
return getEntityTypeId(txnProvider, entityType, allowCreate);
} | 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);
} | 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);
} | java |
@Override
public synchronized void start() {
if (!started.getAndSet(true)) {
finished.set(false);
thread.start();
}
} | 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);
... | 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);
... | 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 pe... | 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("Exclusiv... | 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... | 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);
} ca... | 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(... | 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);
... | 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) strea... | 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;
i... | java |
@Override
public EnvironmentConfig setSetting(@NotNull final String key, @NotNull final Object value) {
return (EnvironmentConfig) super.setSetting(key, value);
} | 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);
... | java |
@Override
public final Job queueIn(final Job job, final long millis) {
return pushAt(job, System.currentTimeMillis() + millis);
} | 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... | 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) ... | 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) {
... | java |
@Nullable
public ByteIterable get(@NotNull final Transaction txn, @NotNull final ByteIterable first) {
return this.first.get(txn, first);
} | java |
@Nullable
public ByteIterable get2(@NotNull final Transaction txn, @NotNull final ByteIterable second) {
return this.second.get(txn, second);
} | java |
@Override
public void close() {
if (closed)
return;
closed = true;
tcpSocketConsumer.prepareToShutdown();
if (shouldSendCloseMessage)
eventLoop.addHandler(new EventHandler() {
@Override
public boolean action() throws InvalidEv... | 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);
// wa... | 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;
} | java |
public void checkConnection() {
long start = Time.currentTimeMillis();
while (clientChannel == null) {
tcpSocketConsumer.checkNotShutdown();
if (start + timeoutMs > Time.currentTimeMillis())
try {
condition.await(1, TimeUnit.MILLISECONDS);
... | java |
protected boolean closeAtomically() {
if (isClosed.compareAndSet(false, true)) {
Closeable.closeQuietly(networkStatsListener);
return true;
} else {
//was already closed.
return false;
}
} | java |
private void onRead0() {
assert inWire.startUse();
ensureCapacity();
try {
while (!inWire.bytes().isEmpty()) {
try (DocumentContext dc = inWire.readingDocument()) {
if (!dc.isPresent())
return;
try {... | java |
private boolean hasReceivedHeartbeat() {
long currentTimeMillis = System.currentTimeMillis();
boolean result = lastTimeMessageReceived + heartbeatTimeoutMs >= currentTimeMillis;
if (!result)
Jvm.warn().on(getClass(), Integer.toHexString(hashCode()) + " missed heartbeat, lastTimeMess... | java |
public boolean mapsCell(String cell) {
return mappedCells.stream().anyMatch(x -> x.equals(cell));
} | java |
public double getDegrees() {
double kms = getValue(GeoDistanceUnit.KILOMETRES);
return DistanceUtils.dist2Degrees(kms, DistanceUtils.EARTH_MEAN_RADIUS_KM);
} | java |
public NRShape makeShape(Date from, Date to) {
UnitNRShape fromShape = tree.toUnitShape(from);
UnitNRShape toShape = tree.toUnitShape(to);
return tree.toRangeShape(fromShape, toShape);
} | 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 ran... | 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 {}",
... | 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 {}",... | 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;
} | java |
public static Index index(String keyspace, String table, String name) {
return new Index(table, name).keyspace(keyspace);
} | java |
public GeoShapeMapper transform(GeoTransformation... transformations) {
if (this.transformations == null) {
this.transformations = Arrays.asList(transformations);
} else {
this.transformations.addAll(Arrays.asList(transformations));
}
return this;
} | java |
@JsonProperty("paging")
void paging(String paging) {
builder.paging(IndexPagingState.fromByteBuffer(ByteBufferUtils.byteBuffer(paging)));
} | java |
public boolean mapsCell(String cell) {
return mappers.values().stream().anyMatch(mapper -> mapper.mapsCell(cell));
} | 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 StringB... | java |
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 formatDateRange(Context context, ReadablePartial start, ReadablePartial end, int flags) {
return formatDateRange(context, toMillis(start), toMillis(end), flags);
} | 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 no... | 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.getQua... | 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... | 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 NotificationPopupV... | java |
private void remove() {
if (removing) {
return;
}
if (deactiveNotifications.size() == 0) {
return;
}
removing = true;
final NotificationPopupView view = deactiveNotifications.get(0);
final LinearFadeOutAnimation fadeOutAnimation = new Linea... | 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,
... | 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) {
... | java |
public String getValueForDisplayValue(final String key) {
if (mapDisplayValuesToValues.containsKey(key)) {
return mapDisplayValuesToValues.get(key);
}
return key;
} | 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) {
... | java |
public static Diagram parseJson(String json,
Boolean keepGlossaryLink) throws JSONException {
JSONObject modelJSON = new JSONObject(json);
return parseJson(modelJSON,
keepGlossaryLink);
} | 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()) {
... | java |
private static void parseRessource(ArrayList<Shape> shapes,
HashMap<String, JSONObject> flatJSON,
String resourceId,
Boolean keepGlossaryLink)
throws JSONException {
JSONObject modelJ... | 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
... | 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;
... | java |
@SuppressWarnings("unchecked")
private static void parseProperties(JSONObject modelJSON,
Shape current,
Boolean keepGlossaryLink) throws JSONException {
if (modelJSON.has("properties")) {
JSONObject propsObject = mod... | 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++) {
... | java |
private static void parseOutgoings(ArrayList<Shape> shapes,
JSONObject modelJSON,
Shape current) throws JSONException {
if (modelJSON.has("outgoing")) {
ArrayList<Shape> outgoings = new ArrayList<Shape>();
JSON... | java |
private static void parseChildShapes(ArrayList<Shape> shapes,
JSONObject modelJSON,
Shape current) throws JSONException {
if (modelJSON.has("childShapes")) {
ArrayList<Shape> childShapes = new ArrayList<Shape>();
... | 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");
f... | 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("l... | java |
private static void parseTarget(ArrayList<Shape> shapes,
JSONObject modelJSON,
Shape current) throws JSONException {
if (modelJSON.has("target")) {
JSONObject targetObject = modelJSON.getJSONObject("target");
if (tar... | 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.getS... | java |
public void setInvalidValues(final Set<String> invalidValues,
final boolean isCaseSensitive,
final String invalidValueErrorMessage) {
if (isCaseSensitive) {
this.invalidValues = invalidValues;
} else {
this.invalid... | java |
public void setRegExp(final String pattern,
final String invalidCharactersInNameErrorMessage,
final String invalidCharacterTypedMessage) {
regExp = RegExp.compile(pattern);
this.invalidCharactersInNameErrorMessage = invalidCharactersInNameErrorMessage;... | java |
public HashMap<String, String> getProperties() {
if (this.properties == null) {
this.properties = new HashMap<String, String>();
}
return properties;
} | java |
public String putProperty(String key,
String value) {
return this.getProperties().put(key,
value);
} | 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,
... | java |
public static Map<String, IDiagramPlugin>
getLocalPluginsRegistry(ServletContext context) {
if (LOCAL == null) {
LOCAL = initializeLocalPlugins(context);
}
return LOCAL;
} | java |
public boolean addSsextension(String ssExt) {
if (this.ssextensions == null) {
this.ssextensions = new ArrayList<String>();
}
return this.ssextensions.add(ssExt);
} | java |
private static JSONObject parseStencil(String stencilId) throws JSONException {
JSONObject stencilObject = new JSONObject();
stencilObject.put("id",
stencilId.toString());
return stencilObject;
} | 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();
... | java |
private static JSONObject parseTarget(Shape target) throws JSONException {
JSONObject targetObject = new JSONObject();
targetObject.put("resourceId",
target.getResourceId().toString());
return targetObject;
} | 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",
... | 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();
outgoingObjec... | 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);
... | java |
private static JSONArray parseStencilSetExtensions(ArrayList<String> extensions) {
if (extensions != null) {
JSONArray extensionsArray = new JSONArray();
for (String extension : extensions) {
extensionsArray.put(extension.toString());
}
return ex... | java |
private static JSONObject parseStencilSet(StencilSet stencilSet) throws JSONException {
if (stencilSet != null) {
JSONObject stencilSetObject = new JSONObject();
stencilSetObject.put("url",
stencilSet.getUrl().toString());
stencilSetObject.pu... | 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",
... | 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;
} | 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,
s... | java |
public static boolean isQuotedConstant(String str) {
if (str == null || str.isEmpty()) {
return false;
}
return (str.startsWith("\"") && str.endsWith("\""));
} | java |
public String urlEncode(String s) {
if (s == null || s.isEmpty()) {
return s;
}
return URL.encodeQueryString(s);
} | java |
public String urlDecode(String s) {
if (s == null || s.isEmpty()) {
return s;
}
return URL.decodeQueryString(s);
} | java |
private Bpmn2Resource unmarshall(JsonParser parser,
String preProcessingData) throws IOException {
try {
parser.nextToken(); // open the object
ResourceSet rSet = new ResourceSetImpl();
rSet.getResourceFactoryRegistry().getExtensionToFacto... | 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>... | java |
private void revisitGateways(Definitions def) {
List<RootElement> rootElements = def.getRootElements();
for (RootElement root : rootElements) {
if (root instanceof Process) {
setGatewayInfo((Process) root);
}
}
} | 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 (!existsMessageIt... | 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
... | java |
protected void parseRequest(HttpServletRequest request,
HttpServletResponse response) {
requestParams = new HashMap<String, Object>();
listFiles = new ArrayList<FileItemStream>();
listFileStreams = new ArrayList<ByteArrayOutputStream>();
// Parse the requ... | java |
protected void putResponse(JSONObject json,
String param,
Object value) {
try {
json.put(param,
value);
} catch (JSONException e) {
logger.error("json write error",
e);
... | 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) {
Stri... | java |
public static Variable deserialize(String s,
VariableType variableType) {
return deserialize(s,
variableType,
null);
} | java |
public void processStencilSet() throws IOException {
StringBuilder stencilSetFileContents = new StringBuilder();
Scanner scanner = null;
try {
scanner = new Scanner(new File(ssInFile),
"UTF-8");
String currentLine = "";
Strin... | java |
public void init(ServletContext context) {
if (profiles != null) {
for (IDiagramProfile profile : profiles) {
profile.init(context);
_registry.put(profile.getName(),
profile);
}
}
} | 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();
... | java |
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, ClassLoader cl) {
try {
return Class.forName(className, false, cl);
} catch(ClassNotFoundException e) {
throw new IllegalArgumentException(e);
}
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.