id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
29,300 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/Panel.java | Panel.removeAllComponents | public Panel removeAllComponents() {
synchronized(components) {
for(Component component : new ArrayList<Component>(components)) {
removeComponent(component);
}
}
return this;
} | java | public Panel removeAllComponents() {
synchronized(components) {
for(Component component : new ArrayList<Component>(components)) {
removeComponent(component);
}
}
return this;
} | [
"public",
"Panel",
"removeAllComponents",
"(",
")",
"{",
"synchronized",
"(",
"components",
")",
"{",
"for",
"(",
"Component",
"component",
":",
"new",
"ArrayList",
"<",
"Component",
">",
"(",
"components",
")",
")",
"{",
"removeComponent",
"(",
"component",
... | Removes all child components from this panel
@return Itself | [
"Removes",
"all",
"child",
"components",
"from",
"this",
"panel"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/Panel.java#L153-L160 |
29,301 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/Panel.java | Panel.setLayoutManager | public synchronized Panel setLayoutManager(LayoutManager layoutManager) {
if(layoutManager == null) {
layoutManager = new AbsoluteLayout();
}
this.layoutManager = layoutManager;
invalidate();
return this;
} | java | public synchronized Panel setLayoutManager(LayoutManager layoutManager) {
if(layoutManager == null) {
layoutManager = new AbsoluteLayout();
}
this.layoutManager = layoutManager;
invalidate();
return this;
} | [
"public",
"synchronized",
"Panel",
"setLayoutManager",
"(",
"LayoutManager",
"layoutManager",
")",
"{",
"if",
"(",
"layoutManager",
"==",
"null",
")",
"{",
"layoutManager",
"=",
"new",
"AbsoluteLayout",
"(",
")",
";",
"}",
"this",
".",
"layoutManager",
"=",
"l... | Assigns a new layout manager to this panel, replacing the previous layout manager assigned. Please note that if
the panel is not empty at the time you assign a new layout manager, the existing components might not show up
where you expect them and their layout data property might need to be re-assigned.
@param layoutManager New layout manager this panel should be using
@return Itself | [
"Assigns",
"a",
"new",
"layout",
"manager",
"to",
"this",
"panel",
"replacing",
"the",
"previous",
"layout",
"manager",
"assigned",
".",
"Please",
"note",
"that",
"if",
"the",
"panel",
"is",
"not",
"empty",
"at",
"the",
"time",
"you",
"assign",
"a",
"new",... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/Panel.java#L169-L176 |
29,302 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/ComboBox.java | ComboBox.addItem | public synchronized ComboBox<V> addItem(V item) {
if(item == null) {
throw new IllegalArgumentException("Cannot add null elements to a ComboBox");
}
items.add(item);
if(selectedIndex == -1 && items.size() == 1) {
setSelectedIndex(0);
}
invalidate();
return this;
} | java | public synchronized ComboBox<V> addItem(V item) {
if(item == null) {
throw new IllegalArgumentException("Cannot add null elements to a ComboBox");
}
items.add(item);
if(selectedIndex == -1 && items.size() == 1) {
setSelectedIndex(0);
}
invalidate();
return this;
} | [
"public",
"synchronized",
"ComboBox",
"<",
"V",
">",
"addItem",
"(",
"V",
"item",
")",
"{",
"if",
"(",
"item",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot add null elements to a ComboBox\"",
")",
";",
"}",
"items",
".",
... | Adds a new item to the combo box, at the end
@param item Item to add to the combo box
@return Itself | [
"Adds",
"a",
"new",
"item",
"to",
"the",
"combo",
"box",
"at",
"the",
"end"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/ComboBox.java#L137-L147 |
29,303 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/ComboBox.java | ComboBox.removeItem | public synchronized ComboBox<V> removeItem(V item) {
int index = items.indexOf(item);
if(index == -1) {
return this;
}
return remoteItem(index);
} | java | public synchronized ComboBox<V> removeItem(V item) {
int index = items.indexOf(item);
if(index == -1) {
return this;
}
return remoteItem(index);
} | [
"public",
"synchronized",
"ComboBox",
"<",
"V",
">",
"removeItem",
"(",
"V",
"item",
")",
"{",
"int",
"index",
"=",
"items",
".",
"indexOf",
"(",
"item",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"return",
"this",
";",
"}",
"return",
... | Removes a particular item from the combo box, if it is present, otherwise does nothing
@param item Item to remove from the combo box
@return Itself | [
"Removes",
"a",
"particular",
"item",
"from",
"the",
"combo",
"box",
"if",
"it",
"is",
"present",
"otherwise",
"does",
"nothing"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/ComboBox.java#L183-L189 |
29,304 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/ComboBox.java | ComboBox.remoteItem | public synchronized ComboBox<V> remoteItem(int index) {
items.remove(index);
if(index < selectedIndex) {
setSelectedIndex(selectedIndex - 1);
}
else if(index == selectedIndex) {
setSelectedIndex(-1);
}
invalidate();
return this;
} | java | public synchronized ComboBox<V> remoteItem(int index) {
items.remove(index);
if(index < selectedIndex) {
setSelectedIndex(selectedIndex - 1);
}
else if(index == selectedIndex) {
setSelectedIndex(-1);
}
invalidate();
return this;
} | [
"public",
"synchronized",
"ComboBox",
"<",
"V",
">",
"remoteItem",
"(",
"int",
"index",
")",
"{",
"items",
".",
"remove",
"(",
"index",
")",
";",
"if",
"(",
"index",
"<",
"selectedIndex",
")",
"{",
"setSelectedIndex",
"(",
"selectedIndex",
"-",
"1",
")",... | Removes an item from the combo box at a particular index
@param index Index of the item to remove
@return Itself
@throws IndexOutOfBoundsException if the index is out of range | [
"Removes",
"an",
"item",
"from",
"the",
"combo",
"box",
"at",
"a",
"particular",
"index"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/ComboBox.java#L197-L207 |
29,305 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/ComboBox.java | ComboBox.setSelectedIndex | public synchronized void setSelectedIndex(final int selectedIndex) {
if(items.size() <= selectedIndex || selectedIndex < -1) {
throw new IndexOutOfBoundsException("Illegal argument to ComboBox.setSelectedIndex: " + selectedIndex);
}
final int oldSelection = this.selectedIndex;
this.selectedIndex = selectedIndex;
if(selectedIndex == -1) {
updateText("");
}
else {
updateText(items.get(selectedIndex).toString());
}
runOnGUIThreadIfExistsOtherwiseRunDirect(new Runnable() {
@Override
public void run() {
for(Listener listener: listeners) {
listener.onSelectionChanged(selectedIndex, oldSelection);
}
}
});
invalidate();
} | java | public synchronized void setSelectedIndex(final int selectedIndex) {
if(items.size() <= selectedIndex || selectedIndex < -1) {
throw new IndexOutOfBoundsException("Illegal argument to ComboBox.setSelectedIndex: " + selectedIndex);
}
final int oldSelection = this.selectedIndex;
this.selectedIndex = selectedIndex;
if(selectedIndex == -1) {
updateText("");
}
else {
updateText(items.get(selectedIndex).toString());
}
runOnGUIThreadIfExistsOtherwiseRunDirect(new Runnable() {
@Override
public void run() {
for(Listener listener: listeners) {
listener.onSelectionChanged(selectedIndex, oldSelection);
}
}
});
invalidate();
} | [
"public",
"synchronized",
"void",
"setSelectedIndex",
"(",
"final",
"int",
"selectedIndex",
")",
"{",
"if",
"(",
"items",
".",
"size",
"(",
")",
"<=",
"selectedIndex",
"||",
"selectedIndex",
"<",
"-",
"1",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",... | Programmatically selects one item in the combo box, which causes the displayed text to change to match the label
of the selected index.
@param selectedIndex Index of the item to select, or -1 if the selection should be cleared
@throws IndexOutOfBoundsException if the index is out of range | [
"Programmatically",
"selects",
"one",
"item",
"in",
"the",
"combo",
"box",
"which",
"causes",
"the",
"displayed",
"text",
"to",
"change",
"to",
"match",
"the",
"label",
"of",
"the",
"selected",
"index",
"."
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/ComboBox.java#L326-L347 |
29,306 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/TerminalTextUtils.java | TerminalTextUtils.getANSIControlSequenceAt | public static String getANSIControlSequenceAt(String string, int index) {
int len = getANSIControlSequenceLength(string, index);
return len == 0 ? null : string.substring(index,index+len);
} | java | public static String getANSIControlSequenceAt(String string, int index) {
int len = getANSIControlSequenceLength(string, index);
return len == 0 ? null : string.substring(index,index+len);
} | [
"public",
"static",
"String",
"getANSIControlSequenceAt",
"(",
"String",
"string",
",",
"int",
"index",
")",
"{",
"int",
"len",
"=",
"getANSIControlSequenceLength",
"(",
"string",
",",
"index",
")",
";",
"return",
"len",
"==",
"0",
"?",
"null",
":",
"string"... | Given a string and an index in that string, returns the ANSI control sequence beginning on this index. If there
is no control sequence starting there, the method will return null. The returned value is the complete escape
sequence including the ESC prefix.
@param string String to scan for control sequences
@param index Index in the string where the control sequence begins
@return {@code null} if there was no control sequence starting at the specified index, otherwise the entire
control sequence | [
"Given",
"a",
"string",
"and",
"an",
"index",
"in",
"that",
"string",
"returns",
"the",
"ANSI",
"control",
"sequence",
"beginning",
"on",
"this",
"index",
".",
"If",
"there",
"is",
"no",
"control",
"sequence",
"starting",
"there",
"the",
"method",
"will",
... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TerminalTextUtils.java#L51-L54 |
29,307 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/TerminalTextUtils.java | TerminalTextUtils.getANSIControlSequenceLength | public static int getANSIControlSequenceLength(String string, int index) {
int len = 0, restlen = string.length() - index;
if (restlen >= 3) { // Control sequences require a minimum of three characters
char esc = string.charAt(index),
bracket = string.charAt(index+1);
if (esc == 0x1B && bracket == '[') { // escape & open bracket
len = 3; // esc,bracket and (later)terminator.
// digits or semicolons can still precede the terminator:
for (int i = 2; i < restlen; i++) {
char ch = string.charAt(i + index);
// only ascii-digits or semicolons allowed here:
if ( (ch >= '0' && ch <= '9') || ch == ';') {
len++;
} else {
break;
}
}
// if string ends in digits/semicolons, then it's not a sequence.
if (len > restlen) {
len = 0;
}
}
}
return len;
} | java | public static int getANSIControlSequenceLength(String string, int index) {
int len = 0, restlen = string.length() - index;
if (restlen >= 3) { // Control sequences require a minimum of three characters
char esc = string.charAt(index),
bracket = string.charAt(index+1);
if (esc == 0x1B && bracket == '[') { // escape & open bracket
len = 3; // esc,bracket and (later)terminator.
// digits or semicolons can still precede the terminator:
for (int i = 2; i < restlen; i++) {
char ch = string.charAt(i + index);
// only ascii-digits or semicolons allowed here:
if ( (ch >= '0' && ch <= '9') || ch == ';') {
len++;
} else {
break;
}
}
// if string ends in digits/semicolons, then it's not a sequence.
if (len > restlen) {
len = 0;
}
}
}
return len;
} | [
"public",
"static",
"int",
"getANSIControlSequenceLength",
"(",
"String",
"string",
",",
"int",
"index",
")",
"{",
"int",
"len",
"=",
"0",
",",
"restlen",
"=",
"string",
".",
"length",
"(",
")",
"-",
"index",
";",
"if",
"(",
"restlen",
">=",
"3",
")",
... | Given a string and an index in that string, returns the number of characters starting at index that make up
a complete ANSI control sequence. If there is no control sequence starting there, the method will return 0.
@param string String to scan for control sequences
@param index Index in the string where the control sequence begins
@return {@code 0} if there was no control sequence starting at the specified index, otherwise the length
of the entire control sequence | [
"Given",
"a",
"string",
"and",
"an",
"index",
"in",
"that",
"string",
"returns",
"the",
"number",
"of",
"characters",
"starting",
"at",
"index",
"that",
"make",
"up",
"a",
"complete",
"ANSI",
"control",
"sequence",
".",
"If",
"there",
"is",
"no",
"control"... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TerminalTextUtils.java#L64-L88 |
29,308 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/TerminalTextUtils.java | TerminalTextUtils.getWordWrappedText | public static List<String> getWordWrappedText(int maxWidth, String... lines) {
//Bounds checking
if(maxWidth <= 0) {
return Arrays.asList(lines);
}
List<String> result = new ArrayList<String>();
LinkedList<String> linesToBeWrapped = new LinkedList<String>(Arrays.asList(lines));
while(!linesToBeWrapped.isEmpty()) {
String row = linesToBeWrapped.removeFirst();
int rowWidth = getColumnWidth(row);
if(rowWidth <= maxWidth) {
result.add(row);
}
else {
//Now search in reverse and find the first possible line-break
final int characterIndexMax = getStringCharacterIndex(row, maxWidth);
int characterIndex = characterIndexMax;
while(characterIndex >= 0 &&
!Character.isSpaceChar(row.charAt(characterIndex)) &&
!isCharCJK(row.charAt(characterIndex))) {
characterIndex--;
}
// right *after* a CJK is also a "nice" spot to break the line!
if (characterIndex >= 0 && characterIndex < characterIndexMax &&
isCharCJK(row.charAt(characterIndex))) {
characterIndex++; // with these conditions it fits!
}
if(characterIndex < 0) {
//Failed! There was no 'nice' place to cut so just cut it at maxWidth
characterIndex = Math.max(characterIndexMax, 1); // at least 1 char
result.add(row.substring(0, characterIndex));
linesToBeWrapped.addFirst(row.substring(characterIndex));
}
else {
// characterIndex == 0 only happens, if either
// - first char is CJK and maxWidth==1 or
// - first char is whitespace
// either way: put it in row before break to prevent infinite loop.
characterIndex = Math.max( characterIndex, 1); // at least 1 char
//Ok, split the row, add it to the result and continue processing the second half on a new line
result.add(row.substring(0, characterIndex));
while(characterIndex < row.length() &&
Character.isSpaceChar(row.charAt(characterIndex))) {
characterIndex++;
}
if (characterIndex < row.length()) { // only if rest contains non-whitespace
linesToBeWrapped.addFirst(row.substring(characterIndex));
}
}
}
}
return result;
} | java | public static List<String> getWordWrappedText(int maxWidth, String... lines) {
//Bounds checking
if(maxWidth <= 0) {
return Arrays.asList(lines);
}
List<String> result = new ArrayList<String>();
LinkedList<String> linesToBeWrapped = new LinkedList<String>(Arrays.asList(lines));
while(!linesToBeWrapped.isEmpty()) {
String row = linesToBeWrapped.removeFirst();
int rowWidth = getColumnWidth(row);
if(rowWidth <= maxWidth) {
result.add(row);
}
else {
//Now search in reverse and find the first possible line-break
final int characterIndexMax = getStringCharacterIndex(row, maxWidth);
int characterIndex = characterIndexMax;
while(characterIndex >= 0 &&
!Character.isSpaceChar(row.charAt(characterIndex)) &&
!isCharCJK(row.charAt(characterIndex))) {
characterIndex--;
}
// right *after* a CJK is also a "nice" spot to break the line!
if (characterIndex >= 0 && characterIndex < characterIndexMax &&
isCharCJK(row.charAt(characterIndex))) {
characterIndex++; // with these conditions it fits!
}
if(characterIndex < 0) {
//Failed! There was no 'nice' place to cut so just cut it at maxWidth
characterIndex = Math.max(characterIndexMax, 1); // at least 1 char
result.add(row.substring(0, characterIndex));
linesToBeWrapped.addFirst(row.substring(characterIndex));
}
else {
// characterIndex == 0 only happens, if either
// - first char is CJK and maxWidth==1 or
// - first char is whitespace
// either way: put it in row before break to prevent infinite loop.
characterIndex = Math.max( characterIndex, 1); // at least 1 char
//Ok, split the row, add it to the result and continue processing the second half on a new line
result.add(row.substring(0, characterIndex));
while(characterIndex < row.length() &&
Character.isSpaceChar(row.charAt(characterIndex))) {
characterIndex++;
}
if (characterIndex < row.length()) { // only if rest contains non-whitespace
linesToBeWrapped.addFirst(row.substring(characterIndex));
}
}
}
}
return result;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getWordWrappedText",
"(",
"int",
"maxWidth",
",",
"String",
"...",
"lines",
")",
"{",
"//Bounds checking",
"if",
"(",
"maxWidth",
"<=",
"0",
")",
"{",
"return",
"Arrays",
".",
"asList",
"(",
"lines",
")",
... | This method will calculate word wrappings given a number of lines of text and how wide the text can be printed.
The result is a list of new rows where word-wrapping was applied.
@param maxWidth Maximum number of columns that can be used before word-wrapping is applied, if <= 0 then the
lines will be returned unchanged
@param lines Input text
@return The input text word-wrapped at {@code maxWidth}; this may contain more rows than the input text | [
"This",
"method",
"will",
"calculate",
"word",
"wrappings",
"given",
"a",
"number",
"of",
"lines",
"of",
"text",
"and",
"how",
"wide",
"the",
"text",
"can",
"be",
"printed",
".",
"The",
"result",
"is",
"a",
"list",
"of",
"new",
"rows",
"where",
"word",
... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TerminalTextUtils.java#L307-L362 |
29,309 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/terminal/AbstractTerminal.java | AbstractTerminal.onResized | protected synchronized void onResized(TerminalSize newSize) {
if (lastKnownSize == null || !lastKnownSize.equals(newSize)) {
lastKnownSize = newSize;
for (TerminalResizeListener resizeListener : resizeListeners) {
resizeListener.onResized(this, lastKnownSize);
}
}
} | java | protected synchronized void onResized(TerminalSize newSize) {
if (lastKnownSize == null || !lastKnownSize.equals(newSize)) {
lastKnownSize = newSize;
for (TerminalResizeListener resizeListener : resizeListeners) {
resizeListener.onResized(this, lastKnownSize);
}
}
} | [
"protected",
"synchronized",
"void",
"onResized",
"(",
"TerminalSize",
"newSize",
")",
"{",
"if",
"(",
"lastKnownSize",
"==",
"null",
"||",
"!",
"lastKnownSize",
".",
"equals",
"(",
"newSize",
")",
")",
"{",
"lastKnownSize",
"=",
"newSize",
";",
"for",
"(",
... | Call this method when the terminal has been resized or the initial size of the terminal has been discovered. It
will trigger all resize listeners, but only if the size has changed from before.
@param newSize Last discovered terminal size | [
"Call",
"this",
"method",
"when",
"the",
"terminal",
"has",
"been",
"resized",
"or",
"the",
"initial",
"size",
"of",
"the",
"terminal",
"has",
"been",
"discovered",
".",
"It",
"will",
"trigger",
"all",
"resize",
"listeners",
"but",
"only",
"if",
"the",
"si... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/AbstractTerminal.java#L75-L82 |
29,310 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/terminal/swing/TerminalEmulatorColorConfiguration.java | TerminalEmulatorColorConfiguration.toAWTColor | public Color toAWTColor(TextColor color, boolean isForeground, boolean inBoldContext) {
if(color instanceof TextColor.ANSI) {
return colorPalette.get((TextColor.ANSI)color, isForeground, inBoldContext && useBrightColorsOnBold);
}
return color.toColor();
} | java | public Color toAWTColor(TextColor color, boolean isForeground, boolean inBoldContext) {
if(color instanceof TextColor.ANSI) {
return colorPalette.get((TextColor.ANSI)color, isForeground, inBoldContext && useBrightColorsOnBold);
}
return color.toColor();
} | [
"public",
"Color",
"toAWTColor",
"(",
"TextColor",
"color",
",",
"boolean",
"isForeground",
",",
"boolean",
"inBoldContext",
")",
"{",
"if",
"(",
"color",
"instanceof",
"TextColor",
".",
"ANSI",
")",
"{",
"return",
"colorPalette",
".",
"get",
"(",
"(",
"Text... | Given a TextColor and a hint as to if the color is to be used as foreground or not and if we currently have
bold text enabled or not, it returns the closest AWT color that matches this.
@param color What text color to convert
@param isForeground Is the color intended to be used as foreground color
@param inBoldContext Is the color intended to be used for on a character this is bold
@return The AWT color that represents this text color | [
"Given",
"a",
"TextColor",
"and",
"a",
"hint",
"as",
"to",
"if",
"the",
"color",
"is",
"to",
"be",
"used",
"as",
"foreground",
"or",
"not",
"and",
"if",
"we",
"currently",
"have",
"bold",
"text",
"enabled",
"or",
"not",
"it",
"returns",
"the",
"closest... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/swing/TerminalEmulatorColorConfiguration.java#L66-L71 |
29,311 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/terminal/swing/AWTTerminalFontConfiguration.java | AWTTerminalFontConfiguration.getFontSize | private static int getFontSize() {
if (Toolkit.getDefaultToolkit().getScreenResolution() >= 110) {
// Rely on DPI if it is a high value.
return Toolkit.getDefaultToolkit().getScreenResolution() / 7 + 1;
} else {
// Otherwise try to guess it from the monitor size:
// If the width is wider than Full HD (1080p, or 1920x1080), then assume it's high-DPI.
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (ge.getMaximumWindowBounds().getWidth() > 4096) {
return 56;
} else if (ge.getMaximumWindowBounds().getWidth() > 2048) {
return 28;
} else {
return 14;
}
}
} | java | private static int getFontSize() {
if (Toolkit.getDefaultToolkit().getScreenResolution() >= 110) {
// Rely on DPI if it is a high value.
return Toolkit.getDefaultToolkit().getScreenResolution() / 7 + 1;
} else {
// Otherwise try to guess it from the monitor size:
// If the width is wider than Full HD (1080p, or 1920x1080), then assume it's high-DPI.
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (ge.getMaximumWindowBounds().getWidth() > 4096) {
return 56;
} else if (ge.getMaximumWindowBounds().getWidth() > 2048) {
return 28;
} else {
return 14;
}
}
} | [
"private",
"static",
"int",
"getFontSize",
"(",
")",
"{",
"if",
"(",
"Toolkit",
".",
"getDefaultToolkit",
"(",
")",
".",
"getScreenResolution",
"(",
")",
">=",
"110",
")",
"{",
"// Rely on DPI if it is a high value.",
"return",
"Toolkit",
".",
"getDefaultToolkit",... | Here we check the screen resolution on the primary monitor and make a guess at if it's high-DPI or not | [
"Here",
"we",
"check",
"the",
"screen",
"resolution",
"on",
"the",
"primary",
"monitor",
"and",
"make",
"a",
"guess",
"at",
"if",
"it",
"s",
"high",
"-",
"DPI",
"or",
"not"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/swing/AWTTerminalFontConfiguration.java#L111-L127 |
29,312 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/terminal/swing/AWTTerminalFontConfiguration.java | AWTTerminalFontConfiguration.selectDefaultFont | protected static Font[] selectDefaultFont() {
String osName = System.getProperty("os.name", "").toLowerCase();
if(osName.contains("win")) {
List<Font> windowsFonts = getDefaultWindowsFonts();
return windowsFonts.toArray(new Font[windowsFonts.size()]);
}
else if(osName.contains("linux")) {
List<Font> linuxFonts = getDefaultLinuxFonts();
return linuxFonts.toArray(new Font[linuxFonts.size()]);
}
else {
List<Font> defaultFonts = getDefaultFonts();
return defaultFonts.toArray(new Font[defaultFonts.size()]);
}
} | java | protected static Font[] selectDefaultFont() {
String osName = System.getProperty("os.name", "").toLowerCase();
if(osName.contains("win")) {
List<Font> windowsFonts = getDefaultWindowsFonts();
return windowsFonts.toArray(new Font[windowsFonts.size()]);
}
else if(osName.contains("linux")) {
List<Font> linuxFonts = getDefaultLinuxFonts();
return linuxFonts.toArray(new Font[linuxFonts.size()]);
}
else {
List<Font> defaultFonts = getDefaultFonts();
return defaultFonts.toArray(new Font[defaultFonts.size()]);
}
} | [
"protected",
"static",
"Font",
"[",
"]",
"selectDefaultFont",
"(",
")",
"{",
"String",
"osName",
"=",
"System",
".",
"getProperty",
"(",
"\"os.name\"",
",",
"\"\"",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"osName",
".",
"contains",
"(",
"\"win... | Returns the default font to use depending on the platform
@return Default font to use, system-dependent | [
"Returns",
"the",
"default",
"font",
"to",
"use",
"depending",
"on",
"the",
"platform"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/swing/AWTTerminalFontConfiguration.java#L133-L147 |
29,313 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/terminal/swing/AWTTerminalFontConfiguration.java | AWTTerminalFontConfiguration.filterMonospaced | public static Font[] filterMonospaced(Font... fonts) {
List<Font> result = new ArrayList<Font>(fonts.length);
for(Font font: fonts) {
if (isFontMonospaced(font)) {
result.add(font);
}
}
return result.toArray(new Font[result.size()]);
} | java | public static Font[] filterMonospaced(Font... fonts) {
List<Font> result = new ArrayList<Font>(fonts.length);
for(Font font: fonts) {
if (isFontMonospaced(font)) {
result.add(font);
}
}
return result.toArray(new Font[result.size()]);
} | [
"public",
"static",
"Font",
"[",
"]",
"filterMonospaced",
"(",
"Font",
"...",
"fonts",
")",
"{",
"List",
"<",
"Font",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"Font",
">",
"(",
"fonts",
".",
"length",
")",
";",
"for",
"(",
"Font",
"font",
":",
... | Given an array of fonts, returns another array with only the ones that are monospaced. The fonts in the result
will have the same order as in which they came in. A font is considered monospaced if the width of 'i' and 'W' is
the same.
@param fonts Fonts to filter monospaced fonts from
@return Array with the fonts from the input parameter that were monospaced | [
"Given",
"an",
"array",
"of",
"fonts",
"returns",
"another",
"array",
"with",
"only",
"the",
"ones",
"that",
"are",
"monospaced",
".",
"The",
"fonts",
"in",
"the",
"result",
"will",
"have",
"the",
"same",
"order",
"as",
"in",
"which",
"they",
"came",
"in... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/swing/AWTTerminalFontConfiguration.java#L164-L172 |
29,314 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/dialogs/TextInputDialogBuilder.java | TextInputDialogBuilder.setValidationPattern | public TextInputDialogBuilder setValidationPattern(final Pattern pattern, final String errorMessage) {
return setValidator(new TextInputDialogResultValidator() {
@Override
public String validate(String content) {
Matcher matcher = pattern.matcher(content);
if(!matcher.matches()) {
if(errorMessage == null) {
return "Invalid input";
}
return errorMessage;
}
return null;
}
});
} | java | public TextInputDialogBuilder setValidationPattern(final Pattern pattern, final String errorMessage) {
return setValidator(new TextInputDialogResultValidator() {
@Override
public String validate(String content) {
Matcher matcher = pattern.matcher(content);
if(!matcher.matches()) {
if(errorMessage == null) {
return "Invalid input";
}
return errorMessage;
}
return null;
}
});
} | [
"public",
"TextInputDialogBuilder",
"setValidationPattern",
"(",
"final",
"Pattern",
"pattern",
",",
"final",
"String",
"errorMessage",
")",
"{",
"return",
"setValidator",
"(",
"new",
"TextInputDialogResultValidator",
"(",
")",
"{",
"@",
"Override",
"public",
"String"... | Helper method that assigned a validator to the text box the dialog will have which matches the pattern supplied
@param pattern Pattern to validate the text box
@param errorMessage Error message to show when the pattern doesn't match
@return Itself | [
"Helper",
"method",
"that",
"assigned",
"a",
"validator",
"to",
"the",
"text",
"box",
"the",
"dialog",
"will",
"have",
"which",
"matches",
"the",
"pattern",
"supplied"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/dialogs/TextInputDialogBuilder.java#L127-L141 |
29,315 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/bundle/BundleLocator.java | BundleLocator.getBundleKeyValue | protected String getBundleKeyValue(Locale locale, String key, Object... parameters) {
String value = null;
try {
value = getBundle(locale).getString(key);
} catch (Exception ignore) {
}
return value != null ? MessageFormat.format(value, parameters) : null;
} | java | protected String getBundleKeyValue(Locale locale, String key, Object... parameters) {
String value = null;
try {
value = getBundle(locale).getString(key);
} catch (Exception ignore) {
}
return value != null ? MessageFormat.format(value, parameters) : null;
} | [
"protected",
"String",
"getBundleKeyValue",
"(",
"Locale",
"locale",
",",
"String",
"key",
",",
"Object",
"...",
"parameters",
")",
"{",
"String",
"value",
"=",
"null",
";",
"try",
"{",
"value",
"=",
"getBundle",
"(",
"locale",
")",
".",
"getString",
"(",
... | Method that centralizes the way to get the value associated to a bundle key.
@param locale the locale.
@param key the key searched for.
@param parameters the parameters to apply to the value associated to the key.
@return the formatted value associated to the given key. Empty string if no value exists for
the given key. | [
"Method",
"that",
"centralizes",
"the",
"way",
"to",
"get",
"the",
"value",
"associated",
"to",
"a",
"bundle",
"key",
"."
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/bundle/BundleLocator.java#L56-L63 |
29,316 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/AnimatedLabel.java | AnimatedLabel.createClassicSpinningLine | public static AnimatedLabel createClassicSpinningLine(int speed) {
AnimatedLabel animatedLabel = new AnimatedLabel("-");
animatedLabel.addFrame("\\");
animatedLabel.addFrame("|");
animatedLabel.addFrame("/");
animatedLabel.startAnimation(speed);
return animatedLabel;
} | java | public static AnimatedLabel createClassicSpinningLine(int speed) {
AnimatedLabel animatedLabel = new AnimatedLabel("-");
animatedLabel.addFrame("\\");
animatedLabel.addFrame("|");
animatedLabel.addFrame("/");
animatedLabel.startAnimation(speed);
return animatedLabel;
} | [
"public",
"static",
"AnimatedLabel",
"createClassicSpinningLine",
"(",
"int",
"speed",
")",
"{",
"AnimatedLabel",
"animatedLabel",
"=",
"new",
"AnimatedLabel",
"(",
"\"-\"",
")",
";",
"animatedLabel",
".",
"addFrame",
"(",
"\"\\\\\"",
")",
";",
"animatedLabel",
".... | Creates a classic spinning bar which can be used to signal to the user that an operation in is process.
@param speed Delay in between each frame
@return {@code AnimatedLabel} instance which is setup to show a spinning bar | [
"Creates",
"a",
"classic",
"spinning",
"bar",
"which",
"can",
"be",
"used",
"to",
"signal",
"to",
"the",
"user",
"that",
"an",
"operation",
"in",
"is",
"process",
"."
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/AnimatedLabel.java#L48-L55 |
29,317 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/AnimatedLabel.java | AnimatedLabel.addFrame | public synchronized AnimatedLabel addFrame(String text) {
String[] lines = splitIntoMultipleLines(text);
frames.add(lines);
ensurePreferredSize(lines);
return this;
} | java | public synchronized AnimatedLabel addFrame(String text) {
String[] lines = splitIntoMultipleLines(text);
frames.add(lines);
ensurePreferredSize(lines);
return this;
} | [
"public",
"synchronized",
"AnimatedLabel",
"addFrame",
"(",
"String",
"text",
")",
"{",
"String",
"[",
"]",
"lines",
"=",
"splitIntoMultipleLines",
"(",
"text",
")",
";",
"frames",
".",
"add",
"(",
"lines",
")",
";",
"ensurePreferredSize",
"(",
"lines",
")",... | Adds one more frame at the end of the list of frames
@param text Text to use for the label at this frame
@return Itself | [
"Adds",
"one",
"more",
"frame",
"at",
"the",
"end",
"of",
"the",
"list",
"of",
"frames"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/AnimatedLabel.java#L88-L93 |
29,318 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/AnimatedLabel.java | AnimatedLabel.nextFrame | public synchronized void nextFrame() {
currentFrame++;
if(currentFrame >= frames.size()) {
currentFrame = 0;
}
super.setLines(frames.get(currentFrame));
invalidate();
} | java | public synchronized void nextFrame() {
currentFrame++;
if(currentFrame >= frames.size()) {
currentFrame = 0;
}
super.setLines(frames.get(currentFrame));
invalidate();
} | [
"public",
"synchronized",
"void",
"nextFrame",
"(",
")",
"{",
"currentFrame",
"++",
";",
"if",
"(",
"currentFrame",
">=",
"frames",
".",
"size",
"(",
")",
")",
"{",
"currentFrame",
"=",
"0",
";",
"}",
"super",
".",
"setLines",
"(",
"frames",
".",
"get"... | Advances the animated label to the next frame. You normally don't need to call this manually as it will be done
by the animation thread. | [
"Advances",
"the",
"animated",
"label",
"to",
"the",
"next",
"frame",
".",
"You",
"normally",
"don",
"t",
"need",
"to",
"call",
"this",
"manually",
"as",
"it",
"will",
"be",
"done",
"by",
"the",
"animation",
"thread",
"."
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/AnimatedLabel.java#L103-L110 |
29,319 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/screen/VirtualScreen.java | VirtualScreen.setMinimumSize | public void setMinimumSize(TerminalSize minimumSize) {
this.minimumSize = minimumSize;
TerminalSize virtualSize = minimumSize.max(realScreen.getTerminalSize());
if(!minimumSize.equals(virtualSize)) {
addResizeRequest(virtualSize);
super.doResizeIfNecessary();
}
calculateViewport(realScreen.getTerminalSize());
} | java | public void setMinimumSize(TerminalSize minimumSize) {
this.minimumSize = minimumSize;
TerminalSize virtualSize = minimumSize.max(realScreen.getTerminalSize());
if(!minimumSize.equals(virtualSize)) {
addResizeRequest(virtualSize);
super.doResizeIfNecessary();
}
calculateViewport(realScreen.getTerminalSize());
} | [
"public",
"void",
"setMinimumSize",
"(",
"TerminalSize",
"minimumSize",
")",
"{",
"this",
".",
"minimumSize",
"=",
"minimumSize",
";",
"TerminalSize",
"virtualSize",
"=",
"minimumSize",
".",
"max",
"(",
"realScreen",
".",
"getTerminalSize",
"(",
")",
")",
";",
... | Sets the minimum size we want the virtual screen to have. If the user resizes the real terminal to something
smaller than this, the virtual screen will refuse to make it smaller and add scrollbars to the view.
@param minimumSize Minimum size we want the screen to have | [
"Sets",
"the",
"minimum",
"size",
"we",
"want",
"the",
"virtual",
"screen",
"to",
"have",
".",
"If",
"the",
"user",
"resizes",
"the",
"real",
"terminal",
"to",
"something",
"smaller",
"than",
"this",
"the",
"virtual",
"screen",
"will",
"refuse",
"to",
"mak... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/screen/VirtualScreen.java#L67-L75 |
29,320 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/TerminalSize.java | TerminalSize.withColumns | public TerminalSize withColumns(int columns) {
if(this.columns == columns) {
return this;
}
if(columns == 0 && this.rows == 0) {
return ZERO;
}
return new TerminalSize(columns, this.rows);
} | java | public TerminalSize withColumns(int columns) {
if(this.columns == columns) {
return this;
}
if(columns == 0 && this.rows == 0) {
return ZERO;
}
return new TerminalSize(columns, this.rows);
} | [
"public",
"TerminalSize",
"withColumns",
"(",
"int",
"columns",
")",
"{",
"if",
"(",
"this",
".",
"columns",
"==",
"columns",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"columns",
"==",
"0",
"&&",
"this",
".",
"rows",
"==",
"0",
")",
"{",
"re... | Creates a new size based on this size, but with a different width
@param columns Width of the new size, in columns
@return New size based on this one, but with a new width | [
"Creates",
"a",
"new",
"size",
"based",
"on",
"this",
"size",
"but",
"with",
"a",
"different",
"width"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TerminalSize.java#L62-L70 |
29,321 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/TerminalSize.java | TerminalSize.withRows | public TerminalSize withRows(int rows) {
if(this.rows == rows) {
return this;
}
if(rows == 0 && this.columns == 0) {
return ZERO;
}
return new TerminalSize(this.columns, rows);
} | java | public TerminalSize withRows(int rows) {
if(this.rows == rows) {
return this;
}
if(rows == 0 && this.columns == 0) {
return ZERO;
}
return new TerminalSize(this.columns, rows);
} | [
"public",
"TerminalSize",
"withRows",
"(",
"int",
"rows",
")",
"{",
"if",
"(",
"this",
".",
"rows",
"==",
"rows",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"rows",
"==",
"0",
"&&",
"this",
".",
"columns",
"==",
"0",
")",
"{",
"return",
"ZE... | Creates a new size based on this size, but with a different height
@param rows Height of the new size, in rows
@return New size based on this one, but with a new height | [
"Creates",
"a",
"new",
"size",
"based",
"on",
"this",
"size",
"but",
"with",
"a",
"different",
"height"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TerminalSize.java#L85-L93 |
29,322 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/TerminalSize.java | TerminalSize.max | public TerminalSize max(TerminalSize other) {
return withColumns(Math.max(columns, other.columns))
.withRows(Math.max(rows, other.rows));
} | java | public TerminalSize max(TerminalSize other) {
return withColumns(Math.max(columns, other.columns))
.withRows(Math.max(rows, other.rows));
} | [
"public",
"TerminalSize",
"max",
"(",
"TerminalSize",
"other",
")",
"{",
"return",
"withColumns",
"(",
"Math",
".",
"max",
"(",
"columns",
",",
"other",
".",
"columns",
")",
")",
".",
"withRows",
"(",
"Math",
".",
"max",
"(",
"rows",
",",
"other",
".",... | Takes a different TerminalSize and returns a new TerminalSize that has the largest dimensions of the two,
measured separately. So calling 3x5 on a 5x3 will return 5x5.
@param other Other TerminalSize to compare with
@return TerminalSize that combines the maximum width between the two and the maximum height | [
"Takes",
"a",
"different",
"TerminalSize",
"and",
"returns",
"a",
"new",
"TerminalSize",
"that",
"has",
"the",
"largest",
"dimensions",
"of",
"the",
"two",
"measured",
"separately",
".",
"So",
"calling",
"3x5",
"on",
"a",
"5x3",
"will",
"return",
"5x5",
"."
... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TerminalSize.java#L152-L155 |
29,323 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/TerminalSize.java | TerminalSize.min | public TerminalSize min(TerminalSize other) {
return withColumns(Math.min(columns, other.columns))
.withRows(Math.min(rows, other.rows));
} | java | public TerminalSize min(TerminalSize other) {
return withColumns(Math.min(columns, other.columns))
.withRows(Math.min(rows, other.rows));
} | [
"public",
"TerminalSize",
"min",
"(",
"TerminalSize",
"other",
")",
"{",
"return",
"withColumns",
"(",
"Math",
".",
"min",
"(",
"columns",
",",
"other",
".",
"columns",
")",
")",
".",
"withRows",
"(",
"Math",
".",
"min",
"(",
"rows",
",",
"other",
".",... | Takes a different TerminalSize and returns a new TerminalSize that has the smallest dimensions of the two,
measured separately. So calling 3x5 on a 5x3 will return 3x3.
@param other Other TerminalSize to compare with
@return TerminalSize that combines the minimum width between the two and the minimum height | [
"Takes",
"a",
"different",
"TerminalSize",
"and",
"returns",
"a",
"new",
"TerminalSize",
"that",
"has",
"the",
"smallest",
"dimensions",
"of",
"the",
"two",
"measured",
"separately",
".",
"So",
"calling",
"3x5",
"on",
"a",
"5x3",
"will",
"return",
"3x3",
"."... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TerminalSize.java#L163-L166 |
29,324 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/RadioBoxList.java | RadioBoxList.isChecked | public synchronized Boolean isChecked(V object) {
if(object == null)
return null;
if(indexOf(object) == -1)
return null;
return checkedIndex == indexOf(object);
} | java | public synchronized Boolean isChecked(V object) {
if(object == null)
return null;
if(indexOf(object) == -1)
return null;
return checkedIndex == indexOf(object);
} | [
"public",
"synchronized",
"Boolean",
"isChecked",
"(",
"V",
"object",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"return",
"null",
";",
"if",
"(",
"indexOf",
"(",
"object",
")",
"==",
"-",
"1",
")",
"return",
"null",
";",
"return",
"checkedIndex... | This method will see if an object is the currently selected item in this RadioCheckBoxList
@param object Object to test if it's the selected one
@return {@code true} if the supplied object is what's currently selected in the list box,
{@code false} otherwise. Returns null if the supplied object is not an item in the list box. | [
"This",
"method",
"will",
"see",
"if",
"an",
"object",
"is",
"the",
"currently",
"selected",
"item",
"in",
"this",
"RadioCheckBoxList"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/RadioBoxList.java#L114-L122 |
29,325 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/terminal/virtual/DefaultVirtualTerminal.java | DefaultVirtualTerminal.moveCursorToNextLine | private void moveCursorToNextLine() {
cursorPosition = cursorPosition.withColumn(0).withRelativeRow(1);
if(cursorPosition.getRow() >= currentTextBuffer.getLineCount()) {
currentTextBuffer.newLine();
}
trimBufferBacklog();
correctCursor();
} | java | private void moveCursorToNextLine() {
cursorPosition = cursorPosition.withColumn(0).withRelativeRow(1);
if(cursorPosition.getRow() >= currentTextBuffer.getLineCount()) {
currentTextBuffer.newLine();
}
trimBufferBacklog();
correctCursor();
} | [
"private",
"void",
"moveCursorToNextLine",
"(",
")",
"{",
"cursorPosition",
"=",
"cursorPosition",
".",
"withColumn",
"(",
"0",
")",
".",
"withRelativeRow",
"(",
"1",
")",
";",
"if",
"(",
"cursorPosition",
".",
"getRow",
"(",
")",
">=",
"currentTextBuffer",
... | Moves the text cursor to the first column of the next line and trims the backlog of necessary | [
"Moves",
"the",
"text",
"cursor",
"to",
"the",
"first",
"column",
"of",
"the",
"next",
"line",
"and",
"trims",
"the",
"backlog",
"of",
"necessary"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/virtual/DefaultVirtualTerminal.java#L395-L402 |
29,326 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/screen/TerminalScreen.java | TerminalScreen.scrollLines | @Override
public void scrollLines(int firstLine, int lastLine, int distance) {
// just ignore certain kinds of garbage:
if (distance == 0 || firstLine > lastLine) { return; }
super.scrollLines(firstLine, lastLine, distance);
// Save scroll hint for next refresh:
ScrollHint newHint = new ScrollHint(firstLine,lastLine,distance);
if (scrollHint == null) {
// no scroll hint yet: use the new one:
scrollHint = newHint;
} else //noinspection StatementWithEmptyBody
if (scrollHint == ScrollHint.INVALID) {
// scroll ranges already inconsistent since latest refresh!
// leave at INVALID
} else if (scrollHint.matches(newHint)) {
// same range: just accumulate distance:
scrollHint.distance += newHint.distance;
} else {
// different scroll range: no scroll-optimization for next refresh
this.scrollHint = ScrollHint.INVALID;
}
} | java | @Override
public void scrollLines(int firstLine, int lastLine, int distance) {
// just ignore certain kinds of garbage:
if (distance == 0 || firstLine > lastLine) { return; }
super.scrollLines(firstLine, lastLine, distance);
// Save scroll hint for next refresh:
ScrollHint newHint = new ScrollHint(firstLine,lastLine,distance);
if (scrollHint == null) {
// no scroll hint yet: use the new one:
scrollHint = newHint;
} else //noinspection StatementWithEmptyBody
if (scrollHint == ScrollHint.INVALID) {
// scroll ranges already inconsistent since latest refresh!
// leave at INVALID
} else if (scrollHint.matches(newHint)) {
// same range: just accumulate distance:
scrollHint.distance += newHint.distance;
} else {
// different scroll range: no scroll-optimization for next refresh
this.scrollHint = ScrollHint.INVALID;
}
} | [
"@",
"Override",
"public",
"void",
"scrollLines",
"(",
"int",
"firstLine",
",",
"int",
"lastLine",
",",
"int",
"distance",
")",
"{",
"// just ignore certain kinds of garbage:",
"if",
"(",
"distance",
"==",
"0",
"||",
"firstLine",
">",
"lastLine",
")",
"{",
"re... | Perform the scrolling and save scroll-range and distance in order
to be able to optimize Terminal-update later. | [
"Perform",
"the",
"scrolling",
"and",
"save",
"scroll",
"-",
"range",
"and",
"distance",
"in",
"order",
"to",
"be",
"able",
"to",
"optimize",
"Terminal",
"-",
"update",
"later",
"."
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/screen/TerminalScreen.java#L353-L376 |
29,327 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/dialogs/AbstractDialogBuilder.java | AbstractDialogBuilder.setTitle | public B setTitle(String title) {
if(title == null) {
title = "";
}
this.title = title;
return self();
} | java | public B setTitle(String title) {
if(title == null) {
title = "";
}
this.title = title;
return self();
} | [
"public",
"B",
"setTitle",
"(",
"String",
"title",
")",
"{",
"if",
"(",
"title",
"==",
"null",
")",
"{",
"title",
"=",
"\"\"",
";",
"}",
"this",
".",
"title",
"=",
"title",
";",
"return",
"self",
"(",
")",
";",
"}"
] | Changes the title of the dialog
@param title New title
@return Itself | [
"Changes",
"the",
"title",
"of",
"the",
"dialog"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/dialogs/AbstractDialogBuilder.java#L53-L59 |
29,328 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/dialogs/AbstractDialogBuilder.java | AbstractDialogBuilder.build | public final T build() {
T dialog = buildDialog();
if(!extraWindowHints.isEmpty()) {
Set<Window.Hint> combinedHints = new HashSet<Window.Hint>(dialog.getHints());
combinedHints.addAll(extraWindowHints);
dialog.setHints(combinedHints);
}
return dialog;
} | java | public final T build() {
T dialog = buildDialog();
if(!extraWindowHints.isEmpty()) {
Set<Window.Hint> combinedHints = new HashSet<Window.Hint>(dialog.getHints());
combinedHints.addAll(extraWindowHints);
dialog.setHints(combinedHints);
}
return dialog;
} | [
"public",
"final",
"T",
"build",
"(",
")",
"{",
"T",
"dialog",
"=",
"buildDialog",
"(",
")",
";",
"if",
"(",
"!",
"extraWindowHints",
".",
"isEmpty",
"(",
")",
")",
"{",
"Set",
"<",
"Window",
".",
"Hint",
">",
"combinedHints",
"=",
"new",
"HashSet",
... | Builds a new dialog following the specifications of this builder
@return New dialog built following the specifications of this builder | [
"Builds",
"a",
"new",
"dialog",
"following",
"the",
"specifications",
"of",
"this",
"builder"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/dialogs/AbstractDialogBuilder.java#L121-L129 |
29,329 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/AbstractListBox.java | AbstractListBox.addItem | public synchronized T addItem(V item) {
if(item == null) {
return self();
}
items.add(item);
if(selectedIndex == -1) {
selectedIndex = 0;
}
invalidate();
return self();
} | java | public synchronized T addItem(V item) {
if(item == null) {
return self();
}
items.add(item);
if(selectedIndex == -1) {
selectedIndex = 0;
}
invalidate();
return self();
} | [
"public",
"synchronized",
"T",
"addItem",
"(",
"V",
"item",
")",
"{",
"if",
"(",
"item",
"==",
"null",
")",
"{",
"return",
"self",
"(",
")",
";",
"}",
"items",
".",
"add",
"(",
"item",
")",
";",
"if",
"(",
"selectedIndex",
"==",
"-",
"1",
")",
... | Adds one more item to the list box, at the end.
@param item Item to add to the list box
@return Itself | [
"Adds",
"one",
"more",
"item",
"to",
"the",
"list",
"box",
"at",
"the",
"end",
"."
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/AbstractListBox.java#L179-L190 |
29,330 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/AbstractListBox.java | AbstractListBox.removeItem | public synchronized V removeItem(int index) {
V existing = items.remove(index);
if(index < selectedIndex) {
selectedIndex--;
}
while(selectedIndex >= items.size()) {
selectedIndex--;
}
invalidate();
return existing;
} | java | public synchronized V removeItem(int index) {
V existing = items.remove(index);
if(index < selectedIndex) {
selectedIndex--;
}
while(selectedIndex >= items.size()) {
selectedIndex--;
}
invalidate();
return existing;
} | [
"public",
"synchronized",
"V",
"removeItem",
"(",
"int",
"index",
")",
"{",
"V",
"existing",
"=",
"items",
".",
"remove",
"(",
"index",
")",
";",
"if",
"(",
"index",
"<",
"selectedIndex",
")",
"{",
"selectedIndex",
"--",
";",
"}",
"while",
"(",
"select... | Removes an item from the list box by its index. The current selection in the list box will be adjusted
accordingly.
@param index Index of the item to remove
@return The item that was removed
@throws IndexOutOfBoundsException if the index is out of bounds in regards to the list of items | [
"Removes",
"an",
"item",
"from",
"the",
"list",
"box",
"by",
"its",
"index",
".",
"The",
"current",
"selection",
"in",
"the",
"list",
"box",
"will",
"be",
"adjusted",
"accordingly",
"."
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/AbstractListBox.java#L199-L209 |
29,331 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/terminal/IOSafeTerminalAdapter.java | IOSafeTerminalAdapter.createRuntimeExceptionConvertingAdapter | public static IOSafeTerminal createRuntimeExceptionConvertingAdapter(Terminal terminal) {
if (terminal instanceof ExtendedTerminal) { // also handle Runtime-type:
return createRuntimeExceptionConvertingAdapter((ExtendedTerminal)terminal);
} else {
return new IOSafeTerminalAdapter(terminal, new ConvertToRuntimeException());
}
} | java | public static IOSafeTerminal createRuntimeExceptionConvertingAdapter(Terminal terminal) {
if (terminal instanceof ExtendedTerminal) { // also handle Runtime-type:
return createRuntimeExceptionConvertingAdapter((ExtendedTerminal)terminal);
} else {
return new IOSafeTerminalAdapter(terminal, new ConvertToRuntimeException());
}
} | [
"public",
"static",
"IOSafeTerminal",
"createRuntimeExceptionConvertingAdapter",
"(",
"Terminal",
"terminal",
")",
"{",
"if",
"(",
"terminal",
"instanceof",
"ExtendedTerminal",
")",
"{",
"// also handle Runtime-type:",
"return",
"createRuntimeExceptionConvertingAdapter",
"(",
... | Creates a wrapper around a Terminal that exposes it as a IOSafeTerminal. If any IOExceptions occur, they will be
wrapped by a RuntimeException and re-thrown.
@param terminal Terminal to wrap
@return IOSafeTerminal wrapping the supplied terminal | [
"Creates",
"a",
"wrapper",
"around",
"a",
"Terminal",
"that",
"exposes",
"it",
"as",
"a",
"IOSafeTerminal",
".",
"If",
"any",
"IOExceptions",
"occur",
"they",
"will",
"be",
"wrapped",
"by",
"a",
"RuntimeException",
"and",
"re",
"-",
"thrown",
"."
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/IOSafeTerminalAdapter.java#L59-L65 |
29,332 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/terminal/IOSafeTerminalAdapter.java | IOSafeTerminalAdapter.createDoNothingOnExceptionAdapter | public static IOSafeTerminal createDoNothingOnExceptionAdapter(Terminal terminal) {
if (terminal instanceof ExtendedTerminal) { // also handle Runtime-type:
return createDoNothingOnExceptionAdapter((ExtendedTerminal)terminal);
} else {
return new IOSafeTerminalAdapter(terminal, new DoNothingAndOrReturnNull());
}
} | java | public static IOSafeTerminal createDoNothingOnExceptionAdapter(Terminal terminal) {
if (terminal instanceof ExtendedTerminal) { // also handle Runtime-type:
return createDoNothingOnExceptionAdapter((ExtendedTerminal)terminal);
} else {
return new IOSafeTerminalAdapter(terminal, new DoNothingAndOrReturnNull());
}
} | [
"public",
"static",
"IOSafeTerminal",
"createDoNothingOnExceptionAdapter",
"(",
"Terminal",
"terminal",
")",
"{",
"if",
"(",
"terminal",
"instanceof",
"ExtendedTerminal",
")",
"{",
"// also handle Runtime-type:",
"return",
"createDoNothingOnExceptionAdapter",
"(",
"(",
"Ext... | Creates a wrapper around a Terminal that exposes it as a IOSafeTerminal. If any IOExceptions occur, they will be
silently ignored and for those method with a non-void return type, null will be returned.
@param terminal Terminal to wrap
@return IOSafeTerminal wrapping the supplied terminal | [
"Creates",
"a",
"wrapper",
"around",
"a",
"Terminal",
"that",
"exposes",
"it",
"as",
"a",
"IOSafeTerminal",
".",
"If",
"any",
"IOExceptions",
"occur",
"they",
"will",
"be",
"silently",
"ignored",
"and",
"for",
"those",
"method",
"with",
"a",
"non",
"-",
"v... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/IOSafeTerminalAdapter.java#L83-L89 |
29,333 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/Button.java | Button.setLabel | public final synchronized void setLabel(String label) {
if(label == null) {
throw new IllegalArgumentException("null label to a button is not allowed");
}
if(label.isEmpty()) {
label = " ";
}
this.label = label;
invalidate();
} | java | public final synchronized void setLabel(String label) {
if(label == null) {
throw new IllegalArgumentException("null label to a button is not allowed");
}
if(label.isEmpty()) {
label = " ";
}
this.label = label;
invalidate();
} | [
"public",
"final",
"synchronized",
"void",
"setLabel",
"(",
"String",
"label",
")",
"{",
"if",
"(",
"label",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"null label to a button is not allowed\"",
")",
";",
"}",
"if",
"(",
"label",
... | Updates the label on the button to the specified string
@param label New label to use on the button | [
"Updates",
"the",
"label",
"on",
"the",
"button",
"to",
"the",
"specified",
"string"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/Button.java#L109-L118 |
29,334 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/graphics/AbstractTheme.java | AbstractTheme.findRedundantDeclarations | public List<String> findRedundantDeclarations() {
List<String> result = new ArrayList<String>();
for(ThemeTreeNode node: rootNode.childMap.values()) {
findRedundantDeclarations(result, node);
}
Collections.sort(result);
return result;
} | java | public List<String> findRedundantDeclarations() {
List<String> result = new ArrayList<String>();
for(ThemeTreeNode node: rootNode.childMap.values()) {
findRedundantDeclarations(result, node);
}
Collections.sort(result);
return result;
} | [
"public",
"List",
"<",
"String",
">",
"findRedundantDeclarations",
"(",
")",
"{",
"List",
"<",
"String",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"ThemeTreeNode",
"node",
":",
"rootNode",
".",
"childMap",
"."... | Returns a list of redundant theme entries in this theme. A redundant entry means that it doesn't need to be
specified because there is a parent node in the hierarchy which has the same property so if the redundant entry
wasn't there, the parent node would be picked up and the end result would be the same.
@return List of redundant theme entries | [
"Returns",
"a",
"list",
"of",
"redundant",
"theme",
"entries",
"in",
"this",
"theme",
".",
"A",
"redundant",
"entry",
"means",
"that",
"it",
"doesn",
"t",
"need",
"to",
"be",
"specified",
"because",
"there",
"is",
"a",
"parent",
"node",
"in",
"the",
"hie... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/graphics/AbstractTheme.java#L156-L163 |
29,335 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/screen/ScreenBuffer.java | ScreenBuffer.copyFrom | public void copyFrom(TextImage source, int startRowIndex, int rows, int startColumnIndex, int columns, int destinationRowOffset, int destinationColumnOffset) {
source.copyTo(backend, startRowIndex, rows, startColumnIndex, columns, destinationRowOffset, destinationColumnOffset);
} | java | public void copyFrom(TextImage source, int startRowIndex, int rows, int startColumnIndex, int columns, int destinationRowOffset, int destinationColumnOffset) {
source.copyTo(backend, startRowIndex, rows, startColumnIndex, columns, destinationRowOffset, destinationColumnOffset);
} | [
"public",
"void",
"copyFrom",
"(",
"TextImage",
"source",
",",
"int",
"startRowIndex",
",",
"int",
"rows",
",",
"int",
"startColumnIndex",
",",
"int",
"columns",
",",
"int",
"destinationRowOffset",
",",
"int",
"destinationColumnOffset",
")",
"{",
"source",
".",
... | Copies the content from a TextImage into this buffer.
@param source Source to copy content from
@param startRowIndex Which row in the source image to start copying from
@param rows How many rows to copy
@param startColumnIndex Which column in the source image to start copying from
@param columns How many columns to copy
@param destinationRowOffset The row offset in this buffer of where to place the copied content
@param destinationColumnOffset The column offset in this buffer of where to place the copied content | [
"Copies",
"the",
"content",
"from",
"a",
"TextImage",
"into",
"this",
"buffer",
"."
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/screen/ScreenBuffer.java#L139-L141 |
29,336 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/TextCharacter.java | TextCharacter.withCharacter | @SuppressWarnings("SameParameterValue")
public TextCharacter withCharacter(char character) {
if(this.character == character) {
return this;
}
return new TextCharacter(character, foregroundColor, backgroundColor, modifiers);
} | java | @SuppressWarnings("SameParameterValue")
public TextCharacter withCharacter(char character) {
if(this.character == character) {
return this;
}
return new TextCharacter(character, foregroundColor, backgroundColor, modifiers);
} | [
"@",
"SuppressWarnings",
"(",
"\"SameParameterValue\"",
")",
"public",
"TextCharacter",
"withCharacter",
"(",
"char",
"character",
")",
"{",
"if",
"(",
"this",
".",
"character",
"==",
"character",
")",
"{",
"return",
"this",
";",
"}",
"return",
"new",
"TextCha... | Returns a new TextCharacter with the same colors and modifiers but a different underlying character
@param character Character the copy should have
@return Copy of this TextCharacter with different underlying character | [
"Returns",
"a",
"new",
"TextCharacter",
"with",
"the",
"same",
"colors",
"and",
"modifiers",
"but",
"a",
"different",
"underlying",
"character"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TextCharacter.java#L212-L218 |
29,337 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/TextCharacter.java | TextCharacter.withForegroundColor | public TextCharacter withForegroundColor(TextColor foregroundColor) {
if(this.foregroundColor == foregroundColor || this.foregroundColor.equals(foregroundColor)) {
return this;
}
return new TextCharacter(character, foregroundColor, backgroundColor, modifiers);
} | java | public TextCharacter withForegroundColor(TextColor foregroundColor) {
if(this.foregroundColor == foregroundColor || this.foregroundColor.equals(foregroundColor)) {
return this;
}
return new TextCharacter(character, foregroundColor, backgroundColor, modifiers);
} | [
"public",
"TextCharacter",
"withForegroundColor",
"(",
"TextColor",
"foregroundColor",
")",
"{",
"if",
"(",
"this",
".",
"foregroundColor",
"==",
"foregroundColor",
"||",
"this",
".",
"foregroundColor",
".",
"equals",
"(",
"foregroundColor",
")",
")",
"{",
"return... | Returns a copy of this TextCharacter with a specified foreground color
@param foregroundColor Foreground color the copy should have
@return Copy of the TextCharacter with a different foreground color | [
"Returns",
"a",
"copy",
"of",
"this",
"TextCharacter",
"with",
"a",
"specified",
"foreground",
"color"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TextCharacter.java#L225-L230 |
29,338 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/TextCharacter.java | TextCharacter.withBackgroundColor | public TextCharacter withBackgroundColor(TextColor backgroundColor) {
if(this.backgroundColor == backgroundColor || this.backgroundColor.equals(backgroundColor)) {
return this;
}
return new TextCharacter(character, foregroundColor, backgroundColor, modifiers);
} | java | public TextCharacter withBackgroundColor(TextColor backgroundColor) {
if(this.backgroundColor == backgroundColor || this.backgroundColor.equals(backgroundColor)) {
return this;
}
return new TextCharacter(character, foregroundColor, backgroundColor, modifiers);
} | [
"public",
"TextCharacter",
"withBackgroundColor",
"(",
"TextColor",
"backgroundColor",
")",
"{",
"if",
"(",
"this",
".",
"backgroundColor",
"==",
"backgroundColor",
"||",
"this",
".",
"backgroundColor",
".",
"equals",
"(",
"backgroundColor",
")",
")",
"{",
"return... | Returns a copy of this TextCharacter with a specified background color
@param backgroundColor Background color the copy should have
@return Copy of the TextCharacter with a different background color | [
"Returns",
"a",
"copy",
"of",
"this",
"TextCharacter",
"with",
"a",
"specified",
"background",
"color"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TextCharacter.java#L237-L242 |
29,339 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/TextCharacter.java | TextCharacter.withModifiers | public TextCharacter withModifiers(Collection<SGR> modifiers) {
EnumSet<SGR> newSet = EnumSet.copyOf(modifiers);
if(modifiers.equals(newSet)) {
return this;
}
return new TextCharacter(character, foregroundColor, backgroundColor, newSet);
} | java | public TextCharacter withModifiers(Collection<SGR> modifiers) {
EnumSet<SGR> newSet = EnumSet.copyOf(modifiers);
if(modifiers.equals(newSet)) {
return this;
}
return new TextCharacter(character, foregroundColor, backgroundColor, newSet);
} | [
"public",
"TextCharacter",
"withModifiers",
"(",
"Collection",
"<",
"SGR",
">",
"modifiers",
")",
"{",
"EnumSet",
"<",
"SGR",
">",
"newSet",
"=",
"EnumSet",
".",
"copyOf",
"(",
"modifiers",
")",
";",
"if",
"(",
"modifiers",
".",
"equals",
"(",
"newSet",
... | Returns a copy of this TextCharacter with specified list of SGR modifiers. None of the currently active SGR codes
will be carried over to the copy, only those in the passed in value.
@param modifiers SGR modifiers the copy should have
@return Copy of the TextCharacter with a different set of SGR modifiers | [
"Returns",
"a",
"copy",
"of",
"this",
"TextCharacter",
"with",
"specified",
"list",
"of",
"SGR",
"modifiers",
".",
"None",
"of",
"the",
"currently",
"active",
"SGR",
"codes",
"will",
"be",
"carried",
"over",
"to",
"the",
"copy",
"only",
"those",
"in",
"the... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TextCharacter.java#L250-L256 |
29,340 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/TextCharacter.java | TextCharacter.withModifier | public TextCharacter withModifier(SGR modifier) {
if(modifiers.contains(modifier)) {
return this;
}
EnumSet<SGR> newSet = EnumSet.copyOf(this.modifiers);
newSet.add(modifier);
return new TextCharacter(character, foregroundColor, backgroundColor, newSet);
} | java | public TextCharacter withModifier(SGR modifier) {
if(modifiers.contains(modifier)) {
return this;
}
EnumSet<SGR> newSet = EnumSet.copyOf(this.modifiers);
newSet.add(modifier);
return new TextCharacter(character, foregroundColor, backgroundColor, newSet);
} | [
"public",
"TextCharacter",
"withModifier",
"(",
"SGR",
"modifier",
")",
"{",
"if",
"(",
"modifiers",
".",
"contains",
"(",
"modifier",
")",
")",
"{",
"return",
"this",
";",
"}",
"EnumSet",
"<",
"SGR",
">",
"newSet",
"=",
"EnumSet",
".",
"copyOf",
"(",
... | Returns a copy of this TextCharacter with an additional SGR modifier. All of the currently active SGR codes
will be carried over to the copy, in addition to the one specified.
@param modifier SGR modifiers the copy should have in additional to all currently present
@return Copy of the TextCharacter with a new SGR modifier | [
"Returns",
"a",
"copy",
"of",
"this",
"TextCharacter",
"with",
"an",
"additional",
"SGR",
"modifier",
".",
"All",
"of",
"the",
"currently",
"active",
"SGR",
"codes",
"will",
"be",
"carried",
"over",
"to",
"the",
"copy",
"in",
"addition",
"to",
"the",
"one"... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TextCharacter.java#L264-L271 |
29,341 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/TextCharacter.java | TextCharacter.withoutModifier | public TextCharacter withoutModifier(SGR modifier) {
if(!modifiers.contains(modifier)) {
return this;
}
EnumSet<SGR> newSet = EnumSet.copyOf(this.modifiers);
newSet.remove(modifier);
return new TextCharacter(character, foregroundColor, backgroundColor, newSet);
} | java | public TextCharacter withoutModifier(SGR modifier) {
if(!modifiers.contains(modifier)) {
return this;
}
EnumSet<SGR> newSet = EnumSet.copyOf(this.modifiers);
newSet.remove(modifier);
return new TextCharacter(character, foregroundColor, backgroundColor, newSet);
} | [
"public",
"TextCharacter",
"withoutModifier",
"(",
"SGR",
"modifier",
")",
"{",
"if",
"(",
"!",
"modifiers",
".",
"contains",
"(",
"modifier",
")",
")",
"{",
"return",
"this",
";",
"}",
"EnumSet",
"<",
"SGR",
">",
"newSet",
"=",
"EnumSet",
".",
"copyOf",... | Returns a copy of this TextCharacter with an SGR modifier removed. All of the currently active SGR codes
will be carried over to the copy, except for the one specified. If the current TextCharacter doesn't have the
SGR specified, it will return itself.
@param modifier SGR modifiers the copy should not have
@return Copy of the TextCharacter without the SGR modifier | [
"Returns",
"a",
"copy",
"of",
"this",
"TextCharacter",
"with",
"an",
"SGR",
"modifier",
"removed",
".",
"All",
"of",
"the",
"currently",
"active",
"SGR",
"codes",
"will",
"be",
"carried",
"over",
"to",
"the",
"copy",
"except",
"for",
"the",
"one",
"specifi... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TextCharacter.java#L280-L287 |
29,342 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/terminal/DefaultTerminalFactory.java | DefaultTerminalFactory.createTerminalEmulator | public Terminal createTerminalEmulator() {
Window window;
if(!forceAWTOverSwing && hasSwing()) {
window = createSwingTerminal();
}
else {
window = createAWTTerminal();
}
if(autoOpenTerminalFrame) {
window.setVisible(true);
}
return (Terminal)window;
} | java | public Terminal createTerminalEmulator() {
Window window;
if(!forceAWTOverSwing && hasSwing()) {
window = createSwingTerminal();
}
else {
window = createAWTTerminal();
}
if(autoOpenTerminalFrame) {
window.setVisible(true);
}
return (Terminal)window;
} | [
"public",
"Terminal",
"createTerminalEmulator",
"(",
")",
"{",
"Window",
"window",
";",
"if",
"(",
"!",
"forceAWTOverSwing",
"&&",
"hasSwing",
"(",
")",
")",
"{",
"window",
"=",
"createSwingTerminal",
"(",
")",
";",
"}",
"else",
"{",
"window",
"=",
"create... | Creates a new terminal emulator window which will be either Swing-based or AWT-based depending on what is
available on the system
@return New terminal emulator exposed as a {@link Terminal} interface | [
"Creates",
"a",
"new",
"terminal",
"emulator",
"window",
"which",
"will",
"be",
"either",
"Swing",
"-",
"based",
"or",
"AWT",
"-",
"based",
"depending",
"on",
"what",
"is",
"available",
"on",
"the",
"system"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/DefaultTerminalFactory.java#L140-L153 |
29,343 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/terminal/DefaultTerminalFactory.java | DefaultTerminalFactory.createTelnetTerminal | public TelnetTerminal createTelnetTerminal() {
try {
System.err.print("Waiting for incoming telnet connection on port "+telnetPort+" ... ");
System.err.flush();
TelnetTerminalServer tts = new TelnetTerminalServer(telnetPort);
TelnetTerminal rawTerminal = tts.acceptConnection();
tts.close(); // Just for single-shot: free up the port!
System.err.println("Ok, got it!");
if(mouseCaptureMode != null) {
rawTerminal.setMouseCaptureMode(mouseCaptureMode);
}
if(inputTimeout >= 0) {
rawTerminal.getInputDecoder().setTimeoutUnits(inputTimeout);
}
return rawTerminal;
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
} | java | public TelnetTerminal createTelnetTerminal() {
try {
System.err.print("Waiting for incoming telnet connection on port "+telnetPort+" ... ");
System.err.flush();
TelnetTerminalServer tts = new TelnetTerminalServer(telnetPort);
TelnetTerminal rawTerminal = tts.acceptConnection();
tts.close(); // Just for single-shot: free up the port!
System.err.println("Ok, got it!");
if(mouseCaptureMode != null) {
rawTerminal.setMouseCaptureMode(mouseCaptureMode);
}
if(inputTimeout >= 0) {
rawTerminal.getInputDecoder().setTimeoutUnits(inputTimeout);
}
return rawTerminal;
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
} | [
"public",
"TelnetTerminal",
"createTelnetTerminal",
"(",
")",
"{",
"try",
"{",
"System",
".",
"err",
".",
"print",
"(",
"\"Waiting for incoming telnet connection on port \"",
"+",
"telnetPort",
"+",
"\" ... \"",
")",
";",
"System",
".",
"err",
".",
"flush",
"(",
... | Creates a new TelnetTerminal
Note: a telnetPort should have been set with setTelnetPort(),
otherwise creation of TelnetTerminal will most likely fail.
@return New terminal emulator exposed as a {@link Terminal} interface | [
"Creates",
"a",
"new",
"TelnetTerminal"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/DefaultTerminalFactory.java#L183-L204 |
29,344 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/table/Table.java | Table.setTableModel | public synchronized Table<V> setTableModel(TableModel<V> tableModel) {
if(tableModel == null) {
throw new IllegalArgumentException("Cannot assign a null TableModel");
}
this.tableModel.removeListener(tableModelListener);
this.tableModel = tableModel;
this.tableModel.addListener(tableModelListener);
invalidate();
return this;
} | java | public synchronized Table<V> setTableModel(TableModel<V> tableModel) {
if(tableModel == null) {
throw new IllegalArgumentException("Cannot assign a null TableModel");
}
this.tableModel.removeListener(tableModelListener);
this.tableModel = tableModel;
this.tableModel.addListener(tableModelListener);
invalidate();
return this;
} | [
"public",
"synchronized",
"Table",
"<",
"V",
">",
"setTableModel",
"(",
"TableModel",
"<",
"V",
">",
"tableModel",
")",
"{",
"if",
"(",
"tableModel",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot assign a null TableModel\"",
... | Updates the table with a new table model, effectively replacing the content of the table completely
@param tableModel New table model
@return Itself | [
"Updates",
"the",
"table",
"with",
"a",
"new",
"table",
"model",
"effectively",
"replacing",
"the",
"content",
"of",
"the",
"table",
"completely"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/table/Table.java#L108-L117 |
29,345 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/terminal/ansi/TelnetTerminalServer.java | TelnetTerminalServer.acceptConnection | public TelnetTerminal acceptConnection() throws IOException {
Socket clientSocket = serverSocket.accept();
clientSocket.setTcpNoDelay(true);
return new TelnetTerminal(clientSocket, charset);
} | java | public TelnetTerminal acceptConnection() throws IOException {
Socket clientSocket = serverSocket.accept();
clientSocket.setTcpNoDelay(true);
return new TelnetTerminal(clientSocket, charset);
} | [
"public",
"TelnetTerminal",
"acceptConnection",
"(",
")",
"throws",
"IOException",
"{",
"Socket",
"clientSocket",
"=",
"serverSocket",
".",
"accept",
"(",
")",
";",
"clientSocket",
".",
"setTcpNoDelay",
"(",
"true",
")",
";",
"return",
"new",
"TelnetTerminal",
"... | Waits for the next client to connect in to our server and returns a Terminal implementation, TelnetTerminal, that
represents the remote terminal this client is running. The terminal can be used just like any other Terminal, but
keep in mind that all operations are sent over the network.
@return TelnetTerminal for the remote client's terminal
@throws IOException If there was an underlying I/O exception | [
"Waits",
"for",
"the",
"next",
"client",
"to",
"connect",
"in",
"to",
"our",
"server",
"and",
"returns",
"a",
"Terminal",
"implementation",
"TelnetTerminal",
"that",
"represents",
"the",
"remote",
"terminal",
"this",
"client",
"is",
"running",
".",
"The",
"ter... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/ansi/TelnetTerminalServer.java#L100-L104 |
29,346 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/ScrollBar.java | ScrollBar.getViewSize | public int getViewSize() {
if(viewSize > 0) {
return viewSize;
}
if(direction == Direction.HORIZONTAL) {
return getSize().getColumns();
}
else {
return getSize().getRows();
}
} | java | public int getViewSize() {
if(viewSize > 0) {
return viewSize;
}
if(direction == Direction.HORIZONTAL) {
return getSize().getColumns();
}
else {
return getSize().getRows();
}
} | [
"public",
"int",
"getViewSize",
"(",
")",
"{",
"if",
"(",
"viewSize",
">",
"0",
")",
"{",
"return",
"viewSize",
";",
"}",
"if",
"(",
"direction",
"==",
"Direction",
".",
"HORIZONTAL",
")",
"{",
"return",
"getSize",
"(",
")",
".",
"getColumns",
"(",
"... | Returns the view size of the scrollbar
@return View size of the scrollbar | [
"Returns",
"the",
"view",
"size",
"of",
"the",
"scrollbar"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/ScrollBar.java#L127-L137 |
29,347 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/Label.java | Label.setText | public synchronized void setText(String text) {
setLines(splitIntoMultipleLines(text));
this.labelSize = getBounds(lines, labelSize);
invalidate();
} | java | public synchronized void setText(String text) {
setLines(splitIntoMultipleLines(text));
this.labelSize = getBounds(lines, labelSize);
invalidate();
} | [
"public",
"synchronized",
"void",
"setText",
"(",
"String",
"text",
")",
"{",
"setLines",
"(",
"splitIntoMultipleLines",
"(",
"text",
")",
")",
";",
"this",
".",
"labelSize",
"=",
"getBounds",
"(",
"lines",
",",
"labelSize",
")",
";",
"invalidate",
"(",
")... | Updates the text this label is displaying
@param text New text to display | [
"Updates",
"the",
"text",
"this",
"label",
"is",
"displaying"
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/Label.java#L70-L74 |
29,348 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/Label.java | Label.getText | public synchronized String getText() {
if(lines.length == 0) {
return "";
}
StringBuilder bob = new StringBuilder(lines[0]);
for(int i = 1; i < lines.length; i++) {
bob.append("\n").append(lines[i]);
}
return bob.toString();
} | java | public synchronized String getText() {
if(lines.length == 0) {
return "";
}
StringBuilder bob = new StringBuilder(lines[0]);
for(int i = 1; i < lines.length; i++) {
bob.append("\n").append(lines[i]);
}
return bob.toString();
} | [
"public",
"synchronized",
"String",
"getText",
"(",
")",
"{",
"if",
"(",
"lines",
".",
"length",
"==",
"0",
")",
"{",
"return",
"\"\"",
";",
"}",
"StringBuilder",
"bob",
"=",
"new",
"StringBuilder",
"(",
"lines",
"[",
"0",
"]",
")",
";",
"for",
"(",
... | Returns the text this label is displaying. Multi-line labels will have their text concatenated with \n, even if
they were originally set using multi-line text having \r\n as line terminators.
@return String of the text this label is displaying | [
"Returns",
"the",
"text",
"this",
"label",
"is",
"displaying",
".",
"Multi",
"-",
"line",
"labels",
"will",
"have",
"their",
"text",
"concatenated",
"with",
"\\",
"n",
"even",
"if",
"they",
"were",
"originally",
"set",
"using",
"multi",
"-",
"line",
"text"... | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/Label.java#L81-L90 |
29,349 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/Label.java | Label.getBounds | protected TerminalSize getBounds(String[] lines, TerminalSize currentBounds) {
if(currentBounds == null) {
currentBounds = TerminalSize.ZERO;
}
currentBounds = currentBounds.withRows(lines.length);
if(labelWidth == null || labelWidth == 0) {
int preferredWidth = 0;
for(String line : lines) {
int lineWidth = TerminalTextUtils.getColumnWidth(line);
if(preferredWidth < lineWidth) {
preferredWidth = lineWidth;
}
}
currentBounds = currentBounds.withColumns(preferredWidth);
}
else {
List<String> wordWrapped = TerminalTextUtils.getWordWrappedText(labelWidth, lines);
currentBounds = currentBounds.withColumns(labelWidth).withRows(wordWrapped.size());
}
return currentBounds;
} | java | protected TerminalSize getBounds(String[] lines, TerminalSize currentBounds) {
if(currentBounds == null) {
currentBounds = TerminalSize.ZERO;
}
currentBounds = currentBounds.withRows(lines.length);
if(labelWidth == null || labelWidth == 0) {
int preferredWidth = 0;
for(String line : lines) {
int lineWidth = TerminalTextUtils.getColumnWidth(line);
if(preferredWidth < lineWidth) {
preferredWidth = lineWidth;
}
}
currentBounds = currentBounds.withColumns(preferredWidth);
}
else {
List<String> wordWrapped = TerminalTextUtils.getWordWrappedText(labelWidth, lines);
currentBounds = currentBounds.withColumns(labelWidth).withRows(wordWrapped.size());
}
return currentBounds;
} | [
"protected",
"TerminalSize",
"getBounds",
"(",
"String",
"[",
"]",
"lines",
",",
"TerminalSize",
"currentBounds",
")",
"{",
"if",
"(",
"currentBounds",
"==",
"null",
")",
"{",
"currentBounds",
"=",
"TerminalSize",
".",
"ZERO",
";",
"}",
"currentBounds",
"=",
... | Returns the area, in terminal columns and rows, required to fully draw the lines passed in.
@param lines Lines to measure the size of
@param currentBounds Optional (can pass {@code null}) terminal size to use for storing the output values. If the
method is called many times and always returning the same value, passing in an external
reference of this size will avoid creating new {@code TerminalSize} objects every time
@return Size that is required to draw the lines | [
"Returns",
"the",
"area",
"in",
"terminal",
"columns",
"and",
"rows",
"required",
"to",
"fully",
"draw",
"the",
"lines",
"passed",
"in",
"."
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/Label.java#L110-L130 |
29,350 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/input/EscapeSequenceCharacterPattern.java | EscapeSequenceCharacterPattern.getKeyStroke | protected KeyStroke getKeyStroke(KeyType key, int mods) {
boolean bShift = false, bCtrl = false, bAlt = false;
if (key == null) { return null; } // alternative: key = KeyType.Unknown;
if (mods >= 0) { // only use when non-negative!
bShift = (mods & SHIFT) != 0;
bAlt = (mods & ALT) != 0;
bCtrl = (mods & CTRL) != 0;
}
return new KeyStroke( key , bCtrl, bAlt, bShift);
} | java | protected KeyStroke getKeyStroke(KeyType key, int mods) {
boolean bShift = false, bCtrl = false, bAlt = false;
if (key == null) { return null; } // alternative: key = KeyType.Unknown;
if (mods >= 0) { // only use when non-negative!
bShift = (mods & SHIFT) != 0;
bAlt = (mods & ALT) != 0;
bCtrl = (mods & CTRL) != 0;
}
return new KeyStroke( key , bCtrl, bAlt, bShift);
} | [
"protected",
"KeyStroke",
"getKeyStroke",
"(",
"KeyType",
"key",
",",
"int",
"mods",
")",
"{",
"boolean",
"bShift",
"=",
"false",
",",
"bCtrl",
"=",
"false",
",",
"bAlt",
"=",
"false",
";",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"return",
"null",
... | combines a KeyType and modifiers into a KeyStroke.
Subclasses can override this for customization purposes.
@param key the KeyType as determined by parsing the sequence.
It will be null, if the pattern looked like a key sequence but wasn't
identified.
@param mods the bitmask of the modifer keys pressed along with the key.
@return either null (to report mis-match), or a valid KeyStroke. | [
"combines",
"a",
"KeyType",
"and",
"modifiers",
"into",
"a",
"KeyStroke",
".",
"Subclasses",
"can",
"override",
"this",
"for",
"customization",
"purposes",
"."
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/input/EscapeSequenceCharacterPattern.java#L140-L149 |
29,351 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/input/EscapeSequenceCharacterPattern.java | EscapeSequenceCharacterPattern.getKeyStrokeRaw | protected KeyStroke getKeyStrokeRaw(char first,int num1,int num2,char last,boolean bEsc) {
KeyType kt;
boolean bPuttyCtrl = false;
if (last == '~' && stdMap.containsKey(num1)) {
kt = stdMap.get(num1);
} else if (finMap.containsKey(last)) {
kt = finMap.get(last);
// Putty sends ^[OA for ctrl arrow-up, ^[[A for plain arrow-up:
// but only for A-D -- other ^[O... sequences are just plain keys
if (first == 'O' && last >= 'A' && last <= 'D') { bPuttyCtrl = true; }
// if we ever stumble into "keypad-mode", then it will end up inverted.
} else {
kt = null; // unknown key.
}
int mods = num2 - 1;
if (bEsc) {
if (mods >= 0) { mods |= ALT; }
else { mods = ALT; }
}
if (bPuttyCtrl) {
if (mods >= 0) { mods |= CTRL; }
else { mods = CTRL; }
}
return getKeyStroke( kt, mods );
} | java | protected KeyStroke getKeyStrokeRaw(char first,int num1,int num2,char last,boolean bEsc) {
KeyType kt;
boolean bPuttyCtrl = false;
if (last == '~' && stdMap.containsKey(num1)) {
kt = stdMap.get(num1);
} else if (finMap.containsKey(last)) {
kt = finMap.get(last);
// Putty sends ^[OA for ctrl arrow-up, ^[[A for plain arrow-up:
// but only for A-D -- other ^[O... sequences are just plain keys
if (first == 'O' && last >= 'A' && last <= 'D') { bPuttyCtrl = true; }
// if we ever stumble into "keypad-mode", then it will end up inverted.
} else {
kt = null; // unknown key.
}
int mods = num2 - 1;
if (bEsc) {
if (mods >= 0) { mods |= ALT; }
else { mods = ALT; }
}
if (bPuttyCtrl) {
if (mods >= 0) { mods |= CTRL; }
else { mods = CTRL; }
}
return getKeyStroke( kt, mods );
} | [
"protected",
"KeyStroke",
"getKeyStrokeRaw",
"(",
"char",
"first",
",",
"int",
"num1",
",",
"int",
"num2",
",",
"char",
"last",
",",
"boolean",
"bEsc",
")",
"{",
"KeyType",
"kt",
";",
"boolean",
"bPuttyCtrl",
"=",
"false",
";",
"if",
"(",
"last",
"==",
... | combines the raw parts of the sequence into a KeyStroke.
This method does not check the first char, but overrides may do so.
@param first the char following after Esc in the sequence (either [ or O)
@param num1 the first decimal, or 0 if not in the sequence
@param num2 the second decimal, or 0 if not in the sequence
@param last the terminating char.
@param bEsc whether an extra Escape-prefix was found.
@return either null (to report mis-match), or a valid KeyStroke. | [
"combines",
"the",
"raw",
"parts",
"of",
"the",
"sequence",
"into",
"a",
"KeyStroke",
".",
"This",
"method",
"does",
"not",
"check",
"the",
"first",
"char",
"but",
"overrides",
"may",
"do",
"so",
"."
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/input/EscapeSequenceCharacterPattern.java#L162-L186 |
29,352 | mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/ActionListBox.java | ActionListBox.addItem | public ActionListBox addItem(final String label, final Runnable action) {
return addItem(new Runnable() {
@Override
public void run() {
action.run();
}
@Override
public String toString() {
return label;
}
});
} | java | public ActionListBox addItem(final String label, final Runnable action) {
return addItem(new Runnable() {
@Override
public void run() {
action.run();
}
@Override
public String toString() {
return label;
}
});
} | [
"public",
"ActionListBox",
"addItem",
"(",
"final",
"String",
"label",
",",
"final",
"Runnable",
"action",
")",
"{",
"return",
"addItem",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"action",
".",
"run"... | Adds a new item to the list, which is displayed in the list using a supplied label.
@param label Label to use in the list for the new item
@param action Runnable to invoke when this action is selected and then triggered
@return Itself | [
"Adds",
"a",
"new",
"item",
"to",
"the",
"list",
"which",
"is",
"displayed",
"in",
"the",
"list",
"using",
"a",
"supplied",
"label",
"."
] | 8dfd62206ff46ab10223b2ef2dbb0a2c51850954 | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/ActionListBox.java#L74-L86 |
29,353 | castorflex/SmoothProgressBar | library-circular/src/main/java/fr.castorflex.android.circularprogressbar/CircularProgressDrawable.java | CircularProgressDrawable.initDelegate | private void initDelegate() {
boolean powerSaveMode = Utils.isPowerSaveModeEnabled(mPowerManager);
if (powerSaveMode) {
if (mPBDelegate == null || !(mPBDelegate instanceof PowerSaveModeDelegate)) {
if (mPBDelegate != null) mPBDelegate.stop();
mPBDelegate = new PowerSaveModeDelegate(this);
}
} else {
if (mPBDelegate == null || (mPBDelegate instanceof PowerSaveModeDelegate)) {
if (mPBDelegate != null) mPBDelegate.stop();
mPBDelegate = new DefaultDelegate(this, mOptions);
}
}
} | java | private void initDelegate() {
boolean powerSaveMode = Utils.isPowerSaveModeEnabled(mPowerManager);
if (powerSaveMode) {
if (mPBDelegate == null || !(mPBDelegate instanceof PowerSaveModeDelegate)) {
if (mPBDelegate != null) mPBDelegate.stop();
mPBDelegate = new PowerSaveModeDelegate(this);
}
} else {
if (mPBDelegate == null || (mPBDelegate instanceof PowerSaveModeDelegate)) {
if (mPBDelegate != null) mPBDelegate.stop();
mPBDelegate = new DefaultDelegate(this, mOptions);
}
}
} | [
"private",
"void",
"initDelegate",
"(",
")",
"{",
"boolean",
"powerSaveMode",
"=",
"Utils",
".",
"isPowerSaveModeEnabled",
"(",
"mPowerManager",
")",
";",
"if",
"(",
"powerSaveMode",
")",
"{",
"if",
"(",
"mPBDelegate",
"==",
"null",
"||",
"!",
"(",
"mPBDeleg... | Inits the delegate. Create one if the delegate is null or not the right mode | [
"Inits",
"the",
"delegate",
".",
"Create",
"one",
"if",
"the",
"delegate",
"is",
"null",
"or",
"not",
"the",
"right",
"mode"
] | 29fe0041f163695510775facdcc8c48114580def | https://github.com/castorflex/SmoothProgressBar/blob/29fe0041f163695510775facdcc8c48114580def/library-circular/src/main/java/fr.castorflex.android.circularprogressbar/CircularProgressDrawable.java#L113-L126 |
29,354 | castorflex/SmoothProgressBar | library/src/main/java/fr/castorflex/android/smoothprogressbar/ContentLoadingSmoothProgressBar.java | ContentLoadingSmoothProgressBar.hide | public void hide() {
mDismissed = true;
removeCallbacks(mDelayedShow);
long diff = System.currentTimeMillis() - mStartTime;
if (diff >= MIN_SHOW_TIME || mStartTime == -1) {
// The progress spinner has been shown long enough
// OR was not shown yet. If it wasn't shown yet,
// it will just never be shown.
setVisibility(View.GONE);
} else {
// The progress spinner is shown, but not long enough,
// so put a delayed message in to hide it when its been
// shown long enough.
if (!mPostedHide) {
postDelayed(mDelayedHide, MIN_SHOW_TIME - diff);
mPostedHide = true;
}
}
} | java | public void hide() {
mDismissed = true;
removeCallbacks(mDelayedShow);
long diff = System.currentTimeMillis() - mStartTime;
if (diff >= MIN_SHOW_TIME || mStartTime == -1) {
// The progress spinner has been shown long enough
// OR was not shown yet. If it wasn't shown yet,
// it will just never be shown.
setVisibility(View.GONE);
} else {
// The progress spinner is shown, but not long enough,
// so put a delayed message in to hide it when its been
// shown long enough.
if (!mPostedHide) {
postDelayed(mDelayedHide, MIN_SHOW_TIME - diff);
mPostedHide = true;
}
}
} | [
"public",
"void",
"hide",
"(",
")",
"{",
"mDismissed",
"=",
"true",
";",
"removeCallbacks",
"(",
"mDelayedShow",
")",
";",
"long",
"diff",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"mStartTime",
";",
"if",
"(",
"diff",
">=",
"MIN_SHOW_TIME",
... | Hide the progress view if it is visible. The progress view will not be
hidden until it has been shown for at least a minimum show time. If the
progress view was not yet visible, cancels showing the progress view. | [
"Hide",
"the",
"progress",
"view",
"if",
"it",
"is",
"visible",
".",
"The",
"progress",
"view",
"will",
"not",
"be",
"hidden",
"until",
"it",
"has",
"been",
"shown",
"for",
"at",
"least",
"a",
"minimum",
"show",
"time",
".",
"If",
"the",
"progress",
"v... | 29fe0041f163695510775facdcc8c48114580def | https://github.com/castorflex/SmoothProgressBar/blob/29fe0041f163695510775facdcc8c48114580def/library/src/main/java/fr/castorflex/android/smoothprogressbar/ContentLoadingSmoothProgressBar.java#L76-L94 |
29,355 | EsotericSoftware/reflectasm | src/com/esotericsoftware/reflectasm/AccessClassLoader.java | AccessClassLoader.loadAccessClass | Class loadAccessClass (String name) {
// No need to check the parent class loader if the access class hasn't been defined yet.
if (localClassNames.contains(name)) {
try {
return loadClass(name, false);
} catch (ClassNotFoundException ex) {
throw new RuntimeException(ex); // Should not happen, since we know the class has been defined.
}
}
return null;
} | java | Class loadAccessClass (String name) {
// No need to check the parent class loader if the access class hasn't been defined yet.
if (localClassNames.contains(name)) {
try {
return loadClass(name, false);
} catch (ClassNotFoundException ex) {
throw new RuntimeException(ex); // Should not happen, since we know the class has been defined.
}
}
return null;
} | [
"Class",
"loadAccessClass",
"(",
"String",
"name",
")",
"{",
"// No need to check the parent class loader if the access class hasn't been defined yet.\r",
"if",
"(",
"localClassNames",
".",
"contains",
"(",
"name",
")",
")",
"{",
"try",
"{",
"return",
"loadClass",
"(",
... | Returns null if the access class has not yet been defined. | [
"Returns",
"null",
"if",
"the",
"access",
"class",
"has",
"not",
"yet",
"been",
"defined",
"."
] | c86a421c5bec16fd82a22a39b85910568d3c7bf4 | https://github.com/EsotericSoftware/reflectasm/blob/c86a421c5bec16fd82a22a39b85910568d3c7bf4/src/com/esotericsoftware/reflectasm/AccessClassLoader.java#L43-L53 |
29,356 | EsotericSoftware/reflectasm | src/com/esotericsoftware/reflectasm/MethodAccess.java | MethodAccess.invoke | public Object invoke (Object object, String methodName, Class[] paramTypes, Object... args) {
return invoke(object, getIndex(methodName, paramTypes), args);
} | java | public Object invoke (Object object, String methodName, Class[] paramTypes, Object... args) {
return invoke(object, getIndex(methodName, paramTypes), args);
} | [
"public",
"Object",
"invoke",
"(",
"Object",
"object",
",",
"String",
"methodName",
",",
"Class",
"[",
"]",
"paramTypes",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"invoke",
"(",
"object",
",",
"getIndex",
"(",
"methodName",
",",
"paramTypes",
")",... | Invokes the method with the specified name and the specified param types. | [
"Invokes",
"the",
"method",
"with",
"the",
"specified",
"name",
"and",
"the",
"specified",
"param",
"types",
"."
] | c86a421c5bec16fd82a22a39b85910568d3c7bf4 | https://github.com/EsotericSoftware/reflectasm/blob/c86a421c5bec16fd82a22a39b85910568d3c7bf4/src/com/esotericsoftware/reflectasm/MethodAccess.java#L38-L40 |
29,357 | EsotericSoftware/reflectasm | src/com/esotericsoftware/reflectasm/MethodAccess.java | MethodAccess.invoke | public Object invoke (Object object, String methodName, Object... args) {
return invoke(object, getIndex(methodName, args == null ? 0 : args.length), args);
} | java | public Object invoke (Object object, String methodName, Object... args) {
return invoke(object, getIndex(methodName, args == null ? 0 : args.length), args);
} | [
"public",
"Object",
"invoke",
"(",
"Object",
"object",
",",
"String",
"methodName",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"invoke",
"(",
"object",
",",
"getIndex",
"(",
"methodName",
",",
"args",
"==",
"null",
"?",
"0",
":",
"args",
".",
"l... | Invokes the first method with the specified name and the specified number of arguments. | [
"Invokes",
"the",
"first",
"method",
"with",
"the",
"specified",
"name",
"and",
"the",
"specified",
"number",
"of",
"arguments",
"."
] | c86a421c5bec16fd82a22a39b85910568d3c7bf4 | https://github.com/EsotericSoftware/reflectasm/blob/c86a421c5bec16fd82a22a39b85910568d3c7bf4/src/com/esotericsoftware/reflectasm/MethodAccess.java#L43-L45 |
29,358 | EsotericSoftware/reflectasm | src/com/esotericsoftware/reflectasm/MethodAccess.java | MethodAccess.getIndex | public int getIndex (String methodName) {
for (int i = 0, n = methodNames.length; i < n; i++)
if (methodNames[i].equals(methodName)) return i;
throw new IllegalArgumentException("Unable to find non-private method: " + methodName);
} | java | public int getIndex (String methodName) {
for (int i = 0, n = methodNames.length; i < n; i++)
if (methodNames[i].equals(methodName)) return i;
throw new IllegalArgumentException("Unable to find non-private method: " + methodName);
} | [
"public",
"int",
"getIndex",
"(",
"String",
"methodName",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"methodNames",
".",
"length",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"if",
"(",
"methodNames",
"[",
"i",
"]",
".",
"equals",
... | Returns the index of the first method with the specified name. | [
"Returns",
"the",
"index",
"of",
"the",
"first",
"method",
"with",
"the",
"specified",
"name",
"."
] | c86a421c5bec16fd82a22a39b85910568d3c7bf4 | https://github.com/EsotericSoftware/reflectasm/blob/c86a421c5bec16fd82a22a39b85910568d3c7bf4/src/com/esotericsoftware/reflectasm/MethodAccess.java#L48-L52 |
29,359 | EsotericSoftware/reflectasm | src/com/esotericsoftware/reflectasm/MethodAccess.java | MethodAccess.getIndex | public int getIndex (String methodName, Class... paramTypes) {
for (int i = 0, n = methodNames.length; i < n; i++)
if (methodNames[i].equals(methodName) && Arrays.equals(paramTypes, parameterTypes[i])) return i;
throw new IllegalArgumentException("Unable to find non-private method: " + methodName + " " + Arrays.toString(paramTypes));
} | java | public int getIndex (String methodName, Class... paramTypes) {
for (int i = 0, n = methodNames.length; i < n; i++)
if (methodNames[i].equals(methodName) && Arrays.equals(paramTypes, parameterTypes[i])) return i;
throw new IllegalArgumentException("Unable to find non-private method: " + methodName + " " + Arrays.toString(paramTypes));
} | [
"public",
"int",
"getIndex",
"(",
"String",
"methodName",
",",
"Class",
"...",
"paramTypes",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"methodNames",
".",
"length",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"if",
"(",
"methodNames",... | Returns the index of the first method with the specified name and param types. | [
"Returns",
"the",
"index",
"of",
"the",
"first",
"method",
"with",
"the",
"specified",
"name",
"and",
"param",
"types",
"."
] | c86a421c5bec16fd82a22a39b85910568d3c7bf4 | https://github.com/EsotericSoftware/reflectasm/blob/c86a421c5bec16fd82a22a39b85910568d3c7bf4/src/com/esotericsoftware/reflectasm/MethodAccess.java#L55-L59 |
29,360 | infinispan/infinispan | commons/src/main/java/org/infinispan/commons/hash/MurmurHash3.java | MurmurHash3.MurmurHash3_x64_128 | public static long[] MurmurHash3_x64_128(final long[] key, final int seed) {
State state = new State();
state.h1 = 0x9368e53c2f6af274L ^ seed;
state.h2 = 0x586dcd208f7cd3fdL ^ seed;
state.c1 = 0x87c37b91114253d5L;
state.c2 = 0x4cf5ad432745937fL;
for (int i = 0; i < key.length / 2; i++) {
state.k1 = key[i * 2];
state.k2 = key[i * 2 + 1];
bmix(state);
}
long tail = key[key.length - 1];
// Key length is odd
if ((key.length & 1) == 1) {
state.k1 ^= tail;
bmix(state);
}
state.h2 ^= key.length * 8;
state.h1 += state.h2;
state.h2 += state.h1;
state.h1 = fmix(state.h1);
state.h2 = fmix(state.h2);
state.h1 += state.h2;
state.h2 += state.h1;
return new long[] { state.h1, state.h2 };
} | java | public static long[] MurmurHash3_x64_128(final long[] key, final int seed) {
State state = new State();
state.h1 = 0x9368e53c2f6af274L ^ seed;
state.h2 = 0x586dcd208f7cd3fdL ^ seed;
state.c1 = 0x87c37b91114253d5L;
state.c2 = 0x4cf5ad432745937fL;
for (int i = 0; i < key.length / 2; i++) {
state.k1 = key[i * 2];
state.k2 = key[i * 2 + 1];
bmix(state);
}
long tail = key[key.length - 1];
// Key length is odd
if ((key.length & 1) == 1) {
state.k1 ^= tail;
bmix(state);
}
state.h2 ^= key.length * 8;
state.h1 += state.h2;
state.h2 += state.h1;
state.h1 = fmix(state.h1);
state.h2 = fmix(state.h2);
state.h1 += state.h2;
state.h2 += state.h1;
return new long[] { state.h1, state.h2 };
} | [
"public",
"static",
"long",
"[",
"]",
"MurmurHash3_x64_128",
"(",
"final",
"long",
"[",
"]",
"key",
",",
"final",
"int",
"seed",
")",
"{",
"State",
"state",
"=",
"new",
"State",
"(",
")",
";",
"state",
".",
"h1",
"=",
"0x9368e53c2f6af274",
"",
"L",
"... | Hash a value using the x64 128 bit variant of MurmurHash3
@param key value to hash
@param seed random value
@return 128 bit hashed key, in an array containing two longs | [
"Hash",
"a",
"value",
"using",
"the",
"x64",
"128",
"bit",
"variant",
"of",
"MurmurHash3"
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/hash/MurmurHash3.java#L239-L275 |
29,361 | infinispan/infinispan | core/src/main/java/org/infinispan/persistence/support/SingletonCacheWriter.java | SingletonCacheWriter.pushState | protected void pushState(final Cache<?, ?> cache) throws Exception {
DataContainer<?, ?> dc = cache.getAdvancedCache().getDataContainer();
dc.forEach(entry -> {
MarshallableEntry me = ctx.getMarshallableEntryFactory().create(entry.getKey(), entry.getValue(), entry.getMetadata(),
entry.getExpiryTime(), entry.getLastUsed());
write(me);
});
} | java | protected void pushState(final Cache<?, ?> cache) throws Exception {
DataContainer<?, ?> dc = cache.getAdvancedCache().getDataContainer();
dc.forEach(entry -> {
MarshallableEntry me = ctx.getMarshallableEntryFactory().create(entry.getKey(), entry.getValue(), entry.getMetadata(),
entry.getExpiryTime(), entry.getLastUsed());
write(me);
});
} | [
"protected",
"void",
"pushState",
"(",
"final",
"Cache",
"<",
"?",
",",
"?",
">",
"cache",
")",
"throws",
"Exception",
"{",
"DataContainer",
"<",
"?",
",",
"?",
">",
"dc",
"=",
"cache",
".",
"getAdvancedCache",
"(",
")",
".",
"getDataContainer",
"(",
"... | Pushes the state of a specific cache by reading the cache's data and putting in the cache store. | [
"Pushes",
"the",
"state",
"of",
"a",
"specific",
"cache",
"by",
"reading",
"the",
"cache",
"s",
"data",
"and",
"putting",
"in",
"the",
"cache",
"store",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/persistence/support/SingletonCacheWriter.java#L141-L148 |
29,362 | infinispan/infinispan | core/src/main/java/org/infinispan/persistence/support/SingletonCacheWriter.java | SingletonCacheWriter.awaitForPushToFinish | protected void awaitForPushToFinish(Future<?> future, long timeout, TimeUnit unit) {
final boolean debugEnabled = log.isDebugEnabled();
try {
if (debugEnabled) log.debug("wait for state push to cache loader to finish");
future.get(timeout, unit);
} catch (TimeoutException e) {
if (debugEnabled) log.debug("timed out waiting for state push to cache loader to finish");
} catch (ExecutionException e) {
if (debugEnabled) log.debug("exception reported waiting for state push to cache loader to finish");
} catch (InterruptedException ie) {
/* Re-assert the thread's interrupted status */
Thread.currentThread().interrupt();
if (trace) log.trace("wait for state push to cache loader to finish was interrupted");
}
} | java | protected void awaitForPushToFinish(Future<?> future, long timeout, TimeUnit unit) {
final boolean debugEnabled = log.isDebugEnabled();
try {
if (debugEnabled) log.debug("wait for state push to cache loader to finish");
future.get(timeout, unit);
} catch (TimeoutException e) {
if (debugEnabled) log.debug("timed out waiting for state push to cache loader to finish");
} catch (ExecutionException e) {
if (debugEnabled) log.debug("exception reported waiting for state push to cache loader to finish");
} catch (InterruptedException ie) {
/* Re-assert the thread's interrupted status */
Thread.currentThread().interrupt();
if (trace) log.trace("wait for state push to cache loader to finish was interrupted");
}
} | [
"protected",
"void",
"awaitForPushToFinish",
"(",
"Future",
"<",
"?",
">",
"future",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"{",
"final",
"boolean",
"debugEnabled",
"=",
"log",
".",
"isDebugEnabled",
"(",
")",
";",
"try",
"{",
"if",
"(",
"... | Method that waits for the in-memory to cache loader state to finish. This method's called in case a push state is
already in progress and we need to wait for it to finish. | [
"Method",
"that",
"waits",
"for",
"the",
"in",
"-",
"memory",
"to",
"cache",
"loader",
"state",
"to",
"finish",
".",
"This",
"method",
"s",
"called",
"in",
"case",
"a",
"push",
"state",
"is",
"already",
"in",
"progress",
"and",
"we",
"need",
"to",
"wai... | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/persistence/support/SingletonCacheWriter.java#L155-L169 |
29,363 | infinispan/infinispan | core/src/main/java/org/infinispan/persistence/support/SingletonCacheWriter.java | SingletonCacheWriter.doPushState | private void doPushState() throws PushStateException {
if (pushStateFuture == null || pushStateFuture.isDone()) {
Callable<?> task = createPushStateTask();
pushStateFuture = executor.submit(task);
try {
waitForTaskToFinish(pushStateFuture, singletonConfiguration.pushStateTimeout(), TimeUnit.MILLISECONDS);
} catch (Exception e) {
throw new PushStateException("unable to complete in memory state push to cache loader", e);
}
} else {
/* at the most, we wait for push state timeout value. if it push task finishes earlier, this call
* will stop when the push task finishes, otherwise a timeout exception will be reported */
awaitForPushToFinish(pushStateFuture, singletonConfiguration.pushStateTimeout(), TimeUnit.MILLISECONDS);
}
} | java | private void doPushState() throws PushStateException {
if (pushStateFuture == null || pushStateFuture.isDone()) {
Callable<?> task = createPushStateTask();
pushStateFuture = executor.submit(task);
try {
waitForTaskToFinish(pushStateFuture, singletonConfiguration.pushStateTimeout(), TimeUnit.MILLISECONDS);
} catch (Exception e) {
throw new PushStateException("unable to complete in memory state push to cache loader", e);
}
} else {
/* at the most, we wait for push state timeout value. if it push task finishes earlier, this call
* will stop when the push task finishes, otherwise a timeout exception will be reported */
awaitForPushToFinish(pushStateFuture, singletonConfiguration.pushStateTimeout(), TimeUnit.MILLISECONDS);
}
} | [
"private",
"void",
"doPushState",
"(",
")",
"throws",
"PushStateException",
"{",
"if",
"(",
"pushStateFuture",
"==",
"null",
"||",
"pushStateFuture",
".",
"isDone",
"(",
")",
")",
"{",
"Callable",
"<",
"?",
">",
"task",
"=",
"createPushStateTask",
"(",
")",
... | Called when the SingletonStore discovers that the cache has become the coordinator and push in memory state has
been enabled. It might not actually push the state if there's an ongoing push task running, in which case will
wait for the push task to finish. | [
"Called",
"when",
"the",
"SingletonStore",
"discovers",
"that",
"the",
"cache",
"has",
"become",
"the",
"coordinator",
"and",
"push",
"in",
"memory",
"state",
"has",
"been",
"enabled",
".",
"It",
"might",
"not",
"actually",
"push",
"the",
"state",
"if",
"the... | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/persistence/support/SingletonCacheWriter.java#L193-L207 |
29,364 | infinispan/infinispan | core/src/main/java/org/infinispan/persistence/support/SingletonCacheWriter.java | SingletonCacheWriter.waitForTaskToFinish | private void waitForTaskToFinish(Future<?> future, long timeout, TimeUnit unit) throws Exception {
try {
future.get(timeout, unit);
} catch (TimeoutException e) {
throw new Exception("task timed out", e);
} catch (InterruptedException e) {
/* Re-assert the thread's interrupted status */
Thread.currentThread().interrupt();
if (trace) log.trace("task was interrupted");
} finally {
/* no-op if task is completed */
future.cancel(true); /* interrupt if running */
}
} | java | private void waitForTaskToFinish(Future<?> future, long timeout, TimeUnit unit) throws Exception {
try {
future.get(timeout, unit);
} catch (TimeoutException e) {
throw new Exception("task timed out", e);
} catch (InterruptedException e) {
/* Re-assert the thread's interrupted status */
Thread.currentThread().interrupt();
if (trace) log.trace("task was interrupted");
} finally {
/* no-op if task is completed */
future.cancel(true); /* interrupt if running */
}
} | [
"private",
"void",
"waitForTaskToFinish",
"(",
"Future",
"<",
"?",
">",
"future",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"Exception",
"{",
"try",
"{",
"future",
".",
"get",
"(",
"timeout",
",",
"unit",
")",
";",
"}",
"catch",
"... | Waits, within a time constraint, for a task to finish. | [
"Waits",
"within",
"a",
"time",
"constraint",
"for",
"a",
"task",
"to",
"finish",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/persistence/support/SingletonCacheWriter.java#L213-L226 |
29,365 | infinispan/infinispan | commons/src/main/java/org/infinispan/commons/util/WeakValueHashMap.java | WeakValueHashMap.create | private ValueRef<K, V> create(K key, V value, ReferenceQueue<V> q) {
return WeakValueRef.create(key, value, q);
} | java | private ValueRef<K, V> create(K key, V value, ReferenceQueue<V> q) {
return WeakValueRef.create(key, value, q);
} | [
"private",
"ValueRef",
"<",
"K",
",",
"V",
">",
"create",
"(",
"K",
"key",
",",
"V",
"value",
",",
"ReferenceQueue",
"<",
"V",
">",
"q",
")",
"{",
"return",
"WeakValueRef",
".",
"create",
"(",
"key",
",",
"value",
",",
"q",
")",
";",
"}"
] | Create new value ref instance.
@param key the key
@param value the value
@param q the ref queue
@return new value ref instance | [
"Create",
"new",
"value",
"ref",
"instance",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/WeakValueHashMap.java#L94-L96 |
29,366 | infinispan/infinispan | commons/src/main/java/org/infinispan/commons/util/WeakValueHashMap.java | WeakValueHashMap.processQueue | @SuppressWarnings("unchecked")
private void processQueue() {
ValueRef<K, V> ref = (ValueRef<K, V>) queue.poll();
while (ref != null) {
// only remove if it is the *exact* same WeakValueRef
if (ref == map.get(ref.getKey()))
map.remove(ref.getKey());
ref = (ValueRef<K, V>) queue.poll();
}
} | java | @SuppressWarnings("unchecked")
private void processQueue() {
ValueRef<K, V> ref = (ValueRef<K, V>) queue.poll();
while (ref != null) {
// only remove if it is the *exact* same WeakValueRef
if (ref == map.get(ref.getKey()))
map.remove(ref.getKey());
ref = (ValueRef<K, V>) queue.poll();
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"processQueue",
"(",
")",
"{",
"ValueRef",
"<",
"K",
",",
"V",
">",
"ref",
"=",
"(",
"ValueRef",
"<",
"K",
",",
"V",
">",
")",
"queue",
".",
"poll",
"(",
")",
";",
"while",
"(",... | Remove all entries whose values have been discarded. | [
"Remove",
"all",
"entries",
"whose",
"values",
"have",
"been",
"discarded",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/WeakValueHashMap.java#L188-L198 |
29,367 | infinispan/infinispan | core/src/main/java/org/infinispan/configuration/cache/ClusteringConfigurationBuilder.java | ClusteringConfigurationBuilder.biasLifespan | public ClusteringConfigurationBuilder biasLifespan(long l, TimeUnit unit) {
attributes.attribute(BIAS_LIFESPAN).set(unit.toMillis(l));
return this;
} | java | public ClusteringConfigurationBuilder biasLifespan(long l, TimeUnit unit) {
attributes.attribute(BIAS_LIFESPAN).set(unit.toMillis(l));
return this;
} | [
"public",
"ClusteringConfigurationBuilder",
"biasLifespan",
"(",
"long",
"l",
",",
"TimeUnit",
"unit",
")",
"{",
"attributes",
".",
"attribute",
"(",
"BIAS_LIFESPAN",
")",
".",
"set",
"(",
"unit",
".",
"toMillis",
"(",
"l",
")",
")",
";",
"return",
"this",
... | Used in scattered cache. Specifies how long can be the acquired bias held; while the reads
will never be stale, tracking that information consumes memory on primary owner. | [
"Used",
"in",
"scattered",
"cache",
".",
"Specifies",
"how",
"long",
"can",
"be",
"the",
"acquired",
"bias",
"held",
";",
"while",
"the",
"reads",
"will",
"never",
"be",
"stale",
"tracking",
"that",
"information",
"consumes",
"memory",
"on",
"primary",
"owne... | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/configuration/cache/ClusteringConfigurationBuilder.java#L112-L115 |
29,368 | infinispan/infinispan | core/src/main/java/org/infinispan/persistence/file/SingleFileStore.java | SingleFileStore.rebuildIndex | private void rebuildIndex() throws Exception {
ByteBuffer buf = ByteBuffer.allocate(KEY_POS);
for (; ; ) {
// read FileEntry fields from file (size, keyLen etc.)
buf.clear().limit(KEY_POS);
channel.read(buf, filePos);
// return if end of file is reached
if (buf.remaining() > 0)
return;
buf.flip();
// initialize FileEntry from buffer
int entrySize = buf.getInt();
int keyLen = buf.getInt();
int dataLen = buf.getInt();
int metadataLen = buf.getInt();
long expiryTime = buf.getLong();
FileEntry fe = new FileEntry(filePos, entrySize, keyLen, dataLen, metadataLen, expiryTime);
// sanity check
if (fe.size < KEY_POS + fe.keyLen + fe.dataLen + fe.metadataLen) {
throw log.errorReadingFileStore(file.getPath(), filePos);
}
// update file pointer
filePos += fe.size;
// check if the entry is used or free
if (fe.keyLen > 0) {
// load the key from file
if (buf.capacity() < fe.keyLen)
buf = ByteBuffer.allocate(fe.keyLen);
buf.clear().limit(fe.keyLen);
channel.read(buf, fe.offset + KEY_POS);
// deserialize key and add to entries map
// Marshaller should allow for provided type return for safety
K key = (K) ctx.getMarshaller().objectFromByteBuffer(buf.array(), 0, fe.keyLen);
entries.put(key, fe);
} else {
// add to free list
freeList.add(fe);
}
}
} | java | private void rebuildIndex() throws Exception {
ByteBuffer buf = ByteBuffer.allocate(KEY_POS);
for (; ; ) {
// read FileEntry fields from file (size, keyLen etc.)
buf.clear().limit(KEY_POS);
channel.read(buf, filePos);
// return if end of file is reached
if (buf.remaining() > 0)
return;
buf.flip();
// initialize FileEntry from buffer
int entrySize = buf.getInt();
int keyLen = buf.getInt();
int dataLen = buf.getInt();
int metadataLen = buf.getInt();
long expiryTime = buf.getLong();
FileEntry fe = new FileEntry(filePos, entrySize, keyLen, dataLen, metadataLen, expiryTime);
// sanity check
if (fe.size < KEY_POS + fe.keyLen + fe.dataLen + fe.metadataLen) {
throw log.errorReadingFileStore(file.getPath(), filePos);
}
// update file pointer
filePos += fe.size;
// check if the entry is used or free
if (fe.keyLen > 0) {
// load the key from file
if (buf.capacity() < fe.keyLen)
buf = ByteBuffer.allocate(fe.keyLen);
buf.clear().limit(fe.keyLen);
channel.read(buf, fe.offset + KEY_POS);
// deserialize key and add to entries map
// Marshaller should allow for provided type return for safety
K key = (K) ctx.getMarshaller().objectFromByteBuffer(buf.array(), 0, fe.keyLen);
entries.put(key, fe);
} else {
// add to free list
freeList.add(fe);
}
}
} | [
"private",
"void",
"rebuildIndex",
"(",
")",
"throws",
"Exception",
"{",
"ByteBuffer",
"buf",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"KEY_POS",
")",
";",
"for",
"(",
";",
";",
")",
"{",
"// read FileEntry fields from file (size, keyLen etc.)",
"buf",
".",
"cle... | Rebuilds the in-memory index from file. | [
"Rebuilds",
"the",
"in",
"-",
"memory",
"index",
"from",
"file",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/persistence/file/SingleFileStore.java#L181-L226 |
29,369 | infinispan/infinispan | core/src/main/java/org/infinispan/persistence/file/SingleFileStore.java | SingleFileStore.allocate | private FileEntry allocate(int len) {
synchronized (freeList) {
// lookup a free entry of sufficient size
SortedSet<FileEntry> candidates = freeList.tailSet(new FileEntry(0, len));
for (Iterator<FileEntry> it = candidates.iterator(); it.hasNext(); ) {
FileEntry free = it.next();
// ignore entries that are still in use by concurrent readers
if (free.isLocked())
continue;
// There's no race condition risk between locking the entry on
// loading and checking whether it's locked (or store allocation),
// because for the entry to be lockable, it needs to be in the
// entries collection, in which case it's not in the free list.
// The only way an entry can be found in the free list is if it's
// been removed, and to remove it, lock on "entries" needs to be
// acquired, which is also a pre-requisite for loading data.
// found one, remove from freeList
it.remove();
return allocateExistingEntry(free, len);
}
// no appropriate free section available, append at end of file
FileEntry fe = new FileEntry(filePos, len);
filePos += len;
if (trace) log.tracef("New entry allocated at %d:%d, %d free entries, file size is %d", fe.offset, fe.size, freeList.size(), filePos);
return fe;
}
} | java | private FileEntry allocate(int len) {
synchronized (freeList) {
// lookup a free entry of sufficient size
SortedSet<FileEntry> candidates = freeList.tailSet(new FileEntry(0, len));
for (Iterator<FileEntry> it = candidates.iterator(); it.hasNext(); ) {
FileEntry free = it.next();
// ignore entries that are still in use by concurrent readers
if (free.isLocked())
continue;
// There's no race condition risk between locking the entry on
// loading and checking whether it's locked (or store allocation),
// because for the entry to be lockable, it needs to be in the
// entries collection, in which case it's not in the free list.
// The only way an entry can be found in the free list is if it's
// been removed, and to remove it, lock on "entries" needs to be
// acquired, which is also a pre-requisite for loading data.
// found one, remove from freeList
it.remove();
return allocateExistingEntry(free, len);
}
// no appropriate free section available, append at end of file
FileEntry fe = new FileEntry(filePos, len);
filePos += len;
if (trace) log.tracef("New entry allocated at %d:%d, %d free entries, file size is %d", fe.offset, fe.size, freeList.size(), filePos);
return fe;
}
} | [
"private",
"FileEntry",
"allocate",
"(",
"int",
"len",
")",
"{",
"synchronized",
"(",
"freeList",
")",
"{",
"// lookup a free entry of sufficient size",
"SortedSet",
"<",
"FileEntry",
">",
"candidates",
"=",
"freeList",
".",
"tailSet",
"(",
"new",
"FileEntry",
"("... | Allocates the requested space in the file.
@param len requested space
@return allocated file position and length as FileEntry object | [
"Allocates",
"the",
"requested",
"space",
"in",
"the",
"file",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/persistence/file/SingleFileStore.java#L244-L273 |
29,370 | infinispan/infinispan | core/src/main/java/org/infinispan/persistence/file/SingleFileStore.java | SingleFileStore.addNewFreeEntry | private void addNewFreeEntry(FileEntry fe) throws IOException {
ByteBuffer buf = ByteBuffer.allocate(KEY_POS);
buf.putInt(fe.size);
buf.putInt(0);
buf.putInt(0);
buf.putInt(0);
buf.putLong(-1);
buf.flip();
channel.write(buf, fe.offset);
freeList.add(fe);
} | java | private void addNewFreeEntry(FileEntry fe) throws IOException {
ByteBuffer buf = ByteBuffer.allocate(KEY_POS);
buf.putInt(fe.size);
buf.putInt(0);
buf.putInt(0);
buf.putInt(0);
buf.putLong(-1);
buf.flip();
channel.write(buf, fe.offset);
freeList.add(fe);
} | [
"private",
"void",
"addNewFreeEntry",
"(",
"FileEntry",
"fe",
")",
"throws",
"IOException",
"{",
"ByteBuffer",
"buf",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"KEY_POS",
")",
";",
"buf",
".",
"putInt",
"(",
"fe",
".",
"size",
")",
";",
"buf",
".",
"putIn... | Writes a new free entry to the file and also adds it to the free list | [
"Writes",
"a",
"new",
"free",
"entry",
"to",
"the",
"file",
"and",
"also",
"adds",
"it",
"to",
"the",
"free",
"list"
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/persistence/file/SingleFileStore.java#L300-L310 |
29,371 | infinispan/infinispan | core/src/main/java/org/infinispan/persistence/file/SingleFileStore.java | SingleFileStore.evict | private FileEntry evict() {
if (configuration.maxEntries() > 0) {
synchronized (entries) {
if (entries.size() > configuration.maxEntries()) {
Iterator<FileEntry> it = entries.values().iterator();
FileEntry fe = it.next();
it.remove();
return fe;
}
}
}
return null;
} | java | private FileEntry evict() {
if (configuration.maxEntries() > 0) {
synchronized (entries) {
if (entries.size() > configuration.maxEntries()) {
Iterator<FileEntry> it = entries.values().iterator();
FileEntry fe = it.next();
it.remove();
return fe;
}
}
}
return null;
} | [
"private",
"FileEntry",
"evict",
"(",
")",
"{",
"if",
"(",
"configuration",
".",
"maxEntries",
"(",
")",
">",
"0",
")",
"{",
"synchronized",
"(",
"entries",
")",
"{",
"if",
"(",
"entries",
".",
"size",
"(",
")",
">",
"configuration",
".",
"maxEntries",... | Try to evict an entry if the capacity of the cache store is reached.
@return FileEntry to evict, or null (if unbounded or capacity is not yet reached) | [
"Try",
"to",
"evict",
"an",
"entry",
"if",
"the",
"capacity",
"of",
"the",
"cache",
"store",
"is",
"reached",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/persistence/file/SingleFileStore.java#L393-L405 |
29,372 | infinispan/infinispan | core/src/main/java/org/infinispan/persistence/file/SingleFileStore.java | SingleFileStore.processFreeEntries | private void processFreeEntries() {
// Get a reverse sorted list of free entries based on file offset (bigger entries will be ahead of smaller entries)
// This helps to work backwards with free entries at end of the file
List<FileEntry> l = new ArrayList<>(freeList);
l.sort((o1, o2) -> {
long diff = o1.offset - o2.offset;
return (diff == 0) ? 0 : ((diff > 0) ? -1 : 1);
});
truncateFile(l);
mergeFreeEntries(l);
} | java | private void processFreeEntries() {
// Get a reverse sorted list of free entries based on file offset (bigger entries will be ahead of smaller entries)
// This helps to work backwards with free entries at end of the file
List<FileEntry> l = new ArrayList<>(freeList);
l.sort((o1, o2) -> {
long diff = o1.offset - o2.offset;
return (diff == 0) ? 0 : ((diff > 0) ? -1 : 1);
});
truncateFile(l);
mergeFreeEntries(l);
} | [
"private",
"void",
"processFreeEntries",
"(",
")",
"{",
"// Get a reverse sorted list of free entries based on file offset (bigger entries will be ahead of smaller entries)",
"// This helps to work backwards with free entries at end of the file",
"List",
"<",
"FileEntry",
">",
"l",
"=",
... | Manipulates the free entries for optimizing disk space. | [
"Manipulates",
"the",
"free",
"entries",
"for",
"optimizing",
"disk",
"space",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/persistence/file/SingleFileStore.java#L578-L589 |
29,373 | infinispan/infinispan | core/src/main/java/org/infinispan/persistence/file/SingleFileStore.java | SingleFileStore.truncateFile | private void truncateFile(List<FileEntry> entries) {
long startTime = 0;
if (trace) startTime = timeService.wallClockTime();
int reclaimedSpace = 0;
int removedEntries = 0;
long truncateOffset = -1;
for (Iterator<FileEntry> it = entries.iterator() ; it.hasNext(); ) {
FileEntry fe = it.next();
// Till we have free entries at the end of the file,
// we can remove them and contract the file to release disk
// space.
if (!fe.isLocked() && ((fe.offset + fe.size) == filePos)) {
truncateOffset = fe.offset;
filePos = fe.offset;
freeList.remove(fe);
it.remove();
reclaimedSpace += fe.size;
removedEntries++;
} else {
break;
}
}
if (truncateOffset > 0) {
try {
channel.truncate(truncateOffset);
} catch (IOException e) {
throw new PersistenceException("Error while truncating file", e);
}
}
if (trace) {
log.tracef("Removed entries: %d, Reclaimed Space: %d, Free Entries %d", removedEntries, reclaimedSpace, freeList.size());
log.tracef("Time taken for truncateFile: %d (ms)", timeService.wallClockTime() - startTime);
}
} | java | private void truncateFile(List<FileEntry> entries) {
long startTime = 0;
if (trace) startTime = timeService.wallClockTime();
int reclaimedSpace = 0;
int removedEntries = 0;
long truncateOffset = -1;
for (Iterator<FileEntry> it = entries.iterator() ; it.hasNext(); ) {
FileEntry fe = it.next();
// Till we have free entries at the end of the file,
// we can remove them and contract the file to release disk
// space.
if (!fe.isLocked() && ((fe.offset + fe.size) == filePos)) {
truncateOffset = fe.offset;
filePos = fe.offset;
freeList.remove(fe);
it.remove();
reclaimedSpace += fe.size;
removedEntries++;
} else {
break;
}
}
if (truncateOffset > 0) {
try {
channel.truncate(truncateOffset);
} catch (IOException e) {
throw new PersistenceException("Error while truncating file", e);
}
}
if (trace) {
log.tracef("Removed entries: %d, Reclaimed Space: %d, Free Entries %d", removedEntries, reclaimedSpace, freeList.size());
log.tracef("Time taken for truncateFile: %d (ms)", timeService.wallClockTime() - startTime);
}
} | [
"private",
"void",
"truncateFile",
"(",
"List",
"<",
"FileEntry",
">",
"entries",
")",
"{",
"long",
"startTime",
"=",
"0",
";",
"if",
"(",
"trace",
")",
"startTime",
"=",
"timeService",
".",
"wallClockTime",
"(",
")",
";",
"int",
"reclaimedSpace",
"=",
"... | Removes free entries towards the end of the file and truncates the file. | [
"Removes",
"free",
"entries",
"towards",
"the",
"end",
"of",
"the",
"file",
"and",
"truncates",
"the",
"file",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/persistence/file/SingleFileStore.java#L594-L630 |
29,374 | infinispan/infinispan | commons/src/main/java/org/infinispan/commons/util/Immutables.java | Immutables.immutableSetConvert | public static <T> Set<T> immutableSetConvert(Collection<? extends T> collection) {
return immutableSetWrap(new HashSet<T>(collection));
} | java | public static <T> Set<T> immutableSetConvert(Collection<? extends T> collection) {
return immutableSetWrap(new HashSet<T>(collection));
} | [
"public",
"static",
"<",
"T",
">",
"Set",
"<",
"T",
">",
"immutableSetConvert",
"(",
"Collection",
"<",
"?",
"extends",
"T",
">",
"collection",
")",
"{",
"return",
"immutableSetWrap",
"(",
"new",
"HashSet",
"<",
"T",
">",
"(",
"collection",
")",
")",
"... | Converts a Collections into an immutable Set by copying it.
@param collection the collection to convert/copy
@return a new immutable set containing the elements in collection | [
"Converts",
"a",
"Collections",
"into",
"an",
"immutable",
"Set",
"by",
"copying",
"it",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/Immutables.java#L145-L147 |
29,375 | infinispan/infinispan | commons/src/main/java/org/infinispan/commons/util/Immutables.java | Immutables.immutableSetCopy | public static <T> Set<T> immutableSetCopy(Set<T> set) {
if (set == null) return null;
if (set.isEmpty()) return Collections.emptySet();
if (set.size() == 1) return Collections.singleton(set.iterator().next());
Set<? extends T> copy = ObjectDuplicator.duplicateSet(set);
if (copy == null)
// Set uses Collection copy-ctor
copy = attemptCopyConstructor(set, Collection.class);
if (copy == null)
copy = new HashSet<>(set);
return new ImmutableSetWrapper<>(copy);
} | java | public static <T> Set<T> immutableSetCopy(Set<T> set) {
if (set == null) return null;
if (set.isEmpty()) return Collections.emptySet();
if (set.size() == 1) return Collections.singleton(set.iterator().next());
Set<? extends T> copy = ObjectDuplicator.duplicateSet(set);
if (copy == null)
// Set uses Collection copy-ctor
copy = attemptCopyConstructor(set, Collection.class);
if (copy == null)
copy = new HashSet<>(set);
return new ImmutableSetWrapper<>(copy);
} | [
"public",
"static",
"<",
"T",
">",
"Set",
"<",
"T",
">",
"immutableSetCopy",
"(",
"Set",
"<",
"T",
">",
"set",
")",
"{",
"if",
"(",
"set",
"==",
"null",
")",
"return",
"null",
";",
"if",
"(",
"set",
".",
"isEmpty",
"(",
")",
")",
"return",
"Col... | Creates an immutable copy of the specified set.
@param set the set to copy from
@return an immutable set copy | [
"Creates",
"an",
"immutable",
"copy",
"of",
"the",
"specified",
"set",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/Immutables.java#L165-L177 |
29,376 | infinispan/infinispan | commons/src/main/java/org/infinispan/commons/util/Immutables.java | Immutables.immutableMapWrap | public static <K, V> Map<K, V> immutableMapWrap(Map<? extends K, ? extends V> map) {
return new ImmutableMapWrapper<>(map);
} | java | public static <K, V> Map<K, V> immutableMapWrap(Map<? extends K, ? extends V> map) {
return new ImmutableMapWrapper<>(map);
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
"V",
">",
"immutableMapWrap",
"(",
"Map",
"<",
"?",
"extends",
"K",
",",
"?",
"extends",
"V",
">",
"map",
")",
"{",
"return",
"new",
"ImmutableMapWrapper",
"<>",
"(",
"map",
")",
... | Wraps a map with an immutable map. There is no copying involved.
@param map the map to wrap
@return an immutable map wrapper that delegates to the original map | [
"Wraps",
"a",
"map",
"with",
"an",
"immutable",
"map",
".",
"There",
"is",
"no",
"copying",
"involved",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/Immutables.java#L186-L188 |
29,377 | infinispan/infinispan | commons/src/main/java/org/infinispan/commons/util/Immutables.java | Immutables.immutableMapCopy | public static <K, V> Map<K, V> immutableMapCopy(Map<K, V> map) {
if (map == null) return null;
if (map.isEmpty()) return Collections.emptyMap();
if (map.size() == 1) {
Map.Entry<K, V> me = map.entrySet().iterator().next();
return Collections.singletonMap(me.getKey(), me.getValue());
}
Map<? extends K, ? extends V> copy = ObjectDuplicator.duplicateMap(map);
if (copy == null)
copy = attemptCopyConstructor(map, Map.class);
if (copy == null)
copy = new HashMap<>(map);
return new ImmutableMapWrapper<>(copy);
} | java | public static <K, V> Map<K, V> immutableMapCopy(Map<K, V> map) {
if (map == null) return null;
if (map.isEmpty()) return Collections.emptyMap();
if (map.size() == 1) {
Map.Entry<K, V> me = map.entrySet().iterator().next();
return Collections.singletonMap(me.getKey(), me.getValue());
}
Map<? extends K, ? extends V> copy = ObjectDuplicator.duplicateMap(map);
if (copy == null)
copy = attemptCopyConstructor(map, Map.class);
if (copy == null)
copy = new HashMap<>(map);
return new ImmutableMapWrapper<>(copy);
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
"V",
">",
"immutableMapCopy",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
")",
"{",
"if",
"(",
"map",
"==",
"null",
")",
"return",
"null",
";",
"if",
"(",
"map",
".",
"isEmpty... | Creates an immutable copy of the specified map.
@param map the map to copy from
@return an immutable map copy | [
"Creates",
"an",
"immutable",
"copy",
"of",
"the",
"specified",
"map",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/Immutables.java#L196-L212 |
29,378 | infinispan/infinispan | commons/src/main/java/org/infinispan/commons/util/Immutables.java | Immutables.immutableCollectionCopy | public static <T> Collection<T> immutableCollectionCopy(Collection<T> collection) {
if (collection == null) return null;
if (collection.isEmpty()) return Collections.emptySet();
if (collection.size() == 1) return Collections.singleton(collection.iterator().next());
Collection<? extends T> copy = ObjectDuplicator.duplicateCollection(collection);
if (copy == null)
copy = attemptCopyConstructor(collection, Collection.class);
if (copy == null)
copy = new ArrayList<>(collection);
return new ImmutableCollectionWrapper<>(copy);
} | java | public static <T> Collection<T> immutableCollectionCopy(Collection<T> collection) {
if (collection == null) return null;
if (collection.isEmpty()) return Collections.emptySet();
if (collection.size() == 1) return Collections.singleton(collection.iterator().next());
Collection<? extends T> copy = ObjectDuplicator.duplicateCollection(collection);
if (copy == null)
copy = attemptCopyConstructor(collection, Collection.class);
if (copy == null)
copy = new ArrayList<>(collection);
return new ImmutableCollectionWrapper<>(copy);
} | [
"public",
"static",
"<",
"T",
">",
"Collection",
"<",
"T",
">",
"immutableCollectionCopy",
"(",
"Collection",
"<",
"T",
">",
"collection",
")",
"{",
"if",
"(",
"collection",
"==",
"null",
")",
"return",
"null",
";",
"if",
"(",
"collection",
".",
"isEmpty... | Creates a new immutable copy of the specified Collection.
@param collection the collection to copy
@return an immutable copy | [
"Creates",
"a",
"new",
"immutable",
"copy",
"of",
"the",
"specified",
"Collection",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/Immutables.java#L220-L232 |
29,379 | infinispan/infinispan | core/src/main/java/org/infinispan/util/concurrent/CommandAckCollector.java | CommandAckCollector.create | public <T> Collector<T> create(long id, Collection<Address> backupOwners, int topologyId) {
if (backupOwners.isEmpty()) {
return new PrimaryOwnerOnlyCollector<>();
}
SingleKeyCollector<T> collector = new SingleKeyCollector<>(id, backupOwners, topologyId);
BaseAckTarget prev = collectorMap.put(id, collector);
//is it possible the have a previous collector when the topology changes after the first collector is created
//in that case, the previous collector must have a lower topology id
assert prev == null || prev.topologyId < topologyId : format("replaced old collector '%s' by '%s'", prev, collector);
if (trace) {
log.tracef("Created new collector for %s. BackupOwners=%s", id, backupOwners);
}
return collector;
} | java | public <T> Collector<T> create(long id, Collection<Address> backupOwners, int topologyId) {
if (backupOwners.isEmpty()) {
return new PrimaryOwnerOnlyCollector<>();
}
SingleKeyCollector<T> collector = new SingleKeyCollector<>(id, backupOwners, topologyId);
BaseAckTarget prev = collectorMap.put(id, collector);
//is it possible the have a previous collector when the topology changes after the first collector is created
//in that case, the previous collector must have a lower topology id
assert prev == null || prev.topologyId < topologyId : format("replaced old collector '%s' by '%s'", prev, collector);
if (trace) {
log.tracef("Created new collector for %s. BackupOwners=%s", id, backupOwners);
}
return collector;
} | [
"public",
"<",
"T",
">",
"Collector",
"<",
"T",
">",
"create",
"(",
"long",
"id",
",",
"Collection",
"<",
"Address",
">",
"backupOwners",
",",
"int",
"topologyId",
")",
"{",
"if",
"(",
"backupOwners",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"ne... | Creates a collector for a single key write operation.
@param id the id from {@link CommandInvocationId}.
@param backupOwners the backup owners of the key.
@param topologyId the current topology id. | [
"Creates",
"a",
"collector",
"for",
"a",
"single",
"key",
"write",
"operation",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/util/concurrent/CommandAckCollector.java#L86-L99 |
29,380 | infinispan/infinispan | core/src/main/java/org/infinispan/util/concurrent/CommandAckCollector.java | CommandAckCollector.backupAck | public void backupAck(long id, Address from, int topologyId) {
BaseAckTarget ackTarget = collectorMap.get(id);
if (ackTarget instanceof SingleKeyCollector) {
((SingleKeyCollector) ackTarget).backupAck(topologyId, from);
} else if (ackTarget instanceof MultiTargetCollectorImpl) {
((MultiTargetCollectorImpl) ackTarget).backupAck(topologyId, from);
}
} | java | public void backupAck(long id, Address from, int topologyId) {
BaseAckTarget ackTarget = collectorMap.get(id);
if (ackTarget instanceof SingleKeyCollector) {
((SingleKeyCollector) ackTarget).backupAck(topologyId, from);
} else if (ackTarget instanceof MultiTargetCollectorImpl) {
((MultiTargetCollectorImpl) ackTarget).backupAck(topologyId, from);
}
} | [
"public",
"void",
"backupAck",
"(",
"long",
"id",
",",
"Address",
"from",
",",
"int",
"topologyId",
")",
"{",
"BaseAckTarget",
"ackTarget",
"=",
"collectorMap",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"ackTarget",
"instanceof",
"SingleKeyCollector",
")",... | Acknowledges a write operation completion in the backup owner.
@param id the id from {@link CommandInvocationId#getId()}.
@param from the backup owner.
@param topologyId the topology id. | [
"Acknowledges",
"a",
"write",
"operation",
"completion",
"in",
"the",
"backup",
"owner",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/util/concurrent/CommandAckCollector.java#L165-L172 |
29,381 | infinispan/infinispan | core/src/main/java/org/infinispan/util/concurrent/CommandAckCollector.java | CommandAckCollector.onMembersChange | public void onMembersChange(Collection<Address> members) {
Set<Address> currentMembers = new HashSet<>(members);
this.currentMembers = currentMembers;
for (BaseAckTarget<?> ackTarget : collectorMap.values()) {
ackTarget.onMembersChange(currentMembers);
}
} | java | public void onMembersChange(Collection<Address> members) {
Set<Address> currentMembers = new HashSet<>(members);
this.currentMembers = currentMembers;
for (BaseAckTarget<?> ackTarget : collectorMap.values()) {
ackTarget.onMembersChange(currentMembers);
}
} | [
"public",
"void",
"onMembersChange",
"(",
"Collection",
"<",
"Address",
">",
"members",
")",
"{",
"Set",
"<",
"Address",
">",
"currentMembers",
"=",
"new",
"HashSet",
"<>",
"(",
"members",
")",
";",
"this",
".",
"currentMembers",
"=",
"currentMembers",
";",
... | Notifies a change in member list.
@param members the new cluster members. | [
"Notifies",
"a",
"change",
"in",
"member",
"list",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/util/concurrent/CommandAckCollector.java#L213-L219 |
29,382 | infinispan/infinispan | core/src/main/java/org/infinispan/commands/functional/Mutations.java | Mutations.writeTo | static <K, V, T, R> void writeTo(ObjectOutput output, Mutation<K, V, R> mutation) throws IOException {
BaseMutation bm = (BaseMutation) mutation;
DataConversion.writeTo(output, bm.keyDataConversion);
DataConversion.writeTo(output, bm.valueDataConversion);
byte type = mutation.type();
output.writeByte(type);
switch (type) {
case ReadWrite.TYPE:
output.writeObject(((ReadWrite<K, V, ?>) mutation).f);
break;
case ReadWriteWithValue.TYPE:
ReadWriteWithValue<K, V, T, R> rwwv = (ReadWriteWithValue<K, V, T, R>) mutation;
output.writeObject(rwwv.argument);
output.writeObject(rwwv.f);
break;
case Write.TYPE:
output.writeObject(((Write<K, V>) mutation).f);
break;
case WriteWithValue.TYPE:
WriteWithValue<K, V, T> wwv = (WriteWithValue<K, V, T>) mutation;
output.writeObject(wwv.argument);
output.writeObject(wwv.f);
break;
}
} | java | static <K, V, T, R> void writeTo(ObjectOutput output, Mutation<K, V, R> mutation) throws IOException {
BaseMutation bm = (BaseMutation) mutation;
DataConversion.writeTo(output, bm.keyDataConversion);
DataConversion.writeTo(output, bm.valueDataConversion);
byte type = mutation.type();
output.writeByte(type);
switch (type) {
case ReadWrite.TYPE:
output.writeObject(((ReadWrite<K, V, ?>) mutation).f);
break;
case ReadWriteWithValue.TYPE:
ReadWriteWithValue<K, V, T, R> rwwv = (ReadWriteWithValue<K, V, T, R>) mutation;
output.writeObject(rwwv.argument);
output.writeObject(rwwv.f);
break;
case Write.TYPE:
output.writeObject(((Write<K, V>) mutation).f);
break;
case WriteWithValue.TYPE:
WriteWithValue<K, V, T> wwv = (WriteWithValue<K, V, T>) mutation;
output.writeObject(wwv.argument);
output.writeObject(wwv.f);
break;
}
} | [
"static",
"<",
"K",
",",
"V",
",",
"T",
",",
"R",
">",
"void",
"writeTo",
"(",
"ObjectOutput",
"output",
",",
"Mutation",
"<",
"K",
",",
"V",
",",
"R",
">",
"mutation",
")",
"throws",
"IOException",
"{",
"BaseMutation",
"bm",
"=",
"(",
"BaseMutation"... | No need to occupy externalizer ids when we have a limited set of options | [
"No",
"need",
"to",
"occupy",
"externalizer",
"ids",
"when",
"we",
"have",
"a",
"limited",
"set",
"of",
"options"
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/commands/functional/Mutations.java#L26-L50 |
29,383 | infinispan/infinispan | core/src/main/java/org/infinispan/cache/impl/CacheImpl.java | CacheImpl.preStart | @Inject
public void preStart() {
// We have to do this before start, since some components may start before the actual cache and they
// have to have access to the default metadata on some operations
defaultMetadata = new EmbeddedMetadata.Builder()
.lifespan(config.expiration().lifespan()).maxIdle(config.expiration().maxIdle()).build();
transactional = config.transaction().transactionMode().isTransactional();
batchingEnabled = config.invocationBatching().enabled();
} | java | @Inject
public void preStart() {
// We have to do this before start, since some components may start before the actual cache and they
// have to have access to the default metadata on some operations
defaultMetadata = new EmbeddedMetadata.Builder()
.lifespan(config.expiration().lifespan()).maxIdle(config.expiration().maxIdle()).build();
transactional = config.transaction().transactionMode().isTransactional();
batchingEnabled = config.invocationBatching().enabled();
} | [
"@",
"Inject",
"public",
"void",
"preStart",
"(",
")",
"{",
"// We have to do this before start, since some components may start before the actual cache and they",
"// have to have access to the default metadata on some operations",
"defaultMetadata",
"=",
"new",
"EmbeddedMetadata",
".",... | of EncoderCache. ATM there's not method to invoke @Start method, just wireDependencies | [
"of",
"EncoderCache",
".",
"ATM",
"there",
"s",
"not",
"method",
"to",
"invoke"
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/cache/impl/CacheImpl.java#L197-L205 |
29,384 | infinispan/infinispan | core/src/main/java/org/infinispan/cache/impl/CacheImpl.java | CacheImpl.getCacheName | @ManagedAttribute(
description = "Returns the cache name",
displayName = "Cache name",
dataType = DataType.TRAIT,
displayType = DisplayType.SUMMARY
)
public String getCacheName() {
String name = getName().equals(BasicCacheContainer.DEFAULT_CACHE_NAME) ? "Default Cache" : getName();
return name + "(" + getCacheConfiguration().clustering().cacheMode().toString().toLowerCase() + ")";
} | java | @ManagedAttribute(
description = "Returns the cache name",
displayName = "Cache name",
dataType = DataType.TRAIT,
displayType = DisplayType.SUMMARY
)
public String getCacheName() {
String name = getName().equals(BasicCacheContainer.DEFAULT_CACHE_NAME) ? "Default Cache" : getName();
return name + "(" + getCacheConfiguration().clustering().cacheMode().toString().toLowerCase() + ")";
} | [
"@",
"ManagedAttribute",
"(",
"description",
"=",
"\"Returns the cache name\"",
",",
"displayName",
"=",
"\"Cache name\"",
",",
"dataType",
"=",
"DataType",
".",
"TRAIT",
",",
"displayType",
"=",
"DisplayType",
".",
"SUMMARY",
")",
"public",
"String",
"getCacheName"... | Returns the cache name. If this is the default cache, it returns a more friendly name. | [
"Returns",
"the",
"cache",
"name",
".",
"If",
"this",
"is",
"the",
"default",
"cache",
"it",
"returns",
"a",
"more",
"friendly",
"name",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/cache/impl/CacheImpl.java#L1344-L1353 |
29,385 | infinispan/infinispan | server/integration/infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/LocalCacheConfigurationAdd.java | LocalCacheConfigurationAdd.createOperation | static ModelNode createOperation(ModelNode address, ModelNode model) throws OperationFailedException {
ModelNode operation = Util.getEmptyOperation(ADD, address);
INSTANCE.populate(model, operation);
return operation;
} | java | static ModelNode createOperation(ModelNode address, ModelNode model) throws OperationFailedException {
ModelNode operation = Util.getEmptyOperation(ADD, address);
INSTANCE.populate(model, operation);
return operation;
} | [
"static",
"ModelNode",
"createOperation",
"(",
"ModelNode",
"address",
",",
"ModelNode",
"model",
")",
"throws",
"OperationFailedException",
"{",
"ModelNode",
"operation",
"=",
"Util",
".",
"getEmptyOperation",
"(",
"ADD",
",",
"address",
")",
";",
"INSTANCE",
"."... | used to create subsystem description | [
"used",
"to",
"create",
"subsystem",
"description"
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/integration/infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/LocalCacheConfigurationAdd.java#L46-L50 |
29,386 | infinispan/infinispan | core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java | AbstractComponentRegistry.registerComponent | public final void registerComponent(Object component, Class<?> type) {
registerComponent(component, type.getName(), type.equals(component.getClass()));
} | java | public final void registerComponent(Object component, Class<?> type) {
registerComponent(component, type.getName(), type.equals(component.getClass()));
} | [
"public",
"final",
"void",
"registerComponent",
"(",
"Object",
"component",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"registerComponent",
"(",
"component",
",",
"type",
".",
"getName",
"(",
")",
",",
"type",
".",
"equals",
"(",
"component",
".",
"g... | Registers a component in the registry under the given type, and injects any dependencies needed.
Note: Until 9.4, if a component of this type already existed, it was overwritten.
@param component component to register
@param type type of component
@throws org.infinispan.commons.CacheConfigurationException If a component is already registered with that
name, or if a dependency cannot be resolved | [
"Registers",
"a",
"component",
"in",
"the",
"registry",
"under",
"the",
"given",
"type",
"and",
"injects",
"any",
"dependencies",
"needed",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java#L115-L117 |
29,387 | infinispan/infinispan | core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java | AbstractComponentRegistry.getFactory | protected AbstractComponentFactory getFactory(Class<?> componentClass) {
String cfClass = getComponentMetadataRepo().findFactoryForComponent(componentClass);
if (cfClass == null) {
throw new CacheConfigurationException("No registered default factory for component '" + componentClass + "' found!");
}
return basicComponentRegistry.getComponent(cfClass, AbstractComponentFactory.class).wired();
} | java | protected AbstractComponentFactory getFactory(Class<?> componentClass) {
String cfClass = getComponentMetadataRepo().findFactoryForComponent(componentClass);
if (cfClass == null) {
throw new CacheConfigurationException("No registered default factory for component '" + componentClass + "' found!");
}
return basicComponentRegistry.getComponent(cfClass, AbstractComponentFactory.class).wired();
} | [
"protected",
"AbstractComponentFactory",
"getFactory",
"(",
"Class",
"<",
"?",
">",
"componentClass",
")",
"{",
"String",
"cfClass",
"=",
"getComponentMetadataRepo",
"(",
")",
".",
"findFactoryForComponent",
"(",
"componentClass",
")",
";",
"if",
"(",
"cfClass",
"... | Retrieves a component factory instance capable of constructing components of a specified type. If the factory
doesn't exist in the registry, one is created.
@param componentClass type of component to construct
@return component factory capable of constructing such components | [
"Retrieves",
"a",
"component",
"factory",
"instance",
"capable",
"of",
"constructing",
"components",
"of",
"a",
"specified",
"type",
".",
"If",
"the",
"factory",
"doesn",
"t",
"exist",
"in",
"the",
"registry",
"one",
"is",
"created",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java#L182-L188 |
29,388 | infinispan/infinispan | core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java | AbstractComponentRegistry.getComponent | @SuppressWarnings("unchecked")
public <T> T getComponent(Class<T> type) {
String className = type.getName();
return (T) getComponent(type, className);
} | java | @SuppressWarnings("unchecked")
public <T> T getComponent(Class<T> type) {
String className = type.getName();
return (T) getComponent(type, className);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"getComponent",
"(",
"Class",
"<",
"T",
">",
"type",
")",
"{",
"String",
"className",
"=",
"type",
".",
"getName",
"(",
")",
";",
"return",
"(",
"T",
")",
"getComponent",... | Retrieves a component of a specified type from the registry, or null if it cannot be found.
@param type type to find
@return component, or null | [
"Retrieves",
"a",
"component",
"of",
"a",
"specified",
"type",
"from",
"the",
"registry",
"or",
"null",
"if",
"it",
"cannot",
"be",
"found",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java#L215-L219 |
29,389 | infinispan/infinispan | core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java | AbstractComponentRegistry.handleLifecycleTransitionFailure | private void handleLifecycleTransitionFailure(Throwable t) {
if (t.getCause() != null && t.getCause() instanceof CacheConfigurationException)
throw (CacheConfigurationException) t.getCause();
else if (t.getCause() != null && t.getCause() instanceof InvocationTargetException && t.getCause().getCause() != null && t.getCause().getCause() instanceof CacheConfigurationException)
throw (CacheConfigurationException) t.getCause().getCause();
else if (t instanceof CacheException)
throw (CacheException) t;
else if (t instanceof RuntimeException)
throw (RuntimeException) t;
else if (t instanceof Error)
throw (Error) t;
else
throw new CacheException(t);
} | java | private void handleLifecycleTransitionFailure(Throwable t) {
if (t.getCause() != null && t.getCause() instanceof CacheConfigurationException)
throw (CacheConfigurationException) t.getCause();
else if (t.getCause() != null && t.getCause() instanceof InvocationTargetException && t.getCause().getCause() != null && t.getCause().getCause() instanceof CacheConfigurationException)
throw (CacheConfigurationException) t.getCause().getCause();
else if (t instanceof CacheException)
throw (CacheException) t;
else if (t instanceof RuntimeException)
throw (RuntimeException) t;
else if (t instanceof Error)
throw (Error) t;
else
throw new CacheException(t);
} | [
"private",
"void",
"handleLifecycleTransitionFailure",
"(",
"Throwable",
"t",
")",
"{",
"if",
"(",
"t",
".",
"getCause",
"(",
")",
"!=",
"null",
"&&",
"t",
".",
"getCause",
"(",
")",
"instanceof",
"CacheConfigurationException",
")",
"throw",
"(",
"CacheConfigu... | Sets the cacheStatus to FAILED and re-throws the problem as one of the declared types. Converts any
non-RuntimeException Exception to CacheException.
@param t throwable thrown during failure | [
"Sets",
"the",
"cacheStatus",
"to",
"FAILED",
"and",
"re",
"-",
"throws",
"the",
"problem",
"as",
"one",
"of",
"the",
"declared",
"types",
".",
"Converts",
"any",
"non",
"-",
"RuntimeException",
"Exception",
"to",
"CacheException",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java#L399-L412 |
29,390 | infinispan/infinispan | core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java | AbstractComponentRegistry.getRegisteredComponents | public Set<Component> getRegisteredComponents() {
Set<Component> set = new HashSet<>();
for (ComponentRef<?> c : basicComponentRegistry.getRegisteredComponents()) {
ComponentMetadata metadata = c.wired() != null ?
componentMetadataRepo.getComponentMetadata(c.wired().getClass()) : null;
Component component = new Component(c, metadata);
set.add(component);
}
return set;
} | java | public Set<Component> getRegisteredComponents() {
Set<Component> set = new HashSet<>();
for (ComponentRef<?> c : basicComponentRegistry.getRegisteredComponents()) {
ComponentMetadata metadata = c.wired() != null ?
componentMetadataRepo.getComponentMetadata(c.wired().getClass()) : null;
Component component = new Component(c, metadata);
set.add(component);
}
return set;
} | [
"public",
"Set",
"<",
"Component",
">",
"getRegisteredComponents",
"(",
")",
"{",
"Set",
"<",
"Component",
">",
"set",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"ComponentRef",
"<",
"?",
">",
"c",
":",
"basicComponentRegistry",
".",
"getReg... | Returns an immutable set containing all the components that exists in the repository at this moment.
@return a set of components | [
"Returns",
"an",
"immutable",
"set",
"containing",
"all",
"the",
"components",
"that",
"exists",
"in",
"the",
"repository",
"at",
"this",
"moment",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java#L445-L454 |
29,391 | infinispan/infinispan | lucene/lucene-directory/src/main/java/org/infinispan/lucene/readlocks/DistributedSegmentReadLocker.java | DistributedSegmentReadLocker.isMultiChunked | private boolean isMultiChunked(final String filename) {
final FileCacheKey fileCacheKey = new FileCacheKey(indexName, filename, affinitySegmentId);
final FileMetadata fileMetadata = metadataCache.get(fileCacheKey);
if (fileMetadata==null) {
//This might happen under high load when the metadata is being written
//using putAsync; in such case we return true as it's the safest option.
//Skipping the readlocks is just a performance optimisation, and this
//condition is extremely rare.
return true;
}
else {
return fileMetadata.isMultiChunked();
}
} | java | private boolean isMultiChunked(final String filename) {
final FileCacheKey fileCacheKey = new FileCacheKey(indexName, filename, affinitySegmentId);
final FileMetadata fileMetadata = metadataCache.get(fileCacheKey);
if (fileMetadata==null) {
//This might happen under high load when the metadata is being written
//using putAsync; in such case we return true as it's the safest option.
//Skipping the readlocks is just a performance optimisation, and this
//condition is extremely rare.
return true;
}
else {
return fileMetadata.isMultiChunked();
}
} | [
"private",
"boolean",
"isMultiChunked",
"(",
"final",
"String",
"filename",
")",
"{",
"final",
"FileCacheKey",
"fileCacheKey",
"=",
"new",
"FileCacheKey",
"(",
"indexName",
",",
"filename",
",",
"affinitySegmentId",
")",
";",
"final",
"FileMetadata",
"fileMetadata",... | Evaluates if the file is potentially being stored as fragmented into multiple chunks;
when it's a single chunk we don't need to apply readlocks.
@param filename
@return true if it is definitely fragmented, or if it's possibly fragmented. | [
"Evaluates",
"if",
"the",
"file",
"is",
"potentially",
"being",
"stored",
"as",
"fragmented",
"into",
"multiple",
"chunks",
";",
"when",
"it",
"s",
"a",
"single",
"chunk",
"we",
"don",
"t",
"need",
"to",
"apply",
"readlocks",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/lucene/lucene-directory/src/main/java/org/infinispan/lucene/readlocks/DistributedSegmentReadLocker.java#L108-L121 |
29,392 | infinispan/infinispan | lucene/lucene-directory/src/main/java/org/infinispan/lucene/readlocks/DistributedSegmentReadLocker.java | DistributedSegmentReadLocker.acquireReadLock | @Override
public boolean acquireReadLock(String filename) {
FileReadLockKey readLockKey = new FileReadLockKey(indexName, filename, affinitySegmentId);
Integer lockValue = locksCache.get(readLockKey);
boolean done = false;
while (done == false) {
if (lockValue != null) {
int refCount = lockValue.intValue();
if (refCount == 0) {
// too late: in case refCount==0 the delete is being performed
return false;
}
Integer newValue = Integer.valueOf(refCount + 1);
done = locksCache.replace(readLockKey, lockValue, newValue);
if ( ! done) {
lockValue = locksCache.get(readLockKey);
}
} else {
// readLocks are not stored, so if there's no value assume it's ==1, which means
// existing file, not deleted, nobody else owning a read lock. but check for ambiguity
lockValue = locksCache.putIfAbsent(readLockKey, 2);
done = (null == lockValue);
if (done) {
// have to check now that the fileKey still exists to prevent the race condition of
// T1 fileKey exists - T2 delete file and remove readlock - T1 putIfAbsent(readlock, 2)
final FileCacheKey fileKey = new FileCacheKey(indexName, filename, affinitySegmentId);
if (metadataCache.get(fileKey) == null) {
locksCache.withFlags(Flag.IGNORE_RETURN_VALUES).removeAsync(readLockKey);
return false;
}
}
}
}
return true;
} | java | @Override
public boolean acquireReadLock(String filename) {
FileReadLockKey readLockKey = new FileReadLockKey(indexName, filename, affinitySegmentId);
Integer lockValue = locksCache.get(readLockKey);
boolean done = false;
while (done == false) {
if (lockValue != null) {
int refCount = lockValue.intValue();
if (refCount == 0) {
// too late: in case refCount==0 the delete is being performed
return false;
}
Integer newValue = Integer.valueOf(refCount + 1);
done = locksCache.replace(readLockKey, lockValue, newValue);
if ( ! done) {
lockValue = locksCache.get(readLockKey);
}
} else {
// readLocks are not stored, so if there's no value assume it's ==1, which means
// existing file, not deleted, nobody else owning a read lock. but check for ambiguity
lockValue = locksCache.putIfAbsent(readLockKey, 2);
done = (null == lockValue);
if (done) {
// have to check now that the fileKey still exists to prevent the race condition of
// T1 fileKey exists - T2 delete file and remove readlock - T1 putIfAbsent(readlock, 2)
final FileCacheKey fileKey = new FileCacheKey(indexName, filename, affinitySegmentId);
if (metadataCache.get(fileKey) == null) {
locksCache.withFlags(Flag.IGNORE_RETURN_VALUES).removeAsync(readLockKey);
return false;
}
}
}
}
return true;
} | [
"@",
"Override",
"public",
"boolean",
"acquireReadLock",
"(",
"String",
"filename",
")",
"{",
"FileReadLockKey",
"readLockKey",
"=",
"new",
"FileReadLockKey",
"(",
"indexName",
",",
"filename",
",",
"affinitySegmentId",
")",
";",
"Integer",
"lockValue",
"=",
"lock... | Acquires a readlock on all chunks for this file, to make sure chunks are not deleted while
iterating on the group. This is needed to avoid an eager lock on all elements.
If no value is found in the cache, a disambiguation procedure is needed: not value
might mean both "existing, no readlocks, no deletions in progress", but also "not existent file".
The first possibility is coded as no value to avoid storing readlocks in a permanent store,
which would unnecessarily slow down and provide unwanted long term storage of the lock;
so the value is treated as one if not found, but obviously it's also not found for non-existent
or concurrently deleted files.
@param filename the name of the "file" for which a readlock is requested
@see #deleteOrReleaseReadLock(String) | [
"Acquires",
"a",
"readlock",
"on",
"all",
"chunks",
"for",
"this",
"file",
"to",
"make",
"sure",
"chunks",
"are",
"not",
"deleted",
"while",
"iterating",
"on",
"the",
"group",
".",
"This",
"is",
"needed",
"to",
"avoid",
"an",
"eager",
"lock",
"on",
"all"... | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/lucene/lucene-directory/src/main/java/org/infinispan/lucene/readlocks/DistributedSegmentReadLocker.java#L138-L172 |
29,393 | infinispan/infinispan | client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transaction/AbstractTransactionTable.java | AbstractTransactionTable.forgetTransaction | void forgetTransaction(Xid xid) {
try {
TransactionOperationFactory factory = assertStartedAndReturnFactory();
ForgetTransactionOperation operation = factory.newForgetTransactionOperation(xid);
//async.
//we don't need the reply from server. If we can't forget for some reason (timeouts or other exception),
// the server reaper will cleanup the completed transactions after a while. (default 1 min)
operation.execute();
} catch (Exception e) {
if (isTraceLogEnabled()) {
getLog().tracef(e, "Exception in forget transaction xid=%s", xid);
}
}
} | java | void forgetTransaction(Xid xid) {
try {
TransactionOperationFactory factory = assertStartedAndReturnFactory();
ForgetTransactionOperation operation = factory.newForgetTransactionOperation(xid);
//async.
//we don't need the reply from server. If we can't forget for some reason (timeouts or other exception),
// the server reaper will cleanup the completed transactions after a while. (default 1 min)
operation.execute();
} catch (Exception e) {
if (isTraceLogEnabled()) {
getLog().tracef(e, "Exception in forget transaction xid=%s", xid);
}
}
} | [
"void",
"forgetTransaction",
"(",
"Xid",
"xid",
")",
"{",
"try",
"{",
"TransactionOperationFactory",
"factory",
"=",
"assertStartedAndReturnFactory",
"(",
")",
";",
"ForgetTransactionOperation",
"operation",
"=",
"factory",
".",
"newForgetTransactionOperation",
"(",
"xi... | Tells the server to forget this transaction.
@param xid The transaction {@link Xid}. | [
"Tells",
"the",
"server",
"to",
"forget",
"this",
"transaction",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transaction/AbstractTransactionTable.java#L83-L96 |
29,394 | infinispan/infinispan | client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transaction/AbstractTransactionTable.java | AbstractTransactionTable.fetchPreparedTransactions | CompletableFuture<Collection<Xid>> fetchPreparedTransactions() {
try {
TransactionOperationFactory factory = assertStartedAndReturnFactory();
return factory.newRecoveryOperation().execute();
} catch (Exception e) {
if (isTraceLogEnabled()) {
getLog().trace("Exception while fetching prepared transactions", e);
}
return CompletableFuture.completedFuture(Collections.emptyList());
}
} | java | CompletableFuture<Collection<Xid>> fetchPreparedTransactions() {
try {
TransactionOperationFactory factory = assertStartedAndReturnFactory();
return factory.newRecoveryOperation().execute();
} catch (Exception e) {
if (isTraceLogEnabled()) {
getLog().trace("Exception while fetching prepared transactions", e);
}
return CompletableFuture.completedFuture(Collections.emptyList());
}
} | [
"CompletableFuture",
"<",
"Collection",
"<",
"Xid",
">",
">",
"fetchPreparedTransactions",
"(",
")",
"{",
"try",
"{",
"TransactionOperationFactory",
"factory",
"=",
"assertStartedAndReturnFactory",
"(",
")",
";",
"return",
"factory",
".",
"newRecoveryOperation",
"(",
... | It requests the server for all in-doubt prepared transactions, to be handled by the recovery process.
@return A {@link CompletableFuture} which is completed with a collections of transaction {@link Xid}. | [
"It",
"requests",
"the",
"server",
"for",
"all",
"in",
"-",
"doubt",
"prepared",
"transactions",
"to",
"be",
"handled",
"by",
"the",
"recovery",
"process",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transaction/AbstractTransactionTable.java#L103-L113 |
29,395 | infinispan/infinispan | core/src/main/java/org/infinispan/util/concurrent/CompletionStages.java | CompletionStages.allOf | public static CompletionStage<Void> allOf(CompletionStage<Void> first, CompletionStage<Void> second) {
if (!isCompletedSuccessfully(first)) {
if (isCompletedSuccessfully(second)) {
return first;
} else {
return CompletionStages.aggregateCompletionStage().dependsOn(first).dependsOn(second).freeze();
}
}
return second;
} | java | public static CompletionStage<Void> allOf(CompletionStage<Void> first, CompletionStage<Void> second) {
if (!isCompletedSuccessfully(first)) {
if (isCompletedSuccessfully(second)) {
return first;
} else {
return CompletionStages.aggregateCompletionStage().dependsOn(first).dependsOn(second).freeze();
}
}
return second;
} | [
"public",
"static",
"CompletionStage",
"<",
"Void",
">",
"allOf",
"(",
"CompletionStage",
"<",
"Void",
">",
"first",
",",
"CompletionStage",
"<",
"Void",
">",
"second",
")",
"{",
"if",
"(",
"!",
"isCompletedSuccessfully",
"(",
"first",
")",
")",
"{",
"if",... | Returns a CompletableStage that completes when both of the provides CompletionStages complete. This method
may choose to return either of the argument if the other is complete or a new instance completely.
@param first the first CompletionStage
@param second the second CompletionStage
@return a CompletionStage that is complete when both of the given CompletionStages complete | [
"Returns",
"a",
"CompletableStage",
"that",
"completes",
"when",
"both",
"of",
"the",
"provides",
"CompletionStages",
"complete",
".",
"This",
"method",
"may",
"choose",
"to",
"return",
"either",
"of",
"the",
"argument",
"if",
"the",
"other",
"is",
"complete",
... | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/util/concurrent/CompletionStages.java#L81-L90 |
29,396 | infinispan/infinispan | core/src/main/java/org/infinispan/util/concurrent/CompletionStages.java | CompletionStages.allOf | public static CompletionStage<Void> allOf(CompletionStage<?>... stages) {
AggregateCompletionStage<Void> aggregateCompletionStage = null;
for (CompletionStage<?> stage : stages) {
if (!isCompletedSuccessfully(stage)) {
if (aggregateCompletionStage == null) {
aggregateCompletionStage = CompletionStages.aggregateCompletionStage();
}
aggregateCompletionStage.dependsOn(stage);
}
}
return aggregateCompletionStage != null ? aggregateCompletionStage.freeze() : CompletableFutures.completedNull();
} | java | public static CompletionStage<Void> allOf(CompletionStage<?>... stages) {
AggregateCompletionStage<Void> aggregateCompletionStage = null;
for (CompletionStage<?> stage : stages) {
if (!isCompletedSuccessfully(stage)) {
if (aggregateCompletionStage == null) {
aggregateCompletionStage = CompletionStages.aggregateCompletionStage();
}
aggregateCompletionStage.dependsOn(stage);
}
}
return aggregateCompletionStage != null ? aggregateCompletionStage.freeze() : CompletableFutures.completedNull();
} | [
"public",
"static",
"CompletionStage",
"<",
"Void",
">",
"allOf",
"(",
"CompletionStage",
"<",
"?",
">",
"...",
"stages",
")",
"{",
"AggregateCompletionStage",
"<",
"Void",
">",
"aggregateCompletionStage",
"=",
"null",
";",
"for",
"(",
"CompletionStage",
"<",
... | Returns a CompletionStage that completes when all of the provided stages complete, either normally or via
exception. If one or more states complete exceptionally the returned CompletionStage will complete with the
exception of one of these. If no CompletionStages are provided, returns a CompletionStage completed with the value
null.
@param stages the CompletionStages
@return a CompletionStage that is completed when all of the given CompletionStages complete | [
"Returns",
"a",
"CompletionStage",
"that",
"completes",
"when",
"all",
"of",
"the",
"provided",
"stages",
"complete",
"either",
"normally",
"or",
"via",
"exception",
".",
"If",
"one",
"or",
"more",
"states",
"complete",
"exceptionally",
"the",
"returned",
"Compl... | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/util/concurrent/CompletionStages.java#L100-L112 |
29,397 | infinispan/infinispan | query/src/main/java/org/infinispan/query/clustered/commandworkers/CQWorker.java | CQWorker.extractKey | Object extractKey(DocumentExtractor extractor, int docIndex) {
String strKey;
try {
strKey = (String) extractor.extract(docIndex).getId();
} catch (IOException e) {
throw new SearchException("Error while extracting key", e);
}
return keyTransformationHandler.stringToKey(strKey);
} | java | Object extractKey(DocumentExtractor extractor, int docIndex) {
String strKey;
try {
strKey = (String) extractor.extract(docIndex).getId();
} catch (IOException e) {
throw new SearchException("Error while extracting key", e);
}
return keyTransformationHandler.stringToKey(strKey);
} | [
"Object",
"extractKey",
"(",
"DocumentExtractor",
"extractor",
",",
"int",
"docIndex",
")",
"{",
"String",
"strKey",
";",
"try",
"{",
"strKey",
"=",
"(",
"String",
")",
"extractor",
".",
"extract",
"(",
"docIndex",
")",
".",
"getId",
"(",
")",
";",
"}",
... | Utility to extract the cache key of a DocumentExtractor and use the KeyTransformationHandler to turn the string
into the actual key object.
@param extractor
@param docIndex
@return | [
"Utility",
"to",
"extract",
"the",
"cache",
"key",
"of",
"a",
"DocumentExtractor",
"and",
"use",
"the",
"KeyTransformationHandler",
"to",
"turn",
"the",
"string",
"into",
"the",
"actual",
"key",
"object",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/query/src/main/java/org/infinispan/query/clustered/commandworkers/CQWorker.java#L71-L80 |
29,398 | infinispan/infinispan | core/src/main/java/org/infinispan/statetransfer/InboundTransferTask.java | InboundTransferTask.requestSegments | public CompletableFuture<Void> requestSegments() {
return startTransfer(applyState ? StateRequestCommand.Type.START_STATE_TRANSFER : StateRequestCommand.Type.START_CONSISTENCY_CHECK);
} | java | public CompletableFuture<Void> requestSegments() {
return startTransfer(applyState ? StateRequestCommand.Type.START_STATE_TRANSFER : StateRequestCommand.Type.START_CONSISTENCY_CHECK);
} | [
"public",
"CompletableFuture",
"<",
"Void",
">",
"requestSegments",
"(",
")",
"{",
"return",
"startTransfer",
"(",
"applyState",
"?",
"StateRequestCommand",
".",
"Type",
".",
"START_STATE_TRANSFER",
":",
"StateRequestCommand",
".",
"Type",
".",
"START_CONSISTENCY_CHEC... | Send START_STATE_TRANSFER request to source node.
@return a {@code CompletableFuture} that completes when the transfer is done. | [
"Send",
"START_STATE_TRANSFER",
"request",
"to",
"source",
"node",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/statetransfer/InboundTransferTask.java#L115-L117 |
29,399 | infinispan/infinispan | core/src/main/java/org/infinispan/statetransfer/InboundTransferTask.java | InboundTransferTask.cancelSegments | public void cancelSegments(IntSet cancelledSegments) {
if (isCancelled) {
throw new IllegalArgumentException("The task is already cancelled.");
}
if (trace) {
log.tracef("Partially cancelling inbound state transfer from node %s, segments %s", source, cancelledSegments);
}
synchronized (segments) {
// healthy paranoia
if (!segments.containsAll(cancelledSegments)) {
throw new IllegalArgumentException("Some of the specified segments cannot be cancelled because they were not previously requested");
}
unfinishedSegments.removeAll(cancelledSegments);
if (unfinishedSegments.isEmpty()) {
isCancelled = true;
}
}
sendCancelCommand(cancelledSegments);
if (isCancelled) {
notifyCompletion(false);
}
} | java | public void cancelSegments(IntSet cancelledSegments) {
if (isCancelled) {
throw new IllegalArgumentException("The task is already cancelled.");
}
if (trace) {
log.tracef("Partially cancelling inbound state transfer from node %s, segments %s", source, cancelledSegments);
}
synchronized (segments) {
// healthy paranoia
if (!segments.containsAll(cancelledSegments)) {
throw new IllegalArgumentException("Some of the specified segments cannot be cancelled because they were not previously requested");
}
unfinishedSegments.removeAll(cancelledSegments);
if (unfinishedSegments.isEmpty()) {
isCancelled = true;
}
}
sendCancelCommand(cancelledSegments);
if (isCancelled) {
notifyCompletion(false);
}
} | [
"public",
"void",
"cancelSegments",
"(",
"IntSet",
"cancelledSegments",
")",
"{",
"if",
"(",
"isCancelled",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The task is already cancelled.\"",
")",
";",
"}",
"if",
"(",
"trace",
")",
"{",
"log",
".",
... | Cancels a set of segments and marks them as finished.
If all segments are cancelled then the whole task is cancelled, as if {@linkplain #cancel()} was called.
@param cancelledSegments the segments to be cancelled | [
"Cancels",
"a",
"set",
"of",
"segments",
"and",
"marks",
"them",
"as",
"finished",
"."
] | 7c62b94886c3febb4774ae8376acf2baa0265ab5 | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/statetransfer/InboundTransferTask.java#L170-L196 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.