Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
297,300
CharsetDecoder () { return new Native2AsciiCharsetDecoder(this); }
newDecoder
297,301
CharsetEncoder () { return new Native2AsciiCharsetEncoder(this); }
newEncoder
297,302
String (String baseCharsetName) { if (baseCharsetName == null) baseCharsetName = DEFAULT_ENCODING_NAME; return NAME_PREFIX + baseCharsetName; }
makeNative2AsciiEncodingName
297,303
Charset (String charsetName) { if (charsetName.startsWith(NAME_PREFIX)) { Native2AsciiCharset cached = cache.get(charsetName); if (cached == null) { cached = new Native2AsciiCharset(charsetName); Native2AsciiCharset prev = cache.putIfAbsent(charsetName, cached); if (prev != null) cached = prev; } return cached; } return null; }
forName
297,304
Charset (Charset baseCharset) { return forName(NAME_PREFIX + baseCharset.name()); }
wrap
297,305
Charset (Charset charset) { if (charset instanceof Native2AsciiCharset) { return ((Native2AsciiCharset)charset).getBaseCharset(); } return charset; }
nativeToBaseCharset
297,306
CoderResult (CharBuffer in, ByteBuffer out) { while (in.position() < in.limit()) { in.mark(); try { char c = in.get(); if (c < '\u0080') { ByteBuffer byteBuffer = myBaseCharset.encode(Character.toString(c)); out.put(byteBuffer); } else { if (out.remaining() < 6) throw new BufferOverflowException(); out.put((byte)'\\'); out.put((byte)'u'); out.put(toHexChar(c >> 12)); out.put(toHexChar((c >> 8) & 0xf)); out.put(toHexChar((c >> 4) & 0xf)); out.put(toHexChar(c & 0xf)); } } catch (BufferUnderflowException e) { in.reset(); } catch (BufferOverflowException e) { in.reset(); return CoderResult.OVERFLOW; } } return CoderResult.UNDERFLOW; }
encodeLoop
297,307
byte (int digit) { if (digit < 10) { return (byte)('0' + digit); } return (byte)(ANCHOR - 10 + digit); }
toHexChar
297,308
void () { super.implReset(); myOutBuffer = new StringBuilder(); }
implReset
297,309
CoderResult (CharBuffer out) { return doFlush(out); }
implFlush
297,310
CoderResult (final CharBuffer out) { if (myOutBuffer.length() != 0) { int remaining = out.remaining(); int outLen = Math.min(remaining, myOutBuffer.length()); out.append(myOutBuffer, 0, outLen); myOutBuffer.delete(0, outLen); if (myOutBuffer.length() != 0) return CoderResult.OVERFLOW; } return CoderResult.UNDERFLOW; }
doFlush
297,311
CoderResult (ByteBuffer in, CharBuffer out) { try { CoderResult coderResult = doFlush(out); if (coderResult == CoderResult.OVERFLOW) return CoderResult.OVERFLOW; int start = in.position(); byte[] buf = new byte[4]; while (in.position() < in.limit()) { in.mark(); final byte b = in.get(); if (b == '\\') { decodeArray(in.array(), start, in.position()-1); byte next = in.get(); if (next == 'u') { buf[0] = in.get(); buf[1] = in.get(); buf[2] = in.get(); buf[3] = in.get(); char decoded = unicode(buf); if (decoded == INVALID_CHAR) { myOutBuffer.append("\\u"); myOutBuffer.append((char)buf[0]); myOutBuffer.append((char)buf[1]); myOutBuffer.append((char)buf[2]); myOutBuffer.append((char)buf[3]); } else { myOutBuffer.append(decoded); } } else { myOutBuffer.append("\\"); myOutBuffer.append((char)next); } start = in.position(); } } decodeArray(in.array(), start, in.position()); } catch (BufferUnderflowException e) { in.reset(); } return doFlush(out); }
decodeLoop
297,312
void (final byte[] buf, int start, int end) { if (end <= start) return; ByteBuffer byteBuffer = ByteBuffer.wrap(buf, start, end-start); CharBuffer charBuffer = myBaseCharset.decode(byteBuffer); myOutBuffer.append(charBuffer); }
decodeArray
297,313
char (byte[] ord) { int d1 = Character.digit((char)ord[0], 16); if (d1 == -1) return INVALID_CHAR; int d2 = Character.digit((char)ord[1], 16); if (d2 == -1) return INVALID_CHAR; int d3 = Character.digit((char)ord[2], 16); if (d3 == -1) return INVALID_CHAR; int d4 = Character.digit((char)ord[3], 16); if (d4 == -1) return INVALID_CHAR; int b1 = (d1 << 12) & 0xF000; int b2 = (d2 << 8) & 0x0F00; int b3 = (d3 << 4) & 0x00F0; int b4 = (d4) & 0x000F; int code = b1 | b2 | b3 | b4; if (Character.isWhitespace((char)code)) return INVALID_CHAR; return (char)code; }
unicode
297,314
void (boolean headless) { System.setProperty("java.util.concurrent.ForkJoinPool.common.threadFactory", IdeaForkJoinWorkerThreadFactory.class.getName()); boolean parallelismWasNotSpecified = System.getProperty("java.util.concurrent.ForkJoinPool.common.parallelism") == null; if (parallelismWasNotSpecified) { int N_CPU = Runtime.getRuntime().availableProcessors(); // By default, FJP initialized with the parallelism=N_CPU - 1 // so in case of two processors it becomes parallelism=1 which is too unexpected. // In this case force parallelism=2 // In case of headless execution (unit tests or inspection command-line) there is no AWT thread to reserve cycles for, so dedicate all CPUs for FJP if (headless || N_CPU == 2) { System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", String.valueOf(N_CPU)); } } }
setupForkJoinCommonPool
297,315
ForkJoinWorkerThread (ForkJoinPool pool) { final int n = setNextBit(); //System.out.println("New FJP thread "+n); ForkJoinWorkerThread thread = new ForkJoinWorkerThread(pool) { @Override protected void onTermination(Throwable exception) { //System.out.println("Exit FJP thread "+n); clearBit(n); super.onTermination(exception); } }; thread.setName("JobScheduler FJ pool " + n + "/" + pool.getParallelism()); thread.setPriority(Thread.NORM_PRIORITY - 1); return thread; }
newThread
297,316
void (Throwable exception) { //System.out.println("Exit FJP thread "+n); clearBit(n); super.onTermination(exception); }
onTermination
297,317
int () { long oldValue = bits.getAndUpdate(value -> value + 1 | value); return Long.numberOfTrailingZeros(oldValue + 1); }
setNextBit
297,318
void (int n) { bits.updateAndGet(value -> value & ~(1L << n)); }
clearBit
297,319
Icon (@NotNull String path, int cacheKey, int flags) { return IconManager.getInstance().loadRasterizedIcon(path, VisualisationIcons.class.getClassLoader(), cacheKey, flags); }
load
297,320
boolean (RowFilter.Entry rowEntry) { return !isEnabled() || !super.include(rowEntry); }
include
297,321
Set<IFilterObserver> () { return new HashSet<>(observers); }
getFilterObservers
297,322
void () { for (IFilterObserver obs : new ArrayList<>(observers)) { obs.filterUpdated(this); } }
reportFilterUpdatedToObservers
297,323
void (IFilter... filtersToAdd) { for (IFilter filter : filtersToAdd) { if (filters.add(filter)) { filter.addFilterObserver(this); if (filter.isEnabled()) { super.setEnabled(true); } else { disabledFilters.add(filter); } } } }
addFilter
297,324
void (IFilter... filtersToRemove) { boolean report = false; for (IFilter filter : filtersToRemove) { if (filters.remove(filter)) { filter.removeFilterObserver(this); disabledFilters.remove(filter); report = true; } } if (report) { if (isEnabled() && !filters.isEmpty() && (disabledFilters.size() == filters.size())) { super.setEnabled(false); } else { reportFilterUpdatedToObservers(); } } }
removeFilter
297,325
Set<IFilter> () { return new HashSet<>(filters); }
getFilters
297,326
boolean (IFilter filter) { return disabledFilters.contains(filter); }
isDisabled
297,327
DateComparator (Format dateFormat) { // the idea is to build a date instance, change then each field // (milliseconds / seconds / etc) and check the change on the // parsed instance. If changing, for example, the seconds, does // not produce a different formatted string, the comparator will // not pay attention to the seconds, and so on Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(new Date().getTime()); if (change(calendar, dateFormat, Calendar.MILLISECOND)) { // Milliseconds affect the output, full comparison return new DateComparator() { @Override public long diff(Date o1, Date o2) { return o1.compareTo(o2); } }; } int divisor = 0; if (change(calendar, dateFormat, Calendar.SECOND)) { divisor = 1000; } else if (change(calendar, dateFormat, Calendar.MINUTE)) { divisor = 1000 * 60; } else if (change(calendar, dateFormat, Calendar.HOUR)) { divisor = 1000 * 60 * 60; } else if (change(calendar, dateFormat, Calendar.DAY_OF_YEAR)) { return new DayMonthYearComparator(calendar); } else if (change(calendar, dateFormat, Calendar.MONTH)) { return new MonthYearComparator(calendar); } else if (change(calendar, dateFormat, Calendar.YEAR)) { return new YearComparator(calendar); } else { // nothing affects the output, great formatter! return new DateComparator() { @Override public long diff(Date o1, Date o2) { return 0; } }; } return new TimeComparator(divisor); }
getDateComparator
297,328
boolean (Calendar c, Format f, int field) { c.set(field, 10); String sf = f.format(c.getTime()); c.set(field, 11); return !sf.equals(f.format(c.getTime())); }
change
297,329
String (String expression) { return instantOperand.getAppliedExpression(expression); }
getInstantAppliedExpression
297,330
IOperand () { return instantOperand; }
getDefaultOperator
297,331
String (String expression) { return htmlHandler.stripHtml(expression); }
stripHtml
297,332
String (String expression) { expression = expression.trim(); Matcher matcher = expressionMatcher.matcher(expression); if (matcher.matches()) { String operator = matcher.group(1); int lastAdded = 0; if (operator != null) { escapeBuffer.append('\\').append(operator); expression = matcher.group(2); } int total = expression.length(); for (int i = 0; i < total; i++) { char ch = expression.charAt(i); if ((ch == '*') || (ch == '?')) { escapeBuffer.append(expression, lastAdded, i); escapeBuffer.append('\\').append(ch); lastAdded = i + 1; } } if (escapeBuffer.length() > 0) { escapeBuffer.append(expression, lastAdded, total); expression = escapeBuffer.toString(); escapeBuffer.delete(0, escapeBuffer.length()); } } return expression; }
escape
297,333
String () { boolean gt = matches(1); boolean eq = matches(0); boolean ls = matches(-1); if (gt) { if (eq) return ">="; if (ls) return "!="; return ">"; } if (ls) { if (eq) return "<="; return "<"; } return "=="; }
getOperator
297,334
RowFilter (final Object right, final int modelIndex, final Comparator comparator) { return new RowFilter() { @Override public boolean include(Entry entry) { Object left = entry.getValue(modelIndex); if (left instanceof String) { left = htmlHandler.stripHtml((String)left); } return (left != null) && matches(comparator.compare(left, right)); } }; }
createOperator
297,335
boolean (Entry entry) { Object left = entry.getValue(modelIndex); if (left instanceof String) { left = htmlHandler.stripHtml((String)left); } return (left != null) && matches(comparator.compare(left, right)); }
include
297,336
RowFilter ( final String right, final int modelIndex, final FormatWrapper format, final Comparator stringComparator) { return new RowFilter() { @Override public boolean include(Entry entry) { Object left = entry.getValue(modelIndex); if (left == null) { return false; } String s = format.format(left); return (s.length() > 0) && matches(stringComparator.compare(s, right)); } }; }
createStringOperator
297,337
boolean (Entry entry) { Object left = entry.getValue(modelIndex); if (left == null) { return false; } String s = format.format(left); return (s.length() > 0) && matches(stringComparator.compare(s, right)); }
include
297,338
RowFilter (final Object right, final int modelIndex, final Comparator comparator) { return new RowFilter() { @Override public boolean include(Entry entry) { Object left = entry.getValue(modelIndex); if (left instanceof String) { left = htmlHandler.stripHtml((String)left); } boolean value = (left != null) && (0 == comparator.compare(left, right)); return value == expected; } }; }
createOperator
297,339
boolean (Entry entry) { Object left = entry.getValue(modelIndex); if (left instanceof String) { left = htmlHandler.stripHtml((String)left); } boolean value = (left != null) && (0 == comparator.compare(left, right)); return value == expected; }
include
297,340
RowFilter (final int modelIndex) { return new RowFilter() { @Override public boolean include(Entry entry) { Object left = entry.getValue(modelIndex); return expected == (left == null); } }; }
createNullOperator
297,341
boolean (Entry entry) { Object left = entry.getValue(modelIndex); return expected == (left == null); }
include
297,342
RowFilter ( final String right, final int modelIndex, final FormatWrapper format, final Comparator stringComparator) { return new RowFilter() { @Override public boolean include(Entry entry) { Object left = entry.getValue(modelIndex); String value = format.format(left); return expected == (stringComparator.compare(value, right) == 0); } }; }
createStringOperator
297,343
boolean (Entry entry) { Object left = entry.getValue(modelIndex); String value = format.format(left); return expected == (stringComparator.compare(value, right) == 0); }
include
297,344
boolean (Entry entry) { Object o = entry.getValue(modelIndex); String left = format.format(o); return equals == pattern.matcher(left).matches(); }
include
297,345
void (boolean instantMode) { this.instantMode = instantMode; }
setInstantMode
297,346
String (String baseExpression) { return switch (instantApplied) { case 0 -> baseExpression; case 1 -> "*" + baseExpression; case 2 -> baseExpression + "*"; case 3 -> "*" + baseExpression + "*"; default -> baseExpression; }; }
getAppliedExpression
297,347
String (String s) { StringBuilder sb = new StringBuilder(); boolean escaped = false; instantApplied = 0; for (char c : s.toCharArray()) { if (c == '*') { if (escaped) { sb.append("\\*"); escaped = false; } else { sb.append(".*"); } } else if (c == '?') { if (escaped) { sb.append("\\?"); escaped = false; } else { sb.append("."); } } else if (c == '\\') { if (escaped) { sb.append("\\\\\\\\"); } escaped = !escaped; } else { if (escaped) { sb.append("\\\\"); escaped = false; } switch (c) { case '[', ']', '^', '$', '+', '{', '}', '|', '(', ')', '.' -> sb.append('\\').append(c); default -> sb.append(c); } } } if (escaped) { sb.append("\\\\"); } if (instantMode) { int l = sb.length(); boolean okStart, okEnd; if (l < 2) { okStart = okEnd = false; } else { okStart = sb.substring(0, 2).equals(".*"); okEnd = sb.substring(l - 2).equals(".*"); } if (!okStart) { instantApplied = 1; sb.insert(0, ".*"); } if (!okEnd) { instantApplied += 2; sb.append(".*"); } } return sb.toString(); }
convertToRE
297,348
String (Object o) { if (format == null) { return (o == null) ? "" : htmlHandler.stripHtml(o.toString()); } return format.format(o).trim(); }
format
297,349
int (String entity) { Integer value = ents.get(entity); return value==null? -1 : value; }
getEntityValue
297,350
String (String s) { String inner = getSubstringUnderHtmlTag(s); return (inner == null ? s : removeHtmlInfo(inner)).trim(); }
stripHtml
297,351
String (String inner) { boolean inTag = false, inQuoteInTag = false; char quoteChar = '"'; int entityPos = -1; buffer.delete(0, buffer.length()); for (char c : inner.toCharArray()) { if (c == '<') { inTag = true; entityPos = -1; } else if (c == '>') { // not anymore tag, unless is inside a quote inTag = inTag && inQuoteInTag; } else if (inTag) { // special attention to "' characters if (c == '"' || c == '\'') { if (inQuoteInTag) { inQuoteInTag = (quoteChar != c); } else { inQuoteInTag = true; quoteChar = c; } } } else { if (c == '&') { entityPos = buffer.length(); } else if (c == ';' && entityPos != -1) { int len = buffer.length(); if (len > entityPos + 2) { int entityValue = getEntityValue(entityPos + 1); if (entityValue > 0 && entityValue < 65536) { buffer.delete(entityPos, len); c = (char) entityValue; } } } buffer.append(c); } } return buffer.toString(); }
removeHtmlInfo
297,352
int (int start) { if (buffer.charAt(start) == '#') { char hex = buffer.charAt(start); try { if (hex == 'x' || hex == 'X') { return Integer.valueOf(buffer.substring(start + 2), 16); } return Integer.parseInt(buffer.substring(start + 1)); } catch (NumberFormatException nfe) { return -1; } } return HtmlEntities.getEntityValue(buffer.substring(start)); }
getEntityValue
297,353
String (String s) { int l = s.length(); if (l >= 6 && (s.charAt(0) == '<') && (s.charAt(5) == '>') && (s.charAt(1) == 'h' || s.charAt(1) == 'H') && (s.charAt(2) == 't' || s.charAt(2) == 'T') && (s.charAt(3) == 'm' || s.charAt(3) == 'M') && (s.charAt(4) == 'l' || s.charAt(4) == 'L')) { // it is enough if the string starts with <html>, ending not // important if (l >= 13 && (s.charAt(l - 1) == '>') && (s.charAt(l - 7) == '<') && (s.charAt(l - 6) == '/') && (s.charAt(l - 5) == 'h' || s.charAt(l - 5) == 'H') && (s.charAt(l - 4) == 't' || s.charAt(l - 4) == 'T') && (s.charAt(l - 3) == 'm' || s.charAt(l - 3) == 'M') && (s.charAt(l - 2) == 'l' || s.charAt(l - 2) == 'L')) { l -= 7; } return s.substring(6, l); } return null; }
getSubstringUnderHtmlTag
297,354
void () { Collection<FilterEditor> eds = handler.getEditors(); FilterEditor[] array = eds.toArray(new FilterEditor[0]); adaptiveSupport = new AdaptiveChoicesSupport(handler.getTable() .getModel(), array, handler.getFilters()); setEnableTableModelEvents(true); }
createAdaptiveChoicesSupport
297,355
boolean () { if (adaptiveSupport == null) { return false; } adaptiveSupport = null; setEnableTableModelEvents(false); return true; }
removeAdaptiveChoicesSupport
297,356
void (int event, int firstRow, int lastRow, int column) { if (column != TableModelEvent.ALL_COLUMNS) { rowsUpdated(firstRow, lastRow, column); } else if (event == TableModelEvent.UPDATE) { // an update can signal that all cells have changed // https://bitbucket.org/coderazzi/tablefilter-swing/issue/ // 8/enabled-adaptive-choices-cause if (lastRow >= rows.size()) { rows.clear(); rowsAdded(0, rowEntry.getModel().getRowCount() - 1); } else { rowsUpdated(firstRow, lastRow, TableModelEvent.ALL_COLUMNS); } } else if (event == TableModelEvent.INSERT) { rowsAdded(firstRow, lastRow); } else if (event == TableModelEvent.DELETE) { rowsDeleted(firstRow, lastRow); } }
tableChanged
297,357
void (int firstRow, int lastRow) { rows.ensureCapacity(rows.size() + lastRow - firstRow + 1); for (int r = firstRow; r <= lastRow; r++) { RowInfo row = new RowInfo(filters.length); rows.add(r, row); rowEntry.row = r; for (RowInfo.Filter filter : filters) { if ((filter != null) && !filter.include(rowEntry)) { filter.set(row, false); } } } extractChoices(editorHandles.length, firstRow, lastRow); }
rowsAdded
297,358
void (int firstRow, int lastRow, int column) { RowInfo.Filter filter = (column == TableModelEvent.ALL_COLUMNS) ? null : filters[column]; while (firstRow <= lastRow) { RowInfo row = rows.get(firstRow); rowEntry.row = firstRow++; if (filter == null) { for (RowInfo.Filter f : filters) { if (f != null) { f.set(row, f.include(rowEntry)); } } } else { filter.set(row, filter.include(rowEntry)); } } // reread all the model extractChoices(editorHandles.length, 0, -1); }
rowsUpdated
297,359
void (int firstRow, int lastRow) { rows.subList(firstRow, lastRow + 1).clear(); extractChoices(editorHandles.length, 0, -1); }
rowsDeleted
297,360
boolean (IFilter iFilter) { RowInfo.Filter filter = getFilter(iFilter); int update = updateRowInfo(filter, iFilter); boolean changed = 1 == (update & 1); if (changed) { // only propagate changes if this is not an editor // or the editor has no focus (is still editing) // https://bitbucket.org/coderazzi/tablefilter-swing/issue/ // 11/slow-progress-with-instant-filtering int editorHandle = getEditorHandle(filter.column); if ((editorHandle == -1) || !editorHandles[editorHandle].editor.isEditing()) { propagateChanges(filter.column); } } return (update & 2) == 2; }
update
297,361
void (int modelPosition) { int width = editorHandles.length; int handle = getEditorHandle(modelPosition); if (handle >= 0) { switchHandle(handle, --width); } extractChoices(width, 0, -1); }
propagateChanges
297,362
void (FilterEditor fe) { int column = fe.getModelIndex(); int editorHandle = getEditorHandle(column); // invoke the editor update call editorHandles[editorHandle].updateFormatter(rowEntry.getModel(), rowEntry.getFormatters()); int width; // and update the filter for this editor int updateRowInfo = updateRowInfo(filters[fe.getModelIndex()], fe.getFilter()); if (1 == (1 & updateRowInfo)) { // if changed, update all editor choices width = editorHandles.length; } else { // update only the associated editor, move it at the beginning switchHandle(editorHandle, 0); width = 1; } extractChoices(width, 0, -1); }
editorUpdated
297,363
int (RowInfo.Filter filter, IFilter iFilter) { int changedBit = 0; int anyBitSet = 1; rowEntry.row = 0; for (RowInfo ri : rows) { boolean set = !iFilter.isEnabled() || iFilter.include(rowEntry); if (filter.set(ri, set)) { changedBit = 1; } if (set) { anyBitSet = 2; } rowEntry.row++; } return changedBit | anyBitSet; }
updateRowInfo
297,364
void (IFilter iFilter) { RowInfo.Filter filter = getFilter(iFilter); if (filter.column < editorHandles.length) { // update only the associated editor, move it at the beginning switchHandle(getEditorHandle(filter.column), 0); extractChoices(1, 0, -1); } }
initChoices
297,365
void (int handles, int firstRow, int lastRow) { int rows = rowEntry.getModelRowCount() - 1; if (lastRow == -1) { lastRow = rows; } boolean fullMode = (firstRow == 0) && (lastRow == rows); int check = handles; for (int i = 0; i < check;) { if (editorHandles[i].startIteration(fullMode)) { // if startIteration returns true, this editor will require // no additional iteration (move it to the end) switchHandle(i, --check); } else { ++i; } } if (check > 0) { iterateRows(check, firstRow, lastRow); } while (handles-- > 0) { editorHandles[handles].iterationCompleted(fullMode); } }
extractChoices
297,366
void (int handles, int firstRow, int lastRow) { for (; firstRow <= lastRow; firstRow++) { rowEntry.row = firstRow; RowInfo row = rows.get(firstRow); for (int i = 0; i < handles;) { EditorHandle handle = editorHandles[i++]; if (filters[handle.column].is(row)) { if (handle.handleRow(rowEntry)) { // if handleRow returns true, this editor will // require no additional iteration (move it to the // end) if no handles remain, just return switchHandle(--i, --handles); if (handles == 0) { return; } } } } } }
iterateRows
297,367
void (int source, int target) { if (target != source) { EditorHandle move = editorHandles[target]; editorHandles[target] = editorHandles[source]; editorHandles[source] = move; } }
switchHandle
297,368
int (int column) { int len = editorHandles.length; while (len-- > 0) { if (editorHandles[len].column == column) { return len; } } return len; }
getEditorHandle
297,369
boolean (int row) { return rows.get(row).is(); }
include
297,370
void (TableModel model, Format[] formatters) { formatters[column] = editor.getFormat(); init(model); }
updateFormatter
297,371
void (TableModel model) { Set<CustomChoice> choices = editor.getCustomChoices(); if (AutoChoices.DISABLED == editor.getAutoChoices()) { maxChoices = 0; } else { Class<?> c = model.getColumnClass(column); if (c.equals(Boolean.class)) { // consider true and false (plus null!) maxChoices = 3; } else { // consider enum constants, plus null Object[] o = c.getEnumConstants(); if (o == null){ // no enum, only handle ENABLED if (AutoChoices.ENUMS == editor.getAutoChoices()) { maxChoices = 0; } else { maxChoices = Integer.MAX_VALUE; } } else { maxChoices = o.length + 1; } } } autoOptions = maxChoices > 0; if (choices.isEmpty()) { customChoices = null; } else { customChoices = new HashMap<>(); for (CustomChoice cc : choices) { customChoices.put(cc, cc.getFilter(editor)); } if (maxChoices != Integer.MAX_VALUE) { maxChoices += customChoices.size(); } } }
init
297,372
boolean (boolean fullMode) { if (!editor.isEnabled()) { // do nothing if not enabled return true; } choices.clear(); maxIterationChoices = maxChoices; if (fullMode) { missingChoices = (customChoices == null) ? Collections.emptyMap() : new HashMap<>(customChoices); } else { maxIterationChoices -= editor.getChoicesSize(); } return maxIterationChoices <= 0; }
startIteration
297,373
boolean (RowEntry entry) { if (!missingChoices.isEmpty()) { Iterator<Map.Entry<CustomChoice, RowFilter>> it = missingChoices.entrySet().iterator(); while (it.hasNext()) { Map.Entry<CustomChoice, RowFilter> o = it.next(); if (o.getValue().include(entry)) { choices.add(o.getKey()); it.remove(); } } } if (autoOptions) { // otherwise, no care for column's value choices.add(entry.getValue(column)); } return maxIterationChoices == choices.size(); }
handleRow
297,374
void (boolean fullMode) { if (editor.isEnabled()) { if (fullMode) { editor.setChoices(choices); } else { editor.addChoices(choices); } } }
iterationCompleted
297,375
boolean () { int length = info.length; while (length-- > 0) { if (info[length] != SET) { return false; } } return true; }
is
297,376
boolean (Entry rowEntry) { return !filter.isEnabled() || filter.include(rowEntry); }
include
297,377
boolean (RowInfo row, boolean set) { byte[] info = row.info; byte now = info[col]; if (set) { info[col] |= bit; } else { info[col] &= (SET ^ bit); } return now != info[col]; }
set
297,378
boolean (RowInfo row) { byte[] info = row.info; boolean now = 0 != (info[col] & bit); set(row, true); boolean ret = row.is(); set(row, now); return ret; }
is
297,379
boolean (Entry entry) { return true; }
include
297,380
RowFilter (IFilterEditor editor) { return passAllRawFilter; }
getFilter
297,381
RowFilter (final IFilterEditor editor) { final int modelIndex = editor.getModelIndex(); return new RowFilter() { @Override public boolean include(Entry entry) { Object o = entry.getValue(modelIndex); if (o == null) { return true; } if (editor.getRenderer() != null) { return false; } Format fmt = editor.getFormat(); String s = (fmt == null) ? o.toString() : fmt.format(o); return (s == null) || (s.trim().length() == 0); } }; }
getFilter
297,382
boolean (Entry entry) { Object o = entry.getValue(modelIndex); if (o == null) { return true; } if (editor.getRenderer() != null) { return false; } Format fmt = editor.getFormat(); String s = (fmt == null) ? o.toString() : fmt.format(o); return (s == null) || (s.trim().length() == 0); }
include
297,383
Set<CustomChoice> (Object[] choices) { Set<CustomChoice> ret = new HashSet<>(); for (Object o : choices) { ret.add(create(o, o.toString())); } return ret; }
createSet
297,384
Set<CustomChoice> (Collection choices) { Set<CustomChoice> ret = new HashSet<>(); for (Object o : choices) { ret.add(create(o, o.toString())); } return ret; }
createSet
297,385
CustomChoice (Object choice) { return create(choice, choice.toString()); }
create
297,386
CustomChoice (final Object choice, String repr) { if (choice instanceof Pattern) { return new CustomChoice(repr) { private static final long serialVersionUID = -3239105477862513930L; @Override public RowFilter getFilter(final IFilterEditor ed) { final int index = ed.getModelIndex(); final Pattern pattern = (Pattern)choice; return new RowFilter() { @Override public boolean include(Entry entry) { Object o = entry.getValue(index); if (o == null) { return false; } Format fmt = ed.getFormat(); String s = (fmt == null) ? o.toString() : fmt.format(o); return pattern.matcher(s).matches(); } }; } }; } return new CustomChoice(repr) { private static final long serialVersionUID = -3573642873044716998L; @Override public RowFilter getFilter(final IFilterEditor editor) { final int index = editor.getModelIndex(); final String string = (choice instanceof String) ? (String)choice : null; return new RowFilter() { @Override public boolean include(Entry entry) { Object o = entry.getValue(index); if ((string != null) && (o instanceof String) && editor.isIgnoreCase()) { return string.equalsIgnoreCase((String)o); } return choice.equals(o); } }; } }; }
create
297,387
RowFilter (final IFilterEditor ed) { final int index = ed.getModelIndex(); final Pattern pattern = (Pattern)choice; return new RowFilter() { @Override public boolean include(Entry entry) { Object o = entry.getValue(index); if (o == null) { return false; } Format fmt = ed.getFormat(); String s = (fmt == null) ? o.toString() : fmt.format(o); return pattern.matcher(s).matches(); } }; }
getFilter
297,388
boolean (Entry entry) { Object o = entry.getValue(index); if (o == null) { return false; } Format fmt = ed.getFormat(); String s = (fmt == null) ? o.toString() : fmt.format(o); return pattern.matcher(s).matches(); }
include
297,389
RowFilter (final IFilterEditor editor) { final int index = editor.getModelIndex(); final String string = (choice instanceof String) ? (String)choice : null; return new RowFilter() { @Override public boolean include(Entry entry) { Object o = entry.getValue(index); if ((string != null) && (o instanceof String) && editor.isIgnoreCase()) { return string.equalsIgnoreCase((String)o); } return choice.equals(o); } }; }
getFilter
297,390
boolean (Entry entry) { Object o = entry.getValue(index); if ((string != null) && (o instanceof String) && editor.isIgnoreCase()) { return string.equalsIgnoreCase((String)o); } return choice.equals(o); }
include
297,391
Color (IFilterEditor editor, boolean isSelected) { return null; }
getBackground
297,392
Color (IFilterEditor editor, boolean isSelected) { return null; }
getForeground
297,393
Font (IFilterEditor editor, boolean isSelected) { return null; }
getFont
297,394
Icon () { return icon; }
getIcon
297,395
void (Icon icon) { this.icon = icon; }
setIcon
297,396
void (IFilterEditor editor, boolean isSelected, JComponent c, Graphics g) { if (icon != null) { Icon use; if (c.isEnabled()) { use = icon; } else { use = UIManager.getLookAndFeel().getDisabledIcon(c, icon); } FontMetrics metrics = g.getFontMetrics(); // FontMetrics metrics = g.getFontMetrics(editor.getLook().getCustomChoiceDecorator().getFont(this, editor, isSelected)); int x = Math.max(4 + metrics.stringWidth(toString()), (c.getWidth() - use.getIconWidth()) / 2); int y = (c.getHeight() - use.getIconHeight()) / 2; use.paintIcon(c, g, x, y); } }
decorateComponent
297,397
int () { return precedence; }
getPrecedence
297,398
void (int precedence) { this.precedence = precedence; }
setPrecedence
297,399
String () { return str; }
getRepresentation