MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / getNextMatch

Method getNextMatch

unused/javax/swing/JTree.java:3012–3040  ·  view source on GitHub ↗

Returns the TreePath to the next tree element that begins with a prefix. To handle the conversion of a TreePath into a String, convertValueToText is used. @param prefix the string to test for a match @param startingRow the row for starting the search @param bias the search

(String prefix, int startingRow,
                                 Position.Bias bias)

Source from the content-addressed store, hash-verified

3010 * @since 1.4
3011 */
3012 public TreePath getNextMatch(String prefix, int startingRow,
3013 Position.Bias bias) {
3014
3015 int max = getRowCount();
3016 if (prefix == null) {
3017 throw new IllegalArgumentException();
3018 }
3019 if (startingRow < 0 || startingRow >= max) {
3020 throw new IllegalArgumentException();
3021 }
3022 prefix = prefix.toUpperCase();
3023
3024 // start search from the next/previous element froom the
3025 // selected element
3026 int increment = (bias == Position.Bias.Forward) ? 1 : -1;
3027 int row = startingRow;
3028 do {
3029 TreePath path = getPathForRow(row);
3030 String text = convertValueToText(
3031 path.getLastPathComponent(), isRowSelected(row),
3032 isExpanded(row), true, row, false);
3033
3034 if (text.toUpperCase().startsWith(prefix)) {
3035 return path;
3036 }
3037 row = (row + increment + max) % max;
3038 } while (row != startingRow);
3039 return null;
3040 }
3041
3042 // Serialization support.
3043 private void writeObject(ObjectOutputStream s) throws IOException {

Callers

nothing calls this directly

Calls 5

getRowCountMethod · 0.95
getPathForRowMethod · 0.95
convertValueToTextMethod · 0.95
isRowSelectedMethod · 0.95
isExpandedMethod · 0.95

Tested by

no test coverage detected