_id
stringlengths 2
7
| title
stringlengths 3
140
| partition
stringclasses 3
values | text
stringlengths 73
34.1k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q4100
|
SimpleJsonEncoder.appendToJSONUnquoted
|
train
|
SimpleJsonEncoder appendToJSONUnquoted(final String key, final Object value) {
if (closed) {
throw new IllegalStateException("Encoder already closed");
}
if (value != null) {
appendKey(key);
sb.append(value);
}
return this;
}
|
java
|
{
"resource": ""
}
|
q4101
|
GelfTcpAppender.sendMessage
|
train
|
@SuppressWarnings("checkstyle:illegalcatch")
private boolean sendMessage(final byte[] messageToSend) {
try {
connectionPool.execute(new PooledObjectConsumer<TcpConnection>() {
@Override
public void accept(final TcpConnection tcpConnection) throws IOException {
tcpConnection.write(messageToSend);
}
});
} catch (final Exception e) {
addError(String.format("Error sending message via tcp://%s:%s",
getGraylogHost(), getGraylogPort()), e);
return false;
}
return true;
}
|
java
|
{
"resource": ""
}
|
q4102
|
BaseEventProcessor.run
|
train
|
@Override
public void run()
{
try {
startBarrier.await();
int idleCount = 0;
while (!isRunning.compareAndSet(idleCount > lingerIterations && pidToProcessMap.isEmpty(), false)) {
idleCount = (!shutdown && process()) ? 0 : (idleCount + 1);
}
}
catch (Exception e) {
// TODO: how to handle this error?
isRunning.set(false);
}
}
|
java
|
{
"resource": ""
}
|
q4103
|
HexDumpElf.dump
|
train
|
public static String dump(final int displayOffset, final byte[] data, final int offset, final int len)
{
StringBuilder sb = new StringBuilder();
Formatter formatter = new Formatter(sb);
StringBuilder ascii = new StringBuilder();
int dataNdx = offset;
final int maxDataNdx = offset + len;
final int lines = (len + 16) / 16;
for (int i = 0; i < lines; i++) {
ascii.append(" |");
formatter.format("%08x ", displayOffset + (i * 16));
for (int j = 0; j < 16; j++) {
if (dataNdx < maxDataNdx) {
byte b = data[dataNdx++];
formatter.format("%02x ", b);
ascii.append((b > MIN_VISIBLE && b < MAX_VISIBLE) ? (char) b : ' ');
}
else {
sb.append(" ");
}
if (j == 7) {
sb.append(' ');
}
}
ascii.append('|');
sb.append(ascii).append('\n');
ascii.setLength(0);
}
formatter.close();
return sb.toString();
}
|
java
|
{
"resource": ""
}
|
q4104
|
ProcessCompletions.run
|
train
|
@Override
public void run()
{
try {
startBarrier.await();
int idleCount = 0;
while (!isRunning.compareAndSet(idleCount > LINGER_ITERATIONS && deadPool.isEmpty() && completionKeyToProcessMap.isEmpty(), false)) {
idleCount = (!shutdown && process()) ? 0 : (idleCount + 1);
}
}
catch (Exception e) {
// TODO: how to handle this error?
e.printStackTrace();
isRunning.set(false);
}
}
|
java
|
{
"resource": ""
}
|
q4105
|
Snackbar.actionLabel
|
train
|
public Snackbar actionLabel(CharSequence actionButtonLabel) {
mActionLabel = actionButtonLabel;
if (snackbarAction != null) {
snackbarAction.setText(mActionLabel);
}
return this;
}
|
java
|
{
"resource": ""
}
|
q4106
|
Snackbar.setBackgroundDrawable
|
train
|
public static void setBackgroundDrawable(View view, Drawable drawable) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
view.setBackgroundDrawable(drawable);
} else {
view.setBackground(drawable);
}
}
|
java
|
{
"resource": ""
}
|
q4107
|
ModuleVisitor.visitRequire
|
train
|
public void visitRequire(String module, int access, String version) {
if (mv != null) {
mv.visitRequire(module, access, version);
}
}
|
java
|
{
"resource": ""
}
|
q4108
|
ModuleVisitor.visitExport
|
train
|
public void visitExport(String packaze, int access, String... modules) {
if (mv != null) {
mv.visitExport(packaze, access, modules);
}
}
|
java
|
{
"resource": ""
}
|
q4109
|
ModuleVisitor.visitOpen
|
train
|
public void visitOpen(String packaze, int access, String... modules) {
if (mv != null) {
mv.visitOpen(packaze, access, modules);
}
}
|
java
|
{
"resource": ""
}
|
q4110
|
ClassReader.readTypeAnnotations
|
train
|
private int[] readTypeAnnotations(final MethodVisitor mv,
final Context context, int u, boolean visible) {
char[] c = context.buffer;
int[] offsets = new int[readUnsignedShort(u)];
u += 2;
for (int i = 0; i < offsets.length; ++i) {
offsets[i] = u;
int target = readInt(u);
switch (target >>> 24) {
case 0x00: // CLASS_TYPE_PARAMETER
case 0x01: // METHOD_TYPE_PARAMETER
case 0x16: // METHOD_FORMAL_PARAMETER
u += 2;
break;
case 0x13: // FIELD
case 0x14: // METHOD_RETURN
case 0x15: // METHOD_RECEIVER
u += 1;
break;
case 0x40: // LOCAL_VARIABLE
case 0x41: // RESOURCE_VARIABLE
for (int j = readUnsignedShort(u + 1); j > 0; --j) {
int start = readUnsignedShort(u + 3);
int length = readUnsignedShort(u + 5);
createLabel(start, context.labels);
createLabel(start + length, context.labels);
u += 6;
}
u += 3;
break;
case 0x47: // CAST
case 0x48: // CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
case 0x49: // METHOD_INVOCATION_TYPE_ARGUMENT
case 0x4A: // CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
case 0x4B: // METHOD_REFERENCE_TYPE_ARGUMENT
u += 4;
break;
// case 0x10: // CLASS_EXTENDS
// case 0x11: // CLASS_TYPE_PARAMETER_BOUND
// case 0x12: // METHOD_TYPE_PARAMETER_BOUND
// case 0x17: // THROWS
// case 0x42: // EXCEPTION_PARAMETER
// case 0x43: // INSTANCEOF
// case 0x44: // NEW
// case 0x45: // CONSTRUCTOR_REFERENCE
// case 0x46: // METHOD_REFERENCE
default:
u += 3;
break;
}
int pathLength = readByte(u);
if ((target >>> 24) == 0x42) {
TypePath path = pathLength == 0 ? null : new TypePath(b, u);
u += 1 + 2 * pathLength;
u = readAnnotationValues(u + 2, c, true,
mv.visitTryCatchAnnotation(target, path,
readUTF8(u, c), visible));
} else {
u = readAnnotationValues(u + 3 + 2 * pathLength, c, true, null);
}
}
return offsets;
}
|
java
|
{
"resource": ""
}
|
q4111
|
MethodWriter.visitImplicitFirstFrame
|
train
|
private void visitImplicitFirstFrame() {
// There can be at most descriptor.length() + 1 locals
int frameIndex = startFrame(0, descriptor.length() + 1, 0);
if ((access & Opcodes.ACC_STATIC) == 0) {
if ((access & ACC_CONSTRUCTOR) == 0) {
frame[frameIndex++] = Frame.OBJECT | cw.addType(cw.thisName);
} else {
frame[frameIndex++] = Frame.UNINITIALIZED_THIS;
}
}
int i = 1;
loop: while (true) {
int j = i;
switch (descriptor.charAt(i++)) {
case 'Z':
case 'C':
case 'B':
case 'S':
case 'I':
frame[frameIndex++] = Frame.INTEGER;
break;
case 'F':
frame[frameIndex++] = Frame.FLOAT;
break;
case 'J':
frame[frameIndex++] = Frame.LONG;
break;
case 'D':
frame[frameIndex++] = Frame.DOUBLE;
break;
case '[':
while (descriptor.charAt(i) == '[') {
++i;
}
if (descriptor.charAt(i) == 'L') {
++i;
while (descriptor.charAt(i) != ';') {
++i;
}
}
frame[frameIndex++] = Frame.type(cw, descriptor.substring(j, ++i));
break;
case 'L':
while (descriptor.charAt(i) != ';') {
++i;
}
frame[frameIndex++] = Frame.OBJECT
| cw.addType(descriptor.substring(j + 1, i++));
break;
default:
break loop;
}
}
frame[1] = frameIndex - 3;
endFrame();
}
|
java
|
{
"resource": ""
}
|
q4112
|
ClassWriter.newStringishItem
|
train
|
Item newStringishItem(final int type, final String value) {
key2.set(type, value, null, null);
Item result = get(key2);
if (result == null) {
pool.put12(type, newUTF8(value));
result = new Item(index++, key2);
put(result);
}
return result;
}
|
java
|
{
"resource": ""
}
|
q4113
|
MethodVisitor.visitParameter
|
train
|
public void visitParameter(String name, int access) {
if (mv != null) {
mv.visitParameter(name, access);
}
}
|
java
|
{
"resource": ""
}
|
q4114
|
MethodVisitor.visitMethodInsn
|
train
|
public void visitMethodInsn(int opcode, String owner, String name,
String desc, boolean itf) {
if (mv != null) {
mv.visitMethodInsn(opcode, owner, name, desc, itf);
}
}
|
java
|
{
"resource": ""
}
|
q4115
|
MethodVisitor.visitLocalVariableAnnotation
|
train
|
public AnnotationVisitor visitLocalVariableAnnotation(int typeRef,
TypePath typePath, Label[] start, Label[] end, int[] index,
String desc, boolean visible) {
if (mv != null) {
return mv.visitLocalVariableAnnotation(typeRef, typePath, start,
end, index, desc, visible);
}
return null;
}
|
java
|
{
"resource": ""
}
|
q4116
|
MaterialCollection.setHeader
|
train
|
public void setHeader(String header) {
headerLabel.getElement().setInnerSafeHtml(SafeHtmlUtils.fromString(header));
addStyleName(CssName.WITH_HEADER);
ListItem item = new ListItem(headerLabel);
UiHelper.addMousePressedHandlers(item);
item.setStyleName(CssName.COLLECTION_HEADER);
insert(item, 0);
}
|
java
|
{
"resource": ""
}
|
q4117
|
MaterialTooltip.setHtml
|
train
|
public void setHtml(String html) {
this.html = html;
if (widget != null) {
if (widget.isAttached()) {
tooltipElement.find("span")
.html(html != null ? html : "");
} else {
widget.addAttachHandler(event ->
tooltipElement.find("span")
.html(html != null ? html : ""));
}
} else {
GWT.log("Please initialize the Target widget.", new IllegalStateException());
}
}
|
java
|
{
"resource": ""
}
|
q4118
|
MaterialListValueBox.addItem
|
train
|
public void addItem(T value, String text, boolean reload) {
values.add(value);
listBox.addItem(text, keyFactory.generateKey(value));
if (reload) {
reload();
}
}
|
java
|
{
"resource": ""
}
|
q4119
|
MaterialListValueBox.addItem
|
train
|
public void addItem(T value, Direction dir, String text) {
addItem(value, dir, text, true);
}
|
java
|
{
"resource": ""
}
|
q4120
|
MaterialListValueBox.removeValue
|
train
|
public void removeValue(T value, boolean reload) {
int idx = getIndex(value);
if (idx >= 0) {
removeItemInternal(idx, reload);
}
}
|
java
|
{
"resource": ""
}
|
q4121
|
MaterialListValueBox.clear
|
train
|
@Override
public void clear() {
values.clear();
listBox.clear();
clearStatusText();
if (emptyPlaceHolder != null) {
insertEmptyPlaceHolder(emptyPlaceHolder);
}
reload();
if (isAllowBlank()) {
addBlankItemIfNeeded();
}
}
|
java
|
{
"resource": ""
}
|
q4122
|
MaterialListValueBox.getItemsSelected
|
train
|
public String[] getItemsSelected() {
List<String> selected = new LinkedList<>();
for (int i = getIndexOffset(); i < listBox.getItemCount(); i++) {
if (listBox.isItemSelected(i)) {
selected.add(listBox.getValue(i));
}
}
return selected.toArray(new String[selected.size()]);
}
|
java
|
{
"resource": ""
}
|
q4123
|
MaterialListValueBox.setValueSelected
|
train
|
public void setValueSelected(T value, boolean selected) {
int idx = getIndex(value);
if (idx >= 0) {
setItemSelectedInternal(idx, selected);
}
}
|
java
|
{
"resource": ""
}
|
q4124
|
MaterialListValueBox.getIndex
|
train
|
public int getIndex(T value) {
int count = getItemCount();
for (int i = 0; i < count; i++) {
if (Objects.equals(getValue(i), value)) {
return i;
}
}
return -1;
}
|
java
|
{
"resource": ""
}
|
q4125
|
MaterialSearch.addSearchFinishHandler
|
train
|
@Override
public HandlerRegistration addSearchFinishHandler(final SearchFinishEvent.SearchFinishHandler handler) {
return addHandler(handler, SearchFinishEvent.TYPE);
}
|
java
|
{
"resource": ""
}
|
q4126
|
MaterialSearch.addSearchNoResultHandler
|
train
|
@Override
public HandlerRegistration addSearchNoResultHandler(final SearchNoResultEvent.SearchNoResultHandler handler) {
return addHandler(handler, SearchNoResultEvent.TYPE);
}
|
java
|
{
"resource": ""
}
|
q4127
|
AbstractButton.setSize
|
train
|
public void setSize(ButtonSize size) {
if (this.size != null) {
removeStyleName(this.size.getCssName());
}
this.size = size;
if (size != null) {
addStyleName(size.getCssName());
}
}
|
java
|
{
"resource": ""
}
|
q4128
|
AbstractButton.setText
|
train
|
public void setText(String text) {
span.setText(text);
if (!span.isAttached()) {
add(span);
}
}
|
java
|
{
"resource": ""
}
|
q4129
|
ColorHelper.fromStyleName
|
train
|
public static <E extends Enum<? extends Style.HasCssName>> E fromStyleName(final String styleName,
final Class<E> enumClass,
final E defaultValue) {
return EnumHelper.fromStyleName(styleName, enumClass, defaultValue, true);
}
|
java
|
{
"resource": ""
}
|
q4130
|
MaterialAnimation.stopAnimation
|
train
|
public void stopAnimation() {
if(widget != null) {
widget.removeStyleName("animated");
widget.removeStyleName(transition.getCssName());
widget.removeStyleName(CssName.INFINITE);
}
}
|
java
|
{
"resource": ""
}
|
q4131
|
MaterialValueBox.clear
|
train
|
public void clear() {
valueBoxBase.setText("");
clearStatusText();
if (getPlaceholder() == null || getPlaceholder().isEmpty()) {
label.removeStyleName(CssName.ACTIVE);
}
}
|
java
|
{
"resource": ""
}
|
q4132
|
MaterialValueBox.updateLabelActiveStyle
|
train
|
protected void updateLabelActiveStyle() {
if (this.valueBoxBase.getText() != null && !this.valueBoxBase.getText().isEmpty()) {
label.addStyleName(CssName.ACTIVE);
} else {
label.removeStyleName(CssName.ACTIVE);
}
}
|
java
|
{
"resource": ""
}
|
q4133
|
MaterialCollapsibleBody.checkActiveState
|
train
|
protected void checkActiveState(Widget child) {
// Check if this widget has a valid href
String href = child.getElement().getAttribute("href");
String url = Window.Location.getHref();
int pos = url.indexOf("#");
String location = pos >= 0 ? url.substring(pos, url.length()) : "";
if (!href.isEmpty() && location.startsWith(href)) {
ListItem li = findListItemParent(child);
if (li != null) {
makeActive(li);
}
} else if (child instanceof HasWidgets) {
// Recursive check
for (Widget w : (HasWidgets) child) {
checkActiveState(w);
}
}
}
|
java
|
{
"resource": ""
}
|
q4134
|
MaterialCollapsibleItem.setActive
|
train
|
@Override
public void setActive(boolean active) {
this.active = active;
if (parent != null) {
fireCollapsibleHandler();
removeStyleName(CssName.ACTIVE);
if (header != null) {
header.removeStyleName(CssName.ACTIVE);
}
if (active) {
if (parent != null && parent.isAccordion()) {
parent.clearActive();
}
addStyleName(CssName.ACTIVE);
if (header != null) {
header.addStyleName(CssName.ACTIVE);
}
}
if (body != null) {
body.setDisplay(active ? Display.BLOCK : Display.NONE);
}
} else {
GWT.log("Please make sure that the Collapsible parent is attached or existed.", new IllegalStateException());
}
}
|
java
|
{
"resource": ""
}
|
q4135
|
MaterialDatePicker.setDateMin
|
train
|
public void setDateMin(Date dateMin) {
this.dateMin = dateMin;
if (isAttached() && dateMin != null) {
getPicker().set("min", JsDate.create((double) dateMin.getTime()));
}
}
|
java
|
{
"resource": ""
}
|
q4136
|
MaterialDatePicker.setDateMax
|
train
|
public void setDateMax(Date dateMax) {
this.dateMax = dateMax;
if (isAttached() && dateMax != null) {
getPicker().set("max", JsDate.create((double) dateMax.getTime()));
}
}
|
java
|
{
"resource": ""
}
|
q4137
|
MaterialDatePicker.getPickerDate
|
train
|
protected Date getPickerDate() {
try {
JsDate pickerDate = getPicker().get("select").obj;
return new Date((long) pickerDate.getTime());
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
|
java
|
{
"resource": ""
}
|
q4138
|
MaterialDatePicker.setSelectionType
|
train
|
public void setSelectionType(MaterialDatePickerType selectionType) {
this.selectionType = selectionType;
switch (selectionType) {
case MONTH_DAY:
options.selectMonths = true;
break;
case YEAR_MONTH_DAY:
options.selectYears = yearsToDisplay;
options.selectMonths = true;
break;
case YEAR:
options.selectYears = yearsToDisplay;
options.selectMonths = false;
break;
}
}
|
java
|
{
"resource": ""
}
|
q4139
|
MaterialDatePicker.setAutoClose
|
train
|
public void setAutoClose(boolean autoClose) {
this.autoClose = autoClose;
if (autoCloseHandlerRegistration != null) {
autoCloseHandlerRegistration.removeHandler();
autoCloseHandlerRegistration = null;
}
if (autoClose) {
autoCloseHandlerRegistration = registerHandler(addValueChangeHandler(event -> close()));
}
}
|
java
|
{
"resource": ""
}
|
q4140
|
AbstractValueWidget.setAllowBlank
|
train
|
public void setAllowBlank(boolean allowBlank) {
this.allowBlank = allowBlank;
// Setup the allow blank validation
if (!allowBlank) {
if (blankValidator == null) {
blankValidator = createBlankValidator();
}
setupBlurValidation();
addValidator(blankValidator);
} else {
removeValidator(blankValidator);
}
}
|
java
|
{
"resource": ""
}
|
q4141
|
ColorsMixin.ensureTextColorFormat
|
train
|
protected String ensureTextColorFormat(String textColor) {
String formatted = "";
boolean mainColor = true;
for (String style : textColor.split(" ")) {
if (mainColor) {
// the main color
if (!style.endsWith("-text")) {
style += "-text";
}
mainColor = false;
} else {
// the shading type
if (!style.startsWith("text-")) {
style = " text-" + style;
}
}
formatted += style;
}
return formatted;
}
|
java
|
{
"resource": ""
}
|
q4142
|
MaterialTabItem.selectTab
|
train
|
public void selectTab() {
for (Widget child : getChildren()) {
if (child instanceof HasHref) {
String href = ((HasHref) child).getHref();
if (parent != null && !href.isEmpty()) {
parent.selectTab(href.replaceAll("[^a-zA-Z\\d\\s:]", ""));
parent.reload();
break;
}
}
}
}
|
java
|
{
"resource": ""
}
|
q4143
|
MessageFormat.format
|
train
|
public static String format(String pattern, Object... arguments) {
String msg = pattern;
if (arguments != null) {
for (int index = 0; index < arguments.length; index++) {
msg = msg.replaceAll("\\{" + (index + 1) + "\\}", String.valueOf(arguments[index]));
}
}
return msg;
}
|
java
|
{
"resource": ""
}
|
q4144
|
MaterialSwitch.setValue
|
train
|
@Override
public void setValue(Boolean value, boolean fireEvents) {
boolean oldValue = getValue();
if (value) {
input.getElement().setAttribute("checked", "true");
} else {
input.getElement().removeAttribute("checked");
}
if (fireEvents && oldValue != value) {
ValueChangeEvent.fire(this, getValue());
}
}
|
java
|
{
"resource": ""
}
|
q4145
|
StyleHelper.addUniqueEnumStyleName
|
train
|
public static <E extends Style.HasCssName, F extends Enum<? extends Style.HasCssName>> void addUniqueEnumStyleName(final UIObject uiObject,
final Class<F> enumClass,
final E style) {
removeEnumStyleNames(uiObject, enumClass);
addEnumStyleName(uiObject, style);
}
|
java
|
{
"resource": ""
}
|
q4146
|
StyleHelper.toggleStyleName
|
train
|
public static void toggleStyleName(final UIObject uiObject,
final boolean toggleStyle,
final String styleName) {
if (toggleStyle) {
uiObject.addStyleName(styleName);
} else {
uiObject.removeStyleName(styleName);
}
}
|
java
|
{
"resource": ""
}
|
q4147
|
ServiceWorkerManager.setupRegistration
|
train
|
protected void setupRegistration() {
if (isServiceWorkerSupported()) {
Navigator.serviceWorker.register(getResource()).then(object -> {
logger.info("Service worker has been successfully registered");
registration = (ServiceWorkerRegistration) object;
onRegistered(new ServiceEvent(), registration);
// Observe service worker lifecycle
observeLifecycle(registration);
// Setup Service Worker events events
setupOnControllerChangeEvent();
setupOnMessageEvent();
setupOnErrorEvent();
return null;
}, error -> {
logger.info("ServiceWorker registration failed: " + error);
return null;
});
} else {
logger.info("Service worker is not supported by this browser.");
}
}
|
java
|
{
"resource": ""
}
|
q4148
|
MaterialRange.addChangeHandler
|
train
|
@Override
public HandlerRegistration addChangeHandler(final ChangeHandler handler) {
return getRangeInputElement().addDomHandler(handler, ChangeEvent.getType());
}
|
java
|
{
"resource": ""
}
|
q4149
|
ViewPortHandler.then
|
train
|
public ViewPort then(Functions.Func1<ViewPortChange> then, ViewPortFallback fallback) {
assert then != null : "'then' callback cannot be null";
this.then = then;
this.fallback = fallback;
return load();
}
|
java
|
{
"resource": ""
}
|
q4150
|
ViewPortHandler.load
|
train
|
protected ViewPort load() {
resize = Window.addResizeHandler(event -> {
execute(event.getWidth(), event.getHeight());
});
execute(window().width(), (int)window().height());
return viewPort;
}
|
java
|
{
"resource": ""
}
|
q4151
|
DateFormatHelper.format
|
train
|
public static String format(String format) {
if (format == null) {
format = DEFAULT_FORMAT;
} else {
if (format.contains("M")) {
format = format.replace("M", "m");
}
if (format.contains("Y")) {
format = format.replace("Y", "y");
}
if (format.contains("D")) {
format = format.replace("D", "d");
}
}
return format;
}
|
java
|
{
"resource": ""
}
|
q4152
|
AbstractSideNav.setWidth
|
train
|
public void setWidth(int width) {
this.width = width;
getElement().getStyle().setWidth(width, Style.Unit.PX);
}
|
java
|
{
"resource": ""
}
|
q4153
|
MaterialCollapsible.setAccordion
|
train
|
public void setAccordion(boolean accordion) {
getElement().setAttribute("data-collapsible", accordion ? CssName.ACCORDION : CssName.EXPANDABLE);
reload();
}
|
java
|
{
"resource": ""
}
|
q4154
|
AbstractValidator.getInvalidMessage
|
train
|
public String getInvalidMessage(String key) {
return invalidMessageOverride == null ? messageMixin.lookup(key, messageValueArgs) : MessageFormat.format(
invalidMessageOverride, messageValueArgs);
}
|
java
|
{
"resource": ""
}
|
q4155
|
PwaManager.installApp
|
train
|
public void installApp(Functions.Func callback) {
if (isPwaSupported()) {
appInstaller = new AppInstaller(callback);
appInstaller.prompt();
}
}
|
java
|
{
"resource": ""
}
|
q4156
|
MaterialLoader.show
|
train
|
public void show() {
if (!(container instanceof RootPanel)) {
if (!(container instanceof MaterialDialog)) {
container.getElement().getStyle().setPosition(Style.Position.RELATIVE);
}
div.getElement().getStyle().setPosition(Style.Position.ABSOLUTE);
}
if (scrollDisabled) {
RootPanel.get().getElement().getStyle().setOverflow(Style.Overflow.HIDDEN);
}
if (type == LoaderType.CIRCULAR) {
div.setStyleName(CssName.VALIGN_WRAPPER + " " + CssName.LOADER_WRAPPER);
div.add(preLoader);
} else if (type == LoaderType.PROGRESS) {
div.setStyleName(CssName.VALIGN_WRAPPER + " " + CssName.PROGRESS_WRAPPER);
progress.getElement().getStyle().setProperty("margin", "auto");
div.add(progress);
}
container.add(div);
}
|
java
|
{
"resource": ""
}
|
q4157
|
MaterialLoader.hide
|
train
|
public void hide() {
div.removeFromParent();
if (scrollDisabled) {
RootPanel.get().getElement().getStyle().setOverflow(Style.Overflow.AUTO);
}
if (type == LoaderType.CIRCULAR) {
preLoader.removeFromParent();
} else if (type == LoaderType.PROGRESS) {
progress.removeFromParent();
}
}
|
java
|
{
"resource": ""
}
|
q4158
|
Waves.detectAndApply
|
train
|
public static void detectAndApply(Widget widget) {
if (!widget.isAttached()) {
widget.addAttachHandler(event -> {
if (event.isAttached()) {
detectAndApply();
}
});
} else {
detectAndApply();
}
}
|
java
|
{
"resource": ""
}
|
q4159
|
MaterialCheckBox.setType
|
train
|
public void setType(CheckBoxType type) {
this.type = type;
switch (type) {
case FILLED:
Element input = DOM.getChild(getElement(), 0);
input.setAttribute("class", CssName.FILLED_IN);
break;
case INTERMEDIATE:
addStyleName(type.getCssName() + "-checkbox");
break;
default:
addStyleName(type.getCssName());
break;
}
}
|
java
|
{
"resource": ""
}
|
q4160
|
ArgumentsBuilder.param
|
train
|
ArgumentsBuilder param(String param, Integer value) {
if (value != null) {
args.add(param);
args.add(value.toString());
}
return this;
}
|
java
|
{
"resource": ""
}
|
q4161
|
ArgumentsBuilder.param
|
train
|
ArgumentsBuilder param(String param, String value) {
if (value != null) {
args.add(param);
args.add(value);
}
return this;
}
|
java
|
{
"resource": ""
}
|
q4162
|
AbstractScalaxbMojo.arguments
|
train
|
protected List<String> arguments() {
List<String> args = new ArgumentsBuilder()
.flag("-v", verbose)
.flag("--package-dir", packageDir)
.param("-d", outputDirectory.getPath())
.param("-p", packageName)
.map("--package:", packageNameMap())
.param("--class-prefix", classPrefix)
.param("--param-prefix", parameterPrefix)
.param("--chunk-size", chunkSize)
.flag("--no-dispatch-client", !generateDispatchClient)
.flag("--dispatch-as", generateDispatchAs)
.param("--dispatch-version", dispatchVersion)
.flag("--no-runtime", !generateRuntime)
.intersperse("--wrap-contents", wrapContents)
.param("--protocol-file", protocolFile)
.param("--protocol-package", protocolPackage)
.param("--attribute-prefix", attributePrefix)
.flag("--prepend-family", prependFamily)
.flag("--blocking", !async)
.flag("--lax-any", laxAny)
.flag("--no-varargs", !varArgs)
.flag("--ignore-unknown", ignoreUnknown)
.flag("--autopackages", autoPackages)
.flag("--mutable", mutable)
.flag("--visitor", visitor)
.getArguments();
return unmodifiableList(args);
}
|
java
|
{
"resource": ""
}
|
q4163
|
AbstractScalaxbMojo.packageNameMap
|
train
|
Map<String, String> packageNameMap() {
if (packageNames == null) {
return emptyMap();
}
Map<String, String> names = new LinkedHashMap<String, String>();
for (PackageName name : packageNames) {
names.put(name.getUri(), name.getPackage());
}
return names;
}
|
java
|
{
"resource": ""
}
|
q4164
|
Queries.placeholders
|
train
|
@NonNull
public static String placeholders(final int numberOfPlaceholders) {
if (numberOfPlaceholders == 1) {
return "?"; // fffast
} else if (numberOfPlaceholders == 0) {
return "";
} else if (numberOfPlaceholders < 0) {
throw new IllegalArgumentException("numberOfPlaceholders must be >= 0, but was = " + numberOfPlaceholders);
}
final StringBuilder stringBuilder = new StringBuilder((numberOfPlaceholders * 2) - 1);
for (int i = 0; i < numberOfPlaceholders; i++) {
stringBuilder.append('?');
if (i != numberOfPlaceholders - 1) {
stringBuilder.append(',');
}
}
return stringBuilder.toString();
}
|
java
|
{
"resource": ""
}
|
q4165
|
Association.get
|
train
|
public Tuple get(RowKey key) {
AssociationOperation result = currentState.get( key );
if ( result == null ) {
return cleared ? null : snapshot.get( key );
}
else if ( result.getType() == REMOVE ) {
return null;
}
return result.getValue();
}
|
java
|
{
"resource": ""
}
|
q4166
|
Association.remove
|
train
|
public void remove(RowKey key) {
currentState.put( key, new AssociationOperation( key, null, REMOVE ) );
}
|
java
|
{
"resource": ""
}
|
q4167
|
Association.isEmpty
|
train
|
public boolean isEmpty() {
int snapshotSize = cleared ? 0 : snapshot.size();
//nothing in both
if ( snapshotSize == 0 && currentState.isEmpty() ) {
return true;
}
//snapshot bigger than changeset
if ( snapshotSize > currentState.size() ) {
return false;
}
return size() == 0;
}
|
java
|
{
"resource": ""
}
|
q4168
|
Association.size
|
train
|
public int size() {
int size = cleared ? 0 : snapshot.size();
for ( Map.Entry<RowKey,AssociationOperation> op : currentState.entrySet() ) {
switch ( op.getValue().getType() ) {
case PUT:
if ( cleared || !snapshot.containsKey( op.getKey() ) ) {
size++;
}
break;
case REMOVE:
if ( !cleared && snapshot.containsKey( op.getKey() ) ) {
size--;
}
break;
}
}
return size;
}
|
java
|
{
"resource": ""
}
|
q4169
|
Association.getKeys
|
train
|
public Iterable<RowKey> getKeys() {
if ( currentState.isEmpty() ) {
if ( cleared ) {
// if the association has been cleared and the currentState is empty, we consider that there are no rows.
return Collections.emptyList();
}
else {
// otherwise, the snapshot rows are the current ones
return snapshot.getRowKeys();
}
}
else {
// It may be a bit too large in case of removals, but that's fine for now
Set<RowKey> keys = CollectionHelper.newLinkedHashSet( cleared ? currentState.size() : snapshot.size() + currentState.size() );
if ( !cleared ) {
// we add the snapshot RowKeys only if the association has not been cleared
for ( RowKey rowKey : snapshot.getRowKeys() ) {
keys.add( rowKey );
}
}
for ( Map.Entry<RowKey,AssociationOperation> op : currentState.entrySet() ) {
switch ( op.getValue().getType() ) {
case PUT:
keys.add( op.getKey() );
break;
case REMOVE:
keys.remove( op.getKey() );
break;
}
}
return keys;
}
}
|
java
|
{
"resource": ""
}
|
q4170
|
RowKey.getColumnValue
|
train
|
public Object getColumnValue(String columnName) {
for ( int j = 0; j < columnNames.length; j++ ) {
if ( columnNames[j].equals( columnName ) ) {
return columnValues[j];
}
}
return null;
}
|
java
|
{
"resource": ""
}
|
q4171
|
RowKey.contains
|
train
|
public boolean contains(String column) {
for ( String columnName : columnNames ) {
if ( columnName.equals( column ) ) {
return true;
}
}
return false;
}
|
java
|
{
"resource": ""
}
|
q4172
|
InfinispanRemoteConfiguration.loadResourceFile
|
train
|
private void loadResourceFile(URL configurationResourceUrl, Properties hotRodConfiguration) {
if ( configurationResourceUrl != null ) {
try ( InputStream openStream = configurationResourceUrl.openStream() ) {
hotRodConfiguration.load( openStream );
}
catch (IOException e) {
throw log.failedLoadingHotRodConfigurationProperties( e );
}
}
}
|
java
|
{
"resource": ""
}
|
q4173
|
OptionValueSources.invokeOptionConfigurator
|
train
|
private static <D extends DatastoreConfiguration<G>, G extends GlobalContext<?, ?>> AppendableConfigurationContext invokeOptionConfigurator(
OptionConfigurator configurator) {
ConfigurableImpl configurable = new ConfigurableImpl();
configurator.configure( configurable );
return configurable.getContext();
}
|
java
|
{
"resource": ""
}
|
q4174
|
DefaultEntityKeyMetadata.isKeyColumn
|
train
|
@Override
public boolean isKeyColumn(String columnName) {
for ( String keyColumName : getColumnNames() ) {
if ( keyColumName.equals( columnName ) ) {
return true;
}
}
return false;
}
|
java
|
{
"resource": ""
}
|
q4175
|
OgmLoader.loadEntitiesFromTuples
|
train
|
@Override
public List<Object> loadEntitiesFromTuples(SharedSessionContractImplementor session, LockOptions lockOptions, OgmLoadingContext ogmContext) {
return loadEntity( null, null, session, lockOptions, ogmContext );
}
|
java
|
{
"resource": ""
}
|
q4176
|
OgmLoader.loadCollection
|
train
|
public final void loadCollection(
final SharedSessionContractImplementor session,
final Serializable id,
final Type type) throws HibernateException {
if ( log.isDebugEnabled() ) {
log.debug(
"loading collection: " +
MessageHelper.collectionInfoString( getCollectionPersisters()[0], id, getFactory() )
);
}
Serializable[] ids = new Serializable[]{id};
QueryParameters qp = new QueryParameters( new Type[]{type}, ids, ids );
doQueryAndInitializeNonLazyCollections(
session,
qp,
OgmLoadingContext.EMPTY_CONTEXT,
true
);
log.debug( "done loading collection" );
}
|
java
|
{
"resource": ""
}
|
q4177
|
OgmLoader.doQueryAndInitializeNonLazyCollections
|
train
|
private List<Object> doQueryAndInitializeNonLazyCollections(
SharedSessionContractImplementor session,
QueryParameters qp,
OgmLoadingContext ogmLoadingContext,
boolean returnProxies) {
//TODO handles the read only
final PersistenceContext persistenceContext = session.getPersistenceContext();
boolean defaultReadOnlyOrig = persistenceContext.isDefaultReadOnly();
persistenceContext.beforeLoad();
List<Object> result;
try {
try {
result = doQuery(
session,
qp,
ogmLoadingContext,
returnProxies
);
}
finally {
persistenceContext.afterLoad();
}
persistenceContext.initializeNonLazyCollections();
}
finally {
// Restore the original default
persistenceContext.setDefaultReadOnly( defaultReadOnlyOrig );
}
log.debug( "done entity load" );
return result;
}
|
java
|
{
"resource": ""
}
|
q4178
|
OgmLoader.doQuery
|
train
|
private List<Object> doQuery(
SharedSessionContractImplementor session,
QueryParameters qp,
OgmLoadingContext ogmLoadingContext,
boolean returnProxies) {
//TODO support lock timeout
int entitySpan = entityPersisters.length;
final List<Object> hydratedObjects = entitySpan == 0 ? null : new ArrayList<Object>( entitySpan * 10 );
//TODO yuk! Is there a cleaner way to access the id?
final Serializable id;
// see if we use batching first
// then look for direct id
// then for a tuple based result set we could extract the id
// otherwise that's a collection so we use the collection key
boolean loadSeveralIds = loadSeveralIds( qp );
boolean isCollectionLoader;
if ( loadSeveralIds ) {
// need to be set to null otherwise the optionalId has precedence
// and is used for all tuples regardless of their actual ids
id = null;
isCollectionLoader = false;
}
else if ( qp.getOptionalId() != null ) {
id = qp.getOptionalId();
isCollectionLoader = false;
}
else if ( ogmLoadingContext.hasResultSet() ) {
// extract the ids from the tuples directly
id = null;
isCollectionLoader = false;
}
else {
id = qp.getCollectionKeys()[0];
isCollectionLoader = true;
}
TupleAsMapResultSet resultset = getResultSet( id, qp, ogmLoadingContext, session );
//Todo implement lockmode
//final LockMode[] lockModesArray = getLockModes( queryParameters.getLockOptions() );
//FIXME should we use subselects as it's closer to this process??
//TODO is resultset a good marker, or should it be an ad-hoc marker??
//It likely all depends on what resultset ends up being
handleEmptyCollections( qp.getCollectionKeys(), resultset, session );
final org.hibernate.engine.spi.EntityKey[] keys = new org.hibernate.engine.spi.EntityKey[entitySpan];
//for each element in resultset
//TODO should we collect List<Object> as result? Not necessary today
Object result = null;
List<Object> results = new ArrayList<Object>();
if ( isCollectionLoader ) {
preLoadBatchFetchingQueue( session, resultset );
}
try {
while ( resultset.next() ) {
result = getRowFromResultSet(
resultset,
session,
qp,
ogmLoadingContext,
//lockmodeArray,
id,
hydratedObjects,
keys,
returnProxies );
results.add( result );
}
//TODO collect subselect result key
}
catch ( SQLException e ) {
//never happens this is not a regular ResultSet
}
//end of for each element in resultset
initializeEntitiesAndCollections( hydratedObjects, resultset, session, qp.isReadOnly( session ) );
//TODO create subselects
return results;
}
|
java
|
{
"resource": ""
}
|
q4179
|
OgmLoader.readCollectionElement
|
train
|
private void readCollectionElement(
final Object optionalOwner,
final Serializable optionalKey,
final CollectionPersister persister,
final CollectionAliases descriptor,
final ResultSet rs,
final SharedSessionContractImplementor session)
throws HibernateException, SQLException {
final PersistenceContext persistenceContext = session.getPersistenceContext();
//implement persister.readKey using the grid type (later)
final Serializable collectionRowKey = (Serializable) persister.readKey(
rs,
descriptor.getSuffixedKeyAliases(),
session
);
if ( collectionRowKey != null ) {
// we found a collection element in the result set
if ( log.isDebugEnabled() ) {
log.debug(
"found row of collection: " +
MessageHelper.collectionInfoString( persister, collectionRowKey, getFactory() )
);
}
Object owner = optionalOwner;
if ( owner == null ) {
owner = persistenceContext.getCollectionOwner( collectionRowKey, persister );
if ( owner == null ) {
//TODO: This is assertion is disabled because there is a bug that means the
// original owner of a transient, uninitialized collection is not known
// if the collection is re-referenced by a different object associated
// with the current Session
//throw new AssertionFailure("bug loading unowned collection");
}
}
PersistentCollection rowCollection = persistenceContext.getLoadContexts()
.getCollectionLoadContext( rs )
.getLoadingCollection( persister, collectionRowKey );
if ( rowCollection != null ) {
hydrateRowCollection( persister, descriptor, rs, owner, rowCollection );
}
}
else if ( optionalKey != null ) {
// we did not find a collection element in the result set, so we
// ensure that a collection is created with the owner's identifier,
// since what we have is an empty collection
if ( log.isDebugEnabled() ) {
log.debug(
"result set contains (possibly empty) collection: " +
MessageHelper.collectionInfoString( persister, optionalKey, getFactory() )
);
}
persistenceContext.getLoadContexts()
.getCollectionLoadContext( rs )
.getLoadingCollection( persister, optionalKey ); // handle empty collection
}
// else no collection element, but also no owner
}
|
java
|
{
"resource": ""
}
|
q4180
|
OgmLoader.instanceAlreadyLoaded
|
train
|
private void instanceAlreadyLoaded(
final Tuple resultset,
final int i,
//TODO create an interface for this usage
final OgmEntityPersister persister,
final org.hibernate.engine.spi.EntityKey key,
final Object object,
final LockMode lockMode,
final SharedSessionContractImplementor session)
throws HibernateException {
if ( !persister.isInstance( object ) ) {
throw new WrongClassException(
"loaded object was of wrong class " + object.getClass(),
key.getIdentifier(),
persister.getEntityName()
);
}
if ( LockMode.NONE != lockMode && upgradeLocks() ) { // no point doing this if NONE was requested
final boolean isVersionCheckNeeded = persister.isVersioned() &&
session.getPersistenceContext().getEntry( object )
.getLockMode().lessThan( lockMode );
// we don't need to worry about existing version being uninitialized
// because this block isn't called by a re-entrant load (re-entrant
// loads _always_ have lock mode NONE)
if ( isVersionCheckNeeded ) {
//we only check the version when _upgrading_ lock modes
Object oldVersion = session.getPersistenceContext().getEntry( object ).getVersion();
persister.checkVersionAndRaiseSOSE( key.getIdentifier(), oldVersion, session, resultset );
//we need to upgrade the lock mode to the mode requested
session.getPersistenceContext().getEntry( object )
.setLockMode( lockMode );
}
}
}
|
java
|
{
"resource": ""
}
|
q4181
|
OgmLoader.instanceNotYetLoaded
|
train
|
private Object instanceNotYetLoaded(
final Tuple resultset,
final int i,
final Loadable persister,
final String rowIdAlias,
final org.hibernate.engine.spi.EntityKey key,
final LockMode lockMode,
final org.hibernate.engine.spi.EntityKey optionalObjectKey,
final Object optionalObject,
final List hydratedObjects,
final SharedSessionContractImplementor session)
throws HibernateException {
final String instanceClass = getInstanceClass(
resultset,
i,
persister,
key.getIdentifier(),
session
);
final Object object;
if ( optionalObjectKey != null && key.equals( optionalObjectKey ) ) {
//its the given optional object
object = optionalObject;
}
else {
// instantiate a new instance
object = session.instantiate( instanceClass, key.getIdentifier() );
}
//need to hydrate it.
// grab its state from the ResultSet and keep it in the Session
// (but don't yet initialize the object itself)
// note that we acquire LockMode.READ even if it was not requested
LockMode acquiredLockMode = lockMode == LockMode.NONE ? LockMode.READ : lockMode;
loadFromResultSet(
resultset,
i,
object,
instanceClass,
key,
rowIdAlias,
acquiredLockMode,
persister,
session
);
//materialize associations (and initialize the object) later
hydratedObjects.add( object );
return object;
}
|
java
|
{
"resource": ""
}
|
q4182
|
OgmLoader.registerNonExists
|
train
|
private void registerNonExists(
final org.hibernate.engine.spi.EntityKey[] keys,
final Loadable[] persisters,
final SharedSessionContractImplementor session) {
final int[] owners = getOwners();
if ( owners != null ) {
EntityType[] ownerAssociationTypes = getOwnerAssociationTypes();
for ( int i = 0; i < keys.length; i++ ) {
int owner = owners[i];
if ( owner > -1 ) {
org.hibernate.engine.spi.EntityKey ownerKey = keys[owner];
if ( keys[i] == null && ownerKey != null ) {
final PersistenceContext persistenceContext = session.getPersistenceContext();
/*final boolean isPrimaryKey;
final boolean isSpecialOneToOne;
if ( ownerAssociationTypes == null || ownerAssociationTypes[i] == null ) {
isPrimaryKey = true;
isSpecialOneToOne = false;
}
else {
isPrimaryKey = ownerAssociationTypes[i].getRHSUniqueKeyPropertyName()==null;
isSpecialOneToOne = ownerAssociationTypes[i].getLHSPropertyName()!=null;
}*/
//TODO: can we *always* use the "null property" approach for everything?
/*if ( isPrimaryKey && !isSpecialOneToOne ) {
persistenceContext.addNonExistantEntityKey(
new EntityKey( ownerKey.getIdentifier(), persisters[i], session.getEntityMode() )
);
}
else if ( isSpecialOneToOne ) {*/
boolean isOneToOneAssociation = ownerAssociationTypes != null &&
ownerAssociationTypes[i] != null &&
ownerAssociationTypes[i].isOneToOne();
if ( isOneToOneAssociation ) {
persistenceContext.addNullProperty( ownerKey,
ownerAssociationTypes[i].getPropertyName() );
}
/*}
else {
persistenceContext.addNonExistantEntityUniqueKey( new EntityUniqueKey(
persisters[i].getEntityName(),
ownerAssociationTypes[i].getRHSUniqueKeyPropertyName(),
ownerKey.getIdentifier(),
persisters[owner].getIdentifierType(),
session.getEntityMode()
) );
}*/
}
}
}
}
}
|
java
|
{
"resource": ""
}
|
q4183
|
NativeQueryParser.CriteriaOnlyFindQuery
|
train
|
public Rule CriteriaOnlyFindQuery() {
return Sequence( !peek().isCliQuery(), JsonParameter( JsonObject() ) , peek().setOperation( Operation.FIND ), peek().setCriteria( match() ) );
}
|
java
|
{
"resource": ""
}
|
q4184
|
ReflectionHelper.introspect
|
train
|
public static Map<String, Object> introspect(Object obj) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
Map<String, Object> result = new HashMap<>();
BeanInfo info = Introspector.getBeanInfo( obj.getClass() );
for ( PropertyDescriptor pd : info.getPropertyDescriptors() ) {
Method reader = pd.getReadMethod();
String name = pd.getName();
if ( reader != null && !"class".equals( name ) ) {
result.put( name, reader.invoke( obj ) );
}
}
return result;
}
|
java
|
{
"resource": ""
}
|
q4185
|
ReflectionHelper.propertyExists
|
train
|
public static boolean propertyExists(Class<?> clazz, String property, ElementType elementType) {
if ( ElementType.FIELD.equals( elementType ) ) {
return getDeclaredField( clazz, property ) != null;
}
else {
String capitalizedPropertyName = capitalize( property );
Method method = getMethod( clazz, PROPERTY_ACCESSOR_PREFIX_GET + capitalizedPropertyName );
if ( method != null && method.getReturnType() != void.class ) {
return true;
}
method = getMethod( clazz, PROPERTY_ACCESSOR_PREFIX_IS + capitalizedPropertyName );
if ( method != null && method.getReturnType() == boolean.class ) {
return true;
}
}
return false;
}
|
java
|
{
"resource": ""
}
|
q4186
|
ReflectionHelper.setField
|
train
|
public static void setField(Object object, String field, Object value) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Class<?> clazz = object.getClass();
Method m = clazz.getMethod( PROPERTY_ACCESSOR_PREFIX_SET + capitalize( field ), value.getClass() );
m.invoke( object, value );
}
|
java
|
{
"resource": ""
}
|
q4187
|
ParserPropertyHelper.isEmbeddedProperty
|
train
|
public boolean isEmbeddedProperty(String targetTypeName, List<String> namesWithoutAlias) {
OgmEntityPersister persister = getPersister( targetTypeName );
Type propertyType = persister.getPropertyType( namesWithoutAlias.get( 0 ) );
if ( propertyType.isComponentType() ) {
// Embedded
return true;
}
else if ( propertyType.isAssociationType() ) {
Joinable associatedJoinable = ( (AssociationType) propertyType ).getAssociatedJoinable( persister.getFactory() );
if ( associatedJoinable.isCollection() ) {
OgmCollectionPersister collectionPersister = (OgmCollectionPersister) associatedJoinable;
return collectionPersister.getType().isComponentType();
}
}
return false;
}
|
java
|
{
"resource": ""
}
|
q4188
|
ParserPropertyHelper.isAssociation
|
train
|
public boolean isAssociation(String targetTypeName, List<String> pathWithoutAlias) {
OgmEntityPersister persister = getPersister( targetTypeName );
Type propertyType = persister.getPropertyType( pathWithoutAlias.get( 0 ) );
return propertyType.isAssociationType();
}
|
java
|
{
"resource": ""
}
|
q4189
|
ParserPropertyHelper.findAssociationPath
|
train
|
public List<String> findAssociationPath(String targetTypeName, List<String> pathWithoutAlias) {
List<String> subPath = new ArrayList<String>( pathWithoutAlias.size() );
for ( String name : pathWithoutAlias ) {
subPath.add( name );
if ( isAssociation( targetTypeName, subPath ) ) {
return subPath;
}
}
return null;
}
|
java
|
{
"resource": ""
}
|
q4190
|
AssociationRow.buildRowKey
|
train
|
private static <R> RowKey buildRowKey(AssociationKey associationKey, R row, AssociationRowAccessor<R> accessor) {
String[] columnNames = associationKey.getMetadata().getRowKeyColumnNames();
Object[] columnValues = new Object[columnNames.length];
for ( int i = 0; i < columnNames.length; i++ ) {
String columnName = columnNames[i];
columnValues[i] = associationKey.getMetadata().isKeyColumn( columnName ) ? associationKey.getColumnValue( columnName ) : accessor.get( row, columnName );
}
return new RowKey( columnNames, columnValues );
}
|
java
|
{
"resource": ""
}
|
q4191
|
BaseNeo4jDialect.getEntityKey
|
train
|
protected EntityKey getEntityKey(Tuple tuple, AssociatedEntityKeyMetadata associatedEntityKeyMetadata) {
Object[] columnValues = new Object[ associatedEntityKeyMetadata.getAssociationKeyColumns().length];
int i = 0;
for ( String associationKeyColumn : associatedEntityKeyMetadata.getAssociationKeyColumns() ) {
columnValues[i] = tuple.get( associationKeyColumn );
i++;
}
return new EntityKey( associatedEntityKeyMetadata.getEntityKeyMetadata(), columnValues );
}
|
java
|
{
"resource": ""
}
|
q4192
|
BaseNeo4jDialect.isPartOfRegularEmbedded
|
train
|
public static boolean isPartOfRegularEmbedded(String[] keyColumnNames, String column) {
return isPartOfEmbedded( column ) && !ArrayHelper.contains( keyColumnNames, column );
}
|
java
|
{
"resource": ""
}
|
q4193
|
EmbeddableStateFinder.getOuterMostNullEmbeddableIfAny
|
train
|
public String getOuterMostNullEmbeddableIfAny(String column) {
String[] path = column.split( "\\." );
if ( !isEmbeddableColumn( path ) ) {
return null;
}
// the cached value may be null hence the explicit key lookup
if ( columnToOuterMostNullEmbeddableCache.containsKey( column ) ) {
return columnToOuterMostNullEmbeddableCache.get( column );
}
return determineAndCacheOuterMostNullEmbeddable( column, path );
}
|
java
|
{
"resource": ""
}
|
q4194
|
EmbeddableStateFinder.determineAndCacheOuterMostNullEmbeddable
|
train
|
private String determineAndCacheOuterMostNullEmbeddable(String column, String[] path) {
String embeddable = path[0];
// process each embeddable from less specific to most specific
// exclude path leaves as it's a column and not an embeddable
for ( int index = 0; index < path.length - 1; index++ ) {
Set<String> columnsOfEmbeddable = getColumnsOfEmbeddableAndComputeEmbeddableNullness( embeddable );
if ( nullEmbeddables.contains( embeddable ) ) {
// the current embeddable only has null columns; cache that info for all the columns
for ( String columnOfEmbeddable : columnsOfEmbeddable ) {
columnToOuterMostNullEmbeddableCache.put( columnOfEmbeddable, embeddable );
}
break;
}
else {
maybeCacheOnNonNullEmbeddable( path, index, columnsOfEmbeddable );
}
// a more specific null embeddable might be present, carry on
embeddable += "." + path[index + 1];
}
return columnToOuterMostNullEmbeddableCache.get( column );
}
|
java
|
{
"resource": ""
}
|
q4195
|
EntityAssociationUpdater.addNavigationalInformationForInverseSide
|
train
|
public void addNavigationalInformationForInverseSide() {
if ( log.isTraceEnabled() ) {
log.trace( "Adding inverse navigational information for entity: " + MessageHelper.infoString( persister, id, persister.getFactory() ) );
}
for ( int propertyIndex = 0; propertyIndex < persister.getEntityMetamodel().getPropertySpan(); propertyIndex++ ) {
if ( persister.isPropertyOfTable( propertyIndex, tableIndex ) ) {
AssociationKeyMetadata associationKeyMetadata = getInverseAssociationKeyMetadata( propertyIndex );
// there is no inverse association for the given property
if ( associationKeyMetadata == null ) {
continue;
}
Object[] newColumnValues = LogicalPhysicalConverterHelper.getColumnValuesFromResultset(
resultset,
persister.getPropertyColumnNames( propertyIndex )
);
//don't index null columns, this means no association
if ( ! CollectionHelper.isEmptyOrContainsOnlyNull( ( newColumnValues ) ) ) {
addNavigationalInformationForInverseSide( propertyIndex, associationKeyMetadata, newColumnValues );
}
}
}
}
|
java
|
{
"resource": ""
}
|
q4196
|
StringHelper.escapeDoubleQuotesForJson
|
train
|
public static String escapeDoubleQuotesForJson(String text) {
if ( text == null ) {
return null;
}
StringBuilder builder = new StringBuilder( text.length() );
for ( int i = 0; i < text.length(); i++ ) {
char c = text.charAt( i );
switch ( c ) {
case '"':
case '\\':
builder.append( "\\" );
default:
builder.append( c );
}
}
return builder.toString();
}
|
java
|
{
"resource": ""
}
|
q4197
|
HttpNeo4jEntityQueries.row
|
train
|
private static Row row(List<StatementResult> results) {
Row row = results.get( 0 ).getData().get( 0 );
return row;
}
|
java
|
{
"resource": ""
}
|
q4198
|
GridDialects.getDialectFacetOrNull
|
train
|
static <T extends GridDialect> T getDialectFacetOrNull(GridDialect gridDialect, Class<T> facetType) {
if ( hasFacet( gridDialect, facetType ) ) {
@SuppressWarnings("unchecked")
T asFacet = (T) gridDialect;
return asFacet;
}
return null;
}
|
java
|
{
"resource": ""
}
|
q4199
|
GridDialects.hasFacet
|
train
|
public static boolean hasFacet(GridDialect gridDialect, Class<? extends GridDialect> facetType) {
if ( gridDialect instanceof ForwardingGridDialect ) {
return hasFacet( ( (ForwardingGridDialect<?>) gridDialect ).getGridDialect(), facetType );
}
else {
return facetType.isAssignableFrom( gridDialect.getClass() );
}
}
|
java
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.